annotate lisp/textmodes/bibtex.el @ 8052:18870eff0f54

(ispell-message): Avoid an infinite loop.
author Richard M. Stallman <rms@gnu.org>
date Sat, 25 Jun 1994 04:30:44 +0000
parents 55a80566d955
children e56d09b95778
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
662
8a533acedb77 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 584
diff changeset
1 ;;; bibtex.el --- BibTeX mode for GNU Emacs
8a533acedb77 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 584
diff changeset
2
7300
cc7cd83ccf3f Update copyright.
Karl Heuer <kwzh@gnu.org>
parents: 5409
diff changeset
3 ;; Copyright (C) 1992, 1994 Free Software Foundation, Inc.
845
213978acbc1e entered into RCS
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
4
810
80303373daae *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 807
diff changeset
5 ;; Author: Bengt Martensson <ubrinf!mond!bengt>
80303373daae *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 807
diff changeset
6 ;; Mark Shapiro <shapiro@corto.inria.fr>
80303373daae *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 807
diff changeset
7 ;; Mike Newton <newton@gumby.cs.caltech.edu>
80303373daae *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 807
diff changeset
8 ;; Aaron Larson <alarson@src.honeywell.com>
2602
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
9 ;; Version: 1.3.1
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
10 ;; Maintainer:Aaron Larson <alarson@src.honeywell.com>
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
11 ;; Adapted-By: ESR
810
80303373daae *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 807
diff changeset
12 ;; Keywords: tex, bib
80303373daae *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 807
diff changeset
13
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
14 ;; This file is part of GNU Emacs.
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
15
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
16 ;; GNU Emacs is free software; you can redistribute it and/or modify
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
17 ;; it under the terms of the GNU General Public License as published by
1851
b3ce1eae3eb0 Update GPL version.
Richard M. Stallman <rms@gnu.org>
parents: 845
diff changeset
18 ;; the Free Software Foundation; either version 2, or (at your option)
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
19 ;; any later version.
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
20
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
21 ;; GNU Emacs is distributed in the hope that it will be useful,
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
22 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
23 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
24 ;; GNU General Public License for more details.
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
25
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
26 ;; You should have received a copy of the GNU General Public License
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
27 ;; along with GNU Emacs; see the file COPYING. If not, write to
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
28 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
29
2602
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
30 ;;; TODO distribute texinfo file.
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
31
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
32 ;;; LCD Archive Entry:
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
33 ;;; bibtex-mode|Bengt Martensson, Marc Shapiro, Aaron Larson|
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
34 ;;; alarson@src.honeywell.com|
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
35 ;;; Support for maintaining BibTeX format bibliography databases|
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
36 ;;; 93-03-29|version 1.3|~/modes/bibtex-mode.el.Z|
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
37
2307
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1851
diff changeset
38 ;;; Commentary:
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1851
diff changeset
39
2602
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
40 ;;; BUGS:
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
41 ;;; 1. using regular expressions to match the entire bibtex entry dies
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
42 ;;; on long bibtex entires (e.g. those containing abstracts) since
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
43 ;;; the length of regular expression matches is fairly limited.
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
44 ;;; 2. When inserting a string (with \C-C\C-E\s) hitting a TAB results
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
45 ;;; in the error message "Can't find enclosing Bibtex field" instead
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
46 ;;; of moving to the empty string. [reported by gernot@cs.unsw.oz.au]
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
47 ;;; 3. Function string-equalp should be in a library file, not in this
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
48 ;;; file.
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
49
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
50 ;;; (current keeper: alarson@src.honeywell.com
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
51 ;;; previous: shapiro@corto.inria.fr)
2307
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1851
diff changeset
52
810
80303373daae *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 807
diff changeset
53 ;;; Change Log:
561
a819dc25b9e7 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 257
diff changeset
54
2602
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
55 ;; Mon Mar 29 14:06:06 1993 Aaron Larson (alarson at gendibal)
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
56 ;;
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
57 ;; * bibtex.el: V1.3 released Mar 30, 1993
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
58 ;; (bibtex-field-name): Fix to match definition if latex manual,
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
59 ;; specifically letters, digits, and punctuation other than comma.
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
60 ;; Underscore is retained for historical reasons.
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
61 ;; (bibtex-make-field): Fix to work around bug in Lucid prin1-to-string
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
62 ;; function as reported by Martin Sjolin <marsj@ida.liu.se>.
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
63 ;; (bibtex-entry): minor code cleanup.
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
64 ;; (bibtex-mode-map): Remove key binding (C-c n) for
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
65 ;; narrow-to-bibtex-entry, previous binding violated emacs policy of
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
66 ;; reserving C-c followed by a letter for user customization.
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
67 ;; revise modification history to better conform to FSF changelog
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
68 ;; standards.
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
69 ;; (bibtex-refile-entry): Removed. Would need disclaimer papers to
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
70 ;; incorporate it into official sources, and unable to contact author.
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
71 ;; Fix minor "syntax" errors in documentation strings and such found
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
72 ;; by new byte compiler. Funs bibtex-mode, bibtex-remove-double-quotes
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
73 ;;
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
74 ;;
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
75 ;; Fri Jan 15 14:06:06 1993 Aaron Larson (alarson at gendibal)
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
76 ;;
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
77 ;; * bibtex.el: V1.2 released Feb 15 1993
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
78 ;; (find-bibtex-entry-location bibtex-make-field): Fixed placement of
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
79 ;; "interactive specification". [Bug report from
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
80 ;; mernst@theory.lcs.mit.edu]
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
81 ;; Fixed problem where bibtex-entry would fail if user typed entry
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
82 ;; name in wrong case.
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
83 ;; (bibtex-inside-field) Position the cursor _before_ the last comma
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
84 ;; on a line (the comma is not necessarily "inside" the field); this
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
85 ;; does not seem to break any existing code. ref sct@dcs.edinburgh.ac.uk
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
86 ;; (bibtex-enclosing-field, bibtex-enclosing-reference): leave
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
87 ;; point unmoved if no enclosing field/reference is found. As a
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
88 ;; result of changes (3) and (4) bibtex-next-field works properly,
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
89 ;; even when called from the entry key position.
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
90 ;; (bibtex-remove-OPT): realign the '=' after removing the 'opt'.
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
91 ;; (bibtex-clean-entry): always remove any trailing comma from the
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
92 ;; end of a bibtex entry (these commas get stripped automatically when
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
93 ;; optional fields are killed by bibtex-kill-optional-field, but can be
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
94 ;; left if optional fields are removed by other means).
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
95 ;; (bibtex-x-help) Replace tab with spaces in X menu as noted by
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
96 ;; khera@cs.duke.edu
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
97 ;; (bibtex-refile-entry): Added (from brannon@jove.cs.caltech.edu)
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
98 ;; (bibtex-sort-ignore-string-entries sort-bibtex-entries,
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
99 ;; map-bibtex-entries): Added variable as requested by
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
100 ;; gernot@cs.unsw.oz.au, required changes to funs.
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
101 ;; (bibtex-current-entry-label): Added at request of
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
102 ;; yasuro@maekawa.is.uec.ac.jp
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
103 ;; (bibtex-DEAthesis:) Deleted along with corresponding entry from
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
104 ;; bibtex-x-help per shapiro@corto.inria.fr
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
105 ;; Moved narrow-to-bibtex-entry from C-c C-n to C-c n (the previous
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
106 ;; binding was in conflict with the binding for bibtex-pop-next.
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
107 ;; bug report from [shapiro@corto.inria.fr]
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
108 ;;
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
109
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
110 ;;;
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
111 ;;; alarson@src.honeywell.com 92-Feb-13
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
112 ;;; 1. Made bibtex-entry user callable, now prompts for entry type (e.g.
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
113 ;;; Article), with completion, and bound it to a key. This is now my
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
114 ;;; preferred way to add most entries.
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
115 ;;; 2. Made fields of a bibtex entry derived from the alist bibtex-entry-
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
116 ;;; field-alist.
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
117 ;;; 3. Fixed handling of escaped double quotes, e.g. "Schr{\"o}dinger".
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
118 ;;; 4. Fixed bug where unhiding bibtex entries moved point.
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
119 ;;; 5. Made "field name" specs permit (name . value) for defaulting. E.g.
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
120 ;;; (setq bibtex-mode-user-optional-fields '(("library" . "alarson")))
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
121 ;;; will generate the field:
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
122 ;;; library = "alarson",
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
123 ;;; 6. Added binding for narrow-to-bibtex-entry
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
124 ;;; 7. Adding a bibtex entry now runs hook: bibtex-add-entry-hook
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
125 ;;; 8. Made bibtex-clean-entry fixup text alignment, and eliminated the
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
126 ;;; dependency on bibtex-enclosing-reference which has a problem with
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
127 ;;; long entries (e.g. those containing abstracts).
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
128 ;;;
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
129 ;;; alarson@src.honeywell.com 92-Jan-31
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
130 ;;; Added support for: ispell, beginning/end of entry movement, a simple
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
131 ;;; outline like mode (hide the bodies of bibtex entries), support for
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
132 ;;; sorting bibtex entries, and maintaining them in sorted order, and
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
133 ;;; simple buffer validation.
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
134 ;;; User visible functions added:
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
135 ;;; ispell-{abstract,bibtex-entry}, {beginning,end}-of-bibtex-entry
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
136 ;;; hide-bibtex-entry-bodies, sort-bibtex-entries, validate-bibtex-
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
137 ;;; buffer, find-bibtex-duplicates
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
138 ;;; user visible variables added:
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
139 ;;; bibtex-maintain-sorted-entries
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
140 ;;; new local keybindings:
3618
58f653fa4e5b (bibtex-mode-map): Use tex-insert-quote, not TeX-...
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
141 ;;; " tex-insert-quote
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
142 ;;; C-c$ ispell-bibtex-entry
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
143 ;;; M-C-a beginning-of-bibtex-entry
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
144 ;;; M-C-e end-of-bibtex-entry
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
145 ;;; Mike Newton (newton@gumby.cs.caltech.edu) 90.11.17
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
146 ;;; * Handle items like
3591
507f64624555 Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents: 3552
diff changeset
147 ;;; title = poft # "Fifth Tri-quarterly" # random-conf,
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
148 ;;; and title = {This title is inside curlies}
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
149 ;;; * added user settable, always present, optional fields
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
150 ;;; * fixed 'bibtex-find-it's doc string's location
3591
507f64624555 Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents: 3552
diff changeset
151 ;;; * bibtex-field-text made more general (it wouldn't handle the # construct)
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
152 ;;; and it now handles a small subset of the {} cases
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
153
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
154 ;;; Bengt Martensson, March 6
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
155 ;;; Adapted to Bibtex 0.99 by updating the optional fields according
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
156 ;;; to the document BibTeXing, Oren Patashnik, dated January 31, 1988.
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
157 ;;; Updated documentation strings accordingly. Added (provide 'bibtex).
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
158 ;;; If bibtex-include-OPT-crossref is non-nil, every entry will have
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
159 ;;; an OPTcrossref field, analogously for bibtex-include-OPTkey and
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
160 ;;; bibtex-include-OPTannote. Added bibtex-preamble, bound to ^C^EP,
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
161 ;;; and also found in X- and sun-menus. Cleaned up the sun-menu
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
162 ;;; stuff, and made it more uniform with the X-menu stuff. Marc: I
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
163 ;;; strongly suspect that I broke your parsing... (Or, more
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
164 ;;; correctly, BibTeX 0.99 broke it.)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
165 ;;; Added bibtex-clean-entry-zap-empty-opts, defvar'd to t. If it
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
166 ;;; is nil, bibtex-clean-entry will leave empty optional fields alone.
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
167
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
168 ;;; Marc Shapiro 1-feb-89: integrated changes by Bengt Martensson 88-05-06:
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
169 ;;; Added Sun menu support. Locally bound to right mouse button in
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
170 ;;; bibtex-mode. Emacs 18.49 allows local mouse bindings!!
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
171 ;;; Commented out DEAthesis.
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
172
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
173 ;;; Marc Shapiro 6-oct-88
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
174 ;;; * skip-whitespace replaced by skip-chars-forward
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
175 ;;; * use indent-to-column instead of inserting tabs (changes to
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
176 ;;; bibtex-entry, bibtex-make-entry, bibtex-make-OPT-entry, renamed to
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
177 ;;; bibtex-make-optional-entry)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
178 ;;; * C-c C-k deletes the current OPT entry entirely
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
179 ;;; * C-c C-d replaces text of field with ""
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
180 ;;; * renamed bibtex-find-it to bibtex-find-text. With arg, now goes to
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
181 ;;; start of text. Fixed bugs in it.
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
182
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
183 ;;; Marc Shapiro 23-sep-88
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
184 ;;; * bibtex-clean-entry moves past end of entry.
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
185 ;;; * bibtex-clean-entry signals mandatory fields left empty.
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
186
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
187 ;;; Marc Shapiro 18-jul-88
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
188 ;;; * Fixed bug in bibtex-flash-entry
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
189 ;;; * Moved all the entry type keystrokes to "C-c C-e something" (instead of
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
190 ;;; "C-c something" previously) to make room for more. C-c C-e is
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
191 ;;; supposed to stand for "entry" [idea taken from mail-mode]. Moved
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
192 ;;; bibtex-pop-previous to C-c C-p and bibtex-pop-next to C-c C-n.
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
193 ;;; * removed binding for "\e[25~"
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
194 ;;; * replaced bibtex-clean-optionals by bibtex-clean-entry, bound to
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
195 ;;; C-c C-c
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
196
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
197 ;;; Marc Shapiro 13-jul-88 [based on ideas by Sacha Krakowiak of IMAG]
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
198 ;;; * bibtex-pop-previous replaces current field with value of
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
199 ;;; similar field in previous entry. May be called n times in a row
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
200 ;;; (or with arg n) to pop similar field of n'th previous entry.
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
201 ;;; There is also a bibtex-pop-next to get similar field of next
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
202 ;;; entry.
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
203 ;;; * C-c C-k now kills all empty optional fields of current entry, and
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
204 ;;; removes "OPT" for those optional fields which have text.
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
205
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
206 ;;; Marc Shapiro 14-dec-87
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
207 ;;; Cosmetic fixes. Fixed small bug in bibtex-move-outside-of-entry.
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
208 ;;; Skip Montanaro <steinmetz!sprite!montanaro> 7-dec-87, Shapiro 10-dec-87
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
209 ;;; before inserting an entry, make sure we are outside of a bib entry
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
210 ;;; Marc Shapiro 3-nov-87
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
211 ;;; addition for France: DEAthesis
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
212 ;;; Marc Shapiro 19-oct-1987
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
213 ;;; add X window menu option; bug fixes. TAB, LFD, C-c " and C-c C-o now
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
214 ;;; behave consistently; deletion never occurs blindly.
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
215 ;;; Marc Shapiro <shapiro@inria.inria.fr> 15-oct-1986
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
216 ;;; align long lines nicely; C-c C-o checks for the "OPT" string;
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
217 ;;; TAB goes to the end of the string; use lower case; use
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
218 ;;; run-hooks
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
219
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
220 ;;; Bengt Martensson <ubrinf!mond!bengt> 87-06-28
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
221 ;;; Bengt Martensson <bengt@mathematik.uni-Bremen.de> 87-06-28
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
222 ;;; Original version
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
223
2602
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
224 ;;; Code:
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
225
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
226 ;;; NOTE by Marc Shapiro, 14-dec-87:
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
227 ;;; (bibtex-x-environment) binds an X menu for bibtex mode to x-button-c-right.
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
228 ;;; Trouble is, in Emacs 18.44 you can't have a mode-specific mouse binding,
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
229 ;;; so it will remain active in all windows. Yuck!
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
230
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
231 (provide 'bibtex)
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
232
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
233 ;;; these guys typically don't have autoloads...[alarson:19920131.1548CST]
2602
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
234 ;;; Check for fboundp first so that if user autoloads them from non standard
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
235 ;;; places, the users bindings will take precedence.
3618
58f653fa4e5b (bibtex-mode-map): Use tex-insert-quote, not TeX-...
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
236 (if (not (fboundp 'tex-insert-quote))
58f653fa4e5b (bibtex-mode-map): Use tex-insert-quote, not TeX-...
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
237 (autoload 'tex-insert-quote "tex-mode"))
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
238 (if (not (fboundp 'sort-subr))
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
239 (autoload 'sort-subr "sort"))
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
240
2602
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
241 ;;; These should be in a more generally accessible location.
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
242
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
243 (defun string-equalp (s1 s2)
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
244 "Like string= except differences in case are ignored."
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
245 (let ((ss1 (if (symbolp s1) (symbol-name s1) s1))
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
246 (ss2 (if (symbolp s2) (symbol-name s2) s2)))
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
247 (and (= (length ss1) (length ss2))
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
248 (string-equal (upcase ss1) (upcase ss2)))))
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
249
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
250 ;;; This should be moved into simple.el, and the functions there modified
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
251 ;;; to call it rather than doing it themselves.
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
252 (defun put-string-on-kill-ring (string)
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
253 "Make STRING be the first element of the kill ring."
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
254 (setq kill-ring (cons string kill-ring))
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
255 (if (> (length kill-ring) kill-ring-max)
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
256 (setcdr (nthcdr (1- kill-ring-max) kill-ring) nil))
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
257 (setq kill-ring-yank-pointer kill-ring))
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
258
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
259
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
260
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
261
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
262 (defvar bibtex-clean-entry-zap-empty-opts t
561
a819dc25b9e7 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 257
diff changeset
263 "*If non-nil, bibtex-clean-entry will delete all empty optional fields.")
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
264
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
265 (defvar bibtex-include-OPTcrossref t
561
a819dc25b9e7 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 257
diff changeset
266 "*If non-nil, all entries will have an OPTcrossref field.")
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
267 (defvar bibtex-include-OPTkey t
561
a819dc25b9e7 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 257
diff changeset
268 "*If non-nil, all entries will have an OPTkey field.")
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
269 (defvar bibtex-include-OPTannote t
561
a819dc25b9e7 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 257
diff changeset
270 "*If non-nil, all entries will have an OPTannote field.")
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
271
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
272 ;; note: the user should be allowed to have their own list of always
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
273 ;; available optional fields. exs: "keywords" "categories"
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
274
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
275 (defvar bibtex-mode-user-optional-fields nil ;no default value
561
a819dc25b9e7 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 257
diff changeset
276 "*List of optional fields that user want to have as always present
2602
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
277 when making a bibtex entry. One possibility is for ``keywords''.
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
278 Entries can be either strings or conses, in which case the car should be
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
279 string and the cdr the value to be inserted.")
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
280
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
281 (defvar bibtex-mode-syntax-table
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
282 (let ((st (make-syntax-table)))
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
283 ;; [alarson:19920214.1004CST] make double quote a string quote
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
284 (modify-syntax-entry ?\" "\"" st)
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
285 (modify-syntax-entry ?$ "$$ " st)
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
286 (modify-syntax-entry ?% "< " st)
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
287 (modify-syntax-entry ?' "w " st)
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
288 (modify-syntax-entry ?@ "w " st)
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
289 (modify-syntax-entry ?\\ "\\" st)
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
290 (modify-syntax-entry ?\f "> " st)
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
291 (modify-syntax-entry ?\n "> " st)
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
292 (modify-syntax-entry ?~ " " st)
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
293 st))
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
294
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
295 (defvar bibtex-mode-abbrev-table nil "")
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
296 (define-abbrev-table 'bibtex-mode-abbrev-table ())
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
297 (defvar bibtex-mode-map
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
298 (let ((km (make-sparse-keymap)))
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
299
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
300 (define-key km "\t" 'bibtex-find-text)
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
301 (define-key km "\n" 'bibtex-next-field)
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
302 (define-key km "\C-c\"" 'bibtex-remove-double-quotes)
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
303 (define-key km "\C-c\C-c" 'bibtex-clean-entry)
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
304 (define-key km "\C-c?" 'describe-mode)
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
305 (define-key km "\C-c\C-p" 'bibtex-pop-previous)
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
306 (define-key km "\C-c\C-n" 'bibtex-pop-next)
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
307 (define-key km "\C-c\C-k" 'bibtex-kill-optional-field)
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
308 (define-key km "\C-c\C-d" 'bibtex-empty-field)
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
309
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
310 ;; [alarson:19920131.1543CST]
3618
58f653fa4e5b (bibtex-mode-map): Use tex-insert-quote, not TeX-...
Richard M. Stallman <rms@gnu.org>
parents: 3591
diff changeset
311 (define-key km "\"" 'tex-insert-quote)
2602
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
312 (define-key km "\C-c$" 'ispell-bibtex-entry)
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
313 (define-key km "\M-\C-a" 'beginning-of-bibtex-entry)
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
314 (define-key km "\M-\C-e" 'end-of-bibtex-entry)
4611
5495e1a7a79c (bibtex-mode-map): Change C-c e to C-c C-b.
Richard M. Stallman <rms@gnu.org>
parents: 3618
diff changeset
315 (define-key km "\C-c\C-b" 'bibtex-entry)
2602
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
316 ; (define-key km "\C-cn" 'narrow-to-bibtex-entry)
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
317
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
318 (define-key km "\C-c\C-e\C-a" 'bibtex-Article)
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
319 (define-key km "\C-c\C-e\C-b" 'bibtex-Book)
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
320 ; (define-key km "\C-c\C-e\C-d" 'bibtex-DEAthesis)
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
321 (define-key km "\C-c\C-e\C-c" 'bibtex-InProceedings)
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
322 (define-key km "\C-c\C-e\C-i" 'bibtex-InBook)
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
323 (define-key km "\C-c\C-ei" 'bibtex-InCollection)
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
324 (define-key km "\C-c\C-eI" 'bibtex-InProceedings)
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
325 (define-key km "\C-c\C-e\C-m" 'bibtex-Manual)
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
326 (define-key km "\C-c\C-em" 'bibtex-MastersThesis)
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
327 (define-key km "\C-c\C-eM" 'bibtex-Misc)
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
328 (define-key km "\C-c\C-o" 'bibtex-remove-OPT)
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
329 (define-key km "\C-c\C-e\C-p" 'bibtex-PhdThesis)
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
330 (define-key km "\C-c\C-ep" 'bibtex-Proceedings)
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
331 (define-key km "\C-c\C-eP" 'bibtex-preamble)
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
332 (define-key km "\C-c\C-e\C-t" 'bibtex-TechReport)
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
333 (define-key km "\C-c\C-e\C-s" 'bibtex-string)
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
334 (define-key km "\C-c\C-e\C-u" 'bibtex-Unpublished)
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
335 km))
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
336
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
337 (defvar bibtex-pop-previous-search-point nil
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
338 "Next point where bibtex-pop-previous should start looking for a similar
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
339 entry.")
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
340
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
341 (defvar bibtex-pop-next-search-point nil
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
342 "Next point where bibtex-pop-next should start looking for a similar
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
343 entry.")
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
344
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
345 (defvar bibtex-entry-field-alist
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
346 '(
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
347 ("Article" . ((("author" "title" "journal" "year")
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
348 ("volume" "number" "pages" "month" "note"))
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
349 (("author" "title")
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
350 ("journal" "year" "volume" "number" "pages"
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
351 "month" "note"))))
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
352 ("Book" . ((("author" "title" "publisher" "year")
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
353 ("editor" "volume" "number" "series" "address"
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
354 "edition" "month" "note"))))
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
355 ("Booklet" . ((("title")
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
356 ("author" "howpublished" "address" "month" "year" "note"))))
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
357
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
358 ;; France: Dipl\^{o}me d'Etudes Approfondies (similar to Master's)
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
359 ; ("DEAthesis" . ((("author" "title" "school" "year")
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
360 ; ("address" "month" "note"))))
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
361
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
362 ("InBook" . ((("author" "title" "chapter" "publisher" "year")
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
363 ("editor" "pages" "volume" "number" "series" "address"
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
364 "edition" "month" "type" "note"))
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
365 (("author" "title" "chapter")
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
366 ("publisher" "year" "editor" "pages" "volume" "number"
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
367 "series" "address" "edition" "month" "type" "note"))))
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
368
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
369
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
370 ("InCollection" . ((("author" "title"
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
371 "booktitle" "publisher" "year")
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
372 ("editor" "volume" "number" "series" "type" "chapter"
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
373 "pages" "address" "edition" "month" "note"))
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
374 (("author" "title")
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
375 ("booktitle" "publisher" "year"
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
376 "editor" "volume" "number" "series" "type" "chapter"
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
377 "pages" "address" "edition" "month" "note"))))
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
378
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
379
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
380 ("InProceedings" . ((("author" "title" "booktitle" "year")
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
381 ("editor" "volume" "number" "series" "pages"
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
382 "organization" "publisher" "address" "month" "note"))
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
383 (("author" "title")
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
384 ("editor" "volume" "number" "series" "pages"
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
385 "booktitle" "year"
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
386 "organization" "publisher" "address" "month" "note"))))
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
387
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
388
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
389 ("Manual" . ((("title")
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
390 ("author" "organization" "address" "edition" "year"
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
391 "month" "note"))))
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
392
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
393 ("MastersThesis" . ((("author" "title" "school" "year")
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
394 ("address" "month" "note" "type"))))
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
395
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
396 ("Misc" . ((()
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
397 ("author" "title" "howpublished" "year" "month" "note"))))
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
398
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
399 ("PhdThesis" . ((("author" "title" "school" "year")
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
400 ("address" "month" "type" "note"))))
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
401
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
402 ("Proceedings" . ((("title" "year")
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
403 ("editor" "volume" "number" "series" "publisher"
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
404 "organization" "address" "month" "note"))))
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
405
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
406 ("TechReport" . ((("author" "title" "institution" "year")
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
407 ("type" "number" "address" "month" "note"))))
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
408
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
409 ("Unpublished" . ((("author" "title" "note")
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
410 ("year" "month"))))
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
411 )
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
412
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
413 "List of (entry-name (required optional) (crossref-required crossref-optional))
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
414 tripples. If the third element is nil, then the first pair can be used. Required
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
415 and optional are lists of strings. All entry creation functions use this variable
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
416 to generate entries, and bibtex-entry ensures the entry type is valid. This
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
417 variable can be used for example to make bibtex manipulate a different set of entry
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
418 types, e.g. a crossreference document of organization types.")
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
419
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
420
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
421 ;;; A bibtex file is a sequence of entries, either string definitions
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
422 ;;; or reference entries. A reference entry has a type part, a
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
423 ;;; key part, and a comma-separated sequence of fields. A string
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
424 ;;; entry has a single field. A field has a left and right part,
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
425 ;;; separated by a '='. The left part is the name, the right part is
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
426 ;;; the text. Here come the definitions allowing to create and/or parse
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
427 ;;; entries and fields:
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
428
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
429 ;;; fields
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
430 (defun bibtex-cfield (name text)
561
a819dc25b9e7 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 257
diff changeset
431 "Create a regexp for a bibtex field of name NAME and text TEXT"
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
432 (concat ",[ \t\n]*\\("
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
433 name
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
434 "\\)[ \t\n]*=[ \t\n]*\\("
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
435 text
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
436 "\\)"))
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
437 (defconst bibtex-name-in-cfield 1
561
a819dc25b9e7 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 257
diff changeset
438 "The regexp subexpression number of the name part in bibtex-cfield.")
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
439 (defconst bibtex-text-in-cfield 2
561
a819dc25b9e7 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 257
diff changeset
440 "The regexp subexpression number of the text part in bibtex-cfield.")
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
441
2602
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
442 ;;; KAWATA Yasuro <yasuro@qqqq.maekawa.is.uec.ac.jp> reported bug that "/"
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
443 ;;; was not premitted in field names. The old value of this var was:
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
444 ;;; "[A-Za-z][---A-Za-z0-9:_+]*"
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
445 ;;; According to the LaTeX manual, page 71, the legal values are letters,
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
446 ;;; digits, and punctuation other than comma. Section 2.1 defines
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
447 ;;; punctuation as:
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
448 ;;; .:;,?!`'()[]-/*@
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
449 ;;; and says that += can be used in normal text. Specifically #$%&~_^\{}
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
450 ;;; are called out as special chars. Some experimentation with LaTeX
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
451 ;;; indicates that # and ~ definitely don't work, but that the following
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
452 ;;; citation does! \cite{a0.:;?!`'()[]-/*@_&$^+=|<>}. I chose here to
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
453 ;;; permit _ since it was previously allowed, but otherwise to only handle
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
454 ;;; punc and +=
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
455 ;;; Amendment: I couldn't get a regexp with both "[]"'s and hyphen to
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
456 ;;; work. It looks like you need them both to be the first entries in a
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
457 ;;; regexp pattern. [alarson:19930315.0900CST]
5409
a5c38a92e787 (bibtex-field-name, bibtex-field-const, bibtex-field-text):
Richard M. Stallman <rms@gnu.org>
parents: 5309
diff changeset
458 ;;;
a5c38a92e787 (bibtex-field-name, bibtex-field-const, bibtex-field-text):
Richard M. Stallman <rms@gnu.org>
parents: 5309
diff changeset
459 ;;; New amendment[MB]: I have corrected the following regexp according to
a5c38a92e787 (bibtex-field-name, bibtex-field-const, bibtex-field-text):
Richard M. Stallman <rms@gnu.org>
parents: 5309
diff changeset
460 ;;; emacs19 rules. I also added ']' to the list of characters allowed in
a5c38a92e787 (bibtex-field-name, bibtex-field-const, bibtex-field-text):
Richard M. Stallman <rms@gnu.org>
parents: 5309
diff changeset
461 ;;; a field name.
2602
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
462
5409
a5c38a92e787 (bibtex-field-name, bibtex-field-const, bibtex-field-text):
Richard M. Stallman <rms@gnu.org>
parents: 5309
diff changeset
463 (defconst bibtex-field-name "[A-Za-z][]A-Za-z0-9.:;?!`'()/*@_+=-]*"
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
464 "Regexp defining the name part of a bibtex field.")
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
465
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
466 ;; bibtex-field-text must be able to handle
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
467 ;; title = "Proc. Fifteenth Annual" # STOC,
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
468 ;; month = "10~" # jan,
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
469 ;; year = "{\noopsort{1973c}}1981",
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
470 ;; month = apr # "-" # may,
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
471 ;; key = {Volume-2},
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
472 ;; note = "Volume~2 is listed under Knuth \cite{book-full}"
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
473 ;; i have added a few of these, but not all! -- MON
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
474
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
475 (defconst bibtex-field-const
5409
a5c38a92e787 (bibtex-field-name, bibtex-field-const, bibtex-field-text):
Richard M. Stallman <rms@gnu.org>
parents: 5309
diff changeset
476 "[0-9A-Za-z][A-Za-z0-9:_+-]*"
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
477 "Format of a bibtex field constant.")
561
a819dc25b9e7 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 257
diff changeset
478
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
479 (defconst bibtex-field-string
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
480 (concat
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
481 "\"[^\"]*[^\\\\]\"\\|\"\"")
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
482 "Match either a string or an empty string.")
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
483
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
484 (defconst bibtex-field-string-or-const
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
485 (concat bibtex-field-const "\\|" bibtex-field-string)
561
a819dc25b9e7 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 257
diff changeset
486 "Match either bibtex-field-string or bibtex-field-const.")
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
487
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
488 (defconst bibtex-field-text
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
489 (concat
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
490 "\\(" bibtex-field-string-or-const "\\)"
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
491 "\\([ \t\n]+#[ \t\n]+\\(" bibtex-field-string-or-const "\\)\\)*\\|"
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
492 "{[^{}]*[^\\\\]}")
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
493 "Regexp defining the text part of a bibtex field: either a string, or
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
494 an empty string, or a constant followed by one or more # / constant pairs.
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
495 Also matches simple {...} patterns.")
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
496
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
497 ;(defconst bibtex-field-text
5409
a5c38a92e787 (bibtex-field-name, bibtex-field-const, bibtex-field-text):
Richard M. Stallman <rms@gnu.org>
parents: 5309
diff changeset
498 ; "\"[^\"]*[^\\\\]\"\\|\"\"\\|[0-9A-Za-z][A-Za-z0-9:_+-]*"
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
499 ; "Regexp defining the text part of a bibtex field: either a string, or an empty string, or a constant.")
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
500
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
501 (defconst bibtex-field
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
502 (bibtex-cfield bibtex-field-name bibtex-field-text)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
503 "Regexp defining the format of a bibtex field")
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
504
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
505 (defconst bibtex-name-in-field bibtex-name-in-cfield
561
a819dc25b9e7 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 257
diff changeset
506 "The regexp subexpression number of the name part in bibtex-field")
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
507 (defconst bibtex-text-in-field bibtex-text-in-cfield
561
a819dc25b9e7 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 257
diff changeset
508 "The regexp subexpression number of the text part in bibtex-field")
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
509
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
510 ;;; references
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
511 (defconst bibtex-reference-type
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
512 "@[A-Za-z]+"
561
a819dc25b9e7 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 257
diff changeset
513 "Regexp defining the type part of a bibtex reference entry")
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
514 (defconst bibtex-reference-head
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
515 (concat "^[ \t]*\\("
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
516 bibtex-reference-type
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
517 "\\)[ \t]*[({]\\("
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
518 bibtex-field-name
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
519 "\\)")
561
a819dc25b9e7 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 257
diff changeset
520 "Regexp defining format of the header line of a bibtex reference entry")
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
521 (defconst bibtex-type-in-head 1
561
a819dc25b9e7 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 257
diff changeset
522 "The regexp subexpression number of the type part in bibtex-reference-head")
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
523 (defconst bibtex-key-in-head 2
561
a819dc25b9e7 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 257
diff changeset
524 "The regexp subexpression number of the key part in
a819dc25b9e7 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 257
diff changeset
525 bibtex-reference-head")
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
526
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
527 (defconst bibtex-reference
5409
a5c38a92e787 (bibtex-field-name, bibtex-field-const, bibtex-field-text):
Richard M. Stallman <rms@gnu.org>
parents: 5309
diff changeset
528 (concat
a5c38a92e787 (bibtex-field-name, bibtex-field-const, bibtex-field-text):
Richard M. Stallman <rms@gnu.org>
parents: 5309
diff changeset
529 ;; This is the unparenthesized equivalent of bibtex-reference-head:
a5c38a92e787 (bibtex-field-name, bibtex-field-const, bibtex-field-text):
Richard M. Stallman <rms@gnu.org>
parents: 5309
diff changeset
530 "^[ \t]*"
a5c38a92e787 (bibtex-field-name, bibtex-field-const, bibtex-field-text):
Richard M. Stallman <rms@gnu.org>
parents: 5309
diff changeset
531 bibtex-reference-type
a5c38a92e787 (bibtex-field-name, bibtex-field-const, bibtex-field-text):
Richard M. Stallman <rms@gnu.org>
parents: 5309
diff changeset
532 "[ \t]*[({]\\("
a5c38a92e787 (bibtex-field-name, bibtex-field-const, bibtex-field-text):
Richard M. Stallman <rms@gnu.org>
parents: 5309
diff changeset
533 bibtex-field-name
a5c38a92e787 (bibtex-field-name, bibtex-field-const, bibtex-field-text):
Richard M. Stallman <rms@gnu.org>
parents: 5309
diff changeset
534 "\\)"
a5c38a92e787 (bibtex-field-name, bibtex-field-const, bibtex-field-text):
Richard M. Stallman <rms@gnu.org>
parents: 5309
diff changeset
535 ;; End of unparenthesized equivalent of bibtex-reference-head
a5c38a92e787 (bibtex-field-name, bibtex-field-const, bibtex-field-text):
Richard M. Stallman <rms@gnu.org>
parents: 5309
diff changeset
536 "\\([ \t\n]*" bibtex-field "\\)*"
a5c38a92e787 (bibtex-field-name, bibtex-field-const, bibtex-field-text):
Richard M. Stallman <rms@gnu.org>
parents: 5309
diff changeset
537 "[ \t\n]*[})]")
561
a819dc25b9e7 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 257
diff changeset
538 "Regexp defining the format of a bibtex reference entry")
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
539 (defconst bibtex-type-in-reference bibtex-type-in-head
561
a819dc25b9e7 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 257
diff changeset
540 "The regexp subexpression number of the type part in bibtex-reference")
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
541 (defconst bibtex-key-in-reference bibtex-key-in-head
561
a819dc25b9e7 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 257
diff changeset
542 "The regexp subexpression number of the key part in
a819dc25b9e7 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 257
diff changeset
543 bibtex-reference")
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
544
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
545 ;;; strings
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
546 (defconst bibtex-string
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
547 (concat "^[ \t]*@[sS][tT][rR][iI][nN][gG][ \t\n]*[({][ \t\n]*\\("
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
548 bibtex-field-name
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
549 "\\)[ \t\n]*=[ \t\n]*\\("
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
550 bibtex-field-text
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
551 "\\)[ \t\n]*[})]")
561
a819dc25b9e7 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 257
diff changeset
552 "Regexp defining the format of a bibtex string entry")
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
553 (defconst bibtex-name-in-string 1
561
a819dc25b9e7 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 257
diff changeset
554 "The regexp subexpression of the name part in bibtex-string")
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
555 (defconst bibtex-text-in-string 2
561
a819dc25b9e7 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 257
diff changeset
556 "The regexp subexpression of the text part in bibtex-string")
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
557
3552
84fded047f22 Fix typos in previous change.
Richard M. Stallman <rms@gnu.org>
parents: 3527
diff changeset
558 (defconst bibtex-name-alignment 2
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
559 "Alignment for the name part in BibTeX fields.
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
560 Chosen on aesthetic grounds only.")
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
561
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
562 (defconst bibtex-text-alignment (length " organization = ")
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
563 "Alignment for the text part in BibTeX fields.
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
564 Equal to the space needed for the longest name part.")
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
565
2602
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
566 (defun bibtex-current-entry-label (&optional include-cite kill)
3591
507f64624555 Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents: 3552
diff changeset
567 "Return the label of the bibtex entry containing, or preceding point.
2602
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
568 Optional argument INCLUDE-CITE, if true means put a '\\cite{}' around the
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
569 returned value. Second optional argument KILL, if true, means place the
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
570 returned value in the kill buffer. Interactively; providing prefix
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
571 argument makes INCLUDE-CITE true, and kill is true by default.
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
572
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
573 Rationale:
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
574 The intention is that someone will write a function that can be bound to
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
575 a mouse key so that people entering TeX can just mouse on the bibtex entry
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
576 and have the citation key inserted at the current point (which will almost
3591
507f64624555 Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents: 3552
diff changeset
577 certainly be in some other buffer). In the interim this function is
2602
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
578 marginally useful for keyboard binding and is not bound by default.
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
579 Suggested binding is ^C-k."
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
580 (interactive (list current-prefix-arg t))
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
581 (save-excursion
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
582 (beginning-of-bibtex-entry)
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
583 (re-search-forward bibtex-reference-head (save-excursion (end-of-bibtex-entry) (point)))
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
584 (let* ((key (buffer-substring (match-beginning bibtex-key-in-head)
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
585 (match-end bibtex-key-in-head)))
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
586 (val (if include-cite
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
587 (format "\\cite{%s}" key)
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
588 key)))
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
589 (if kill
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
590 (put-string-on-kill-ring val))
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
591 val)))
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
592
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
593 ;;; bibtex mode:
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
594
3367
d8301f8d5b73 (bibtex-mode): Add autoload.
Richard M. Stallman <rms@gnu.org>
parents: 2864
diff changeset
595 ;;;###autoload
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
596 (defun bibtex-mode ()
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
597 "Major mode for editing bibtex files.
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
598
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
599 \\{bibtex-mode-map}
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
600
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
601 A command such as \\[bibtex-Book] will outline the fields for a BibTeX book entry.
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
602
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
603 The optional fields start with the string OPT, and thus ignored by BibTeX.
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
604 The OPT string may be removed from a field with \\[bibtex-remove-OPT].
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
605 \\[bibtex-kill-optional-field] kills the current optional field entirely.
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
606 \\[bibtex-remove-double-quotes] removes the double-quotes around the text of
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
607 the current field. \\[bibtex-empty-field] replaces the text of the current
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
608 field with the default \"\".
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
609
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
610 The command \\[bibtex-clean-entry] cleans the current entry, i.e. (i) removes
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
611 double-quotes from entirely numerical fields, (ii) removes OPT from all
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
612 non-empty optional fields, (iii) removes all empty optional fields, and (iv)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
613 checks that no non-optional fields are empty.
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
614
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
615 Use \\[bibtex-find-text] to position the dot at the end of the current field.
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
616 Use \\[bibtex-next-field] to move to end of the next field.
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
617
2602
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
618 The following may be of interest as well:
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
619
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
620 Functions:
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
621 find-bibtex-duplicates
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
622 find-bibtex-entry-location
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
623 hide-bibtex-entry-bodies
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
624 sort-bibtex-entries
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
625 validate-bibtex-buffer
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
626
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
627 Variables:
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
628 bibtex-clean-entry-zap-empty-opts
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
629 bibtex-entry-field-alist
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
630 bibtex-include-OPTannote
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
631 bibtex-include-OPTcrossref
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
632 bibtex-include-OPTkey
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
633 bibtex-maintain-sorted-entries
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
634 bibtex-mode-user-optional-fields
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
635
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
636 Fields:
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
637 address
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
638 Publisher's address
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
639 annote
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
640 Long annotation used for annotated bibliographies (begins sentence)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
641 author
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
642 Name(s) of author(s), in BibTeX name format
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
643 booktitle
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
644 Book title when the thing being referenced isn't the whole book.
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
645 For book entries, the title field should be used instead.
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
646 chapter
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
647 Chapter number
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
648 crossref
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
649 The database key of the entry being cross referenced.
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
650 edition
2602
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
651 Edition of a book (e.g., \"second\")
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
652 editor
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
653 Name(s) of editor(s), in BibTeX name format.
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
654 If there is also an author field, then the editor field should be
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
655 for the book or collection that the work appears in
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
656 howpublished
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
657 How something strange has been published (begins sentence)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
658 institution
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
659 Sponsoring institution
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
660 journal
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
661 Journal name (macros are provided for many)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
662 key
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
663 Alphabetizing and labeling key (needed when no author or editor)
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
664 month
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
665 Month (macros are provided)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
666 note
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
667 To help the reader find a reference (begins sentence)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
668 number
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
669 Number of a journal or technical report
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
670 organization
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
671 Organization (sponsoring a conference)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
672 pages
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
673 Page number or numbers (use `--' to separate a range)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
674 publisher
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
675 Publisher name
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
676 school
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
677 School name (for theses)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
678 series
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
679 The name of a series or set of books.
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
680 An individual book will will also have it's own title
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
681 title
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
682 The title of the thing being referenced
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
683 type
2602
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
684 Type of a technical report (e.g., \"Research Note\") to be used
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
685 instead of the default \"Technical Report\"
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
686 volume
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
687 Volume of a journal or multivolume work
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
688 year
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
689 Year---should contain only numerals
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
690 ---------------------------------------------------------
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
691 Entry to this mode calls the value of bibtex-mode-hook if that value is
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
692 non-nil."
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
693 (interactive)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
694 (kill-all-local-variables)
2602
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
695 (set-syntax-table bibtex-mode-syntax-table)
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
696 (use-local-map bibtex-mode-map)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
697 (setq major-mode 'bibtex-mode)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
698 (setq mode-name "BibTeX")
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
699 (set-syntax-table bibtex-mode-syntax-table)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
700 (setq local-abbrev-table bibtex-mode-abbrev-table)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
701 (make-local-variable 'paragraph-start)
7925
55a80566d955 (bibtex-mode): Set up comment-start locally.
Richard M. Stallman <rms@gnu.org>
parents: 7750
diff changeset
702 (make-local-variable 'comment-start)
55a80566d955 (bibtex-mode): Set up comment-start locally.
Richard M. Stallman <rms@gnu.org>
parents: 7750
diff changeset
703 (setq comment-start "%")
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
704 (setq paragraph-start "^[ \f\n\t]*$")
3591
507f64624555 Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents: 3552
diff changeset
705 (auto-fill-mode 1) ; nice alignments
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
706 (setq left-margin (+ bibtex-text-alignment 1))
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
707
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
708 (run-hooks 'bibtex-mode-hook))
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
709
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
710 (defun bibtex-move-outside-of-entry ()
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
711 "Make sure we are outside of a bib entry"
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
712 (cond ((or
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
713 (= (point) (point-max))
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
714 (= (point) (point-min))
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
715 (looking-at "[ \n]*@")
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
716 )
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
717 t)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
718 (t
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
719 (backward-paragraph)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
720 (forward-paragraph)))
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
721 (re-search-forward "[ \t\n]*" (point-max) t))
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
722
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
723 (defun ispell-abstract ()
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
724 (interactive)
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
725 (beginning-of-bibtex-entry)
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
726 (re-search-forward "^[ \t]*[OPT]*abstract[ \t]*=")
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
727 (ispell-region (point)
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
728 (save-excursion (forward-sexp) (point))))
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
729
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
730 (defun beginning-of-bibtex-entry ()
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
731 (interactive)
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
732 (re-search-backward "^@" nil 'move))
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
733
2602
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
734 (defun skip-whitespace-and-comments ()
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
735 ;; It might be a good idea to have forward-sexp with argument 0 do what
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
736 ;; this function tries to do, namely skip whitespace and comments.
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
737 ;; Maybe a better name for this would be skip-to-next-sexp.
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
738 ;; alternative implementation:
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
739 ;; (let ((parse-sexp-ignore-comments t))
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
740 ;; (forward-sexp 1)
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
741 ;; (forward-sexp -1))
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
742 ;; but I've had problems with this not getting the parse of comments
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
743 ;; right going backward if they contain unbalanced expressions or string
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
744 ;; quotes. [alarson:19920217.1021CST]
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
745 (let ((md (match-data)))
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
746 (unwind-protect
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
747 (while (cond ((looking-at "\\s>+\\|\\s +")
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
748 ;; was whitespace
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
749 ;; NOTE: also checked end-comment. In latex and
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
750 ;; lisp modes, newline is an end comment, but it
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
751 ;; should also be a whitespace char.
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
752 (goto-char (match-end 0)))
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
753 ;; If looking at beginning of comment, skip to end.
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
754 ((looking-at "\\s<")
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
755 (re-search-forward "\\s>"))))
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
756 (store-match-data md))))
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
757
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
758 ;;; [alarson:19920214.1007CST]
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
759 (defun end-of-bibtex-entry ()
2602
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
760 "If inside an entry, move to the end of it, otherwise move to the end
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
761 of the next entry."
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
762 (interactive)
2602
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
763 ;; if point was previously at the end of an entry, this puts us
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
764 ;; inside the next entry, otherwise we remain in the current one.
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
765 (progn
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
766 (skip-whitespace-and-comments)
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
767 ;;; (skip-chars-forward " \t\n")
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
768 (end-of-line))
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
769 (beginning-of-bibtex-entry)
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
770 (let ((parse-sexp-ignore-comments t))
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
771 (forward-sexp) ; skip entry type
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
772 (forward-sexp) ; skip entry body
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
773 ))
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
774 ;(defun end-of-bibtex-entry ()
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
775 ; (interactive)
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
776 ; (re-search-forward "}$" nil 'move))
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
777
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
778 (defun ispell-bibtex-entry ()
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
779 (interactive)
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
780 (ispell-region (progn (beginning-of-bibtex-entry) (point))
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
781 (progn (end-of-bibtex-entry) (point))))
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
782
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
783 (defun narrow-to-bibtex-entry ()
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
784 (interactive)
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
785 (save-excursion
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
786 (narrow-to-region (progn (beginning-of-bibtex-entry) (point))
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
787 (progn (end-of-bibtex-entry) (point)))))
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
788
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
789
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
790 (defun beginning-of-first-bibtex-entry ()
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
791 (goto-char (point-min))
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
792 (cond
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
793 ((re-search-forward "^@" nil 'move)
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
794 (beginning-of-line))
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
795 ((and (bobp) (eobp))
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
796 nil)
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
797 (t
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
798 (message "Warning: No bibtex entries found!"))))
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
799
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
800 (defun hide-bibtex-entry-bodies (&optional arg)
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
801 "Hide all lines between first and last bibtex entries not beginning with @.
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
802 With argument, show all text."
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
803 (interactive "P")
2602
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
804 (save-excursion
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
805 (beginning-of-first-bibtex-entry)
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
806 ;; subst-char-in-region modifies the buffer, despite what the
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
807 ;; documentation says...
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
808 (let ((modifiedp (buffer-modified-p))
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
809 (buffer-read-only nil))
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
810 (if arg
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
811 (subst-char-in-region (point) (point-max) ?\r ?\n t)
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
812 (while (save-excursion (re-search-forward "\n[^@]" (point-max) t))
5309
dc1a3f9ea36d (hide-bibtex-entry-bodies): Don't use replace-regexp.
Richard M. Stallman <rms@gnu.org>
parents: 4611
diff changeset
813 ;; (save-excursion (replace-regexp "\n\\([^@]\\)" "\r\\1"))
dc1a3f9ea36d (hide-bibtex-entry-bodies): Don't use replace-regexp.
Richard M. Stallman <rms@gnu.org>
parents: 4611
diff changeset
814 (save-excursion
dc1a3f9ea36d (hide-bibtex-entry-bodies): Don't use replace-regexp.
Richard M. Stallman <rms@gnu.org>
parents: 4611
diff changeset
815 (while (re-search-forward "\n\\([^@]\\)" nil t)
dc1a3f9ea36d (hide-bibtex-entry-bodies): Don't use replace-regexp.
Richard M. Stallman <rms@gnu.org>
parents: 4611
diff changeset
816 (replace-match "\r\\1" nil nil)))))
2602
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
817 (setq selective-display (not arg))
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
818 (set-buffer-modified-p modifiedp))))
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
819
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
820 (defvar bibtex-sort-ignore-string-entries nil
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
821 "*If true, bibtex @STRING entries are ignored when determining ordering
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
822 of the buffer (e.g. sorting, locating alphabetical position for new entries,
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
823 etc.)")
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
824
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
825 (defun sort-bibtex-entries ()
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
826 "Sort bibtex entries alphabetically by key.
2602
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
827 Text before the first bibtex entry, and following the last is not affected.
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
828 If bibtex-sort-ignore-string-entries is true, @string entries will be ignored.
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
829
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
830 Bugs:
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
831 1. Text between the closing brace ending one bibtex entry, and the @ starting
3591
507f64624555 Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents: 3552
diff changeset
832 the next, is considered part of the PRECEDING entry. Perhaps it should be
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
833 part of the following entry."
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
834 (interactive)
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
835 (save-restriction
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
836 (beginning-of-first-bibtex-entry)
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
837 (narrow-to-region (point)
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
838 (save-excursion
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
839 (goto-char (point-max))
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
840 (beginning-of-bibtex-entry)
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
841 (end-of-bibtex-entry)
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
842 (point)))
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
843 (sort-subr nil ; reversep
3591
507f64624555 Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents: 3552
diff changeset
844 ;; beginning of record function
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
845 'forward-line
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
846 ;; end of record function
2602
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
847 (function (lambda () (and (re-search-forward "}\\s-*\n[\n \t]*@" nil 'move)
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
848 (forward-char -2))))
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
849 ;; start of key function
2602
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
850 (if bibtex-sort-ignore-string-entries
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
851 (function (lambda ()
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
852 (while (and (re-search-forward "^\\s-*\\([@a-zA-Z]*\\)\\s-*{\\s-*")
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
853 (string-equalp "@string"
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
854 (buffer-substring (match-beginning 1)
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
855 (match-end 1)))))
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
856 nil))
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
857 (function (lambda () (re-search-forward "{\\s-*") nil)))
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
858 ;; end of key function
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
859 (function (lambda () (search-forward ",")))
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
860 )))
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
861
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
862 (defun map-bibtex-entries (fun)
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
863 "Call FUN for each bibtex entry starting with the current, to the end of the file.
2602
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
864 FUN is called with one argument, the key of the entry, and with point inside the entry.
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
865 If bibtex-sort-ignore-string-entries is true, FUN will not be called for @string entries."
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
866 (beginning-of-bibtex-entry)
2602
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
867 (while (re-search-forward "^@[^{]*{[ \t]*\\([^, ]*\\)" nil t)
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
868 (if (and bibtex-sort-ignore-string-entries
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
869 (string-equalp "@string{"
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
870 (buffer-substring (match-beginning 0)
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
871 (match-beginning 1))))
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
872 nil ; ignore the @string entry.
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
873 (funcall fun (buffer-substring (match-beginning 1) (match-end 1))))))
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
874
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
875 (defun find-bibtex-entry-location (entry-name)
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
876 "Searches from beginning of current buffer looking for place to put the
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
877 bibtex entry named ENTRY-NAME. Buffer is assumed to be in sorted order,
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
878 without duplicates (see \\[sort-bibtex-entries]), if it is not, an error will
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
879 be signalled."
2602
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
880 (interactive "sBibtex entry key: ")
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
881 (let ((previous nil)
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
882 point)
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
883 (beginning-of-first-bibtex-entry)
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
884 (or (catch 'done
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
885 (map-bibtex-entries (function (lambda (current)
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
886 (cond
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
887 ((string-equal entry-name current)
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
888 (error "Entry duplicates existing!"))
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
889 ((or (null previous)
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
890 (string< previous current))
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
891 (setq previous current
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
892 point (point))
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
893 (if (string< entry-name current)
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
894 (progn
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
895 (beginning-of-bibtex-entry)
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
896 ;; Many schemes append strings to
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
897 ;; existing entries to resolve them,
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
898 ;; so initial substring matches may
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
899 ;; indicate a duplicate entry.
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
900 (let ((idx (string-match (regexp-quote entry-name) current)))
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
901 (if (and (integerp idx)
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
902 (zerop idx))
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
903 (progn
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
904 (message "Warning: Entry %s may be a duplicate of %s!"
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
905 entry-name current)
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
906 (ding t))))
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
907 (throw 'done t))))
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
908 ((string-equal previous current)
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
909 (error "Duplicate here with previous!"))
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
910 (t (error "Entries out of order here!")))))))
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
911 (end-of-bibtex-entry))))
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
912
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
913 (defun validate-bibtex-buffer ()
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
914 "Find some typical errors in bibtex files.
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
915 1. At signs (@) not as first char of a line.
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
916 2. Double quotes (\") inside strings.
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
917 3. Closing braces (}) not the last character of a line."
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
918 (interactive)
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
919 (let ((point (point)))
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
920 (while (re-search-forward ".@" nil t)
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
921 (let* ((foo (parse-partial-sexp (save-excursion (beginning-of-bibtex-entry)
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
922 (point))
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
923 (point)))
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
924 (in-a-string (nth 3 foo)))
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
925 (if (not in-a-string)
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
926 (error "At sign (@) out of place!"))))
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
927 (goto-char point)
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
928 (while (search-forward "\"" nil t)
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
929 (or (looking-at "[,}][ \t]*$")
2602
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
930 (char-equal (preceding-char) ?\")
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
931 ;; some versions put closing brace on separate line.
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
932 (looking-at "[ \t]*\n}")
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
933 (save-excursion
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
934 (save-restriction
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
935 (narrow-to-region (point)
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
936 (progn (beginning-of-line) (point)))
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
937 (looking-at "^[ \t]*[a-zA-Z]+[ \t]*=[ \t]*\"$")))
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
938 (error "Quote out of place, or missing \",\" or \"}\"!")))
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
939 (goto-char point)
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
940 ;; This is only approximate, should actually search for close braces,
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
941 ;; then see if they are inside a string, or at the end of a line.
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
942 ;; This just gets the typical case of whitespace after a closing brace.
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
943 (while (search-forward "}[ \t]+$" nil t)
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
944 (error "Brace not last char of line!"))
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
945 (goto-char point)
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
946 (message "Bibtex buffer appears o.k.")))
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
947
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
948 (defun find-bibtex-duplicates ()
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
949 "Searches forward in current buffer looking for duplicate bibtex entries.
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
950 Buffer is assumed to be sorted, see \\[sort-bibtex-entries]"
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
951 (interactive)
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
952 (let ((point (point)))
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
953 ;; errors if things are not right...
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
954 (find-bibtex-entry-location (make-string 10 255))
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
955 (goto-char point)
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
956 (message "No duplicates found!")))
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
957
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
958
2602
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
959 ;;; assoc doesn't ignore case, so we need an assoc that does...
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
960 (defun assoc-string-equalp (thing alist)
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
961 (or (assoc thing alist)
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
962 (while (and alist
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
963 (not (string-equalp thing (car (car alist)))))
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
964 (setq alist (cdr alist)))
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
965 (car alist)))
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
966
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
967 (defvar bibtex-maintain-sorted-entries nil
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
968 "*If true, bibtex-mode will attempt to maintain all bibtex entries in
2602
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
969 sorted order.
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
970
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
971 Note that this is more a property of a file than a personal preference and
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
972 as such should normally be set via a file local variable entry.")
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
973
2602
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
974 (defun bibtex-entry (entry-type &optional required optional)
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
975 (interactive (let* ((completion-ignore-case t)
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
976 (e-t (completing-read "Entry Type: " bibtex-entry-field-alist
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
977 nil t)))
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
978 (list e-t)))
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
979 (if (and (null required) (null optional))
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
980 (let* ((e (assoc-string-equalp entry-type bibtex-entry-field-alist))
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
981 (r-n-o (elt e 1))
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
982 (c-ref (elt e 2)))
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
983 (if (null e)
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
984 (error "Bibtex entry type %s not defined!"))
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
985 (if (and bibtex-include-OPTcrossref c-ref)
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
986 (setq required (elt c-ref 0)
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
987 optional (elt c-ref 1))
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
988 (setq required (elt r-n-o 0)
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
989 optional (elt r-n-o 1)))))
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
990 (let ((key (if bibtex-maintain-sorted-entries
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
991 (read-string (format "%s key: " entry-type)))))
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
992 (if key
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
993 (find-bibtex-entry-location key))
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
994 (bibtex-move-outside-of-entry)
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
995 (insert "@" entry-type "{")
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
996 (if key
2602
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
997 (insert key))
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
998 (save-excursion
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
999 (mapcar 'bibtex-make-field required)
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1000 (if bibtex-include-OPTcrossref
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1001 (bibtex-make-optional-field "crossref"))
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1002 (if bibtex-include-OPTkey
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1003 (bibtex-make-optional-field "key"))
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1004 (mapcar 'bibtex-make-optional-field optional)
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1005 (mapcar 'bibtex-make-optional-field
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1006 bibtex-mode-user-optional-fields)
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1007 (if bibtex-include-OPTannote
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1008 (bibtex-make-optional-field "annote"))
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1009 (insert "\n}\n\n"))
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1010 (if key
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1011 (bibtex-next-field t))
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1012 (run-hooks 'bibtex-add-entry-hook)))
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1013
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1014 ;; (defun bibtex-entry (entry-type required optional)
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1015 ;; (bibtex-move-outside-of-entry)
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1016 ;; (insert (concat "@" entry-type "{,\n\n}\n\n"))
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1017 ;; (previous-line 3)
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1018 ;; (insert (mapconcat 'bibtex-make-entry required ",\n"))
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1019 ;; (if required
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1020 ;; (if optional
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1021 ;; (insert ",\n")))
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1022 ;; (insert (mapconcat 'bibtex-make-OPT-entry optional ",\n"))
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1023 ;; (if bibtex-mode-user-optional-fields ;MON...
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1024 ;; (progn
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1025 ;; (if optional
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1026 ;; (insert ",\n"))
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1027 ;; (insert (mapconcat 'bibtex-make-OPT-entry
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1028 ;; bibtex-mode-user-optional-fields
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1029 ;; ",\n")))) ;MON
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1030 ;; (up-list -1)
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1031 ;; (forward-char 1))
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1032
561
a819dc25b9e7 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 257
diff changeset
1033
2602
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1034 (defun bibtex-make-field (e-t)
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1035 (interactive "sBibTeX entry type: ")
2602
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1036 (let ((name (if (consp e-t) (car e-t) e-t))
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1037 (value (if (consp e-t) (cdr e-t) "")))
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1038 (insert ",\n")
3552
84fded047f22 Fix typos in previous change.
Richard M. Stallman <rms@gnu.org>
parents: 3527
diff changeset
1039 (indent-to-column bibtex-name-alignment)
2602
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1040 (insert name " = ")
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1041 (indent-to-column bibtex-text-alignment)
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1042 ;; lucid emacs prin1-to-string breaks the undo chain. When they fix
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1043 ;; that, the hack can be removed. [alarson:19930316.0805CST]
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1044 ; (insert (prin1-to-string value))
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1045 ;; begin hack
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1046 (insert (format (if (stringp value) "\"%s\"" "%s")
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1047 value))
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1048 ;; end hack
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1049 nil))
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1050
2602
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1051 (defun bibtex-make-optional-field (e-t)
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1052 (interactive "sOptional BibTeX entry type: ")
2602
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1053 (if (consp e-t)
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1054 (setq e-t (cons (concat "OPT" (car e-t)) (cdr e-t)))
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1055 (setq e-t (concat "OPT" e-t)))
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1056 (bibtex-make-field e-t))
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1057
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1058 ;; What to do about crossref? if present, journal and year are
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1059 ;; both optional. Due to this, i move all of them into optional. -- MON
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1060
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1061 (defun bibtex-Article ()
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1062 (interactive)
2602
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1063 (bibtex-entry "Article"))
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1064
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1065 (defun bibtex-Book ()
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1066 (interactive)
2602
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1067 (bibtex-entry "Book"))
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1068
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1069 (defun bibtex-Booklet ()
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1070 (interactive)
2602
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1071 (bibtex-entry "Booklet"))
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1072
2602
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1073 ;(defun bibtex-DEAthesis ()
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1074 ; (interactive)
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1075 ; (bibtex-entry "DEAthesis"))
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1076
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1077 (defun bibtex-InBook ()
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1078 (interactive)
2602
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1079 (bibtex-entry "InBook"))
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1080
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1081 (defun bibtex-InCollection ()
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1082 (interactive)
2602
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1083 (bibtex-entry "InCollection"))
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1084
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1085 (defun bibtex-InProceedings ()
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1086 (interactive)
2602
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1087 (bibtex-entry "InProceedings"))
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1088
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1089 (defun bibtex-Manual ()
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1090 (interactive)
2602
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1091 (bibtex-entry "Manual"))
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1092
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1093 (defun bibtex-MastersThesis ()
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1094 (interactive)
2602
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1095 (bibtex-entry "MastersThesis"))
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1096
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1097 (defun bibtex-Misc ()
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1098 (interactive)
2602
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1099 (bibtex-entry "Misc"))
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1100
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1101 (defun bibtex-PhdThesis ()
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1102 (interactive)
2602
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1103 (bibtex-entry "PhdThesis"))
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1104
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1105 (defun bibtex-Proceedings ()
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1106 (interactive)
2602
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1107 (bibtex-entry "Proceedings"))
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1108
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1109 (defun bibtex-TechReport ()
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1110 (interactive)
2602
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1111 (bibtex-entry "TechReport"))
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1112
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1113 (defun bibtex-Unpublished ()
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1114 (interactive)
2602
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1115 (bibtex-entry "Unpublished"))
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1116
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1117 (defun bibtex-string ()
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1118 (interactive)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1119 (bibtex-move-outside-of-entry)
2864
9c3bf565b354 * bibtex.el (bibtex-string): Use \" instead of "" to get a double
Jim Blandy <jimb@redhat.com>
parents: 2602
diff changeset
1120 (insert "@string{ = \"\"}\n")
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1121 (previous-line 1)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1122 (forward-char 8))
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1123
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1124 (defun bibtex-preamble ()
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1125 (interactive)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1126 (bibtex-move-outside-of-entry)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1127 (insert "@Preamble{}\n")
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1128 (previous-line 1)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1129 (forward-char 10))
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1130
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1131 (defun bibtex-next-field (arg)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1132 "Finds end of text of next BibTeX field; with arg, to its beginning"
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1133 (interactive "P")
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1134 (bibtex-inside-field)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1135 (let ((start (point)))
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1136 (condition-case ()
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1137 (progn
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1138 (bibtex-enclosing-field)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1139 (goto-char (match-end 0))
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1140 (forward-char 2))
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1141 (error
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1142 (goto-char start)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1143 (end-of-line)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1144 (forward-char 1))))
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1145 (bibtex-find-text arg))
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1146
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1147 ;; (defun bibtex-next-field ()
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1148 ;; "Finds end of text of next field."
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1149 ;; (interactive)
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1150 ;; (condition-case ()
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1151 ;; (progn
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1152 ;; (bibtex-inside-field)
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1153 ;; (re-search-forward ",[ \t\n]*" (point-max) 1)
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1154 ;; (bibtex-enclosing-field)
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1155 ;; (bibtex-inside-field))
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1156 ;; (error nil)))
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1157
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1158 (defun bibtex-find-text (arg)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1159 "Go to end of text of current field; with arg, go to beginning."
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1160 (interactive "P")
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1161 (bibtex-inside-field)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1162 (bibtex-enclosing-field)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1163 (if arg
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1164 (progn
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1165 (goto-char (match-beginning bibtex-text-in-field))
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1166 (if (looking-at "\"")
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1167 (forward-char 1)))
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1168 (goto-char (match-end bibtex-text-in-field))
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1169 (if (= (preceding-char) ?\")
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1170 (forward-char -1))))
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1171
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1172 ;; (defun bibtex-find-text ()
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1173 ;; "Go to end of text of current field."
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1174 ;; (interactive)
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1175 ;; (condition-case ()
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1176 ;; (progn
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1177 ;; (bibtex-inside-field)
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1178 ;; (bibtex-enclosing-field)
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1179 ;; (goto-char (match-end bibtex-text-in-field))
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1180 ;; (bibtex-inside-field))
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1181 ;; (error nil)))
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1182
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1183 (defun bibtex-remove-OPT ()
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1184 "Removes the 'OPT' starting optional arguments and goes to end of text"
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1185 (interactive)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1186 (bibtex-inside-field)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1187 (bibtex-enclosing-field)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1188 (save-excursion
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1189 (goto-char (match-beginning bibtex-name-in-field))
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1190 (if (looking-at "OPT")
2602
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1191 ;; sct@dcs.edinburgh.ac.uk
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1192 (progn
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1193 (delete-char (length "OPT"))
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1194 (search-forward "=")
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1195 (delete-horizontal-space)
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1196 (indent-to-column bibtex-text-alignment))))
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1197 (bibtex-inside-field))
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1198
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1199 (defun bibtex-inside-field ()
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1200 "Try to avoid point being at end of a bibtex field."
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1201 (interactive)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1202 (end-of-line)
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1203 (skip-chars-backward " \t") ;MON - maybe delete these chars?
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1204 (cond ((= (preceding-char) ?,)
2602
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1205 (forward-char -2))) ; -1 --> -2 sct@dcs.edinburgh.ac.uk
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1206 (cond ((= (preceding-char) ?\")
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1207 (forward-char -1)))) ;MON - only go back if quote
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1208
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1209 (defun bibtex-remove-double-quotes ()
2602
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1210 "Removes \"\" around string."
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1211 (interactive)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1212 (save-excursion
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1213 (bibtex-inside-field)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1214 (bibtex-enclosing-field)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1215 (let ((start (match-beginning bibtex-text-in-field))
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1216 (stop (match-end bibtex-text-in-field)))
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1217 (goto-char stop)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1218 (forward-char -1)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1219 (if (looking-at "\"")
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1220 (delete-char 1))
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1221 (goto-char start)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1222 (if (looking-at "\"")
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1223 (delete-char 1)))))
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1224
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1225 (defun bibtex-kill-optional-field ()
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1226 "Kill the entire enclosing optional BibTeX field"
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1227 (interactive)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1228 (bibtex-inside-field)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1229 (bibtex-enclosing-field)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1230 (goto-char (match-beginning bibtex-name-in-field))
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1231 (let ((the-end (match-end 0))
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1232 (the-beginning (match-beginning 0)))
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1233 (if (looking-at "OPT")
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1234 (progn
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1235 (goto-char the-end)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1236 (skip-chars-forward " \t\n,")
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1237 (kill-region the-beginning the-end))
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1238 (error "Mandatory fields can't be killed"))))
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1239
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1240 (defun bibtex-empty-field ()
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1241 "Delete the text part of the current field, replace with empty text"
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1242 (interactive)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1243 (bibtex-inside-field)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1244 (bibtex-enclosing-field)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1245 (goto-char (match-beginning bibtex-text-in-field))
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1246 (kill-region (point) (match-end bibtex-text-in-field))
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1247 (insert "\"\"")
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1248 (bibtex-find-text t))
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1249
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1250
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1251 (defun bibtex-pop-previous (arg)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1252 "Replace text of current field with the text of similar field in previous entry.
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1253 With arg, go up ARG entries. Repeated, goes up so many times. May be
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1254 intermixed with \\[bibtex-pop-next] (bibtex-pop-next)."
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1255 (interactive "p")
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1256 (bibtex-inside-field)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1257 (save-excursion
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1258 ; parse current field
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1259 (bibtex-enclosing-field)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1260 (let ((start-old-text (match-beginning bibtex-text-in-field))
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1261 (stop-old-text (match-end bibtex-text-in-field))
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1262 (start-name (match-beginning bibtex-name-in-field))
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1263 (stop-name (match-end bibtex-name-in-field))
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1264 (new-text))
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1265 (goto-char start-name)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1266 ; construct regexp for previous field with same name as this one
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1267 (let ((matching-entry
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1268 (bibtex-cfield
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1269 (buffer-substring (if (looking-at "OPT")
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1270 (+ (point) (length "OPT"))
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1271 (point))
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1272 stop-name)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1273 bibtex-field-text)))
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1274
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1275 ; if executed several times in a row, start each search where the
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1276 ; last one finished
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1277 (cond ((or (eq last-command 'bibtex-pop-previous)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1278 (eq last-command 'bibtex-pop-next))
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1279 t
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1280 )
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1281 (t
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1282 (bibtex-enclosing-reference)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1283 (setq bibtex-pop-previous-search-point (match-beginning 0))
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1284 (setq bibtex-pop-next-search-point (match-end 0))))
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1285 (goto-char bibtex-pop-previous-search-point)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1286
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1287 ; Now search for arg'th previous similar field
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1288 (cond
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1289 ((re-search-backward matching-entry (point-min) t arg)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1290 (setq new-text
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1291 (buffer-substring (match-beginning bibtex-text-in-cfield)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1292 (match-end bibtex-text-in-cfield)))
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1293 ; Found a matching field. Remember boundaries.
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1294 (setq bibtex-pop-next-search-point (match-end 0))
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1295 (setq bibtex-pop-previous-search-point (match-beginning 0))
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1296 (bibtex-flash-head)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1297 ; Go back to where we started, delete old text, and pop new.
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1298 (goto-char stop-old-text)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1299 (delete-region start-old-text stop-old-text)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1300 (insert new-text))
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1301 (t ; search failed
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1302 (error "No previous matching BibTeX field."))))))
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1303 (setq this-command 'bibtex-pop-previous))
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1304
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1305 (defun bibtex-pop-next (arg)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1306 "Replace text of current field with the text of similar field in next entry.
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1307 With arg, go up ARG entries. Repeated, goes up so many times. May be
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1308 intermixed with \\[bibtex-pop-previous] (bibtex-pop-previous)."
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1309 (interactive "p")
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1310 (bibtex-inside-field)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1311 (save-excursion
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1312 ; parse current field
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1313 (bibtex-enclosing-field)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1314 (let ((start-old-text (match-beginning bibtex-text-in-field))
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1315 (stop-old-text (match-end bibtex-text-in-field))
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1316 (start-name (match-beginning bibtex-name-in-field))
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1317 (stop-name (match-end bibtex-name-in-field))
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1318 (new-text))
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1319 (goto-char start-name)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1320 ; construct regexp for next field with same name as this one,
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1321 ; ignoring possible OPT's
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1322 (let ((matching-entry
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1323 (bibtex-cfield
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1324 (buffer-substring (if (looking-at "OPT")
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1325 (+ (point) (length "OPT"))
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1326 (point))
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1327 stop-name)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1328 bibtex-field-text)))
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1329
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1330 ; if executed several times in a row, start each search where the
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1331 ; last one finished
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1332 (cond ((or (eq last-command 'bibtex-pop-next)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1333 (eq last-command 'bibtex-pop-previous))
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1334 t
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1335 )
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1336 (t
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1337 (bibtex-enclosing-reference)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1338 (setq bibtex-pop-previous-search-point (match-beginning 0))
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1339 (setq bibtex-pop-next-search-point (match-end 0))))
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1340 (goto-char bibtex-pop-next-search-point)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1341
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1342 ; Now search for arg'th next similar field
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1343 (cond
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1344 ((re-search-forward matching-entry (point-max) t arg)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1345 (setq new-text
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1346 (buffer-substring (match-beginning bibtex-text-in-cfield)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1347 (match-end bibtex-text-in-cfield)))
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1348 ; Found a matching field. Remember boundaries.
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1349 (setq bibtex-pop-next-search-point (match-end 0))
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1350 (setq bibtex-pop-previous-search-point (match-beginning 0))
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1351 (bibtex-flash-head)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1352 ; Go back to where we started, delete old text, and pop new.
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1353 (goto-char stop-old-text)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1354 (delete-region start-old-text stop-old-text)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1355 (insert new-text))
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1356 (t ; search failed
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1357 (error "No next matching BibTeX field."))))))
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1358 (setq this-command 'bibtex-pop-next))
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1359
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1360 (defun bibtex-flash-head ()
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1361 "Flash at BibTeX reference head before point, if exists. (Moves point)."
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1362 (let ((flash))
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1363 (cond ((re-search-backward bibtex-reference-head (point-min) t)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1364 (goto-char (match-beginning bibtex-type-in-head))
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1365 (setq flash (match-end bibtex-key-in-reference)))
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1366 (t
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1367 (end-of-line)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1368 (skip-chars-backward " \t")
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1369 (setq flash (point))
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1370 (beginning-of-line)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1371 (skip-chars-forward " \t")))
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1372 (if (pos-visible-in-window-p (point))
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1373 (sit-for 1)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1374 (message "From: %s"
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1375 (buffer-substring (point) flash)))))
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1376
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1377
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1378
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1379 (defun bibtex-enclosing-field ()
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1380 "Search for BibTeX field enclosing point.
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1381 Point moves to end of field; also, use match-beginning and match-end
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1382 to parse the field."
2602
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1383 ;; sct@dcs.edinburgh.ac.uk
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1384 (let ((old-point (point)))
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1385 (condition-case errname
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1386 (bibtex-enclosing-regexp bibtex-field)
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1387 (search-failed
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1388 (goto-char old-point)
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1389 (error "Can't find enclosing BibTeX field.")))))
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1390
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1391 (defun bibtex-enclosing-reference ()
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1392 "Search for BibTeX reference enclosing point.
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1393 Point moves to end of reference; also, use match-beginning and match-end
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1394 to parse the reference."
2602
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1395 ;; sct@dcs.edinburgh.ac.uk
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1396 (let ((old-point (point)))
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1397 (condition-case errname
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1398 (bibtex-enclosing-regexp bibtex-reference)
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1399 (search-failed
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1400 (goto-char old-point)
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1401 (error "Can't find enclosing BibTeX reference.")))))
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1402
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1403 (defun bibtex-enclosing-regexp (regexp)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1404 "Search for REGEXP enclosing point.
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1405 Point moves to end of REGEXP. See also match-beginning and match-end.
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1406 If an enclosing REGEXP is not found, signals search-failed; point is left in
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1407 an undefined location.
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1408
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1409 [Doesn't something like this exist already?]"
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1410
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1411 (interactive "sRegexp: ")
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1412 ; compute reasonable limits for the loop
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1413 (let* ((initial (point))
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1414 (right (if (re-search-forward regexp (point-max) t)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1415 (match-end 0)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1416 (point-max)))
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1417 (left
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1418 (progn
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1419 (goto-char initial)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1420 (if (re-search-backward regexp (point-min) t)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1421 (match-beginning 0)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1422 (point-min)))))
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1423 ; within the prescribed limits, loop until a match is found
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1424 (goto-char left)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1425 (re-search-forward regexp right nil 1)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1426 (if (> (match-beginning 0) initial)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1427 (signal 'search-failed (list regexp)))
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1428 (while (<= (match-end 0) initial)
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1429 (re-search-forward regexp right nil 1)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1430 (if (> (match-beginning 0) initial)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1431 (signal 'search-failed (list regexp))))
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1432 ))
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1433
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1434 (defun bibtex-clean-entry ()
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1435 "For all optional fields of current BibTeX entry: if empty, kill the whole field; otherwise, remove the \"OPT\" string in the name; if text numerical, remove double-quotes. For all mandatory fields: if empty, signal error."
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1436 (interactive)
2602
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1437 (beginning-of-bibtex-entry)
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1438 (let ((start (point)))
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1439 (save-restriction
2602
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1440 (narrow-to-region start (save-excursion (end-of-bibtex-entry) (point)))
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1441 (while (re-search-forward bibtex-field (point-max) t 1)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1442 (let ((begin-field (match-beginning 0))
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1443 (end-field (match-end 0))
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1444 (begin-name (match-beginning bibtex-name-in-field))
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1445 (end-name (match-end bibtex-name-in-field))
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1446 (begin-text (match-beginning bibtex-text-in-field))
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1447 (end-text (match-end bibtex-text-in-field))
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1448 )
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1449 (goto-char begin-name)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1450 (cond ((and
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1451 (looking-at "OPT")
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1452 bibtex-clean-entry-zap-empty-opts)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1453 (goto-char begin-text)
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1454 (if (looking-at "\"\"") ; empty: delete whole field
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1455 (delete-region begin-field end-field)
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1456 ; otherwise: not empty, delete "OPT"
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1457 (goto-char begin-name)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1458 (delete-char (length "OPT"))
2602
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1459 (progn
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1460 ;; fixup alignment. [alarson:19920309.2047CST]
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1461 (search-forward "=")
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1462 (delete-horizontal-space)
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1463 (indent-to-column bibtex-text-alignment))
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1464 (goto-char begin-field) ; and loop to go through next test
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1465 ))
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1466 (t
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1467 (goto-char begin-text)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1468 (cond ((looking-at "\"[0-9]+\"") ; if numerical,
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1469 (goto-char end-text)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1470 (delete-char -1) ; delete enclosing double-quotes
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1471 (goto-char begin-text)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1472 (delete-char 1)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1473 (goto-char end-field) ; go to end for next search
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1474 (forward-char -2) ; to compensate for the 2 quotes deleted
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1475 )
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1476 ((looking-at "\"\"") ; if empty quotes, complain
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1477 (forward-char 1)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1478 (if (not (or (equal (buffer-substring
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1479 begin-name
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1480 (+ begin-name 3))
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1481 "OPT")
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1482 (equal (buffer-substring
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1483 begin-name
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1484 (+ begin-name 3))
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1485 "opt")))
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1486 (error "Mandatory field ``%s'' is empty"
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1487 (buffer-substring begin-name end-name))))
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1488 (t
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1489 (goto-char end-field))))))))
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1490 (goto-char start)
2602
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1491 (end-of-bibtex-entry)
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1492 ;; sct@dcs.edinburgh.ac.uk
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1493 (save-excursion
7750
892098bdaa24 (bibtex-clean-entry): Back over close delimiter carefully.
Richard M. Stallman <rms@gnu.org>
parents: 7300
diff changeset
1494 (backward-char 1)
892098bdaa24 (bibtex-clean-entry): Back over close delimiter carefully.
Richard M. Stallman <rms@gnu.org>
parents: 7300
diff changeset
1495 (skip-syntax-backward " >")
2602
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1496 (if (eq (preceding-char) ?,)
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1497 (backward-delete-char 1)))
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1498 (skip-whitespace-and-comments)))
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1499
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1500
3527
a0bd8ccfcf1c Define 2 local menu-bar submaps.
Richard M. Stallman <rms@gnu.org>
parents: 3367
diff changeset
1501 ;;; Menus for bibtex mode
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1502
3527
a0bd8ccfcf1c Define 2 local menu-bar submaps.
Richard M. Stallman <rms@gnu.org>
parents: 3367
diff changeset
1503 (define-key bibtex-mode-map [menu-bar entry-types]
3552
84fded047f22 Fix typos in previous change.
Richard M. Stallman <rms@gnu.org>
parents: 3527
diff changeset
1504 (cons "Entry Types" (make-sparse-keymap "Entry Types")))
2602
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1505
3527
a0bd8ccfcf1c Define 2 local menu-bar submaps.
Richard M. Stallman <rms@gnu.org>
parents: 3367
diff changeset
1506 (define-key bibtex-mode-map [menu-bar entry-types bibtex-InProceedings]
a0bd8ccfcf1c Define 2 local menu-bar submaps.
Richard M. Stallman <rms@gnu.org>
parents: 3367
diff changeset
1507 '(" article in conference Proceedings " . bibtex-InProceedings))
a0bd8ccfcf1c Define 2 local menu-bar submaps.
Richard M. Stallman <rms@gnu.org>
parents: 3367
diff changeset
1508 (define-key bibtex-mode-map [menu-bar entry-types bibtex-Article]
a0bd8ccfcf1c Define 2 local menu-bar submaps.
Richard M. Stallman <rms@gnu.org>
parents: 3367
diff changeset
1509 '(" Article in journal " . bibtex-Article))
a0bd8ccfcf1c Define 2 local menu-bar submaps.
Richard M. Stallman <rms@gnu.org>
parents: 3367
diff changeset
1510 (define-key bibtex-mode-map [menu-bar entry-types bibtex-Book]
a0bd8ccfcf1c Define 2 local menu-bar submaps.
Richard M. Stallman <rms@gnu.org>
parents: 3367
diff changeset
1511 '(" Book " . bibtex-Book))
a0bd8ccfcf1c Define 2 local menu-bar submaps.
Richard M. Stallman <rms@gnu.org>
parents: 3367
diff changeset
1512 (define-key bibtex-mode-map [menu-bar entry-types bibtex-Booklet]
a0bd8ccfcf1c Define 2 local menu-bar submaps.
Richard M. Stallman <rms@gnu.org>
parents: 3367
diff changeset
1513 '(" Booklet " . bibtex-Booklet))
a0bd8ccfcf1c Define 2 local menu-bar submaps.
Richard M. Stallman <rms@gnu.org>
parents: 3367
diff changeset
1514 (define-key bibtex-mode-map [menu-bar entry-types bibtex-InProceedings]
a0bd8ccfcf1c Define 2 local menu-bar submaps.
Richard M. Stallman <rms@gnu.org>
parents: 3367
diff changeset
1515 '(" Conference " . bibtex-InProceedings))
a0bd8ccfcf1c Define 2 local menu-bar submaps.
Richard M. Stallman <rms@gnu.org>
parents: 3367
diff changeset
1516 (define-key bibtex-mode-map [menu-bar entry-types bibtex-MastersThesis]
a0bd8ccfcf1c Define 2 local menu-bar submaps.
Richard M. Stallman <rms@gnu.org>
parents: 3367
diff changeset
1517 '(" Master's Thesis " . bibtex-MastersThesis))
a0bd8ccfcf1c Define 2 local menu-bar submaps.
Richard M. Stallman <rms@gnu.org>
parents: 3367
diff changeset
1518 ;define-key bibtex-mode-map [menu-bar entry-types bibtex-DEAthesis]
3552
84fded047f22 Fix typos in previous change.
Richard M. Stallman <rms@gnu.org>
parents: 3527
diff changeset
1519 ;'((" DEA Thesis " . bibtex-DEAthesis))
3527
a0bd8ccfcf1c Define 2 local menu-bar submaps.
Richard M. Stallman <rms@gnu.org>
parents: 3367
diff changeset
1520 (define-key bibtex-mode-map [menu-bar entry-types bibtex-PhdThesis]
a0bd8ccfcf1c Define 2 local menu-bar submaps.
Richard M. Stallman <rms@gnu.org>
parents: 3367
diff changeset
1521 '(" Phd. Thesis " . bibtex-PhdThesis))
a0bd8ccfcf1c Define 2 local menu-bar submaps.
Richard M. Stallman <rms@gnu.org>
parents: 3367
diff changeset
1522 (define-key bibtex-mode-map [menu-bar entry-types bibtex-TechReport]
a0bd8ccfcf1c Define 2 local menu-bar submaps.
Richard M. Stallman <rms@gnu.org>
parents: 3367
diff changeset
1523 '(" Technical Report " . bibtex-TechReport))
a0bd8ccfcf1c Define 2 local menu-bar submaps.
Richard M. Stallman <rms@gnu.org>
parents: 3367
diff changeset
1524 (define-key bibtex-mode-map [menu-bar entry-types bibtex-Manual]
a0bd8ccfcf1c Define 2 local menu-bar submaps.
Richard M. Stallman <rms@gnu.org>
parents: 3367
diff changeset
1525 '(" technical Manual " . bibtex-Manual))
a0bd8ccfcf1c Define 2 local menu-bar submaps.
Richard M. Stallman <rms@gnu.org>
parents: 3367
diff changeset
1526 (define-key bibtex-mode-map [menu-bar entry-types bibtex-Proceedings]
a0bd8ccfcf1c Define 2 local menu-bar submaps.
Richard M. Stallman <rms@gnu.org>
parents: 3367
diff changeset
1527 '(" conference Proceedings " . bibtex-Proceedings))
a0bd8ccfcf1c Define 2 local menu-bar submaps.
Richard M. Stallman <rms@gnu.org>
parents: 3367
diff changeset
1528 (define-key bibtex-mode-map [menu-bar entry-types bibtex-InBook]
a0bd8ccfcf1c Define 2 local menu-bar submaps.
Richard M. Stallman <rms@gnu.org>
parents: 3367
diff changeset
1529 '(" a chapter in a Book " . bibtex-InBook))
a0bd8ccfcf1c Define 2 local menu-bar submaps.
Richard M. Stallman <rms@gnu.org>
parents: 3367
diff changeset
1530 (define-key bibtex-mode-map [menu-bar entry-types bibtex-InCollection]
a0bd8ccfcf1c Define 2 local menu-bar submaps.
Richard M. Stallman <rms@gnu.org>
parents: 3367
diff changeset
1531 '(" an article in a Collection " . bibtex-InCollection))
a0bd8ccfcf1c Define 2 local menu-bar submaps.
Richard M. Stallman <rms@gnu.org>
parents: 3367
diff changeset
1532 (define-key bibtex-mode-map [menu-bar entry-types bibtex-Misc]
a0bd8ccfcf1c Define 2 local menu-bar submaps.
Richard M. Stallman <rms@gnu.org>
parents: 3367
diff changeset
1533 '(" miscellaneous " . bibtex-Misc))
a0bd8ccfcf1c Define 2 local menu-bar submaps.
Richard M. Stallman <rms@gnu.org>
parents: 3367
diff changeset
1534 (define-key bibtex-mode-map [menu-bar entry-types bibtex-Unpublished]
a0bd8ccfcf1c Define 2 local menu-bar submaps.
Richard M. Stallman <rms@gnu.org>
parents: 3367
diff changeset
1535 '(" unpublished " . bibtex-Unpublished))
a0bd8ccfcf1c Define 2 local menu-bar submaps.
Richard M. Stallman <rms@gnu.org>
parents: 3367
diff changeset
1536 (define-key bibtex-mode-map [menu-bar entry-types bibtex-string]
a0bd8ccfcf1c Define 2 local menu-bar submaps.
Richard M. Stallman <rms@gnu.org>
parents: 3367
diff changeset
1537 '(" string " . bibtex-string))
a0bd8ccfcf1c Define 2 local menu-bar submaps.
Richard M. Stallman <rms@gnu.org>
parents: 3367
diff changeset
1538 (define-key bibtex-mode-map [menu-bar entry-types bibtex-preamble]
a0bd8ccfcf1c Define 2 local menu-bar submaps.
Richard M. Stallman <rms@gnu.org>
parents: 3367
diff changeset
1539 '(" preamble " . bibtex-preamble))
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1540
3527
a0bd8ccfcf1c Define 2 local menu-bar submaps.
Richard M. Stallman <rms@gnu.org>
parents: 3367
diff changeset
1541 (define-key bibtex-mode-map [menu-bar move/edit]
3552
84fded047f22 Fix typos in previous change.
Richard M. Stallman <rms@gnu.org>
parents: 3527
diff changeset
1542 (cons "Bibtex Edit" (make-sparse-keymap "Bibtex Edit")))
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1543
3527
a0bd8ccfcf1c Define 2 local menu-bar submaps.
Richard M. Stallman <rms@gnu.org>
parents: 3367
diff changeset
1544 (define-key bibtex-mode-map [menu-bar move/edit bibtex-next-field]
a0bd8ccfcf1c Define 2 local menu-bar submaps.
Richard M. Stallman <rms@gnu.org>
parents: 3367
diff changeset
1545 '(" next field " . bibtex-next-field))
a0bd8ccfcf1c Define 2 local menu-bar submaps.
Richard M. Stallman <rms@gnu.org>
parents: 3367
diff changeset
1546 (define-key bibtex-mode-map [menu-bar move/edit bibtex-find-text]
a0bd8ccfcf1c Define 2 local menu-bar submaps.
Richard M. Stallman <rms@gnu.org>
parents: 3367
diff changeset
1547 '(" to end of field " . bibtex-find-text))
a0bd8ccfcf1c Define 2 local menu-bar submaps.
Richard M. Stallman <rms@gnu.org>
parents: 3367
diff changeset
1548 (define-key bibtex-mode-map [menu-bar move/edit bibtex-pop-previous]
a0bd8ccfcf1c Define 2 local menu-bar submaps.
Richard M. Stallman <rms@gnu.org>
parents: 3367
diff changeset
1549 '("snatch from similar preceding field" . bibtex-pop-previous))
a0bd8ccfcf1c Define 2 local menu-bar submaps.
Richard M. Stallman <rms@gnu.org>
parents: 3367
diff changeset
1550 (define-key bibtex-mode-map [menu-bar move/edit bibtex-pop-next]
a0bd8ccfcf1c Define 2 local menu-bar submaps.
Richard M. Stallman <rms@gnu.org>
parents: 3367
diff changeset
1551 '("snatch from similar following field" . bibtex-pop-next))
a0bd8ccfcf1c Define 2 local menu-bar submaps.
Richard M. Stallman <rms@gnu.org>
parents: 3367
diff changeset
1552 (define-key bibtex-mode-map [menu-bar move/edit bibtex-remove-OPT]
3552
84fded047f22 Fix typos in previous change.
Richard M. Stallman <rms@gnu.org>
parents: 3527
diff changeset
1553 '(" remove OPT " . bibtex-remove-OPT))
3527
a0bd8ccfcf1c Define 2 local menu-bar submaps.
Richard M. Stallman <rms@gnu.org>
parents: 3367
diff changeset
1554 (define-key bibtex-mode-map [menu-bar move/edit bibtex-remove-double-quotes]
a0bd8ccfcf1c Define 2 local menu-bar submaps.
Richard M. Stallman <rms@gnu.org>
parents: 3367
diff changeset
1555 '(" remove quotes " . bibtex-remove-double-quotes))
a0bd8ccfcf1c Define 2 local menu-bar submaps.
Richard M. Stallman <rms@gnu.org>
parents: 3367
diff changeset
1556 (define-key bibtex-mode-map [menu-bar move/edit bibtex-clean-entry]
a0bd8ccfcf1c Define 2 local menu-bar submaps.
Richard M. Stallman <rms@gnu.org>
parents: 3367
diff changeset
1557 '(" clean up entry " . bibtex-clean-entry))
3552
84fded047f22 Fix typos in previous change.
Richard M. Stallman <rms@gnu.org>
parents: 3527
diff changeset
1558 (define-key bibtex-mode-map [menu-bar move/edit find-bibtex-duplicates]
84fded047f22 Fix typos in previous change.
Richard M. Stallman <rms@gnu.org>
parents: 3527
diff changeset
1559 '(" find duplicates " . find-bibtex-duplicates))
84fded047f22 Fix typos in previous change.
Richard M. Stallman <rms@gnu.org>
parents: 3527
diff changeset
1560 (define-key bibtex-mode-map [menu-bar move/edit sort-bibtex-entries]
84fded047f22 Fix typos in previous change.
Richard M. Stallman <rms@gnu.org>
parents: 3527
diff changeset
1561 '(" sort entries " . sort-bibtex-entries))
84fded047f22 Fix typos in previous change.
Richard M. Stallman <rms@gnu.org>
parents: 3527
diff changeset
1562 (define-key bibtex-mode-map [menu-bar move/edit validate-bibtex-buffer]
84fded047f22 Fix typos in previous change.
Richard M. Stallman <rms@gnu.org>
parents: 3527
diff changeset
1563 '(" validate entries " . validate-bibtex-buffer))
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1564
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1565
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1566 ;; Please don't send anything to bug-gnu-emacs about these Sunwindows functions
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1567 ;; since we aren't interested. See etc/SUN-SUPPORT for the reasons why
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1568 ;; we consider this nothing but a distraction from our work.
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1569
2602
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1570 ;(defmacro eval-in-menu-window (&rest l)
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1571 ; "Evaluates its argument in the window in which the mouse button was pressed."
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1572 ; (list 'eval-in-window '*menu-window* l))
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1573
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1574 ;(defmenu bibtex-sun-entry-menu
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1575 ; ("Article In Conf. Proc." eval-in-menu-window bibtex-InProceedings)
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1576 ; ("Article In Journal" eval-in-menu-window bibtex-Article)
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1577 ; ("Book" eval-in-menu-window bibtex-Book)
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1578 ; ("Booklet" eval-in-menu-window bibtex-Booklet)
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1579 ; ("Master's Thesis" eval-in-menu-window bibtex-MastersThesis)
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1580 ; ("PhD. Thesis" eval-in-menu-window bibtex-PhdThesis)
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1581 ; ("Technical Report" eval-in-menu-window bibtex-TechReport)
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1582 ; ("Technical Manual" eval-in-menu-window bibtex-Manual)
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1583 ; ("Conference Proceedings" eval-in-menu-window bibtex-Proceedings)
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1584 ; ("In A Book" eval-in-menu-window bibtex-InBook)
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1585 ; ("In A Collection" eval-in-menu-window bibtex-InCollection)
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1586 ; ("Miscellaneous" eval-in-menu-window bibtex-Misc)
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1587 ; ("Unpublished" eval-in-menu-window bibtex-Unpublished)
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1588 ; ("string" eval-in-menu-window bibtex-string)
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1589 ; ("preamble" eval-in-menu-window bibtex-preamble))
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1590 ;
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1591 ;(defmenu bibtex-sun-menu
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1592 ; ("BibTeX menu")
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1593 ; ("add entry" . bibtex-sun-entry-menu)
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1594 ; ("next field" eval-in-menu-window bibtex-next-field nil)
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1595 ; ("to end of field" eval-in-menu-window bibtex-find-text nil)
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1596 ; ("snatch similar preceding field" eval-in-menu-window bibtex-pop-previous 1)
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1597 ; ("snatch similar following field" eval-in-menu-window bibtex-pop-next 1)
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1598 ; ("remove OPT" eval-in-menu-window bibtex-remove-OPT)
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1599 ; ("remove quotes" eval-in-menu-window bibtex-remove-double-quotes)
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1600 ; ("clean entry" eval-in-menu-window bibtex-clean-entry)
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1601 ; ("describe BibTeX mode" eval-in-menu-window describe-mode)
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1602 ; ("Main Emacs menu" . emacs-menu))
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1603
2602
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1604 ;(defun bibtex-sun-menu-eval (window x y)
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1605 ; "Pop-up menu of BibTeX commands."
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1606 ; (sun-menu-evaluate window (1+ x) (1- y) 'bibtex-sun-menu))
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1607 ;
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1608 ;(defun bibtex-sun-environment ()
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1609 ; "Set up sun menus for BibTeX mode. Call it as bibtex-mode-hook, or
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1610 ;interactively"
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1611 ; (interactive)
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1612 ; (local-set-mouse '(text right) 'bibtex-sun-menu-eval))
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1613 ;
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1614
2602
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
1615 ;;; bibtex.el ends here