Mercurial > hg > xemacs-beta
diff lisp/packages/refbib.el @ 2:ac2d302a0011 r19-15b2
Import from CVS: tag r19-15b2
author | cvs |
---|---|
date | Mon, 13 Aug 2007 08:46:35 +0200 |
parents | 376386a54a3c |
children |
line wrap: on
line diff
--- a/lisp/packages/refbib.el Mon Aug 13 08:45:53 2007 +0200 +++ b/lisp/packages/refbib.el Mon Aug 13 08:46:35 2007 +0200 @@ -1,8 +1,10 @@ ;;; refbib.el --- convert refer-style references to ones usable by Latex bib -;; Keywords: bib, tex ;; Copyright (C) 1989 Free Software Foundation, Inc. +;; Author: Henry Kautz <kautz@research.att.com> +;; Keywords: bib, tex + ;; This file is part of XEmacs. ;; XEmacs is free software; you can redistribute it and/or modify it @@ -17,38 +19,45 @@ ;; You should have received a copy of the GNU General Public License ;; along with XEmacs; see the file COPYING. If not, write to the Free -;; Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. +;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +;; 02111-1307, USA. -;;; Synched up with: Very close to FSF 19.28 but not synched. +;;; Synched up with: FSF 19.34 + +;;; Commentary: ;; Use: from a buffer containing the refer-style bibliography, ;; M-x r2b-convert-buffer ;; Program will prompt for an output buffer name, and will log ;; warnings during the conversion process in the buffer *Log*. -; HISTORY -; 9/88, created -; modified 1/19/89, allow books with editor but no author; -; added %O ordering field; -; appended illegal multiple fields, instead of -; discarding; -; added rule, a tech report whose %R number -; contains "ISBN" is really a book -; added rule, anything with an editor is a book -; or a proceedings -; added 'manual type, for items with institution -; but no author or editor -; fixed bug so trailing blanks are trimmed -; added 'proceedings type -; used "organization" field for proceedings -; modified 2/16/89, updated help messages -; modified 2/23/89, include capitalize stop words in r2b stop words, -; fixed problems with contractions (e.g. it's), -; caught multiple stop words in a row -; modified 3/1/89, fixed capitialize-title for first words all caps -; modified 3/15/89, allow use of " to delimit fields -; modified 4/18/89, properly "quote" special characters on output -(provide 'refer-to-bibtex) +;;; Change Log: + +;; HISTORY +;; 9/88, created H.Kautz +;; modified 1/19/89, allow books with editor but no author; +;; added %O ordering field; +;; appended illegal multiple fields, instead of +;; discarding; +;; added rule, a tech report whose %R number +;; contains "ISBN" is really a book +;; added rule, anything with an editor is a book +;; or a proceedings +;; added 'manual type, for items with institution +;; but no author or editor +;; fixed bug so trailing blanks are trimmed +;; added 'proceedings type +;; used "organization" field for proceedings +;; modified 2/16/89, updated help messages +;; modified 2/23/89, include capitalize stop words in r2b stop words, +;; fixed problems with contractions (e.g. it's), +;; caught multiple stop words in a row +;; modified 3/1/89, fixed capitalize-title for first words all caps +;; modified 3/15/89, allow use of " to delimit fields +;; modified 4/18/89, properly "quote" special characters on output + +;;; Code: + ;********************************************************** ; User Parameters @@ -66,7 +75,7 @@ for the journal name should be listed as beginning with a capital letter, even if it really doesn't. For example, a value of '((\"Aij\" \"{Artificial Intelligence}\") -(\"Ijcai81\" \"ijcai7\")) would expand Aij to the text string +\(\"Ijcai81\" \"ijcai7\")) would expand Aij to the text string \"Artificial Intelligence\", but would replace Ijcai81 with the BibTeX macro \"ijcai7\".") @@ -81,29 +90,29 @@ Because titles are capitalized before matching, the abbreviated title should be listed as beginning with a capital letter, even if it doesn't. For example, a value of '((\"Aij\" \"{Artificial Intelligence}\") -(\"Ijcai81\" \"ijcai7\")) would expand Aij to the text string +\(\"Ijcai81\" \"ijcai7\")) would expand Aij to the text string \"Artificial Intelligence\", but would replace Ijcai81 with the BibTeX macro \"ijcai7\".") (defvar r2b-proceedings-list '() " Assoc list of books or journals which are really conference proceedings, -but whose name and whose abbrev expansion (as defined in r2b-journal-abbrevs -and r2b-booktitle-abbrevs) does not contain the words 'conference' or -'proceedings'. (Those cases are handled automatically.) +but whose name and whose abbrev expansion (as defined in `r2b-journal-abbrevs' +and `r2b-booktitle-abbrevs') does not contain the words \"conference\" or +\"proceedings\". (Those cases are handled automatically.) The entry must match the given data exactly. Because titles are capitalized before matching, the items in this list should begin with a capital letter. For example, suppose the title \"Ijcai81\" is used for the proceedings of -a conference, and it's expansion is the BibTeX macro \"ijcai7\". Then -r2b-proceedings-list should be '((\"Ijcai81\") ...). If instead its +a conference, and its expansion is the BibTeX macro \"ijcai7\". Then +`r2b-proceedings-list' should be '((\"Ijcai81\") ...). If instead its expansion were \"Proceedings of the Seventh International Conference -on Artificial Intelligence\", then you would NOT need to include Ijcai81 -in r2b-proceedings-list (although it wouldn't cause an error).") +on Artificial Intelligence\", then you would NOT need to include Ijcai81 +in `r2b-proceedings-list' (although it wouldn't cause an error).") (defvar r2b-additional-stop-words "Some\\|What" - "Words other than the capitialize-title-stop-words + "Words other than the `capitalize-title-stop-words' which are not to be used to build the citation key") @@ -118,14 +127,14 @@ (concat "the\\|and\\|of\\|is\\|a\\|an\\|of\\|for\\|in\\|to\\|in\\|on\\|at\\|" "by\\|with\\|that\\|its") - "Words not to be capitialized in a title (unless they are the first + "Words not to be capitalized in a title (unless they are the first word in the title)") (defvar capitalize-title-stop-regexp (concat "\\(" capitalize-title-stop-words "\\)\\(\\b\\|'\\)")) (defun capitalize-title-region (begin end) - "Like capitalize-region, but don't capitalize stop words, except the first" + "Like `capitalize-region', but don't capitalize stop words, except the first." (interactive "r") (let ((case-fold-search nil) (orig-syntax-table (syntax-table))) (unwind-protect @@ -148,7 +157,7 @@ (defun capitalize-title (s) - "Like capitalize, but don't capitalize stop words, except the first" + "Like `capitalize', but don't capitalize stop words, except the first." (save-excursion (set-buffer (get-buffer-create "$$$Scratch$$$")) (erase-buffer) @@ -158,7 +167,7 @@ ;********************************************************* (defun r2b-reset () - "unbind defvars, for debugging" + "Unbind defvars, for debugging." (interactive) (makunbound 'r2b-journal-abbrevs) (makunbound 'r2b-booktitle-abbrevs) @@ -166,8 +175,7 @@ (makunbound 'capitalize-title-stop-words) (makunbound 'capitalize-title-stop-regexp) (makunbound 'r2b-additional-stop-words) - (makunbound 'r2b-stop-regexp) - ) + (makunbound 'r2b-stop-regexp)) (defvar r2b-stop-regexp (concat "\\`\\(\\(" @@ -179,11 +187,10 @@ (if r2b-trace-on (progn (apply (function message) args) - (sit-for 0) - ))) + (sit-for 0)))) (defun r2b-match (exp) - "returns string matched in current buffer" + "Returns string matched in current buffer." (buffer-substring (match-beginning exp) (match-end exp))) (defvar r2b-out-buf-name "*Out*" "*output from refer-to-bibtex" ) @@ -227,12 +234,11 @@ )) (defun r2b-clear-variables () - "set all global vars used by r2b to nil" + "Set all global vars used by r2b to nil." (let ((vars r2b-variables)) (while vars (set (car vars) nil) - (setq vars (cdr vars))) - )) + (setq vars (cdr vars))))) (defun r2b-warning (&rest args) (setq r2b-error-found t) @@ -240,8 +246,7 @@ (princ "\n" r2b-log) (princ "\n" r2b-out-buf) (princ "% " r2b-out-buf) - (princ (apply (function format) args) r2b-out-buf) - ) + (princ (apply (function format) args) r2b-out-buf)) (defun r2b-get-field (var field &optional unique required capitalize) "Set VAR to string value of FIELD, if any. If none, VAR is set to @@ -282,7 +287,7 @@ )) (defun r2b-set-match (var n regexp string ) - "set VAR to the Nth subpattern in REGEXP matched by STRING, or nil if none" + "Set VAR to the Nth subpattern in REGEXP matched by STRING, or nil if none." (set var (if (and (stringp string) (string-match regexp string)) (substring string (match-beginning n) (match-end n)) @@ -295,7 +300,7 @@ ("sep") ("oct") ("nov") ("dec"))) (defun r2b-convert-month () - "Try to convert r2bv-month to a standard 3 letter name" + "Try to convert `r2bv-month' to a standard 3 letter name." (if r2bv-month (let ((months r2b-month-abbrevs)) (if (string-match "[^0-9]" r2bv-month) @@ -320,7 +325,7 @@ ) (defun r2b-snarf-input () - "parse buffer into global variables" + "Parse buffer into global variables." (let ((case-fold-search t)) (r2b-trace "snarfing...") (sit-for 0) @@ -380,9 +385,9 @@ (defun r2b-put-field (field data &optional abbrevs) - "print bibtex FIELD = {DATA} if DATA not null; precede + "Print bibtex FIELD = {DATA} if DATA not null; precede with a comma and newline; if ABBREVS list is given, then -try to replace the {DATA} with an abbreviation" +try to replace the {DATA} with an abbreviation." (if data (let (match nodelim multi-line index) (cond @@ -437,7 +442,7 @@ (defun r2b-require (vars) - "If any of VARS is null, set to empty string and log error" + "If any of VARS is null, set to empty string and log error." (cond ((null vars)) ((listp vars) (r2b-require (car vars)) (r2b-require (cdr vars))) @@ -452,11 +457,11 @@ (defmacro r2b-moveq (new old) - "set NEW to OLD and set OLD to nil" + "Set NEW to OLD and set OLD to nil." (list 'progn (list 'setq new old) (list 'setq old 'nil))) (defun r2b-isa-proceedings (name) - "return t if NAME is the name of proceedings" + "Return t if NAME is the name of proceedings." (and name (or @@ -468,8 +473,8 @@ ))) (defun r2b-isa-university (name) - "return t if NAME is a university or similar organization, -but not a publisher" + "Return t if NAME is a university or similar organization, +but not a publisher." (and name (string-match "university" name) @@ -478,7 +483,7 @@ )) (defun r2b-barf-output () - "generate bibtex based on global variables" + "Generate bibtex based on global variables." (let ((standard-output r2b-out-buf) (case-fold-search t) match) (r2b-trace "...barfing") @@ -608,8 +613,8 @@ (defun r2b-convert-record (output-name) - "transform current bib entry and append to buffer OUTPUT; -do M-x r2b-help for more info" + "Transform current bib entry and append to buffer OUTPUT; +do \"M-x r2b-help\" for more info." (interactive (list (read-string "Output to buffer: " r2b-out-buf-name))) (let (rec-end rec-begin not-done) @@ -645,8 +650,8 @@ (defun r2b-convert-buffer (output-name) - "transform current buffer and append to buffer OUTPUT; -do M-x r2b-help for more info" + "Transform current buffer and append to buffer OUTPUT; +do \"M-x r2b-help\" for more info." (interactive (list (read-string "Output to buffer: " r2b-out-buf-name))) (save-excursion @@ -703,17 +708,27 @@ then include the following line in your .emacs file: (setq r2b-load-quietly t) To see this message again, perform - M-x r2b-help") + M-x r2b-help +Please send bug reports and suggestions to + Henry Kautz + kautz@research.att.com + allegra!kautz") (defun r2b-help () - "print help message" + "Print help message." (interactive) (with-output-to-temp-buffer "*Help*" - (princ r2b-help-message))) + (princ r2b-help-message) + (save-excursion + (set-buffer standard-output) + (help-mode)))) (if (not r2b-load-quietly) (r2b-help)) (message "r2b loaded") +(provide 'refer-to-bibtex) + +;;; refbib.el ends here