Remove stuff about selection timeout, which is
[bpt/emacs.git] / lisp / textmodes / refbib.el
index 31b63da..a57f6c2 100644 (file)
@@ -1,11 +1,10 @@
 ;;; 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>
-;; Last-Modified: 16 Mar 1992
 ;; Keywords: bib, tex
 
-;; Copyright (C) 1989 Free Software Foundation, Inc.
-
 ;; This file is part of GNU Emacs.
 
 ;; GNU Emacs is free software; you can redistribute it and/or modify
@@ -19,8 +18,9 @@
 ;; GNU General Public License for more details.
 
 ;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING.  If not, write to
-;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+;; along with GNU Emacs; see the file COPYING.  If not, write to the
+;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
 
 ;;; Commentary:
 
 
 ;;; 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 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
+;; 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
 
-(defvar r2b-trace-on nil "*trace conversion")
+(defgroup refbib nil
+  "Convert refer-style references to ones usable by Latex bib."
+  :prefix "r2b-"
+  :group 'wp)
 
-(defvar r2b-journal-abbrevs
-   '(  
-       )
-   "  Abbreviation list for journal names.  
+(defcustom r2b-trace-on nil
+  "*Non-nil means trace conversion."
+  :type 'boolean
+  :group 'refbib)
+
+(defcustom r2b-journal-abbrevs
+  '(  
+    )
+  "Abbreviation list for journal names.  
 If the car of an element matches a journal name exactly, it is replaced by
 the cadr when output.  Braces must be included if replacement is a
 {string}, but not if replacement is a bibtex abbreviation.  The cadr
@@ -73,28 +81,33 @@ may be eliminated if is exactly the same as the car.
 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\".")
-
-(defvar r2b-booktitle-abbrevs 
-   '(  
-       )
-   "  Abbreviation list for book and proceedings names.  If the car of
-an element matches a title or booktitle exactly, it is replaced by 
-the cadr when output.  Braces must be included if replacement is 
-a {string}, but not if replacement is a bibtex abbreviation.  The cadr 
-may be eliminated if is exactly the same as the car.  
+BibTeX macro \"ijcai7\"."
+  :type '(repeat (list string string))
+  :group 'refbib)
+
+(defcustom r2b-booktitle-abbrevs 
+  '(  
+    )
+  "Abbreviation list for book and proceedings names.
+If the car of an element matches a title or booktitle exactly, it is
+replaced by the cadr when output.  Braces must be included if
+replacement is a {string}, but not if replacement is a bibtex
+abbreviation.  The cadr may be eliminated if is exactly the same as
+the car.
   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\".")
+BibTeX macro \"ijcai7\"."
+  :type '(repeat (list string string))
+  :group 'refbib)
 
-(defvar r2b-proceedings-list
-   '()
-   "  Assoc list of books or journals which are really conference proceedings,
+(defcustom 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.)
@@ -102,36 +115,37 @@ 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
+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).")
+in `r2b-proceedings-list' (although it wouldn't cause an error)."
+  :type '(repeat (list string string))
+  :group 'refbib)
 
 (defvar r2b-additional-stop-words
-        "Some\\|What"
-   "Words other than the `capitialize-title-stop-words'
-which are not to be used to build the citation key")
-
+  "Some\\|What"
+  "Words not to be used to build the citation key.
+This is in addition to the `r2b-capitalize-title-stop-words'.")
 
-(defvar r2b-delimit-with-quote
-  t
-  "*If true, then use \" to delimit fields, otherwise use braces")
+(defcustom r2b-delimit-with-quote t
+  "*If true, then use \" to delimit fields, otherwise use braces."
+  :type 'boolean
+  :group 'refbib)
 
 ;**********************************************************
 ; Utility Functions
 
-(defvar capitalize-title-stop-words
+(defvar r2b-capitalize-title-stop-words
    (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
-word in the title)")
+   "Words not to be capitalized in a title (unless the first word).")
 
-(defvar capitalize-title-stop-regexp
-   (concat "\\(" capitalize-title-stop-words "\\)\\(\\b\\|'\\)"))
+(defvar r2b-capitalize-title-stop-regexp
+   (concat "\\(" r2b-capitalize-title-stop-words "\\)\\(\\b\\|'\\)"))
 
-(defun capitalize-title-region (begin end)
+(defun r2b-capitalize-title-region (begin end)
    "Like `capitalize-region', but don't capitalize stop words, except the first."
    (interactive "r")
    (let ((case-fold-search nil) (orig-syntax-table (syntax-table)))
@@ -147,20 +161,20 @@ word in the title)")
               (if (looking-at "[A-Z][a-z]*[A-Z]")
                  (forward-word 1)
                  (if (let ((case-fold-search t))
-                        (looking-at capitalize-title-stop-regexp))
+                        (looking-at r2b-capitalize-title-stop-regexp))
                     (downcase-word 1)
                     (capitalize-word 1)))
               ))
         (set-syntax-table orig-syntax-table))))
 
 
-(defun capitalize-title (s)
-   "Like capitalize, but don't capitalize stop words, except the first."
+(defun r2b-capitalize-title (s)
+   "Like `capitalize', but don't capitalize stop words, except the first."
    (save-excursion
       (set-buffer (get-buffer-create "$$$Scratch$$$"))
       (erase-buffer)
       (insert s)
-      (capitalize-title-region (point-min) (point-max))
+      (r2b-capitalize-title-region (point-min) (point-max))
       (buffer-string)))
 
 ;*********************************************************
@@ -170,14 +184,14 @@ word in the title)")
    (makunbound 'r2b-journal-abbrevs)
    (makunbound 'r2b-booktitle-abbrevs)
    (makunbound 'r2b-proceedings-list)
-   (makunbound 'capitalize-title-stop-words)
-   (makunbound 'capitalize-title-stop-regexp)
+   (makunbound 'r2b-capitalize-title-stop-words)
+   (makunbound 'r2b-capitalize-title-stop-regexp)
    (makunbound 'r2b-additional-stop-words)
    (makunbound 'r2b-stop-regexp))
 
 (defvar r2b-stop-regexp
    (concat "\\`\\(\\(" 
-      r2b-additional-stop-words "\\|" capitalize-title-stop-words
+      r2b-additional-stop-words "\\|" r2b-capitalize-title-stop-words
       "\\)\\('\\w*\\)?\\W+\\)*\\([A-Z0-9]+\\)"))
 
 
@@ -191,8 +205,16 @@ word in the title)")
    "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" )
-(defvar r2b-log-name "*Log*" "*logs errors from refer-to-bibtex" )
+(defcustom r2b-out-buf-name "*Out*"
+  "*Name of buffer for output from refer-to-bibtex."
+  :type 'string
+  :group 'refbib)
+
+(defcustom r2b-log-name "*Log*"
+  "*Name of buffer for logs errors from refer-to-bibtex."
+  :type 'string
+  :group 'refbib)
+
 (defvar r2b-in-buf nil)
 (defvar r2b-out-buf nil)
 (defvar r2b-log nil)
@@ -278,7 +300,7 @@ title if CAPITALIZE is true.  Returns value of VAR."
            )
         )
       (if (and val capitalize)
-        (setq val (capitalize-title val)))
+        (setq val (r2b-capitalize-title val)))
       (set var val)
       (if (and (null val) required)
         (r2b-require var))
@@ -648,8 +670,8 @@ do \"M-x r2b-help\" for more info."
       
       
 (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
@@ -665,8 +687,6 @@ do \"M-x r2b-help\" for more info."
       r2b-out-buf-name r2b-log-name)
    )
 
-(defvar r2b-load-quietly nil "*Don't print help message when loaded")
-
 (defvar r2b-help-message
 "                   Refer to Bibtex Bibliography Conversion
 
@@ -682,7 +702,7 @@ users of TeX and LaTex.  Instructions:
 1.  Visit the file containing the refer-style database.
 2.  The command
        M-x r2b-convert-buffer
-    converts the entire buffer, appending it's output by default in a
+    converts the entire buffer, appending its output by default in a
     buffer named *Out*, and logging progress and errors in a buffer
     named *Log*.  The original file is never modified.
        Note that results are appended to *Out*, so if that buffer
@@ -702,11 +722,6 @@ to text, or substituting bibtex macros.  Do M-x describe-variable on
      r2b-proceedings-list
 for information on these features.
 
-If you don't want to see this help message when you load this utility,
-then include the following line in your .emacs file:
-       (setq r2b-load-quietly t)
-To see this message again, perform 
-         M-x r2b-help
 Please send bug reports and suggestions to
        Henry Kautz
         kautz@research.att.com
@@ -714,16 +729,15 @@ Please send bug reports and suggestions to
 
 
 (defun r2b-help ()
-   "Print help message."
+   "Print help describing the `refbib' package."
    (interactive)
    (with-output-to-temp-buffer "*Help*"
-      (princ r2b-help-message)))
-
-(if (not r2b-load-quietly)
-   (r2b-help))
-
-(message "r2b loaded")
+      (princ r2b-help-message)
+      (save-excursion
+       (set-buffer standard-output)
+       (help-mode))))
 
+(provide 'refbib)
 (provide 'refer-to-bibtex)
 
 ;;; refbib.el ends here