(provide (quote BibTeX-mode)) (require (quote VorTeX-common)) (defvar bibtex-abbrev-files nil "\ List of default abbreviation files") (defvar bibtex-abbrev-fields (quote ("JOURNAL" "MONTH")) "\ List of fields that always use abbrevations") (defvar bibtex-entry-use-parens nil "\ Default embracing delimiter pair is braces") (defvar bibtex-field-use-quotes nil "\ Default embracing delimiter for field texts is braces") (defvar bibtex-field-indent 8 "\ Indentation for entry fields.") (defvar bibtex-context nil "\ Global context to be included in draft") (defvar bibtex-softcopy (cond ((and (eq window-system (quote x)) (eq window-system-version 11)) "dvi2x11") ((and (eq window-system (quote x)) (eq window-system-version 10)) "dvi2x") (t "dvitool")) "\ TeX DVI previewer.") (defvar bibtex-error-pos 0 "\ Position of last BibTeX error in *shell*") (defvar bibtex-preview-header nil "\ Customized header string to be inserted after the default header.") (if (not (string-equal window-system "x")) (setq bibtex-softcopy "dvitool")) (defconst bibtex-abbrev "@STRING") (defconst bibtex-abbrev-match "@\\s *STRING\\s *[{(]") (defconst bibtex-abbrev-match-fg "@\\s *STRING\\s *[{(]\\|%\\s *GROUP\\s *[{(]") (defconst bibtex-abbrev-empty "@\\s *STRING\\s *[{(]\\s *=") (defvar bibtex-entry-open 123 "\ Default open symbol for entries") (defvar bibtex-entry-close 125 "\ Default close symbol for entries") (defconst bibtex-entry-close-regexp "[})]") (defconst bibtex-entry-no-group (quote ("ARTICLE" "BOOK" "BOOKLET" "CONFERENCE" "INBOOK" "INCOLLECTION" "INPROCEEDINGS" "MANUAL" "MASTERSTHESIS" "MISC" "PHDTHESIS" "PROCEEDINGS" "TECHREPORT" "UNPUBLISHED" "QUERY"))) (defconst bibtex-entry-no-group-match (vortex-mkstring "@\\s *" "\\s *[{(]" bibtex-entry-no-group)) (defconst bibtex-entry-types (append (mapcar (quote (lambda (en) (concat "@" en))) bibtex-entry-no-group) (list "%GROUP"))) (defconst bibtex-entry-match (concat bibtex-entry-no-group-match "\\|%\\s *GROUP\\s *[{(]")) (defconst bibtex-entry-empty (vortex-mkstring "@\\s *" "\\s *[{(]\\s *," bibtex-entry-no-group)) (defconst bibtex-entry-specs (quote (("@ARTICLE" nil nil ("AUTHOR" "TITLE" "JOURNAL" "YEAR") ("VOLUME" "NUMBER" "PAGES" "MONTH" "NOTE")) ("@BOOK" ("AUTHOR" "EDITOR") nil ("TITLE" "PUBLISHER" "YEAR") ("VOLUME" "SERIES" "ADDRESS" "EDITION" "MONTH" "NOTE")) ("@BOOKLET" nil nil ("TITLE") ("AUTHOR" "HOWPUBLISHED" "ADDRESS" "MONTH" "YEAR" "NOTE")) ("@CONFERENCE" nil nil ("AUTHOR" "TITLE" "BOOKTITLE" "YEAR") ("EDITOR" "PAGES" "ORGANIZATION" "PUBLISHER" "ADDRESS" "MONTH" "NOTE")) ("@INBOOK" ("AUTHOR" "EDITOR") ("CHAPTER" "PAGES") ("TITLE" "PUBLISHER" "YEAR") ("VOLUME" "SERIES" "ADDRESS" "EDITION" "MONTH" "NOTE")) ("@INCOLLECTION" nil nil ("AUTHOR" "TITLE" "BOOKTITLE" "PUBLISHER" "YEAR") ("EDITOR" "CHAPTER" "PAGES" "ADDRESS" "MONTH" "NOTE")) ("@INPROCEEDINGS" nil nil ("AUTHOR" "TITLE" "BOOKTITLE" "YEAR") ("EDITOR" "PAGES" "ORGANIZATION" "PUBLISHER" "ADDRESS" "MONTH" "NOTE")) ("@MANUAL" nil nil ("TITLE") ("AUTHOR" "ORGANIZATION" "ADDRESS" "EDITION" "MONTH" "YEAR" "NOTE")) ("@MASTERSTHESIS" nil nil ("AUTHOR" "TITLE" "SCHOOL" "YEAR") ("ADDRESS" "MONTH" "NOTE")) ("@MISC" nil nil nil ("AUTHOR" "TITLE" "HOWPUBLISHED" "MONTH" "YEAR" "NOTE")) ("@PHDTHESIS" nil nil ("AUTHOR" "TITLE" "SCHOOL" "YEAR") ("ADDRESS" "MONTH" "NOTE")) ("@PROCEEDINGS" nil nil ("TITLE" "YEAR") ("EDITOR" "PUBLISHER" "ORGANIZATION" "ADDRESS" "MONTH" "NOTE")) ("@TECHREPORT" nil nil ("AUTHOR" "TITLE" "INSTITUTION" "YEAR") ("TYPE" "NUMBER" "ADDRESS" "MONTH" "NOTE")) ("@UNPUBLISHED" nil nil ("AUTHOR" "TITLE" "NOTE") ("MONTH" "YEAR"))))) (defvar bibtex-field-pair "{}" "\ Default embracing symbol for field texts is braces") (defconst bibtex-field-types (quote ("ADDRESS" "ANNOTE" "AUTHOR" "BOOKTITLE" "CHAPTER" "EDITION" "EDITOR" "HOWPUBLISHED" "INSTITUTION" "JOURNAL" "KEY" "MONTH" "NOTE" "NUMBER" "ORGANIZATION" "PAGES" "PUBLISHER" "SCHOOL" "SERIES" "TITLE" "TYPE" "VOLUME" "YEAR" "NOTEFILES" "ANYFIELD"))) (defconst bibtex-field-match (concat (vortex-mkstring "\\b" "\\s *=" bibtex-field-types) "\\|" bibtex-entry-match "\\|" bibtex-abbrev-match)) (defconst bibtex-field-empty (concat " *= *[\"{] *[}\"] *, *$\\| *= *[\"{] *[}\"] *$\\| *= *[ ,}] *$\\| *= *\" *\" *}" "\\|" bibtex-entry-empty "\\|" bibtex-abbrev-empty)) (defconst bibtex-field-specs (quote ("ADDRESS *=" "ANNOTE *=" "AUTHOR *=\\|EDITOR *=" "BOOKTITLE *=\\|JOURNAL *=" "CHAPTER *=" "EDITION *=" "EDITOR *=\\|AUTHOR *=" "HOWPUBLISHED *=" "INSTITUTION *=\\|ORGANIZATION *=\\|SCHOOL *=" "JOURNAL *=\\|BOOKTITLE *=" "KEY *=" "MONTH *=" "NOTE *=" "NOTEFILES *=" "NUMBER *=" "ORGANIZATION *=\\|INSTITUTION *=\\|SCHOOL *=" "PAGES *=" "PUBLISHER *=" "SCHOOL *=\\|INSTITUTION *=\\|ORGANIZATION *=" "SERIES *=" "TITLE *=\\|BOOKTITLE *=" "TYPE *=" "VOLUME *=" "YEAR *=" "ANYFIELD *="))) (defvar bibtex-extra-fields nil "\ Fields which the user wishes to have appear in all entries") (defvar bibtex-mode-syntax-table nil "\ Syntax table in use in BibTeX-mode buffers.") (defvar bibtex-mode-abbrev-table nil "\ Abbrev table in use in BibTeX-mode buffers.") (defvar bibtex-mode-customization nil "\ Flag t when BibTeX mode is customized.") (defun bibtex-mode (&optional quiet) "\ Major mode for editing BibTeX database entries." (interactive) (byte-code "ň ? !׉؉ىى\"!ʼn A !   !\"\"\"\" \"  r! \"  !) ! łΉ " [bibtex-mode-map major-mode mode-name paragraph-start paragraph-separate nil local-abbrev-table bibtex-mode-abbrev-table bibtex-require-local-eval bibtex-mode-syntax-table init load-path quiet bibtex-mode-customization t bibtex-entry-use-parens bibtex-entry-open bibtex-entry-close bibtex-field-use-quotes bibtex-field-pair kill-all-local-variables bibtex-mode-keymap-init use-local-map bibtex-mode "BibTeX" "^ *$\\|^ " define-abbrev-table make-local-variable set-syntax-table make-syntax-table modify-syntax-entry 123 "(}" 125 "){" 91 "(]" 93 ")[" vortex-file-exists-p "BibTeX-init.el" load "BibTeX-init" "BibTeX-init.elc" bibtex-copyright run-hooks bibtex-mode-hook 40 41 "\"\""] 20)) (defvar bibtex-mode-map nil "\ Keymap used in BibTeX mode.") (defvar bibtex-control-c-map nil) (defvar bibtex-keymap-data (quote ((nil (bibtex-mode-map ("" bibtex-control-c-map) ("" bibtex-mode-help) (" " bibtex-newline-indent) (" " bibtex-newline-indent-label) (" " bibtex-abbrev-enable) ("" bibtex-abbrev-disable) (" " bibtex-autofill-enable) (" " bibtex-autofill-disable))) ("BibTeX-misc" (bibtex-mode-map ("b" bibtex-cleanup-buffer) ("r" bibtex-cleanup-region) ("e" bibtex-cleanup-entry) (" b" bibtex-sort-buffer) (" r" bibtex-sort-region) ("d" bibtex-make-draft) ("" bibtex-goto-error))) ("BibTeX-ops" (bibtex-mode-map ("p" bibtex-previous-entry) ("c" bibtex-current-entry) ("n" bibtex-next-entry) ("p" bibtex-dup-previous-entry) ("c" bibtex-dup-current-entry) ("n" bibtex-dup-next-entry) (" p" bibtex-kill-previous-entry) (" c" bibtex-kill-current-entry) (" n" bibtex-kill-next-entry) ("" bibtex-rename-current-entry) ("" bibtex-previous-field) ("" bibtex-current-field) ("" bibtex-next-field) ("d" bibtex-erase-delimiters) ("f" bibtex-erase-field) ("t" bibtex-erase-text) ("p" bibtex-text-previous-entry) ("n" bibtex-text-next-entry) ("" bibtex-zap-name) (nil bibtex-current-field-data))) ("BibTeX-abv" (bibtex-mode-map (" " bibtex-load-abbrev) ("" bibtex-save-abbrev) (" g" bibtex-insert-gabbrev) (" f" bibtex-insert-fabbrev) ("g" bibtex-make-gabbrev))) ("BibTeX-notes" (bibtex-mode-map ("" bibtex-view-notefiles)))))) (defun bibtex-mode-keymap-init nil (byte-code "\"!K" [bibtex-keymap-data bibtex-mode-map mapcar define-prefix-command (bibtex-mode-map bibtex-control-c-map) vortex-keymap-util] 4)) (defun bibtex-newline-indent nil (interactive) (byte-code " j" [bibtex-field-indent nil newline] 2)) (defun bibtex-newline-indent-label nil (interactive) (byte-code "ˆ 8@bi)j)" [case-fold-search t nil newline 3 bibtex-current-field-data] 4)) (defun bibtex-do-auto-fill nil "\ This is a modification of the code available in simple.el. The reason to modify the default is for indentations of field text to work properly in auto-fill minor mode." (byte-code "` T!!n#!n?)/ 8@bi)j))" [opoint fill-column t move-to-column skip-chars-backward "^ " re-search-forward "[ ]" " " indent-new-comment-line 3 bibtex-current-field] 8)) (defun bibtex-auto-fill-mode (arg) "\ Toggle auto-fill mode. With arg, turn auto-fill mode on iff arg is positive. In auto-fill mode, inserting a space at a column beyond fill-column automatically breaks the line at a previous space." (interactive "P") (byte-code "ˆ ? ? !Vʼn" [auto-fill-hook arg nil prefix-numeric-value 0 bibtex-do-auto-fill] 3)) (defun bibtex-autofill-enable nil (interactive) (byte-code "!\"" [fill-column nil bibtex-auto-fill-mode 1 message "Auto-fill minor mode enabled (fill column is %d)."] 4)) (defun bibtex-autofill-disable nil (interactive) (byte-code "!!" [nil bibtex-auto-fill-mode 0 message "Auto-fill minor mode disabled."] 3)) (defun bibtex-abbrev-enable nil (interactive) (byte-code "!!" [nil abbrev-mode 1 message "Abbrev minor mode enabled."] 3)) (defun bibtex-abbrev-disable nil (interactive) (byte-code "!!" [nil abbrev-mode 0 message "Abbrev minor mode disabled."] 3)) (defun bibtex-mode-version nil (interactive) (byte-code "!" [nil message "BibTeX-mode V1.12 (1/26/92)."] 2)) (defun bibtex-copyright nil (byte-code "! \"" [tex-bib-to-bibtex nil boundp message "%s C-c C-h for help. Copyright (C) Regents UC." bibtex-mode-version] 5)) (defun bibtex-mode-help nil (interactive) (byte-code "! U!eb!‰!" [nil buffer-read-only t pop-to-buffer "--- BibTeX-mode Help ---" buffer-size 0 insert-string " ----- Catogeries ----- Entry Operations Built-in Entry Types Field Operations Abbreviation Mechanism Cleanup Facility Sorting Facilty Draft Making & Debugging Mode Operations Useful Variables ----- Entry Operations ----- M-x invoke new entry of C-c p bibtex-previous-entry C-c c bibtex-current-entry C-c n bibtex-next-entry C-c C-r bibtex-rename-current-entry C-c C-d p bibtex-dup-previous-entry C-c C-d c bibtex-dup-current-entry C-c C-d n bibtex-dup-next-entry C-c C-k p bibtex-kill-previous-entry C-c C-k c bibtex-kill-current-entry C-c C-k n bibtex-kill-next-entry ----- Built-in Entry Types ----- @article @book @booklet @conference @inbook @incollection @inproceedings @manual @masterthesis @misc @phdthesis @proceeding @techreport @unpublished ----- Field Operations ----- C-c C-p bibtex-previous-field C-c C-c bibtex-current-field C-c C-n bibtex-next-field C-c C-e d bibtex-erase-delimiters C-c C-e f bibtex-erase-field C-c C-e t bibtex-erase-text C-c C-t p bibtex-text-previous-entry C-c C-t n bibtex-text-next-entry LFD bibtex-newline-indent ESC LFD bibtex-newline-indent-label ------ Abbreviation Mechanism ----- M-x@group invoke group abbreviation M-x%group same as M-x@group M-x@string invoke field abbreviation M-x@abbreviation same as M-x@string C-c C-s bibtex-save-abbrev C-c C-l bibtex-load-abbrev C-c C-i g bibtex-insert-gabbrev C-c C-i f bibtex-insert-fabbrev C-c C-\\ g bibtex-make-gabbrev ----- Cleanup Facility ----- C-c ESC b bibtex-cleanup-buffer C-c ESC r bibtex-cleanup-region C-c ESC e bibtex-cleanup-entry ----- Sorting Facility ----- C-c LFD b bibtex-sort-buffer C-c LFD r bibtex-sort-region ----- Draft Making & Debugging ----- C-c C-\\ d bibtex-make-draft C-c C-@ bibtex-goto-error ----- Annotations Facility ----- C-c C-v bibtex-view-notefiles ----- Mode Operations ----- C-c C-h bibtex-mode-help unbound bibtex-mode-version C-c C-a SPC bibtex-abbrev-enable C-c C-a DEL bibtex-abbrev-disable C-c LFD SPC bibtex-autofill-enable C-c LFD DEL bibtex-autofill-disable ----- Useful Variables ----- bibtex-abbrev-files bibtex-abbrev-fields bibtex-context bibtex-entry-use-parens bibtex-field-use-quotes bibtex-field-indent bibtex-extra-fields bibtex-softcopy vortex-default-printer vortex-printer-data vortex-default-print-command " set-buffer-modified-p other-window 1] 6)) (defun bibtex-put-entry (spec) "\ Put out a new entry of TYPE where (TYPE XORF ORF REQF OPTF) is SPEC and XORF is the list of XOR field labels, nil if none; ORF is the list of OR field labels, nil if none; REQF is the list of other required field labels, nil if none; OPTF is the list of optional field labels, nil if none." (byte-code " @ 8 8 8 8 # # # !;8b Cdb  #`Z  \\ \\ ac r jc \"  jc \"  jc  \" c \"   \"! !!\" b*)\"." [type spec xorf orf reqf optf case-fold-search t ce bibtex-entry-open pos put-fl bibtex-field-indent bibtex-extra-fields bibtex-entry-close 1 2 3 4 bibtex-search-entry 0 newline delete-blank-lines insert ", " (lambda (fl) (mapcar (quote (lambda (x) (indent-to bibtex-field-indent) (insert x " = ") (if (vortex-memq x bibtex-abbrev-fields) nil (insert bibtex-field-pair)) (insert ", "))) fl)) "=============================== REQUIRED FIELDS =============================== " "-------------- Exclusive OR fields: specify exactly one -------------- " funcall "-------------- Inclusive OR fields: specify one or both -------------- " "------------- Rest of required fields: specify every one ------------- " "=============================== OPTIONAL FIELDS =============================== " previous-line end-of-line delete-char -1 next-line 10 error "Entry %s doesn't have any field labels. Abort."] 18)) (defun bibtex-invoke-entry (type &optional spec-only) "\ Put out a new bib entry of type TYPE. If the optional SPEC-ONLY is non-nil, return the specification list only." (byte-code " \" # * ' ! \"626 \")" [spec-only nil type spec bibtex-entry-types bibtex-entry-specs message "Invoking new entry of type %s..." bibtex-get-spec bibtex-put-entry "Invoking new entry of type %s...done" error "Invoking new entry of type %s...abort (undefined entry type)"] 7)) (defun bibtex-get-spec (key nl al) (byte-code " @\" @ A A#" [nl key al equal bibtex-get-spec] 5)) (defun @article (&optional spec-only) "\ Put out a new bib entry of type ARTICLE. An article from a journal or magazine. If the optional SPEC-ONLY is non-nil, return the specification list only." (interactive) (byte-code "\"" [spec-only nil bibtex-invoke-entry "@ARTICLE"] 3)) (defun @book (&optional spec-only) "\ Put out a new bib entry of type BOOK. A book with explicit publisher. If the optional SPEC-ONLY is non-nil, return the specification list only." (interactive) (byte-code "\"" [spec-only nil bibtex-invoke-entry "@BOOK"] 3)) (defun @booklet (&optional spec-only) "\ Put out a new bib entry of type BOOKLET. A work that is printed and bound, but without a named publisher or sponsoring institution. If the optional SPEC-ONLY is non-nil, return the specification list only." (interactive) (byte-code "\"" [spec-only nil bibtex-invoke-entry "@BOOKLET"] 3)) (defun @conference (&optional spec-only) "\ Put out a new bib entry of type CONFERENCE. Same as @inproceedings, included for Scribe compatibility. If the optional SPEC-ONLY is non-nil, return the specification list only." (interactive) (byte-code "\"" [spec-only nil bibtex-invoke-entry "@CONFERENCE"] 3)) (defun @inbook (&optional spec-only) "\ Put out a new bib entry of type INBOOK. A part of a book, which may be a chapter and/or a range of pages. If the optional SPEC-ONLY is non-nil, return the specification list only." (interactive) (byte-code "\"" [spec-only nil bibtex-invoke-entry "@INBOOK"] 3)) (defun @incollection (&optional spec-only) "\ Put out a new bib entry of type INCOLLECTION. A part of a book having its own title. If the optional SPEC-ONLY is non-nil, return the specification list only." (interactive) (byte-code "\"" [spec-only nil bibtex-invoke-entry "@INCOLLECTION"] 3)) (defun @inproceedings (&optional spec-only) "\ Put out a new bib entry of type INPROCEEDINGS. An article in a conference proceedings. If the optional SPEC-ONLY is non-nil, return the specification list only." (interactive) (byte-code "\"" [spec-only nil bibtex-invoke-entry "@INPROCEEDINGS"] 3)) (defun @manual (&optional spec-only) "\ Put out a new bib entry of type MANUAL. Technical documentation. If the optional SPEC-ONLY is non-nil, return the specification list only." (interactive) (byte-code "\"" [spec-only nil bibtex-invoke-entry "@MANUAL"] 3)) (defun @mastersthesis (&optional spec-only) "\ Put out a new bib entry of type MASTERSTHESIS. A Master's thesis. If the optional SPEC-ONLY is non-nil, return the specification list only." (interactive) (byte-code "\"" [spec-only nil bibtex-invoke-entry "@MASTERSTHESIS"] 3)) (defun @misc (&optional spec-only) "\ Put out a new bib entry of type MISC. Use this type when nothing else fits. If the optional SPEC-ONLY is non-nil, return the specification list only." (interactive) (byte-code "\"" [spec-only nil bibtex-invoke-entry "@MISC"] 3)) (defun @phdthesis (&optional spec-only) "\ Put out a new bib entry of type PHDTHESIS. A Ph.D. thesis. If the optional SPEC-ONLY is non-nil, return the specification list only." (interactive) (byte-code "\"" [spec-only nil bibtex-invoke-entry "@PHDTHESIS"] 3)) (defun @proceedings (&optional spec-only) "\ Put out a new bib entry of type PROCEEDINGS. The proceedings of a conference. If the optional SPEC-ONLY is non-nil, return the specification list only." (interactive) (byte-code "\"" [spec-only nil bibtex-invoke-entry "@PROCEEDINGS"] 3)) (defun @techreport (&optional spec-only) "\ Put out a new bib entry of type TECHREPORT. A report published by a school or other institution, usually numbered within a series. If the optional SPEC-ONLY is non-nil, return the specification list only." (interactive) (byte-code "\"" [spec-only nil bibtex-invoke-entry "@TECHREPORT"] 3)) (defun @unpublished (&optional spec-only) "\ Put out a new bib entry of type UNPUBLISHED. A document having an author and title, but not formally published. If the optional SPEC-ONLY is non-nil, return the specification list only." (interactive) (byte-code "\"" [spec-only nil bibtex-invoke-entry "@UNPUBLISHED"] 3)) (defun %group (entry) "\ Put out a new group abbreviation of type ENTRY. A group abbreviation is a collection of fields that serve as a special type of abbreviation. Regular (field) abbreviation can be used in group abbrev but not another group abbrev. Regular entry and field operations apply to group abbrev." (interactive "aGroup abbrev of type: ") (byte-code "ň! !! # , ! !c)!0\"*" [type entry spec bibtex-entry-types bibtex-entry-specs nil message "Invoking new group abbreviation..." upcase symbol-name bibtex-get-spec bibtex-put-entry beginning-of-line kill-word 1 "%GROUP" "Invoking new group abbreviation...done" error "Invoking new group abbreviation...abort (undefined entry type %s)"] 11)) (defun @group (entry) "\ Alias of %group." (interactive "aGroup abbrev of type: ") (byte-code "!" [entry nil %group] 2)) (defun @abbreviation nil "\ Put out an abbreviation skeleton." (interactive) (byte-code " !!!" [nil beginning-of-line open-line 1 insert-string "@STRING{ = \"\"}" search-backward " ="] 5)) (defun @string nil "\ An alias of @abbreviation." (interactive) (byte-code " " [nil @abbreviation] 2)) (defun bibtex-search-entry (&optional next) "\ Return attributes of an entry as (ES EE (TS TE TYPE) (LS LE LABEL)). If NEXT is non-nil, search forward, else backward. Return nil if fails." (byte-code " ̂ ͊ `) # $ o2`4`S!mA`C`T)!!b!`T \"E!!! \"E      F,," [direction next eol bor eor bibtex-entry-match t nil es ee tp lb re-search-forward re-search-backward end-of-line beginning-of-line funcall forward-list 1 match-beginning 0 match-end "\\w" buffer-substring "[{(]\\s *\\(\\S *\\)\\s *,"] 21)) (defconst bibtex-env "TEXBIB") (defconst bibtex-path (vortex-mkpath bibtex-env))