[Refdb-cvs] CVS: elisp refdb-mode.el,1.23,1.24
Status: Beta
Brought to you by:
mhoenicka
From: Markus H. <mho...@us...> - 2005-12-20 00:26:42
|
Update of /cvsroot/refdb/elisp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6214 Modified Files: refdb-mode.el Log Message: new config option for citation formats, i.e. SGML vs. XML; new function refdb-check-doctype() determines the document type;check doctype to call proper filename for viewing html output from SGML;use proper citation format for SGML and XML Index: refdb-mode.el =================================================================== RCS file: /cvsroot/refdb/elisp/refdb-mode.el,v retrieving revision 1.23 retrieving revision 1.24 diff -u -U2 -r1.23 -r1.24 --- refdb-mode.el 19 Dec 2005 09:30:12 -0000 1.23 +++ refdb-mode.el 20 Dec 2005 00:26:32 -0000 1.24 @@ -401,4 +401,5 @@ ;; refdb-select-notesdata-output-format ;; refdb-select-additional-data-fields +;; refdb-select-citation-format ;; -- ;; refdb-select-database @@ -761,5 +762,5 @@ full ) - "*List of supported citation formats for RefDB." + "*List of supported citation types for RefDB." :type '(list symbol symbol) :group 'refdb-data-options) @@ -794,4 +795,13 @@ :group 'refdb-data-options) +(defcustom refdb-citation-formats + '( + sgml + xml + ) + "*List of supported citation formats for RefDB." + :type '(list symbol symbol) + :group 'refdb-data-options) + (defcustom refdb-default-ris-encoding 'iso-latin-1 "*Use this character encoding to display datasets in RIS format." @@ -1482,4 +1492,21 @@ ) +(defun refdb-select-citation-format (citationformat) + "Set RefDB citation format to CITATIONFORMAT. +Note that CITATIONFORMAT is a symbol, not a string." + (interactive + (list (intern + (completing-read + "Citation Format: " + (refdb-make-alist-from-symbol-list refdb-citation-formats) + nil t + ) + ) + ) + ) + (setq refdb-citation-format citationformat) + (message "Current citation format is now '%s'" (symbol-name citationformat)) + ) + (defvar refdb-addref-menu-item ["Add References" (refdb-addref-on-region) t] @@ -1960,4 +1987,18 @@ ) +(defvar refdb-select-citation-format-submenu-contents + (list "Select Citation Output Format" + ["XML" + (refdb-select-citation-format 'xml) + :style toggle + :selected (eq refdb-citation-format 'xml)] + ["SGML" + (refdb-select-citation-format 'sgml) + :style toggle + :selected (eq refdb-citation-format 'sgml)] + ) + "RefDB 'Select Citation Format' submenu." + ) + (defvar refdb-whichdb-menu-item ["Show Database Info" (refdb-whichdb) t] @@ -4092,4 +4133,26 @@ ) +(defun refdb-check-doctype () + "Determine the document type of the current document" + (save-excursion + (goto-char (point-min)) + (cond ((search-forward "<!DOCTYPE article" nil t) + "article") + ((search-forward "<!DOCTYPE book" nil t) + "book") + ((search-forward "<!DOCTYPE TEI.2" nil t) + "TEI.2") + ((re-search-forward "<article.*>" nil t) + "book") + ((re-search-forward "<book.*>" nil t) + "book") + ((re-search-forward "<TEI.2.*>" nil t) + "TEI.2") + (t + nil) + ) + ) + ) + (defun refdb-view-output (type) "Display the transformed document in an appropriate viewer" @@ -4100,5 +4163,5 @@ (let ((view-target-file (shell-quote-argument -;; the DSSSL stylesheet generate book1.html, article1.html and so on +;; the DSSSL stylesheet generate book1.html, t1.html and so on ;; the XSLT stylesheets generate basename.html ;; both stylesheets generate basename.XXX for all other output types @@ -4112,5 +4175,8 @@ 0 (string-match "/[^/]+$" buffer-file-name)) - "/book1.html")) + (if (eq (refdb-check-doctype) "book") + "/book1.html" + "/t1.html") + )) (t (concat @@ -4232,8 +4298,10 @@ (if (eq refdb-citation-type 'short) (setq id-string (concat id-string ";" (match-string 1 nil))) - ;; the xref notation used here works for both SGML and XML + ;; the xref notation must be adapted to SGML and XML (setq id-string (concat id-string (format - "<xref linkend=\"ID%s-X\"></xref>" + (if (eq refdb-citation-format 'xml) + "<xref linkend=\"ID%s-X\"/>" + "<xref linkend=\"ID%s-X\">") (match-string 1 nil)) )) @@ -4256,5 +4324,7 @@ ;; the xref notation used here works for both SGML and XML (format - "<xref endterm=\"IM0\" linkend=\"%s\" role=\"MULTIXREF\"></xref>" + (if (eq refdb-citation-format 'xml) + "<xref endterm=\"IM0\" linkend=\"%s\" role=\"MULTIXREF\"/>" + "<xref endterm=\"IM0\" linkend=\"%s\" role=\"MULTIXREF\">") linkend ) @@ -4302,6 +4372,7 @@ (concat (format - ;; the xref notation used here works for both SGML and XML - "<xref endterm=\"IM0\" linkend=\"%s\" role=\"MULTIXREF\"></xref>" + (if (eq refdb-citation-format 'xml) + "<xref endterm=\"IM0\" linkend=\"%s\" role=\"MULTIXREF\"/>" + "<xref endterm=\"IM0\" linkend=\"%s\" role=\"MULTIXREF\">") linkend ) @@ -4365,5 +4436,7 @@ ;; the xref notation used here works for both SGML and XML (format - "<xref linkend=\"ID%s-X\"></xref>" + (if (eq refdb-citation-format 'xml) + "<xref linkend=\"ID%s-X\"/>" + "<xref linkend=\"ID%s-X\">") (match-string 1 nil))) nil) @@ -4382,5 +4455,7 @@ ;; the xref notation used here works for both SGML and XML (format - "<xref linkend=\"ID%s-X\"></xref>" + (if (eq refdb-citation-format 'xml) + "<xref linkend=\"ID%s-X\"/>" + "<xref linkend=\"ID%s-X\">") (match-string 1 nil))) nil) @@ -6291,4 +6366,12 @@ ) +(defcustom refdb-citation-format 'xml + "*Specifies the default citation type." + :type '(choice (const :tag "XML " xml) + (const :tag "SGML " sgml) + ) + :group 'refdb-data-options + ) + (defcustom refdb-data-output-submenu-contents '( @@ -6298,4 +6381,5 @@ refdb-select-additional-data-fields-menu-item refdb-select-citation-type-submenu-contents + refdb-select-citation-format-submenu-contents ) "*Contents of 'Customize Data Output' submenu for RefDB mode. |