--- /home/markus/incoming/muse-contex.el Sat Apr 21 00:59:31 2007
+++ muse/lisp/muse-contex.el Sat Apr 21 01:25:12 2007
@@ -50,6 +50,7 @@
(defcustom muse-contex-header
"\\starttext
\\setupinteraction [state=start]
+(muse-contex-setup-bibliography)
\\startalignment[center]
\\blank[2*big]
{\\tfd (muse-publishing-directive \"title\")}
@@ -67,7 +68,7 @@
:type 'string
:group 'muse-contex)
-(defcustom muse-contex-footer "\n\\stoptext\n"
+(defcustom muse-contex-footer "(muse-contex-bibliography)\n\\stoptext\n"
"Footer used for publishing Context files. This may be text or a filename."
:type 'string
:group 'muse-contex)
@@ -153,6 +154,10 @@
(end-center . "\n\\stopalignment")
(begin-quote . "\\startquotation\n")
(end-quote . "\n\\stopquotation")
+ (begin-cite . "\\cite{")
+ (begin-cite-author . "\\citet{")
+ (begin-cite-year . "\\citet{")
+ (end-cite . "}")
(begin-uli . "\\startitemize\n")
(end-uli . "\n\\stopitemize")
(begin-uli-item . "\\item ")
@@ -319,12 +324,50 @@
:type 'boolean
:group 'muse-contex)
+(defun muse-contex-fixup-citations ()
+ ;; replace semicolons in multi-head citations with colons
+ (save-restriction)
+ (goto-char (point-min))
+ (while (re-search-forward "\\\\cite.?{" nil t)
+ (let ((start (point))
+ (end (re-search-forward "}")))
+ (narrow-to-region start end)
+ (goto-char start)
+ (while (re-search-forward ";" nil t)
+ (replace-match ","))
+ (widen)))
+ )
+
(defun muse-contex-finalize-buffer ()
(muse-contex-fixup-dquotes)
+ (muse-contex-fixup-citations)
(when (and muse-contex-permit-contents-tag
muse-publish-generate-contents)
(goto-char (car muse-publish-generate-contents))
(muse-insert-markup "\\placecontent")))
+
+(defun muse-contex-bibliography ()
+ (save-excursion
+ (save-restriction
+ (widen)
+ (goto-char (point-min))
+ (if (re-search-forward "\\\\cite.?{" nil t)
+ "\\placepublications"
+ "")
+ )))
+
+(defun muse-contex-setup-bibliography ()
+ (save-excursion
+ (save-restriction
+ (widen)
+ (goto-char (point-min))
+ (if (re-search-forward "\\\\cite.?{" nil t)
+ (concat
+ "\\usemodule[bib]\n\\usemodule[bibltx]\n\\setupbibtex [database="
+ (muse-publishing-directive "bibsource")
+ "]\n\\setuppublications[alternative=apa-fr,criterium=all]")
+ "")
+ )))
(defun muse-contex-pdf-browse-file (file)
(shell-command (concat "open " file)))