Add arch taglines
[bpt/emacs.git] / lisp / textmodes / refbib.el
index 6b45a30..5c9e6c1 100644 (file)
@@ -35,7 +35,7 @@
 ;; 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 
+;;                   appended illegal multiple fields, instead of
 ;;                     discarding;
 ;;                   added rule, a tech report whose %R number
 ;;                     contains "ISBN" is really a book
 ;**********************************************************
 ; 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
-may be eliminated if is exactly the same as the car.  
+may be eliminated if is exactly the same as the car.
   Because titles are capitalized before matching, the abbreviation
-for the journal name should be listed as beginning with a capital 
+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
-\"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.  
+\"Artificial Intelligence\", but would replace Ijcai81 with the
+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
-\"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,
+\"Artificial Intelligence\", but would replace Ijcai81 with the
+BibTeX macro \"ijcai7\"."
+  :type '(repeat (list string string))
+  :group 'refbib)
+
+(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.)
 The entry must match the given data exactly.
-  Because titles are capitalized before matching, the items in this list 
+  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 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
@@ -174,7 +190,7 @@ This is in addition to the `r2b-capitalize-title-stop-words'.")
    (makunbound 'r2b-stop-regexp))
 
 (defvar r2b-stop-regexp
-   (concat "\\`\\(\\(" 
+   (concat "\\`\\(\\("
       r2b-additional-stop-words "\\|" r2b-capitalize-title-stop-words
       "\\)\\('\\w*\\)?\\W+\\)*\\([A-Z0-9]+\\)"))
 
@@ -189,8 +205,16 @@ This is in addition to the `r2b-capitalize-title-stop-words'.")
    "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)
@@ -256,7 +280,7 @@ title if CAPITALIZE is true.  Returns value of VAR."
       (r2b-trace "snarfing %s" field)
       (goto-char (point-min))
       (while (and not-past-end
-               (re-search-forward 
+               (re-search-forward
                   (concat "^" field "\\b[ \t]*\\(.*[^ \t\n]\\)[ \t]*") nil t))
         (setq item (r2b-match 1))
         (while (and (setq not-past-end (zerop (forward-line 1)))
@@ -301,7 +325,7 @@ title if CAPITALIZE is true.  Returns value of VAR."
       (let ((months r2b-month-abbrevs))
         (if (string-match "[^0-9]" r2bv-month)
            (progn
-              (while (and months (not (string-match (car (car months)) 
+              (while (and months (not (string-match (car (car months))
                                          r2bv-month)))
                  (setq months (cdr months)))
               (if months
@@ -363,7 +387,7 @@ title if CAPITALIZE is true.  Returns value of VAR."
       (r2b-set-match 'r2bv-title-first-word 4
         r2b-stop-regexp
         r2bv-title)
-      
+
       (r2b-get-field 'r2bv-annote "%X" t )
       (r2b-get-field 'r2bv-tr "%R" t)
       (r2b-get-field 'r2bv-address "%C" t)
@@ -421,7 +445,7 @@ try to replace the {DATA} with an abbreviation."
       (princ ", \n  ")
       (princ field)
       (princ " =\t")
-      (if (not nodelim) 
+      (if (not nodelim)
        (if r2b-delimit-with-quote
          (princ "\"")
          (princ "{")))
@@ -429,7 +453,7 @@ try to replace the {DATA} with an abbreviation."
       (if (> (match-end 0) 59)
        (princ "\n"))
       (princ data)
-      (if (not nodelim) 
+      (if (not nodelim)
        (if r2b-delimit-with-quote
          (princ "\"")
          (princ "}")))
@@ -439,7 +463,7 @@ try to replace the {DATA} with an abbreviation."
 
 (defun r2b-require (vars)
    "If any of VARS is null, set to empty string and log error."
-   (cond 
+   (cond
       ((null vars))
       ((listp vars) (r2b-require (car vars)) (r2b-require (cdr vars)))
       (t
@@ -471,7 +495,7 @@ try to replace the {DATA} with an abbreviation."
 (defun r2b-isa-university (name)
    "Return t if NAME is a university or similar organization,
 but not a publisher."
-   (and 
+   (and
       name
       (string-match "university" name)
       (not (string-match "press" name))
@@ -488,9 +512,9 @@ but not a publisher."
 
       (setq r2bv-kn (concat r2bv-primary-author r2bv-decade
                        r2bv-title-first-word))
-      
+
       (setq r2bv-entry-kind
-        (cond 
+        (cond
            ((r2b-isa-proceedings r2bv-journal)
               (r2b-moveq r2bv-booktitle r2bv-journal)
               (if (r2b-isa-university r2bv-institution)
@@ -541,7 +565,7 @@ but not a publisher."
               'proceedings)
            ((or r2bv-editor
                (and r2bv-author
-                  (or 
+                  (or
                      (null r2bv-tr)
                      (string-match "\\bisbn\\b" r2bv-tr))))
               (r2b-moveq r2bv-publisher r2bv-institution)
@@ -552,12 +576,12 @@ but not a publisher."
               'book)
            (r2bv-tr
               (r2b-require 'r2bv-institution)
-              (if (string-match 
-                     "\\`\\(\\(.\\|\n\\)+\\)[ \t\n]+\\([^ \t\n]\\)+\\'" 
+              (if (string-match
+                     "\\`\\(\\(.\\|\n\\)+\\)[ \t\n]+\\([^ \t\n]\\)+\\'"
                      r2bv-tr)
                  (progn
                     (setq r2bv-type (substring r2bv-tr 0 (match-end 1)))
-                    (setq r2bv-number (substring r2bv-tr 
+                    (setq r2bv-number (substring r2bv-tr
                                          (match-beginning 3)))
                     (setq r2bv-tr nil))
                  (r2b-moveq r2bv-number r2bv-tr))
@@ -611,7 +635,7 @@ but not a publisher."
 (defun r2b-convert-record (output-name)
    "Transform current bib entry and append to buffer OUTPUT;
 do \"M-x r2b-help\" for more info."
-   (interactive 
+   (interactive
       (list (read-string "Output to buffer: " r2b-out-buf-name)))
    (let (rec-end rec-begin not-done)
       (setq r2b-out-buf-name output-name)
@@ -643,12 +667,12 @@ do \"M-x r2b-help\" for more info."
         nil
         )
       ))
-      
-      
+
+
 (defun r2b-convert-buffer (output-name)
-   "Transform current buffer and append to buffer OUTPUT;
-do \"M-x r2b-help\" for more info."
-   (interactive 
+   "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
       (setq r2b-log (get-buffer-create r2b-log-name))
@@ -659,12 +683,10 @@ do \"M-x r2b-help\" for more info."
    (message "Working, please be patient...")
    (sit-for 0)
    (while (r2b-convert-record output-name) t)
-   (message "Done, results in %s, errors in %s" 
+   (message "Done, results in %s, errors in %s"
       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
 
@@ -680,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
@@ -700,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
@@ -712,7 +729,7 @@ 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)
@@ -720,11 +737,8 @@ Please send bug reports and suggestions to
        (set-buffer standard-output)
        (help-mode))))
 
-(if (not r2b-load-quietly)
-   (r2b-help))
-
-(message "r2b loaded")
-
+(provide 'refbib)
 (provide 'refer-to-bibtex)
 
+;;; arch-tag: 664afee2-6e76-4408-ba56-981d8a179586
 ;;; refbib.el ends here