;ELC ;;; compiled by cthomp@willow on Thu Aug 12 00:42:22 1993 ;;; from file /era/era-0.80/editor/lisp/packages/refbib.el ;;; emacs version 19.8 (beta8) Lucid. ;;; bytecomp version 2.15; 14-jul-93. ;;; optimization is on. ;;; this file uses opcodes which do not exist in Emacs 18. (if (and (boundp 'emacs-version) (or (and (boundp 'epoch::version) epoch::version) (string-lessp emacs-version "19"))) (error "This file was compiled for Emacs 19.")) (provide 'refer-to-bibtex) (defvar r2b-trace-on nil "\ *trace conversion") (defvar r2b-journal-abbrevs nil "\ 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. Because titles are capitalized before matching, the abbreviation 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 nil "\ 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 nil "\ 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 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 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).") (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") (defvar r2b-delimit-with-quote t "\ *If true, then use \" to delimit fields, otherwise use braces") (defvar 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)") (byte-code "! Q" [boundp capitalize-title-stop-regexp "\\(" capitalize-title-stop-words "\\)\\(\\b\\|'\\)"] 3) (fset 'capitalize-title-region #[(begin end) " Ď!}eb!v!#!vo!)!`!Z," [nil syntax-table orig-syntax-table case-fold-search ((set-syntax-table orig-syntax-table)) set-syntax-table text-mode-syntax-table begin end looking-at "[A-Z][a-z]*[A-Z]" 1 capitalize-word re-search-forward "\\<" t capitalize-title-stop-regexp downcase-word] 4 "\ Like capitalize-region, but don't capitalize stop words, except the first" "r"]) (fset 'capitalize-title #[(s) "!q ced\" )" [get-buffer-create "$$$Scratch$$$" erase-buffer s capitalize-title-region buffer-string] 3 "\ Like capitalize, but don't capitalize stop words, except the first"]) (fset 'r2b-reset #[nil "!!!!!!!" [makunbound r2b-journal-abbrevs r2b-booktitle-abbrevs r2b-proceedings-list capitalize-title-stop-words capitalize-title-stop-regexp r2b-additional-stop-words r2b-stop-regexp] 2 "\ unbind defvars, for debugging" nil]) (byte-code "! ưM" [boundp r2b-stop-regexp "\\`\\(\\(" r2b-additional-stop-words "\\|" capitalize-title-stop-words "\\)\\('\\w*\\)?\\W+\\)*\\([A-Z0-9]+\\)" r2b-trace #[(&rest args) " \"!" [r2b-trace-on apply message args sit-for 0] 3]] 5) (fset 'r2b-match #[(exp) "{" [exp] 2 "\ returns string matched in current buffer"]) (defvar r2b-out-buf-name "*Out*" "\ *output from refer-to-bibtex") (defvar r2b-log-name "*Log*" "\ *logs errors from refer-to-bibtex") (byte-code "!!!!‡" [boundp r2b-in-buf nil r2b-out-buf r2b-log r2b-error-found (r2b-error-found r2bv-author r2bv-primary-author r2bv-date r2bv-year r2bv-decade r2bv-month r2bv-title r2bv-title-first-word r2bv-editor r2bv-annote r2bv-tr r2bv-address r2bv-institution r2bv-keywords r2bv-booktitle r2bv-journal r2bv-volume r2bv-number r2bv-pages r2bv-booktitle r2bv-kn r2bv-publisher r2bv-organization r2bv-school r2bv-type r2bv-where r2bv-note r2bv-ordering) r2b-variables] 2) (fset 'r2b-clear-variables #[nil " @L Au)" [r2b-variables vars nil] 3 "\ set all global vars used by r2b to nil"]) (fset 'r2b-warning #[(&rest args) " \"\"\"\"\" \"\"" [t r2b-error-found princ apply format args r2b-log "\n" r2b-out-buf "% "] 4]) (fset 'r2b-get-field #[(var field &optional unique required capitalize) "\"eb\nQ#!yU!! !Qf M # Q; Q4  ! L ?!+" [nil t not-past-end val item r2b-trace "snarfing %s" field re-search-forward "^" "\\b[ ]*\\(.*[^ \n]\\)[ ]*" r2b-match 1 0 looking-at "[ ]*$\\|%" "\\(.*[^ \n]\\)[ ]*$" "\n" unique r2b-warning "*Illegal multiple field %s %s" "\n and " capitalize capitalize-title var required r2b-require] 4 "\ Set VAR to string value of FIELD, if any. If none, VAR is set to nil. If multiple fields appear, then separate values with the '\\nand\\t\\t', unless UNIQUE is non-nil, in which case log a warning and just concatenate the values. Trim off leading blanks and tabs on first line, and trailing blanks and tabs of every line. Log a warning and set VAR to the empty string if REQUIRED is true. Capitalize as a title if CAPITALIZE is true. Returns value of VAR."]) (fset 'r2b-set-match #[(var n regexp string) " ; \" OL" [var string string-match regexp n] 4 "\ set VAR to the Nth subpattern in REGEXP matched by STRING, or nil if none"]) (byte-code "!" [boundp r2b-month-abbrevs (("jan") ("feb") ("mar") ("apr") ("may") ("jun") ("jul") ("aug") ("sep") ("oct") ("nov") ("dec"))] 2) (fset 'r2b-convert-month #[nil " \"\n\n@@\"\nAr\n\n@@!@\nV\nW\n 8@!ʉ)" [r2bv-month r2b-month-abbrevs months string-match "[^0-9]" read-from-string 0 13 r2b-warning "* Ridiculous month" nil] 4 "\ Try to convert r2bv-month to a standard 3 letter name"]) (fset 'r2b-snarf-input #[nil "!!qeb \"``{ \" !\"\"  $$$$$P$$;\"ӕO %'#$####\"%%#####)" [t case-fold-search r2b-trace "snarfing..." sit-for 0 r2b-in-buf princ " " r2b-log nil terpri r2b-get-field r2bv-author "%A" r2bv-editor "%E" r2b-set-match r2bv-primary-author 1 "\\b\\(\\w+\\)[ ]*\\($\\|,\\)" "" r2bv-date "%D" r2bv-year "[12][0-9][0-9][0-9]" "[^0-9]\\([0-9][0-9]\\)$" "19" r2bv-decade "..\\(..\\)" r2bv-month "[0-9]+/\\|[a-zA-Z]+" string-match "\\(.*\\)/$" r2b-convert-month r2bv-title "%T" r2bv-title-first-word 4 r2b-stop-regexp r2bv-annote "%X" r2bv-tr "%R" r2bv-address "%C" r2bv-institution "%I" r2bv-keywords "%K" r2bv-booktitle "%B" r2bv-journal "%J" r2bv-volume "%V" r2bv-number "%N" r2bv-pages "%P" r2bv-where "%W" r2bv-ordering "%O"] 6 "\ parse buffer into global variables"]) (fset 'r2b-put-field #[(field data &optional abbrevs) "\" A @ A@ɚ\"\n#̉O̔̕O̕O̕\\]\n#̉O̔OQ̕\\e\n#̉O̕OQ̕\\e!!! !!\"̕V!! ?!!," [data nil index multi-line nodelim match abbrevs assoc t "" string-match "[^0-9]" 0 "[\\~^]" "\\verb+" "+" 7 "[$&%#_{}]" "\\" 1 r2b-delimit-with-quote "\"" "{\"}" 2 princ ", \n " field " = " "{" ".*" 59 "\n" "}"] 7 "\ 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"]) (fset 'r2b-require #[(vars) "?<@!A!J?\"L" [vars r2b-require r2b-warning "*Missing value for field %s" ""] 3 "\ If any of VARS is null, set to empty string and log error"]) (fset 'r2b-moveq '(macro . #[(new old) "\n E EE" [progn setq new old nil] 5 "\ set NEW to OLD and set OLD to nil"])) (fset 'r2b-isa-proceedings #[(name) "\" \" \"A@\")" [name string-match "proceedings\\|conference" assoc r2b-proceedings-list r2b-booktitle-abbrevs match] 4 "\ return t if NAME is the name of proceedings"]) (fset 'r2b-isa-university #[(name) "\"\"?" [name string-match "university" "press"] 3 "\ return t if NAME is a university or similar organization, but not a publisher"]) (fset 'r2b-barf-output #[nil "!!q\n  Q !!!ق!!!ق\"!!݂\"!!߂\"!Ⴁ!₡!!ァ$&\"炡&!!$\"!$!!\"O-O//!2!4!!2!! !\"&<#>\"@A#BC#DE\"F-\"G/\"H<#I$\"J\"K\"L\"M\"NO\"PQ\"R\"ST\"UV\"WX\"YZ\"[!+" [r2b-out-buf t nil match case-fold-search standard-output r2b-trace "...barfing" sit-for 0 r2bv-primary-author r2bv-decade r2bv-title-first-word r2bv-kn r2b-isa-proceedings r2bv-journal r2bv-booktitle r2b-isa-university r2bv-institution r2bv-organization r2bv-publisher r2bv-tr r2bv-note r2b-require r2bv-author inproceedings string-match "phd" r2bv-school phdthesis "master" mastersthesis "draft\\|unpublish" unpublished article incollection r2bv-editor "\\`personal communication\\'" r2bv-title misc proceedings "\\bisbn\\b" book "\\`\\(\\(.\\|\n\\)+\\)[ \n]+\\([^ \n]\\)+\\'" 1 r2bv-type 3 r2bv-number techreport manual r2bv-entry-kind (r2bv-year) r2b-error-found princ "\n% Warning -- Errors During Conversion Next Entry\n" "\n@" "( " r2b-put-field "author" "title" r2b-booktitle-abbrevs "year" r2bv-year "month" r2bv-month r2b-month-abbrevs "journal" r2b-journal-abbrevs "volume" r2bv-volume "type" "number" "booktitle" "editor" "publisher" "institution" "organization" "school" "pages" r2bv-pages "address" r2bv-address "note" "keywords" r2bv-keywords "where" r2bv-where "ordering" r2bv-ordering "annote" r2bv-annote " )\n"] 4 "\ generate bibtex based on global variables"]) (fset 'r2b-convert-record #[(output-name) "  !pqdb !\nqdbq##!y`#`\n } q~ b+" [nil not-done rec-begin rec-end output-name r2b-out-buf-name get-buffer-create r2b-out-buf r2b-in-buf r2b-log-name r2b-log re-search-forward "[^ \n]" t re-search-backward "^[ ]*$" 2 "^%" 0 r2b-clear-variables r2b-snarf-input r2b-barf-output] 5 "\ transform current bib entry and append to buffer OUTPUT; do M-x r2b-help for more info" (byte-code "\n\"C" [read-string "Output to buffer: " r2b-out-buf-name] 3)]) (fset 'r2b-convert-buffer #[(output-name) " !q )~eb!! !z #" [get-buffer-create r2b-log-name r2b-log erase-buffer message "Working, please be patient..." sit-for 0 r2b-convert-record output-name "Done, results in %s, errors in %s" r2b-out-buf-name] 5 "\ transform current buffer and append to buffer OUTPUT; do M-x r2b-help for more info" (byte-code "\n\"C" [read-string "Output to buffer: " r2b-out-buf-name] 3)]) (defvar r2b-load-quietly nil "\ *Don't print help message when loaded") (byte-code "!" [boundp r2b-help-message " Refer to Bibtex Bibliography Conversion\n\nA refer-style database is of the form:\n\n%A Joe Blow\n%T Great Thoughts I've Thought\n%D 1977\netc.\n\nThis utility converts these kind of databases to bibtex form, for\nusers of TeX and LaTex. Instructions:\n1. Visit the file containing the refer-style database.\n2. The command\n M-x r2b-convert-buffer\n converts the entire buffer, appending it's output by default in a\n buffer named *Out*, and logging progress and errors in a buffer\n named *Log*. The original file is never modified.\n Note that results are appended to *Out*, so if that buffer\n buffer already exists and contains material you don't want to\n save, you should kill it first.\n3. Switch to the buffer *Out* and save it as a named file.\n4. To convert a single refer-style entry, simply position the cursor\n at the entry and enter\n M-x r2b-convert-record\n Again output is appended to *Out* and errors are logged in *Log*.\n\nThis utility is very robust and pretty smart about determining the\ntype of the entry. It includes facilities for expanding refer macros\nto text, or substituting bibtex macros. Do M-x describe-variable on\n r2b-journal-abbrevs\n r2b-booktitle-abbrevs\n r2b-proceedings-list\nfor information on these features.\n\nIf you don't want to see this help message when you load this utility,\nthen include the following line in your .emacs file:\n (setq r2b-load-quietly t)\nTo see this message again, perform \n M-x r2b-help"] 2) (fset 'r2b-help #[nil "\n!" ["*Help*" princ r2b-help-message] 3 "\ print help message" nil]) (byte-code " !" [r2b-load-quietly r2b-help message "r2b loaded"] 2)