comparison lisp/textmodes/bibtex.el @ 26711:eac840d283b6

(bibtex-hs-forward-sexp): Added to support using the hideshow package. (hs-special-modes-alist): Added entry for bibtex to allow the use of the hideshow package. (bibtex-hide-entry-bodies): Deleted as hiding of entry bodies is not longer provided by bibtex.el directly. Instead the hideshow package should be used. (bibtex-mode-map, bibtex-edit-menu, bibtex-mode): Delete references to bibtex-hide-entry-bodies. Copyright notice is up to date. Moved maintainer information closer to the beginning of the bibtex.el file. (bibtex-maintainer-salutation): New constant. bibtex-version): New constant. bibtex-submit-bug-report): Use bibtex-version and bibtex-maintainer-salutation. (bibtex-entry-field-alist): Made booktitle field optional for @inproceedings entries when crossreferenced. (bibtex-entry-field-alist): Added booktitle field to proceedings entry type (for cross referencing). Thanks to Wagner Toledo Correa for the suggestion. (bibtex-string-file-path): Fixed typo. (bibtex-mode-map): Reserved the key `C-c &' for reftex.el. (bibtex-edit-menu): Added `reftex-view-crossref-from-bibtex' to menu.
author Gerd Moellmann <gerd@gnu.org>
date Sun, 05 Dec 1999 13:23:17 +0000
parents 37b1636d73d5
children 5e135f0faf1d
comparison
equal deleted inserted replaced
26710:ed440ffea308 26711:eac840d283b6
1 ;;; bibtex.el --- BibTeX mode for GNU Emacs 1 ;;; bibtex.el --- BibTeX mode for GNU Emacs
2 2
3 ;; Copyright (C) 1992, 1994, 1995, 1996, 1997 Free Software Foundation, Inc. 3 ;; Copyright (C) 1992, 1994, 1995, 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
4 4
5 ;; Author: Stefan Schoef <schoef@offis.uni-oldenburg.de> 5 ;; Author: Stefan Schoef <schoef@offis.uni-oldenburg.de>
6 ;; Bengt Martensson <bengt@mathematik.uni-Bremen.de> 6 ;; Bengt Martensson <bengt@mathematik.uni-Bremen.de>
7 ;; Mark Shapiro <shapiro@corto.inria.fr> 7 ;; Mark Shapiro <shapiro@corto.inria.fr>
8 ;; Mike Newton <newton@gumby.cs.caltech.edu> 8 ;; Mike Newton <newton@gumby.cs.caltech.edu>
41 ;;; Code: 41 ;;; Code:
42 42
43 (eval-when-compile 43 (eval-when-compile
44 (require 'compile)) 44 (require 'compile))
45 45
46
47 ;; Bug Reporting
48
49 (defconst
50 bibtex-maintainer-address "Dirk Herrmann <D.Herrmann@tu-bs.de>")
51 ;; current maintainer
52
53 (defconst
54 bibtex-maintainer-salutation "Hallo Dirk,")
55 ;; current maintainer
56
57 (defconst
58 bibtex-version "(emacs 20.4)")
59 ;; current version of the bibtex.el file
60
61
46 ;; User Options: 62 ;; User Options:
47 63
48 (defgroup bibtex nil 64 (defgroup bibtex nil
49 "BibTeX mode." 65 "BibTeX mode."
50 :group 'tex 66 :group 'tex
316 ("month" "Month of the publication as a string (remove braces)") 332 ("month" "Month of the publication as a string (remove braces)")
317 ("organization" "Sponsoring organization of the conference") 333 ("organization" "Sponsoring organization of the conference")
318 ("publisher" "Publishing company, its location") 334 ("publisher" "Publishing company, its location")
319 ("note" "Remarks to be put at the end of the \\bibitem"))) 335 ("note" "Remarks to be put at the end of the \\bibitem")))
320 ((("author" "Author1 [and Author2 ...] [and others]") 336 ((("author" "Author1 [and Author2 ...] [and others]")
321 ("title" "Title of the article in proceedings (BibTeX converts it to lowercase)") 337 ("title" "Title of the article in proceedings (BibTeX converts it to lowercase)"))
322 ("booktitle" "Name of the conference proceedings")) 338 (("booktitle" "Name of the conference proceedings")
323 (("pages" "Pages in the conference proceedings") 339 ("pages" "Pages in the conference proceedings")
324 ("year" "Year of publication") 340 ("year" "Year of publication")
325 ("editor" "Editor1 [and Editor2 ...] [and others]") 341 ("editor" "Editor1 [and Editor2 ...] [and others]")
326 ("volume" "Volume of the conference proceedings in the series") 342 ("volume" "Volume of the conference proceedings in the series")
327 ("number" "Number of the conference proceedings in a small series (overwritten by volume)") 343 ("number" "Number of the conference proceedings in a small series (overwritten by volume)")
328 ("series" "Series in which the conference proceedings appeared") 344 ("series" "Series in which the conference proceedings appeared")
362 ("address" "Address of the school (if not part of field \"school\") or country") 378 ("address" "Address of the school (if not part of field \"school\") or country")
363 ("month" "Month of the publication as a string (remove braces)") 379 ("month" "Month of the publication as a string (remove braces)")
364 ("note" "Remarks to be put at the end of the \\bibitem"))))) 380 ("note" "Remarks to be put at the end of the \\bibitem")))))
365 ("Proceedings" . (((("title" "Title of the conference proceedings") 381 ("Proceedings" . (((("title" "Title of the conference proceedings")
366 ("year" "Year of publication")) 382 ("year" "Year of publication"))
367 (("editor" "Editor1 [and Editor2 ...] [and others]") 383 (("booktitle" "Title of the proceedings for cross references")
384 ("editor" "Editor1 [and Editor2 ...] [and others]")
368 ("volume" "Volume of the conference proceedings in the series") 385 ("volume" "Volume of the conference proceedings in the series")
369 ("number" "Number of the conference proceedings in a small series (overwritten by volume)") 386 ("number" "Number of the conference proceedings in a small series (overwritten by volume)")
370 ("series" "Series in which the conference proceedings appeared") 387 ("series" "Series in which the conference proceedings appeared")
371 ("address" "Location of the Proceedings") 388 ("address" "Location of the Proceedings")
372 ("month" "Month of the publication as a string (remove braces)") 389 ("month" "Month of the publication as a string (remove braces)")
450 file)." 467 file)."
451 :group 'bibtex 468 :group 'bibtex
452 :type '(repeat file)) 469 :type '(repeat file))
453 470
454 (defvar bibtex-string-file-path (getenv "BIBINPUTS") 471 (defvar bibtex-string-file-path (getenv "BIBINPUTS")
455 "*Colon separated list of pathes to search for `bibtex-string-files'.") 472 "*Colon separated list of paths to search for `bibtex-string-files'.")
456 473
457 (defcustom bibtex-help-message t 474 (defcustom bibtex-help-message t
458 "*If not nil print help messages in the echo area on entering a new field." 475 "*If not nil print help messages in the echo area on entering a new field."
459 :group 'bibtex 476 :group 'bibtex
460 :type 'boolean) 477 :type 'boolean)
729 ;; are not used (yet) in bibtex.el. Fix if needed. 746 ;; are not used (yet) in bibtex.el. Fix if needed.
730 (defun bibtex-run-with-idle-timer (secs repeat function &rest args) 747 (defun bibtex-run-with-idle-timer (secs repeat function &rest args)
731 (start-itimer "bibtex" function secs (if repeat secs nil) t))) 748 (start-itimer "bibtex" function secs (if repeat secs nil) t)))
732 749
733 750
751 ;; Support for hideshow minor mode
752 (defun bibtex-hs-forward-sexp (arg)
753 "Replacement for `forward-sexp' to be used by `hs-minor-mode'."
754 (if (< arg 0)
755 (backward-sexp 1)
756 (if (looking-at "@\\S(*\\s(")
757 (progn
758 (goto-char (match-end 0))
759 (forward-char -1)
760 (forward-sexp 1))
761 (forward-sexp 1))))
762
763 (add-to-list
764 'hs-special-modes-alist
765 '(bibtex-mode "@\\S(*\\s(" "\\s)" nil bibtex-hs-forward-sexp nil))
766
767
734 ;; Syntax Table, Keybindings and BibTeX Entry List 768 ;; Syntax Table, Keybindings and BibTeX Entry List
735 (defvar bibtex-mode-syntax-table 769 (defvar bibtex-mode-syntax-table
736 (let ((st (make-syntax-table))) 770 (let ((st (make-syntax-table)))
737 (modify-syntax-entry ?\" "\"" st) 771 (modify-syntax-entry ?\" "\"" st)
738 (modify-syntax-entry ?$ "$$ " st) 772 (modify-syntax-entry ?$ "$$ " st)
745 (modify-syntax-entry ?~ " " st) 779 (modify-syntax-entry ?~ " " st)
746 st)) 780 st))
747 781
748 (defvar bibtex-mode-map 782 (defvar bibtex-mode-map
749 (let ((km (make-sparse-keymap))) 783 (let ((km (make-sparse-keymap)))
784 ;; The Key `C-c&' is reserved for reftex.el
750 (define-key km "\t" 'bibtex-find-text) 785 (define-key km "\t" 'bibtex-find-text)
751 (define-key km "\n" 'bibtex-next-field) 786 (define-key km "\n" 'bibtex-next-field)
752 (define-key km "\M-\t" 'bibtex-complete-string) 787 (define-key km "\M-\t" 'bibtex-complete-string)
753 (define-key km [(meta tab)] 'bibtex-complete-key) 788 (define-key km [(meta tab)] 'bibtex-complete-key)
754 (define-key km "\C-c\"" 'bibtex-remove-delimiters) 789 (define-key km "\C-c\"" 'bibtex-remove-delimiters)
771 (define-key km "\M-\C-a" 'bibtex-beginning-of-entry) 806 (define-key km "\M-\C-a" 'bibtex-beginning-of-entry)
772 (define-key km "\M-\C-e" 'bibtex-end-of-entry) 807 (define-key km "\M-\C-e" 'bibtex-end-of-entry)
773 (define-key km "\C-\M-l" 'bibtex-reposition-window) 808 (define-key km "\C-\M-l" 'bibtex-reposition-window)
774 (define-key km "\C-\M-h" 'bibtex-mark-entry) 809 (define-key km "\C-\M-h" 'bibtex-mark-entry)
775 (define-key km "\C-c\C-b" 'bibtex-entry) 810 (define-key km "\C-c\C-b" 'bibtex-entry)
776 (define-key km "\C-c\C-t" 'bibtex-hide-entry-bodies)
777 (define-key km "\C-c\C-rn" 'bibtex-narrow-to-entry) 811 (define-key km "\C-c\C-rn" 'bibtex-narrow-to-entry)
778 (define-key km "\C-c\C-rw" 'widen) 812 (define-key km "\C-c\C-rw" 'widen)
779 (define-key km "\C-c\C-o" 'bibtex-remove-OPT-or-ALT) 813 (define-key km "\C-c\C-o" 'bibtex-remove-OPT-or-ALT)
780 (define-key km "\C-c\C-e\C-i" 'bibtex-InProceedings) 814 (define-key km "\C-c\C-e\C-i" 'bibtex-InProceedings)
781 (define-key km "\C-c\C-ei" 'bibtex-InCollection) 815 (define-key km "\C-c\C-ei" 'bibtex-InCollection)
814 ["Paste Most Recently Killed Entry" bibtex-yank t] 848 ["Paste Most Recently Killed Entry" bibtex-yank t]
815 ["Paste Previously Killed Entry" bibtex-yank-pop t] 849 ["Paste Previously Killed Entry" bibtex-yank-pop t]
816 "--" 850 "--"
817 ["Ispell Entry" bibtex-ispell-entry t] 851 ["Ispell Entry" bibtex-ispell-entry t]
818 ["Ispell Entry Abstract" bibtex-ispell-abstract t] 852 ["Ispell Entry Abstract" bibtex-ispell-abstract t]
819 ["Narrow to Entry" bibtex-narrow-to-entry t]) 853 ["Narrow to Entry" bibtex-narrow-to-entry t]
854 "--"
855 ["View Cite Locations (RefTeX)" reftex-view-crossref-from-bibtex
856 (fboundp 'reftex-view-crossref-from-bibtex)])
820 ("Operating on Current Field" 857 ("Operating on Current Field"
821 ["Remove Delimiters" bibtex-remove-delimiters t] 858 ["Remove Delimiters" bibtex-remove-delimiters t]
822 ["Remove OPT or ALT Prefix" bibtex-remove-OPT-or-ALT t] 859 ["Remove OPT or ALT Prefix" bibtex-remove-OPT-or-ALT t]
823 ["Clear Field" bibtex-empty-field t] 860 ["Clear Field" bibtex-empty-field t]
824 "--" 861 "--"
838 ["Help about Current Field" bibtex-print-help-message t]) 875 ["Help about Current Field" bibtex-print-help-message t])
839 ("Operating on Buffer or Region" 876 ("Operating on Buffer or Region"
840 ["Validate Entries" bibtex-validate t] 877 ["Validate Entries" bibtex-validate t]
841 ["Sort Entries" bibtex-sort-buffer t] 878 ["Sort Entries" bibtex-sort-buffer t]
842 ["Reformat Entries" bibtex-reformat t] 879 ["Reformat Entries" bibtex-reformat t]
843 ["Hide Entry Bodies" bibtex-hide-entry-bodies t]
844 ["Count Entries" bibtex-count-entries t]) 880 ["Count Entries" bibtex-count-entries t])
845 ("Miscellaneous" 881 ("Miscellaneous"
846 ["Convert Alien Buffer" bibtex-convert-alien t] 882 ["Convert Alien Buffer" bibtex-convert-alien t]
847 ["Submit Bug Report" bibtex-submit-bug-report t]))) 883 ["Submit Bug Report" bibtex-submit-bug-report t])))
848 884
864 ["Miscellaneous" bibtex-Misc t] 900 ["Miscellaneous" bibtex-Misc t]
865 ["String" bibtex-String t] 901 ["String" bibtex-String t]
866 ["Preamble" bibtex-Preamble t])) 902 ["Preamble" bibtex-Preamble t]))
867 903
868 904
869 ;; Bug Reporting
870
871 (defconst
872 bibtex-maintainer-address "Dirk Herrmann <D.Herrmann@tu-bs.de>")
873 ;; current maintainer
874
875
876 ;; Internal Variables 905 ;; Internal Variables
877 906
878 (defvar bibtex-pop-previous-search-point nil) 907 (defvar bibtex-pop-previous-search-point nil)
879 ;; Next point where bibtex-pop-previous starts looking for a similar 908 ;; Next point where bibtex-pop-previous starts looking for a similar
880 ;; entry. 909 ;; entry.
962 991
963 (defconst bibtex-reference-type "@[^\"#%'(),={} \t\n0-9][^\"#%'(),={} \t\n]*") 992 (defconst bibtex-reference-type "@[^\"#%'(),={} \t\n0-9][^\"#%'(),={} \t\n]*")
964 ;; Regexp defining the type part of a BibTeX reference entry (almost 993 ;; Regexp defining the type part of a BibTeX reference entry (almost
965 ;; the same as bibtex-field-name) 994 ;; the same as bibtex-field-name)
966 995
967 (defconst bibtex-reference-key "[][a-z0-9.:;?!`'/*@+=|()<>&_^$-]+") 996 (defconst bibtex-reference-key "[][a-zA-Z0-9.:;?!`'/*@+=|()<>&_^$-]+")
968 ;; Regexp defining the label part of a BibTeX reference entry 997 ;; Regexp defining the label part of a BibTeX reference entry
969 998
970 (defconst bibtex-field-name "[^\"#%'(),={} \t\n0-9][^\"#%'(),={} \t\n]*") 999 (defconst bibtex-field-name "[^\"#%'(),={} \t\n0-9][^\"#%'(),={} \t\n]*")
971 ;; Regexp defining the name part of a BibTeX field (almost the same as 1000 ;; Regexp defining the name part of a BibTeX field (almost the same as
972 ;; bibtex-reference-type) 1001 ;; bibtex-reference-type)
1392 (bibtex-make-field (concat "OPT" e-t)))) 1421 (bibtex-make-field (concat "OPT" e-t))))
1393 1422
1394 (defun bibtex-move-outside-of-entry () 1423 (defun bibtex-move-outside-of-entry ()
1395 ;; Make sure we are outside of a BibTeX entry. 1424 ;; Make sure we are outside of a BibTeX entry.
1396 (let ((orig-point (point))) 1425 (let ((orig-point (point)))
1397 (bibtex-end-of-entry) 1426 (bibtex-end-of-entry)
1398 (if (< (point) orig-point) 1427 (if (< (point) orig-point)
1399 ;; We moved backward, so we weren't inside an entry to begin with. 1428 ;; We moved backward, so we weren't inside an entry to begin with.
1400 ;; Leave point at the beginning of a line, and preferably 1429 ;; Leave point at the beginning of a line, and preferably
1401 ;; at the beginning of a paragraph. 1430 ;; at the beginning of a paragraph.
1402 (progn 1431 (progn
1964 (substring titlestring (match-beginning 0) end-match))) 1993 (substring titlestring (match-beginning 0) end-match)))
1965 (if (bibtex-member-of-regexp 1994 (if (bibtex-member-of-regexp
1966 titleword 1995 titleword
1967 bibtex-autokey-titleword-ignore) 1996 bibtex-autokey-titleword-ignore)
1968 (setq counter (1- counter)) 1997 (setq counter (1- counter))
1969 (setq 1998 (setq
1970 titleword 1999 titleword
1971 (funcall bibtex-autokey-titleword-case-convert titleword)) 2000 (funcall bibtex-autokey-titleword-case-convert titleword))
1972 (if (or (not (numberp bibtex-autokey-titlewords)) 2001 (if (or (not (numberp bibtex-autokey-titlewords))
1973 (< counter bibtex-autokey-titlewords)) 2002 (< counter bibtex-autokey-titlewords))
1974 (setq titlewords (append titlewords (list titleword))) 2003 (setq titlewords (append titlewords (list titleword)))
2469 bibtex-reposition-window 2498 bibtex-reposition-window
2470 bibtex-mark-entry 2499 bibtex-mark-entry
2471 bibtex-ispell-abstract 2500 bibtex-ispell-abstract
2472 bibtex-ispell-entry 2501 bibtex-ispell-entry
2473 bibtex-narrow-to-entry 2502 bibtex-narrow-to-entry
2474 bibtex-hide-entry-bodies
2475 bibtex-sort-buffer 2503 bibtex-sort-buffer
2476 bibtex-validate 2504 bibtex-validate
2477 bibtex-count 2505 bibtex-count
2478 bibtex-fill-entry 2506 bibtex-fill-entry
2479 bibtex-reformat 2507 bibtex-reformat
2610 (progn 2638 (progn
2611 (require 'reporter) 2639 (require 'reporter)
2612 (let ((reporter-prompt-for-summary-p t)) 2640 (let ((reporter-prompt-for-summary-p t))
2613 (reporter-submit-bug-report 2641 (reporter-submit-bug-report
2614 bibtex-maintainer-address 2642 bibtex-maintainer-address
2615 (concat "bibtex.el " "(emacs 19.35)") 2643 (concat "bibtex.el " bibtex-version)
2616 (list 2644 (list
2617 'system-configuration 2645 'system-configuration
2618 'system-configuration-options 2646 'system-configuration-options
2619 'bibtex-mode-hook 2647 'bibtex-mode-hook
2620 'bibtex-parse-keys-timeout 2648 'bibtex-parse-keys-timeout
2676 'bibtex-field-kill-ring-max 2704 'bibtex-field-kill-ring-max
2677 'bibtex-entry-kill-ring-max 2705 'bibtex-entry-kill-ring-max
2678 ;; user variables which shouldn't cause any errors 2706 ;; user variables which shouldn't cause any errors
2679 ) 2707 )
2680 nil nil 2708 nil nil
2681 (concat "To the bibtex.el maintainer: 2709 (concat bibtex-maintainer-salutation "
2682 2710
2683 I want to report a bug on Emacs BibTeX mode. 2711 I want to report a bug on Emacs BibTeX mode " bibtex-version ".
2684 I've read the `Bugs' section in the `Emacs' info page, so I know how 2712 I've read the `Bugs' section in the `Emacs' info page, so I know how
2685 to make a clear and unambiguous report. I have started a fresh Emacs 2713 to make a clear and unambiguous report. I have started a fresh Emacs
2686 via `"invocation-name " --no-init-file --no-site-file', thereafter (in 2714 via `"invocation-name " --no-init-file --no-site-file', thereafter (in
2687 case I'm reporting on a version of `bibtex.el' which is not part of 2715 case I'm reporting on a version of `bibtex.el' which is not part of
2688 the standard emacs distribution) I loaded the questionable version 2716 the standard emacs distribution) I loaded the questionable version
3000 "Narrow buffer to current BibTeX entry." 3028 "Narrow buffer to current BibTeX entry."
3001 (interactive) 3029 (interactive)
3002 (save-excursion 3030 (save-excursion
3003 (narrow-to-region 3031 (narrow-to-region
3004 (bibtex-beginning-of-entry) (bibtex-end-of-entry)))) 3032 (bibtex-beginning-of-entry) (bibtex-end-of-entry))))
3005
3006 (defun bibtex-hide-entry-bodies (&optional arg)
3007 "Hide all lines between first and last BibTeX entries not beginning with @.
3008 With prefix argument ARG, show all text."
3009 (interactive "P")
3010 (save-excursion
3011 (let ((buffer-read-only nil))
3012 (if arg
3013 (subst-char-in-region (point-min) (point-max) ?\r ?\n t)
3014 (let ((pos (point-max)))
3015 (goto-char (point-max))
3016 (while (re-search-backward "^@" nil t)
3017 (subst-char-in-region (point) pos ?\n ?\r t)
3018 (if (not (bobp)) (forward-char -1))
3019 (setq pos (point)))))
3020 (setq selective-display (not arg)))))
3021 3033
3022 (defun bibtex-sort-buffer () 3034 (defun bibtex-sort-buffer ()
3023 "Sort BibTeX buffer alphabetically by key. 3035 "Sort BibTeX buffer alphabetically by key.
3024 Text outside of BibTeX entries is not affected. If 3036 Text outside of BibTeX entries is not affected. If
3025 `bibtex-sort-ignore-string-entries' is non-nil, @String entries will be 3037 `bibtex-sort-ignore-string-entries' is non-nil, @String entries will be