-;; Convert refer-style bibliographic entries to ones usable by latex bib
+;;; refbib.el --- convert refer-style references to ones usable by Latex bib
+
;; Copyright (C) 1989 Free Software Foundation, Inc.
+;; Author: Henry Kautz <kautz@research.att.com>
+;; Keywords: bib, tex
+
;; This file is part of GNU Emacs.
;; GNU Emacs is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 1, or (at your option)
+;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; along with GNU Emacs; see the file COPYING. If not, write to
;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+;;; 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*.
+;;; Change Log:
+
; HISTORY
-; 9/88, created
+; 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
; 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/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
-(provide 'refer-to-bibtex)
+
+;;; Code:
+
;**********************************************************
; User Parameters
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\".")
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 it's 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")
(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
(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)
;*********************************************************
(defun r2b-reset ()
- "unbind defvars, for debugging"
+ "Unbind defvars, for debugging."
(interactive)
(makunbound 'r2b-journal-abbrevs)
(makunbound 'r2b-booktitle-abbrevs)
(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 "\\`\\(\\("
(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" )
))
(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)
(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
))
(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))
("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)
)
(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)
(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
(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)))
(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
)))
(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)
))
(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")
(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)
(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
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