annotate lisp/textmodes/bibtex.el @ 101940:dea4466580a6

* vc-dir.el (vc-dir-filename-mouse-map): Rename from vc-dir-mouse-map. (vc-default-dir-printer): Add a comment about updating this function. * vc-git.el (vc-git-dir-printer): Use vc-dir-filename-mouse-map for the file name.
author Dan Nicolaescu <dann@ics.uci.edu>
date Wed, 11 Feb 2009 06:36:32 +0000
parents 372dac1d4b95
children b91b8e9fcb55
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
74509
f7702c5f335d Update copyright years.
Glenn Morris <rgm@gnu.org>
parents: 73792
diff changeset
3 ;; Copyright (C) 1992, 1994, 1995, 1996, 1997, 1998, 1999, 2001, 2002,
100908
a9dc0e7c3f2b Add 2009 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 100439
diff changeset
4 ;; 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
845
213978acbc1e entered into RCS
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 810
diff changeset
5
14789
d68b71228abd (bibtex-pop): New generic function which unifies the
Richard M. Stallman <rms@gnu.org>
parents: 14410
diff changeset
6 ;; Author: Stefan Schoef <schoef@offis.uni-oldenburg.de>
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
7 ;; Bengt Martensson <bengt@mathematik.uni-Bremen.de>
73792
9429d986b2d1 Fix typo in name of author of bibtex.el,
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 71044
diff changeset
8 ;; Marc Shapiro <marc.shapiro@acm.org>
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
9 ;; Mike Newton <newton@gumby.cs.caltech.edu>
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
10 ;; Aaron Larson <alarson@src.honeywell.com>
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
11 ;; Dirk Herrmann <D.Herrmann@tu-bs.de>
45849
4f21f0785255 New maintainer.
Richard M. Stallman <rms@gnu.org>
parents: 45788
diff changeset
12 ;; Maintainer: Roland Winkler <roland.winkler@physik.uni-erlangen.de>
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
13 ;; Keywords: BibTeX, LaTeX, TeX
810
80303373daae *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 807
diff changeset
14
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
15 ;; This file is part of GNU Emacs.
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
16
94670
f4a69fedbd46 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 92218
diff changeset
17 ;; GNU Emacs is free software: you can redistribute it and/or modify
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
18 ;; it under the terms of the GNU General Public License as published by
94670
f4a69fedbd46 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 92218
diff changeset
19 ;; the Free Software Foundation, either version 3 of the License, or
f4a69fedbd46 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 92218
diff changeset
20 ;; (at your option) any later version.
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
21
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
22 ;; GNU Emacs is distributed in the hope that it will be useful,
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
23 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
24 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
25 ;; GNU General Public License for more details.
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
26
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
27 ;; You should have received a copy of the GNU General Public License
94670
f4a69fedbd46 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 92218
diff changeset
28 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
29
12700
b3a8ee2da96a Add keywords and comments as per conventions.
Richard M. Stallman <rms@gnu.org>
parents: 12028
diff changeset
30 ;;; Commentary:
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13968
diff changeset
31
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
32 ;; Major mode for editing and validating BibTeX files.
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
33
12700
b3a8ee2da96a Add keywords and comments as per conventions.
Richard M. Stallman <rms@gnu.org>
parents: 12028
diff changeset
34 ;; Usage:
81591
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
35 ;; See documentation for `bibtex-mode' or type "M-x describe-mode"
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
36 ;; when you are in BibTeX mode.
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
37
12700
b3a8ee2da96a Add keywords and comments as per conventions.
Richard M. Stallman <rms@gnu.org>
parents: 12028
diff changeset
38 ;; Todo:
b3a8ee2da96a Add keywords and comments as per conventions.
Richard M. Stallman <rms@gnu.org>
parents: 12028
diff changeset
39 ;; Distribute texinfo file.
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
40
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
41 ;;; Code:
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
42
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
43 (require 'button)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
44
26711
eac840d283b6 (bibtex-hs-forward-sexp): Added to support
Gerd Moellmann <gerd@gnu.org>
parents: 25444
diff changeset
45
12700
b3a8ee2da96a Add keywords and comments as per conventions.
Richard M. Stallman <rms@gnu.org>
parents: 12028
diff changeset
46 ;; User Options:
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
47
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
48 (defgroup bibtex nil
64054
23a07b9b6687 (bibtex, bibtex-autokey): Finish `defgroup' description with period.
Juanma Barranquero <lekktu@gmail.com>
parents: 63470
diff changeset
49 "BibTeX mode."
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
50 :group 'tex
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
51 :prefix "bibtex-")
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
52
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
53 (defgroup bibtex-autokey nil
64054
23a07b9b6687 (bibtex, bibtex-autokey): Finish `defgroup' description with period.
Juanma Barranquero <lekktu@gmail.com>
parents: 63470
diff changeset
54 "Generate automatically a key from the author/editor and the title field."
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
55 :group 'bibtex
20907
9a55a557cb5a (bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents: 20866
diff changeset
56 :prefix "bibtex-autokey-")
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
57
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
58 (defcustom bibtex-mode-hook nil
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
59 "List of functions to call on entry to BibTeX mode."
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
60 :group 'bibtex
20907
9a55a557cb5a (bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents: 20866
diff changeset
61 :type 'hook)
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
62
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
63 (defcustom bibtex-field-delimiters 'braces
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
64 "Type of field delimiters. Allowed values are `braces' or `double-quotes'."
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
65 :group 'bibtex
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
66 :type '(choice (const braces)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
67 (const double-quotes)))
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
68
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
69 (defcustom bibtex-entry-delimiters 'braces
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
70 "Type of entry delimiters. Allowed values are `braces' or `parentheses'."
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
71 :group 'bibtex
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
72 :type '(choice (const braces)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
73 (const parentheses)))
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
74
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
75 (defcustom bibtex-include-OPTcrossref '("InProceedings" "InCollection")
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
76 "List of BibTeX entries that get an OPTcrossref field."
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
77 :group 'bibtex
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
78 :type '(repeat string))
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
79
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
80 (defcustom bibtex-include-OPTkey t
58772
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
81 "If non-nil, all newly created entries get an OPTkey field.
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
82 If this is a string, use it as the initial field text.
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
83 If this is a function, call it to generate the initial field text."
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
84 :group 'bibtex
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
85 :type '(choice (const :tag "None" nil)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
86 (string :tag "Initial text")
77281
372e6a7ea660 (bibtex-include-OPTkey, bibtex-user-optional-fields)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77269
diff changeset
87 (function :tag "Initialize Function")
70808
0c087a8f2e1c (bibtex-maintain-sorted-entries): Mark as safe.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 70250
diff changeset
88 (const :tag "Default" t)))
69581
98eee222dceb * textmodes/bibtex.el (bibtex-include-OPTkey)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 68648
diff changeset
89 (put 'bibtex-include-OPTkey 'risky-local-variable t)
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
90
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
91 (defcustom bibtex-user-optional-fields
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
92 '(("annote" "Personal annotation (ignored)"))
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
93 "List of optional fields the user wants to have always present.
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
94 Entries should be of the same form as the OPTIONAL and
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
95 CROSSREF-OPTIONAL lists in `bibtex-entry-field-alist' (which see)."
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
96 :group 'bibtex
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
97 :type '(repeat (group (string :tag "Field")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
98 (string :tag "Comment")
77281
372e6a7ea660 (bibtex-include-OPTkey, bibtex-user-optional-fields)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77269
diff changeset
99 (option (choice :tag "Init"
372e6a7ea660 (bibtex-include-OPTkey, bibtex-user-optional-fields)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77269
diff changeset
100 (const nil) string function)))))
70249
eb2b6bd1c6f0 (bibtex-user-optional-fields): Mark as risky.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 70210
diff changeset
101 (put 'bibtex-user-optional-fields 'risky-local-variable t)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
102
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
103 (defcustom bibtex-entry-format
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
104 '(opts-or-alts required-fields numerical-fields)
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
105 "Type of formatting performed by `bibtex-clean-entry'.
22563
2e2a71dfec63 Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents: 21169
diff changeset
106 It may be t, nil, or a list of symbols out of the following:
19461
6b67f20dd710 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 19460
diff changeset
107 opts-or-alts Delete empty optional and alternative fields and
6b67f20dd710 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 19460
diff changeset
108 remove OPT and ALT prefixes from used fields.
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
109 required-fields Signal an error if a required field is missing.
19461
6b67f20dd710 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 19460
diff changeset
110 numerical-fields Delete delimiters around numeral fields.
6b67f20dd710 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 19460
diff changeset
111 page-dashes Change double dashes in page field to single dash
6b67f20dd710 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 19460
diff changeset
112 (for scribe compatibility).
81591
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
113 whitespace Delete whitespace at the beginning and end of fields.
58772
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
114 inherit-booktitle If entry contains a crossref field and the booktitle
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
115 field is empty, set the booktitle field to the content
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
116 of the title field of the crossreferenced entry.
19461
6b67f20dd710 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 19460
diff changeset
117 realign Realign entries, so that field texts and perhaps equal
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
118 signs (depending on the value of
22563
2e2a71dfec63 Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents: 21169
diff changeset
119 `bibtex-align-at-equal-sign') begin in the same column.
87650
29fbecdf9527 (bibtex-initialize): New autoloaded command. Rename from function
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87649
diff changeset
120 Also fill fields.
19461
6b67f20dd710 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 19460
diff changeset
121 last-comma Add or delete comma on end of last field in entry,
6b67f20dd710 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 19460
diff changeset
122 according to value of `bibtex-comma-after-last-field'.
6b67f20dd710 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 19460
diff changeset
123 delimiters Change delimiters according to variables
6b67f20dd710 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 19460
diff changeset
124 `bibtex-field-delimiters' and `bibtex-entry-delimiters'.
92218
1d8a03656f39 (bibtex-format-entry): Handle error message refering to a missing
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 92217
diff changeset
125 unify-case Change case of entry types and field names.
81591
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
126 braces Enclose parts of field entries by braces according to
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
127 `bibtex-field-braces-alist'.
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
128 strings Replace parts of field entries by string constants
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
129 according to `bibtex-field-strings-alist'.
19461
6b67f20dd710 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 19460
diff changeset
130
6b67f20dd710 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 19460
diff changeset
131 The value t means do all of the above formatting actions.
6b67f20dd710 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 19460
diff changeset
132 The value nil means do no formatting at all."
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
133 :group 'bibtex
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
134 :type '(choice (const :tag "None" nil)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
135 (const :tag "All" t)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
136 (set :menu-tag "Some"
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
137 (const opts-or-alts)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
138 (const required-fields)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
139 (const numerical-fields)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
140 (const page-dashes)
81591
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
141 (const whitespace)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
142 (const inherit-booktitle)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
143 (const realign)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
144 (const last-comma)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
145 (const delimiters)
81591
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
146 (const unify-case)
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
147 (const braces)
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
148 (const strings))))
97521
c383ec0fd021 (bibtex-entry-format): Mark as safe.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94670
diff changeset
149 (put 'bibtex-entry-format 'safe-local-variable
c383ec0fd021 (bibtex-entry-format): Mark as safe.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94670
diff changeset
150 (lambda (x)
c383ec0fd021 (bibtex-entry-format): Mark as safe.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94670
diff changeset
151 (or (eq x t)
c383ec0fd021 (bibtex-entry-format): Mark as safe.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94670
diff changeset
152 (let ((OK t))
c383ec0fd021 (bibtex-entry-format): Mark as safe.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94670
diff changeset
153 (while (consp x)
c383ec0fd021 (bibtex-entry-format): Mark as safe.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94670
diff changeset
154 (unless (memq (pop x)
c383ec0fd021 (bibtex-entry-format): Mark as safe.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94670
diff changeset
155 '(opts-or-alts required-fields numerical-fields
c383ec0fd021 (bibtex-entry-format): Mark as safe.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94670
diff changeset
156 page-dashes whitespace inherit-booktitle realign
c383ec0fd021 (bibtex-entry-format): Mark as safe.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94670
diff changeset
157 last-comma delimiters unify-case braces strings))
c383ec0fd021 (bibtex-entry-format): Mark as safe.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94670
diff changeset
158 (setq OK nil)))
c383ec0fd021 (bibtex-entry-format): Mark as safe.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94670
diff changeset
159 (unless (null x) (setq OK nil))
c383ec0fd021 (bibtex-entry-format): Mark as safe.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94670
diff changeset
160 OK))))
81591
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
161
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
162 (defcustom bibtex-field-braces-alist nil
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
163 "Alist of field regexps that \\[bibtex-clean-entry] encloses by braces.
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
164 Each element has the form (FIELDS REGEXP), where FIELDS is a list
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
165 of BibTeX field names and REGEXP is a regexp.
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
166 Whitespace in REGEXP will be replaced by \"[ \\t\\n]+\"."
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
167 :group 'bibtex
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
168 :type '(repeat (list (repeat (string :tag "field name"))
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
169 (choice (regexp :tag "regexp")
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
170 (sexp :tag "sexp")))))
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
171
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
172 (defcustom bibtex-field-strings-alist nil
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
173 "Alist of regexps that \\[bibtex-clean-entry] replaces by string constants.
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
174 Each element has the form (FIELDS REGEXP TO-STR), where FIELDS is a list
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
175 of BibTeX field names. In FIELDS search for REGEXP, which are replaced
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
176 by the BibTeX string constant TO-STR.
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
177 Whitespace in REGEXP will be replaced by \"[ \\t\\n]+\"."
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
178 :group 'bibtex
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
179 :type '(repeat (list (repeat (string :tag "field name"))
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
180 (regexp :tag "From regexp")
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
181 (regexp :tag "To string constant"))))
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
182
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
183 (defcustom bibtex-clean-entry-hook nil
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
184 "List of functions to call when entry has been cleaned.
19461
6b67f20dd710 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 19460
diff changeset
185 Functions are called with point inside the cleaned entry, and the buffer
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
186 narrowed to just the entry."
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
187 :group 'bibtex
20907
9a55a557cb5a (bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents: 20866
diff changeset
188 :type 'hook)
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
189
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
190 (defcustom bibtex-maintain-sorted-entries nil
58772
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
191 "If non-nil, BibTeX mode maintains all entries in sorted order.
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
192 Allowed non-nil values are:
70808
0c087a8f2e1c (bibtex-maintain-sorted-entries): Mark as safe.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 70250
diff changeset
193 plain or t All entries are sorted alphabetically.
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
194 crossref All entries are sorted alphabetically unless an entry has a
57070
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
195 crossref field. These crossrefed entries are placed in
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
196 alphabetical order immediately preceding the main entry.
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
197 entry-class The entries are divided into classes according to their
92218
1d8a03656f39 (bibtex-format-entry): Handle error message refering to a missing
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 92217
diff changeset
198 entry type, see `bibtex-sort-entry-class'. Within each class
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
199 the entries are sorted alphabetically.
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
200 See also `bibtex-sort-ignore-string-entries'."
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
201 :group 'bibtex
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
202 :type '(choice (const nil)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
203 (const plain)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
204 (const crossref)
70808
0c087a8f2e1c (bibtex-maintain-sorted-entries): Mark as safe.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 70250
diff changeset
205 (const entry-class)
0c087a8f2e1c (bibtex-maintain-sorted-entries): Mark as safe.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 70250
diff changeset
206 (const t)))
0c087a8f2e1c (bibtex-maintain-sorted-entries): Mark as safe.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 70250
diff changeset
207 (put 'bibtex-maintain-sorted-entries 'safe-local-variable
70837
c60679e723c7 (bibtex-maintain-sorted-entries): Quote safe-local-variable predicate.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 70808
diff changeset
208 '(lambda (a) (memq a '(nil t plain crossref entry-class))))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
209
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
210 (defcustom bibtex-sort-entry-class
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
211 '(("String")
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
212 (catch-all)
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
213 ("Book" "Proceedings"))
92218
1d8a03656f39 (bibtex-format-entry): Handle error message refering to a missing
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 92217
diff changeset
214 "List of classes of BibTeX entry types, used for sorting entries.
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
215 If value of `bibtex-maintain-sorted-entries' is `entry-class'
57070
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
216 entries are ordered according to the classes they belong to. Each
92218
1d8a03656f39 (bibtex-format-entry): Handle error message refering to a missing
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 92217
diff changeset
217 class contains a list of entry types. An entry `catch-all' applies
59733
96d73eb02751 (bibtex-format-entry): Use `bibtex-empty-field-re' only on the text of
Lute Kamstra <lute@gnu.org>
parents: 58772
diff changeset
218 to all entries not explicitly mentioned."
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
219 :group 'BibTeX
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
220 :type '(repeat (choice :tag "Class"
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
221 (const :tag "catch-all" (catch-all))
92218
1d8a03656f39 (bibtex-format-entry): Handle error message refering to a missing
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 92217
diff changeset
222 (repeat :tag "Entry type" string))))
71044
da5fa425123d (bibtex-autokey-name-case-convert-function)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70841
diff changeset
223 (put 'bibtex-sort-entry-class 'safe-local-variable
da5fa425123d (bibtex-autokey-name-case-convert-function)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70841
diff changeset
224 (lambda (x) (let ((OK t))
da5fa425123d (bibtex-autokey-name-case-convert-function)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70841
diff changeset
225 (while (consp x)
da5fa425123d (bibtex-autokey-name-case-convert-function)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70841
diff changeset
226 (let ((y (pop x)))
da5fa425123d (bibtex-autokey-name-case-convert-function)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70841
diff changeset
227 (while (consp y)
da5fa425123d (bibtex-autokey-name-case-convert-function)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70841
diff changeset
228 (let ((z (pop y)))
da5fa425123d (bibtex-autokey-name-case-convert-function)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70841
diff changeset
229 (unless (or (stringp z) (eq z 'catch-all))
da5fa425123d (bibtex-autokey-name-case-convert-function)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70841
diff changeset
230 (setq OK nil))))
da5fa425123d (bibtex-autokey-name-case-convert-function)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70841
diff changeset
231 (unless (null y) (setq OK nil))))
da5fa425123d (bibtex-autokey-name-case-convert-function)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70841
diff changeset
232 (unless (null x) (setq OK nil))
da5fa425123d (bibtex-autokey-name-case-convert-function)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70841
diff changeset
233 OK)))
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
234
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
235 (defcustom bibtex-sort-ignore-string-entries t
58772
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
236 "If non-nil, BibTeX @String entries are not sort-significant.
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
237 That means they are ignored when determining ordering of the buffer
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
238 \(e.g., sorting, locating alphabetical position for new entries, etc.)."
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
239 :group 'bibtex
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
240 :type 'boolean)
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
241
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
242 (defcustom bibtex-field-kill-ring-max 20
58772
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
243 "Max length of `bibtex-field-kill-ring' before discarding oldest elements."
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
244 :group 'bibtex
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
245 :type 'integer)
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
246
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
247 (defcustom bibtex-entry-kill-ring-max 20
58772
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
248 "Max length of `bibtex-entry-kill-ring' before discarding oldest elements."
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
249 :group 'bibtex
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
250 :type 'integer)
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
251
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
252 (defcustom bibtex-parse-keys-timeout 60
58772
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
253 "Time interval in seconds for parsing BibTeX buffers during idle time.
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
254 Parsing initializes `bibtex-reference-keys' and `bibtex-strings'."
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
255 :group 'bibtex
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
256 :type 'integer)
15637
405b1ecbf8ba (bibtex-reference-head): Allow spaces and tabs between
Karl Heuer <kwzh@gnu.org>
parents: 15565
diff changeset
257
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
258 (defcustom bibtex-parse-keys-fast t
58772
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
259 "If non-nil, use fast but simplified algorithm for parsing BibTeX keys.
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
260 If parsing fails, try to set this variable to nil."
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
261 :group 'bibtex
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
262 :type 'boolean)
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
263
77269
b9298f94662a (bibtex-entry-field-alist): Use defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77217
diff changeset
264 (defcustom bibtex-entry-field-alist
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
265 '(("Article"
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
266 ((("author" "Author1 [and Author2 ...] [and others]")
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
267 ("title" "Title of the article (BibTeX converts it to lowercase)")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
268 ("journal" "Name of the journal (use string, remove braces)")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
269 ("year" "Year of publication"))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
270 (("volume" "Volume of the journal")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
271 ("number" "Number of the journal (only allowed if entry contains volume)")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
272 ("pages" "Pages in the journal")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
273 ("month" "Month of the publication as a string (remove braces)")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
274 ("note" "Remarks to be put at the end of the \\bibitem")))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
275 ((("author" "Author1 [and Author2 ...] [and others]")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
276 ("title" "Title of the article (BibTeX converts it to lowercase)"))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
277 (("pages" "Pages in the journal")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
278 ("journal" "Name of the journal (use string, remove braces)")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
279 ("year" "Year of publication")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
280 ("volume" "Volume of the journal")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
281 ("number" "Number of the journal")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
282 ("month" "Month of the publication as a string (remove braces)")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
283 ("note" "Remarks to be put at the end of the \\bibitem"))))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
284 ("Book"
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
285 ((("author" "Author1 [and Author2 ...] [and others]" nil t)
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
286 ("editor" "Editor1 [and Editor2 ...] [and others]" nil t)
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
287 ("title" "Title of the book")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
288 ("publisher" "Publishing company")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
289 ("year" "Year of publication"))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
290 (("volume" "Volume of the book in the series")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
291 ("number" "Number of the book in a small series (overwritten by volume)")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
292 ("series" "Series in which the book appeared")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
293 ("address" "Address of the publisher")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
294 ("edition" "Edition of the book as a capitalized English word")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
295 ("month" "Month of the publication as a string (remove braces)")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
296 ("note" "Remarks to be put at the end of the \\bibitem")))
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
297 ((("author" "Author1 [and Author2 ...] [and others]" nil t)
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
298 ("editor" "Editor1 [and Editor2 ...] [and others]" nil t)
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
299 ("title" "Title of the book"))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
300 (("publisher" "Publishing company")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
301 ("year" "Year of publication")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
302 ("volume" "Volume of the book in the series")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
303 ("number" "Number of the book in a small series (overwritten by volume)")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
304 ("series" "Series in which the book appeared")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
305 ("address" "Address of the publisher")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
306 ("edition" "Edition of the book as a capitalized English word")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
307 ("month" "Month of the publication as a string (remove braces)")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
308 ("note" "Remarks to be put at the end of the \\bibitem"))))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
309 ("Booklet"
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
310 ((("title" "Title of the booklet (BibTeX converts it to lowercase)"))
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
311 (("author" "Author1 [and Author2 ...] [and others]")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
312 ("howpublished" "The way in which the booklet was published")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
313 ("address" "Address of the publisher")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
314 ("month" "Month of the publication as a string (remove braces)")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
315 ("year" "Year of publication")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
316 ("note" "Remarks to be put at the end of the \\bibitem"))))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
317 ("InBook"
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
318 ((("author" "Author1 [and Author2 ...] [and others]" nil t)
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
319 ("editor" "Editor1 [and Editor2 ...] [and others]" nil t)
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
320 ("title" "Title of the book")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
321 ("chapter" "Chapter in the book")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
322 ("publisher" "Publishing company")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
323 ("year" "Year of publication"))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
324 (("volume" "Volume of the book in the series")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
325 ("number" "Number of the book in a small series (overwritten by volume)")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
326 ("series" "Series in which the book appeared")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
327 ("type" "Word to use instead of \"chapter\"")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
328 ("address" "Address of the publisher")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
329 ("edition" "Edition of the book as a capitalized English word")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
330 ("month" "Month of the publication as a string (remove braces)")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
331 ("pages" "Pages in the book")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
332 ("note" "Remarks to be put at the end of the \\bibitem")))
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
333 ((("author" "Author1 [and Author2 ...] [and others]" nil t)
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
334 ("editor" "Editor1 [and Editor2 ...] [and others]" nil t)
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
335 ("title" "Title of the book")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
336 ("chapter" "Chapter in the book"))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
337 (("pages" "Pages in the book")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
338 ("publisher" "Publishing company")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
339 ("year" "Year of publication")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
340 ("volume" "Volume of the book in the series")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
341 ("number" "Number of the book in a small series (overwritten by volume)")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
342 ("series" "Series in which the book appeared")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
343 ("type" "Word to use instead of \"chapter\"")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
344 ("address" "Address of the publisher")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
345 ("edition" "Edition of the book as a capitalized English word")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
346 ("month" "Month of the publication as a string (remove braces)")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
347 ("note" "Remarks to be put at the end of the \\bibitem"))))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
348 ("InCollection"
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
349 ((("author" "Author1 [and Author2 ...] [and others]")
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
350 ("title" "Title of the article in book (BibTeX converts it to lowercase)")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
351 ("booktitle" "Name of the book")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
352 ("publisher" "Publishing company")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
353 ("year" "Year of publication"))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
354 (("editor" "Editor1 [and Editor2 ...] [and others]")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
355 ("volume" "Volume of the book in the series")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
356 ("number" "Number of the book in a small series (overwritten by volume)")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
357 ("series" "Series in which the book appeared")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
358 ("type" "Word to use instead of \"chapter\"")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
359 ("chapter" "Chapter in the book")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
360 ("pages" "Pages in the book")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
361 ("address" "Address of the publisher")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
362 ("edition" "Edition of the book as a capitalized English word")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
363 ("month" "Month of the publication as a string (remove braces)")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
364 ("note" "Remarks to be put at the end of the \\bibitem")))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
365 ((("author" "Author1 [and Author2 ...] [and others]")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
366 ("title" "Title of the article in book (BibTeX converts it to lowercase)")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
367 ("booktitle" "Name of the book"))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
368 (("pages" "Pages in the book")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
369 ("publisher" "Publishing company")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
370 ("year" "Year of publication")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
371 ("editor" "Editor1 [and Editor2 ...] [and others]")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
372 ("volume" "Volume of the book in the series")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
373 ("number" "Number of the book in a small series (overwritten by volume)")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
374 ("series" "Series in which the book appeared")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
375 ("type" "Word to use instead of \"chapter\"")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
376 ("chapter" "Chapter in the book")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
377 ("address" "Address of the publisher")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
378 ("edition" "Edition of the book as a capitalized English word")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
379 ("month" "Month of the publication as a string (remove braces)")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
380 ("note" "Remarks to be put at the end of the \\bibitem"))))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
381 ("InProceedings"
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
382 ((("author" "Author1 [and Author2 ...] [and others]")
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
383 ("title" "Title of the article in proceedings (BibTeX converts it to lowercase)")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
384 ("booktitle" "Name of the conference proceedings")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
385 ("year" "Year of publication"))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
386 (("editor" "Editor1 [and Editor2 ...] [and others]")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
387 ("volume" "Volume of the conference proceedings in the series")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
388 ("number" "Number of the conference proceedings in a small series (overwritten by volume)")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
389 ("series" "Series in which the conference proceedings appeared")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
390 ("pages" "Pages in the conference proceedings")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
391 ("address" "Location of the Proceedings")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
392 ("month" "Month of the publication as a string (remove braces)")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
393 ("organization" "Sponsoring organization of the conference")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
394 ("publisher" "Publishing company, its location")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
395 ("note" "Remarks to be put at the end of the \\bibitem")))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
396 ((("author" "Author1 [and Author2 ...] [and others]")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
397 ("title" "Title of the article in proceedings (BibTeX converts it to lowercase)"))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
398 (("booktitle" "Name of the conference proceedings")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
399 ("pages" "Pages in the conference proceedings")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
400 ("year" "Year of publication")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
401 ("editor" "Editor1 [and Editor2 ...] [and others]")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
402 ("volume" "Volume of the conference proceedings in the series")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
403 ("number" "Number of the conference proceedings in a small series (overwritten by volume)")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
404 ("series" "Series in which the conference proceedings appeared")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
405 ("address" "Location of the Proceedings")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
406 ("month" "Month of the publication as a string (remove braces)")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
407 ("organization" "Sponsoring organization of the conference")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
408 ("publisher" "Publishing company, its location")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
409 ("note" "Remarks to be put at the end of the \\bibitem"))))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
410 ("Manual"
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
411 ((("title" "Title of the manual"))
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
412 (("author" "Author1 [and Author2 ...] [and others]")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
413 ("organization" "Publishing organization of the manual")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
414 ("address" "Address of the organization")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
415 ("edition" "Edition of the manual as a capitalized English word")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
416 ("month" "Month of the publication as a string (remove braces)")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
417 ("year" "Year of publication")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
418 ("note" "Remarks to be put at the end of the \\bibitem"))))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
419 ("MastersThesis"
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
420 ((("author" "Author1 [and Author2 ...] [and others]")
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
421 ("title" "Title of the master\'s thesis (BibTeX converts it to lowercase)")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
422 ("school" "School where the master\'s thesis was written")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
423 ("year" "Year of publication"))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
424 (("type" "Type of the master\'s thesis (if other than \"Master\'s thesis\")")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
425 ("address" "Address of the school (if not part of field \"school\") or country")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
426 ("month" "Month of the publication as a string (remove braces)")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
427 ("note" "Remarks to be put at the end of the \\bibitem"))))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
428 ("Misc"
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
429 (()
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
430 (("author" "Author1 [and Author2 ...] [and others]")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
431 ("title" "Title of the work (BibTeX converts it to lowercase)")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
432 ("howpublished" "The way in which the work was published")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
433 ("month" "Month of the publication as a string (remove braces)")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
434 ("year" "Year of publication")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
435 ("note" "Remarks to be put at the end of the \\bibitem"))))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
436 ("PhdThesis"
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
437 ((("author" "Author1 [and Author2 ...] [and others]")
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
438 ("title" "Title of the PhD. thesis")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
439 ("school" "School where the PhD. thesis was written")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
440 ("year" "Year of publication"))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
441 (("type" "Type of the PhD. thesis")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
442 ("address" "Address of the school (if not part of field \"school\") or country")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
443 ("month" "Month of the publication as a string (remove braces)")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
444 ("note" "Remarks to be put at the end of the \\bibitem"))))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
445 ("Proceedings"
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
446 ((("title" "Title of the conference proceedings")
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
447 ("year" "Year of publication"))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
448 (("booktitle" "Title of the proceedings for cross references")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
449 ("editor" "Editor1 [and Editor2 ...] [and others]")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
450 ("volume" "Volume of the conference proceedings in the series")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
451 ("number" "Number of the conference proceedings in a small series (overwritten by volume)")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
452 ("series" "Series in which the conference proceedings appeared")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
453 ("address" "Location of the Proceedings")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
454 ("month" "Month of the publication as a string (remove braces)")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
455 ("organization" "Sponsoring organization of the conference")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
456 ("publisher" "Publishing company, its location")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
457 ("note" "Remarks to be put at the end of the \\bibitem"))))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
458 ("TechReport"
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
459 ((("author" "Author1 [and Author2 ...] [and others]")
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
460 ("title" "Title of the technical report (BibTeX converts it to lowercase)")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
461 ("institution" "Sponsoring institution of the report")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
462 ("year" "Year of publication"))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
463 (("type" "Type of the report (if other than \"technical report\")")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
464 ("number" "Number of the technical report")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
465 ("address" "Address of the institution (if not part of field \"institution\") or country")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
466 ("month" "Month of the publication as a string (remove braces)")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
467 ("note" "Remarks to be put at the end of the \\bibitem"))))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
468 ("Unpublished"
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
469 ((("author" "Author1 [and Author2 ...] [and others]")
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
470 ("title" "Title of the unpublished work (BibTeX converts it to lowercase)")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
471 ("note" "Remarks to be put at the end of the \\bibitem"))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
472 (("month" "Month of the publication as a string (remove braces)")
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
473 ("year" "Year of publication")))))
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
474
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
475 "List of BibTeX entry types and their associated fields.
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
476 List elements are triples
92218
1d8a03656f39 (bibtex-format-entry): Handle error message refering to a missing
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 92217
diff changeset
477 \(ENTRY-TYPE (REQUIRED OPTIONAL) (CROSSREF-REQUIRED CROSSREF-OPTIONAL)).
1d8a03656f39 (bibtex-format-entry): Handle error message refering to a missing
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 92217
diff changeset
478 ENTRY-TYPE is the type of a BibTeX entry. The remaining pairs contain
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
479 the required and optional fields of the BibTeX entry.
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
480 The second pair is used if a crossref field is present
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
481 and the first pair is used if a crossref field is absent.
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
482 If the second pair is nil, the first pair is always used.
22563
2e2a71dfec63 Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents: 21169
diff changeset
483 REQUIRED, OPTIONAL, CROSSREF-REQUIRED and CROSSREF-OPTIONAL are lists.
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
484 Each element of these lists is a list of the form
43950
5ef8be2a8db1 (bibtex-sort-ignore-string-entries)
Pavel Janík <Pavel@Janik.cz>
parents: 43758
diff changeset
485 \(FIELD-NAME COMMENT-STRING INIT ALTERNATIVE-FLAG).
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
486 COMMENT-STRING, INIT, and ALTERNATIVE-FLAG are optional.
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
487 FIELD-NAME is the name of the field, COMMENT-STRING is the comment that
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
488 appears in the echo area, INIT is either the initial content of the
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
489 field or a function, which is called to determine the initial content
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
490 of the field, and ALTERNATIVE-FLAG (either nil or t) marks if the
19461
6b67f20dd710 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 19460
diff changeset
491 field is an alternative. ALTERNATIVE-FLAG may be t only in the
77269
b9298f94662a (bibtex-entry-field-alist): Use defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77217
diff changeset
492 REQUIRED or CROSSREF-REQUIRED lists."
b9298f94662a (bibtex-entry-field-alist): Use defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77217
diff changeset
493 :group 'bibtex
92218
1d8a03656f39 (bibtex-format-entry): Handle error message refering to a missing
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 92217
diff changeset
494 :type '(repeat (group (string :tag "Entry type")
77281
372e6a7ea660 (bibtex-include-OPTkey, bibtex-user-optional-fields)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77269
diff changeset
495 (group (repeat :tag "Required fields"
372e6a7ea660 (bibtex-include-OPTkey, bibtex-user-optional-fields)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77269
diff changeset
496 (group (string :tag "Field")
372e6a7ea660 (bibtex-include-OPTkey, bibtex-user-optional-fields)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77269
diff changeset
497 (string :tag "Comment")
372e6a7ea660 (bibtex-include-OPTkey, bibtex-user-optional-fields)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77269
diff changeset
498 (option (choice :tag "Init" :value nil
372e6a7ea660 (bibtex-include-OPTkey, bibtex-user-optional-fields)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77269
diff changeset
499 (const nil) string function))
372e6a7ea660 (bibtex-include-OPTkey, bibtex-user-optional-fields)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77269
diff changeset
500 (option (choice :tag "Alternative"
372e6a7ea660 (bibtex-include-OPTkey, bibtex-user-optional-fields)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77269
diff changeset
501 (const :tag "No" nil)
372e6a7ea660 (bibtex-include-OPTkey, bibtex-user-optional-fields)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77269
diff changeset
502 (const :tag "Yes" t)))))
372e6a7ea660 (bibtex-include-OPTkey, bibtex-user-optional-fields)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77269
diff changeset
503 (repeat :tag "Optional fields"
372e6a7ea660 (bibtex-include-OPTkey, bibtex-user-optional-fields)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77269
diff changeset
504 (group (string :tag "Field")
372e6a7ea660 (bibtex-include-OPTkey, bibtex-user-optional-fields)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77269
diff changeset
505 (string :tag "Comment")
372e6a7ea660 (bibtex-include-OPTkey, bibtex-user-optional-fields)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77269
diff changeset
506 (option (choice :tag "Init" :value nil
372e6a7ea660 (bibtex-include-OPTkey, bibtex-user-optional-fields)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77269
diff changeset
507 (const nil) string function)))))
372e6a7ea660 (bibtex-include-OPTkey, bibtex-user-optional-fields)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77269
diff changeset
508 (option :extra-offset -4
372e6a7ea660 (bibtex-include-OPTkey, bibtex-user-optional-fields)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77269
diff changeset
509 (group (repeat :tag "Crossref: required fields"
372e6a7ea660 (bibtex-include-OPTkey, bibtex-user-optional-fields)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77269
diff changeset
510 (group (string :tag "Field")
372e6a7ea660 (bibtex-include-OPTkey, bibtex-user-optional-fields)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77269
diff changeset
511 (string :tag "Comment")
372e6a7ea660 (bibtex-include-OPTkey, bibtex-user-optional-fields)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77269
diff changeset
512 (option (choice :tag "Init" :value nil
372e6a7ea660 (bibtex-include-OPTkey, bibtex-user-optional-fields)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77269
diff changeset
513 (const nil) string function))
372e6a7ea660 (bibtex-include-OPTkey, bibtex-user-optional-fields)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77269
diff changeset
514 (option (choice :tag "Alternative"
372e6a7ea660 (bibtex-include-OPTkey, bibtex-user-optional-fields)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77269
diff changeset
515 (const :tag "No" nil)
372e6a7ea660 (bibtex-include-OPTkey, bibtex-user-optional-fields)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77269
diff changeset
516 (const :tag "Yes" t)))))
372e6a7ea660 (bibtex-include-OPTkey, bibtex-user-optional-fields)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77269
diff changeset
517 (repeat :tag "Crossref: optional fields"
372e6a7ea660 (bibtex-include-OPTkey, bibtex-user-optional-fields)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77269
diff changeset
518 (group (string :tag "Field")
372e6a7ea660 (bibtex-include-OPTkey, bibtex-user-optional-fields)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77269
diff changeset
519 (string :tag "Comment")
372e6a7ea660 (bibtex-include-OPTkey, bibtex-user-optional-fields)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77269
diff changeset
520 (option (choice :tag "Init" :value nil
372e6a7ea660 (bibtex-include-OPTkey, bibtex-user-optional-fields)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77269
diff changeset
521 (const nil) string function)))))))))
69581
98eee222dceb * textmodes/bibtex.el (bibtex-include-OPTkey)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 68648
diff changeset
522 (put 'bibtex-entry-field-alist 'risky-local-variable t)
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
523
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
524 (defcustom bibtex-comment-start "@Comment"
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
525 "String starting a BibTeX comment."
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
526 :group 'bibtex
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
527 :type 'string)
20907
9a55a557cb5a (bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents: 20866
diff changeset
528
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
529 (defcustom bibtex-add-entry-hook nil
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
530 "List of functions to call when BibTeX entry has been inserted."
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
531 :group 'bibtex
20907
9a55a557cb5a (bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents: 20866
diff changeset
532 :type 'hook)
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
533
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
534 (defcustom bibtex-predefined-month-strings
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
535 '(("jan" . "January")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
536 ("feb" . "February")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
537 ("mar" . "March")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
538 ("apr" . "April")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
539 ("may" . "May")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
540 ("jun" . "June")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
541 ("jul" . "July")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
542 ("aug" . "August")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
543 ("sep" . "September")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
544 ("oct" . "October")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
545 ("nov" . "November")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
546 ("dec" . "December"))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
547 "Alist of month string definitions used in the BibTeX style files.
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
548 Each element is a pair of strings (ABBREVIATION . EXPANSION)."
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
549 :group 'bibtex
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
550 :type '(repeat (cons (string :tag "Month abbreviation")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
551 (string :tag "Month expansion"))))
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
552
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
553 (defcustom bibtex-predefined-strings
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
554 (append
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
555 bibtex-predefined-month-strings
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
556 '(("acmcs" . "ACM Computing Surveys")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
557 ("acta" . "Acta Informatica")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
558 ("cacm" . "Communications of the ACM")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
559 ("ibmjrd" . "IBM Journal of Research and Development")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
560 ("ibmsj" . "IBM Systems Journal")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
561 ("ieeese" . "IEEE Transactions on Software Engineering")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
562 ("ieeetc" . "IEEE Transactions on Computers")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
563 ("ieeetcad" . "IEEE Transactions on Computer-Aided Design of Integrated Circuits")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
564 ("ipl" . "Information Processing Letters")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
565 ("jacm" . "Journal of the ACM")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
566 ("jcss" . "Journal of Computer and System Sciences")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
567 ("scp" . "Science of Computer Programming")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
568 ("sicomp" . "SIAM Journal on Computing")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
569 ("tcs" . "Theoretical Computer Science")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
570 ("tocs" . "ACM Transactions on Computer Systems")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
571 ("tods" . "ACM Transactions on Database Systems")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
572 ("tog" . "ACM Transactions on Graphics")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
573 ("toms" . "ACM Transactions on Mathematical Software")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
574 ("toois" . "ACM Transactions on Office Information Systems")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
575 ("toplas" . "ACM Transactions on Programming Languages and Systems")))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
576 "Alist of string definitions used in the BibTeX style files.
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
577 Each element is a pair of strings (ABBREVIATION . EXPANSION)."
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
578 :group 'bibtex
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
579 :type '(repeat (cons (string :tag "String")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
580 (string :tag "String expansion"))))
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
581
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
582 (defcustom bibtex-string-files nil
58772
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
583 "List of BibTeX files containing string definitions.
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
584 List elements can be absolute file names or file names relative
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
585 to the directories specified in `bibtex-string-file-path'."
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
586 :group 'bibtex
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
587 :type '(repeat file))
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
588
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
589 (defvar bibtex-string-file-path (getenv "BIBINPUTS")
26711
eac840d283b6 (bibtex-hs-forward-sexp): Added to support
Gerd Moellmann <gerd@gnu.org>
parents: 25444
diff changeset
590 "*Colon separated list of paths to search for `bibtex-string-files'.")
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
591
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
592 (defcustom bibtex-files nil
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
593 "List of BibTeX files that are searched for entry keys.
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
594 List elements can be absolute file names or file names relative to the
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
595 directories specified in `bibtex-file-path'. If an element is a directory,
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
596 check all BibTeX files in this directory. If an element is the symbol
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
597 `bibtex-file-path', check all BibTeX files in `bibtex-file-path'."
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
598 :group 'bibtex
75356
2600e61a031f (bibtex-files): Fix customization type.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 75347
diff changeset
599 :type '(repeat (choice (const :tag "bibtex-file-path" bibtex-file-path)
2600e61a031f (bibtex-files): Fix customization type.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 75347
diff changeset
600 directory file)))
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
601
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
602 (defvar bibtex-file-path (getenv "BIBINPUTS")
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
603 "*Colon separated list of paths to search for `bibtex-files'.")
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
604
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
605 (defcustom bibtex-help-message t
58772
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
606 "If non-nil print help messages in the echo area on entering a new field."
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
607 :group 'bibtex
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
608 :type 'boolean)
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
609
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
610 (defcustom bibtex-autokey-prefix-string ""
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
611 "String prefix for automatically generated reference keys.
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
612 See `bibtex-generate-autokey' for details."
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
613 :group 'bibtex-autokey
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
614 :type 'string)
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
615
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
616 (defcustom bibtex-autokey-names 1
58772
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
617 "Number of names to use for the automatically generated reference key.
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
618 Possibly more names are used according to `bibtex-autokey-names-stretch'.
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
619 If this variable is nil, all names are used.
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
620 See `bibtex-generate-autokey' for details."
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
621 :group 'bibtex-autokey
20907
9a55a557cb5a (bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents: 20866
diff changeset
622 :type '(choice (const :tag "All" infty)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
623 integer))
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
624
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
625 (defcustom bibtex-autokey-names-stretch 0
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
626 "Number of names that can additionally be used for reference keys.
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
627 These names are used only, if all names are used then.
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
628 See `bibtex-generate-autokey' for details."
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
629 :group 'bibtex-autokey
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
630 :type 'integer)
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
631
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
632 (defcustom bibtex-autokey-additional-names ""
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
633 "String to append to the generated key if not all names could be used.
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
634 See `bibtex-generate-autokey' for details."
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
635 :group 'bibtex-autokey
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
636 :type 'string)
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
637
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
638 (defcustom bibtex-autokey-expand-strings nil
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
639 "If non-nil, expand strings when extracting the content of a BibTeX field.
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
640 See `bibtex-generate-autokey' for details."
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
641 :group 'bibtex-autokey
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
642 :type 'boolean)
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
643
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
644 (defvar bibtex-autokey-transcriptions
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
645 '(;; language specific characters
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
646 ("\\\\aa" . "a") ; \aa -> a
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
647 ("\\\\AA" . "A") ; \AA -> A
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
648 ("\\\"a\\|\\\\\\\"a\\|\\\\ae" . "ae") ; "a,\"a,\ae -> ae
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
649 ("\\\"A\\|\\\\\\\"A\\|\\\\AE" . "Ae") ; "A,\"A,\AE -> Ae
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
650 ("\\\\i" . "i") ; \i -> i
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
651 ("\\\\j" . "j") ; \j -> j
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
652 ("\\\\l" . "l") ; \l -> l
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
653 ("\\\\L" . "L") ; \L -> L
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
654 ("\\\"o\\|\\\\\\\"o\\|\\\\o\\|\\\\oe" . "oe") ; "o,\"o,\o,\oe -> oe
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
655 ("\\\"O\\|\\\\\\\"O\\|\\\\O\\|\\\\OE" . "Oe") ; "O,\"O,\O,\OE -> Oe
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
656 ("\\\"s\\|\\\\\\\"s\\|\\\\3" . "ss") ; "s,\"s,\3 -> ss
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
657 ("\\\"u\\|\\\\\\\"u" . "ue") ; "u,\"u -> ue
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
658 ("\\\"U\\|\\\\\\\"U" . "Ue") ; "U,\"U -> Ue
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
659 ;; accents
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
660 ("\\\\`\\|\\\\'\\|\\\\\\^\\|\\\\~\\|\\\\=\\|\\\\\\.\\|\\\\u\\|\\\\v\\|\\\\H\\|\\\\t\\|\\\\c\\|\\\\d\\|\\\\b" . "")
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
661 ;; braces, quotes, concatenation.
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
662 ("[`'\"{}#]" . "")
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
663 ;; spaces
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
664 ("\\\\?[ \t\n]+\\|~" . " "))
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
665 "Alist of (OLD-REGEXP . NEW-STRING) pairs.
19461
6b67f20dd710 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 19460
diff changeset
666 Used by the default values of `bibtex-autokey-name-change-strings' and
6b67f20dd710 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 19460
diff changeset
667 `bibtex-autokey-titleword-change-strings'. Defaults to translating some
6b67f20dd710 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 19460
diff changeset
668 language specific characters to their ASCII transcriptions, and
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
669 removing any character accents.")
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
670
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
671 (defcustom bibtex-autokey-name-change-strings
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
672 bibtex-autokey-transcriptions
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
673 "Alist of (OLD-REGEXP . NEW-STRING) pairs.
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
674 Any part of a name matching OLD-REGEXP is replaced by NEW-STRING.
19461
6b67f20dd710 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 19460
diff changeset
675 Case is significant in OLD-REGEXP. All regexps are tried in the
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
676 order in which they appear in the list.
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
677 See `bibtex-generate-autokey' for details."
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
678 :group 'bibtex-autokey
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
679 :type '(repeat (cons (regexp :tag "Old")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
680 (string :tag "New"))))
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
681
69581
98eee222dceb * textmodes/bibtex.el (bibtex-include-OPTkey)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 68648
diff changeset
682 (defcustom bibtex-autokey-name-case-convert-function 'downcase
58772
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
683 "Function called for each name to perform case conversion.
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
684 See `bibtex-generate-autokey' for details."
20907
9a55a557cb5a (bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents: 20866
diff changeset
685 :group 'bibtex-autokey
9a55a557cb5a (bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents: 20866
diff changeset
686 :type '(choice (const :tag "Preserve case" identity)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
687 (const :tag "Downcase" downcase)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
688 (const :tag "Capitalize" capitalize)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
689 (const :tag "Upcase" upcase)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
690 (function :tag "Conversion function")))
71044
da5fa425123d (bibtex-autokey-name-case-convert-function)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70841
diff changeset
691 (put 'bibtex-autokey-name-case-convert-function 'safe-local-variable
da5fa425123d (bibtex-autokey-name-case-convert-function)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70841
diff changeset
692 (lambda (x) (memq x '(upcase downcase capitalize identity))))
69581
98eee222dceb * textmodes/bibtex.el (bibtex-include-OPTkey)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 68648
diff changeset
693 (defvaralias 'bibtex-autokey-name-case-convert
98eee222dceb * textmodes/bibtex.el (bibtex-include-OPTkey)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 68648
diff changeset
694 'bibtex-autokey-name-case-convert-function)
20907
9a55a557cb5a (bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents: 20866
diff changeset
695
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
696 (defcustom bibtex-autokey-name-length 'infty
58772
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
697 "Number of characters from name to incorporate into key.
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
698 If this is set to anything but a number, all characters are used.
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
699 See `bibtex-generate-autokey' for details."
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
700 :group 'bibtex-autokey
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
701 :type '(choice (const :tag "All" infty)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
702 integer))
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
703
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
704 (defcustom bibtex-autokey-name-separator ""
58772
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
705 "String that comes between any two names in the key.
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
706 See `bibtex-generate-autokey' for details."
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
707 :group 'bibtex-autokey
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
708 :type 'string)
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
709
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
710 (defcustom bibtex-autokey-year-length 2
58772
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
711 "Number of rightmost digits from the year field to incorporate into key.
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
712 See `bibtex-generate-autokey' for details."
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
713 :group 'bibtex-autokey
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
714 :type 'integer)
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
715
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
716 (defcustom bibtex-autokey-use-crossref t
58772
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
717 "If non-nil use fields from crossreferenced entry if necessary.
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
718 If this variable is non-nil and some field has no entry, but a
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
719 valid crossref entry, the field from the crossreferenced entry is used.
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
720 See `bibtex-generate-autokey' for details."
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
721 :group 'bibtex-autokey
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
722 :type 'boolean)
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
723
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
724 (defcustom bibtex-autokey-titlewords 5
58772
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
725 "Number of title words to use for the automatically generated reference key.
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
726 If this is set to anything but a number, all title words are used.
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
727 Possibly more words from the title are used according to
19461
6b67f20dd710 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 19460
diff changeset
728 `bibtex-autokey-titlewords-stretch'.
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
729 See `bibtex-generate-autokey' for details."
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
730 :group 'bibtex-autokey
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
731 :type '(choice (const :tag "All" infty)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
732 integer))
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
733
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
734 (defcustom bibtex-autokey-title-terminators "[.!?:;]\\|--"
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
735 "Regexp defining the termination of the main part of the title.
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
736 Case of the regexps is ignored. See `bibtex-generate-autokey' for details."
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
737 :group 'bibtex-autokey
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
738 :type 'regexp)
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
739
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
740 (defcustom bibtex-autokey-titlewords-stretch 2
58772
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
741 "Number of words that can additionally be used from the title.
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
742 These words are used only, if a sentence from the title can be ended then.
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
743 See `bibtex-generate-autokey' for details."
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
744 :group 'bibtex-autokey
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
745 :type 'integer)
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
746
20907
9a55a557cb5a (bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents: 20866
diff changeset
747 (defcustom bibtex-autokey-titleword-ignore
9a55a557cb5a (bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents: 20866
diff changeset
748 '("A" "An" "On" "The" "Eine?" "Der" "Die" "Das"
61439
267229876c56 (bibtex-autokey-titleword-ignore, bibtex-reference-key)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61247
diff changeset
749 "[^[:upper:]].*" ".*[^[:upper:]0-9].*")
58772
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
750 "Determines words from the title that are not to be used in the key.
59733
96d73eb02751 (bibtex-format-entry): Use `bibtex-empty-field-re' only on the text of
Lute Kamstra <lute@gnu.org>
parents: 58772
diff changeset
751 Each item of the list is a regexp. If a word of the title matches a
20907
9a55a557cb5a (bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents: 20866
diff changeset
752 regexp from that list, it is not included in the title part of the key.
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
753 See `bibtex-generate-autokey' for details."
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
754 :group 'bibtex-autokey
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
755 :type '(repeat regexp))
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
756
69581
98eee222dceb * textmodes/bibtex.el (bibtex-include-OPTkey)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 68648
diff changeset
757 (defcustom bibtex-autokey-titleword-case-convert-function 'downcase
58772
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
758 "Function called for each titleword to perform case conversion.
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
759 See `bibtex-generate-autokey' for details."
20907
9a55a557cb5a (bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents: 20866
diff changeset
760 :group 'bibtex-autokey
9a55a557cb5a (bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents: 20866
diff changeset
761 :type '(choice (const :tag "Preserve case" identity)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
762 (const :tag "Downcase" downcase)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
763 (const :tag "Capitalize" capitalize)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
764 (const :tag "Upcase" upcase)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
765 (function :tag "Conversion function")))
69581
98eee222dceb * textmodes/bibtex.el (bibtex-include-OPTkey)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 68648
diff changeset
766 (defvaralias 'bibtex-autokey-titleword-case-convert
98eee222dceb * textmodes/bibtex.el (bibtex-include-OPTkey)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 68648
diff changeset
767 'bibtex-autokey-titleword-case-convert-function)
20907
9a55a557cb5a (bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents: 20866
diff changeset
768
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
769 (defcustom bibtex-autokey-titleword-abbrevs nil
58772
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
770 "Determines exceptions to the usual abbreviation mechanism.
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
771 An alist of (OLD-REGEXP . NEW-STRING) pairs. Case is ignored
19461
6b67f20dd710 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 19460
diff changeset
772 in matching against OLD-REGEXP, and the first matching pair is used.
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
773 See `bibtex-generate-autokey' for details."
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
774 :group 'bibtex-autokey
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
775 :type '(repeat (cons (regexp :tag "Old")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
776 (string :tag "New"))))
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
777
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
778 (defcustom bibtex-autokey-titleword-change-strings
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
779 bibtex-autokey-transcriptions
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
780 "Alist of (OLD-REGEXP . NEW-STRING) pairs.
19461
6b67f20dd710 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 19460
diff changeset
781 Any part of title word matching a OLD-REGEXP is replaced by NEW-STRING.
6b67f20dd710 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 19460
diff changeset
782 Case is significant in OLD-REGEXP. All regexps are tried in the
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
783 order in which they appear in the list.
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
784 See `bibtex-generate-autokey' for details."
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
785 :group 'bibtex-autokey
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
786 :type '(repeat (cons (regexp :tag "Old")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
787 (string :tag "New"))))
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
788
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
789 (defcustom bibtex-autokey-titleword-length 5
58772
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
790 "Number of characters from title words to incorporate into key.
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
791 If this is set to anything but a number, all characters are used.
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
792 See `bibtex-generate-autokey' for details."
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
793 :group 'bibtex-autokey
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
794 :type '(choice (const :tag "All" infty)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
795 integer))
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
796
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
797 (defcustom bibtex-autokey-titleword-separator "_"
58772
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
798 "String to be put between the title words.
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
799 See `bibtex-generate-autokey' for details."
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
800 :group 'bibtex-autokey
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
801 :type 'string)
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
802
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
803 (defcustom bibtex-autokey-name-year-separator ""
58772
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
804 "String to be put between name part and year part of key.
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
805 See `bibtex-generate-autokey' for details."
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
806 :group 'bibtex-autokey
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
807 :type 'string)
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
808
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
809 (defcustom bibtex-autokey-year-title-separator ":_"
97521
c383ec0fd021 (bibtex-entry-format): Mark as safe.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94670
diff changeset
810 "String to be put between year part and title part of key.
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
811 See `bibtex-generate-autokey' for details."
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
812 :group 'bibtex-autokey
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
813 :type 'string)
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
814
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
815 (defcustom bibtex-autokey-edit-before-use t
58772
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
816 "If non-nil, user is allowed to edit the generated key before it is used."
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
817 :group 'bibtex-autokey
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
818 :type 'boolean)
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
819
20907
9a55a557cb5a (bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents: 20866
diff changeset
820 (defcustom bibtex-autokey-before-presentation-function nil
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
821 "If non-nil, function to call before generated key is presented.
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
822 The function must take one argument (the automatically generated key),
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
823 and must return a string (the key to use)."
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
824 :group 'bibtex-autokey
35962
ad7104908c16 (bibtex-autokey-before-presentation-function): Fix :type.
Dave Love <fx@gnu.org>
parents: 27701
diff changeset
825 :type '(choice (const nil) function))
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
826
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
827 (defcustom bibtex-entry-offset 0
58772
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
828 "Offset for BibTeX entries.
59733
96d73eb02751 (bibtex-format-entry): Use `bibtex-empty-field-re' only on the text of
Lute Kamstra <lute@gnu.org>
parents: 58772
diff changeset
829 Added to the value of all other variables which determine columns."
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
830 :group 'bibtex
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
831 :type 'integer)
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
832
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
833 (defcustom bibtex-field-indentation 2
58772
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
834 "Starting column for the name part in BibTeX fields."
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
835 :group 'bibtex
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
836 :type 'integer)
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
837
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
838 (defcustom bibtex-text-indentation
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
839 (+ bibtex-field-indentation
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
840 (length "organization = "))
58772
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
841 "Starting column for the text part in BibTeX fields.
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
842 Should be equal to the space needed for the longest name part."
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
843 :group 'bibtex
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
844 :type 'integer)
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
845
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
846 (defcustom bibtex-contline-indentation
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
847 (+ bibtex-text-indentation 1)
58772
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
848 "Starting column for continuation lines of BibTeX fields."
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
849 :group 'bibtex
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
850 :type 'integer)
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
851
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
852 (defcustom bibtex-align-at-equal-sign nil
58772
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
853 "If non-nil, align fields at equal sign instead of field text.
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
854 If non-nil, the column for the equal sign is the value of
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
855 `bibtex-text-indentation', minus 2."
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
856 :group 'bibtex
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
857 :type 'boolean)
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
858
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
859 (defcustom bibtex-comma-after-last-field nil
58772
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
860 "If non-nil, a comma is put at end of last field in the entry template."
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
861 :group 'bibtex
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
862 :type 'boolean)
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
863
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
864 (defcustom bibtex-autoadd-commas t
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
865 "If non-nil automatically add missing commas at end of BibTeX fields."
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
866 :group 'bibtex
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
867 :type 'boolean)
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
868
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
869 (defcustom bibtex-autofill-types '("Proceedings")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
870 "Automatically fill fields if possible for those BibTeX entry types."
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
871 :group 'bibtex
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
872 :type '(repeat string))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
873
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
874 (defcustom bibtex-summary-function 'bibtex-summary
62077
e233a73cbf79 (bibtex-summary): Use current BibTeX entry to avoid calling
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61439
diff changeset
875 "Function to call for generating a summary of current BibTeX entry.
e233a73cbf79 (bibtex-summary): Use current BibTeX entry to avoid calling
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61439
diff changeset
876 It takes no arguments. Point must be at beginning of entry.
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
877 Used by `bibtex-complete-crossref-cleanup' and `bibtex-copy-summary-as-kill'."
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
878 :group 'bibtex
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
879 :type '(choice (const :tag "Default" bibtex-summary)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
880 (function :tag "Personalized function")))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
881
57054
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
882 (defcustom bibtex-generate-url-list
61247
d11749d2bcff (bibtex-url): Use format to generate the url.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59733
diff changeset
883 '((("url" . ".*:.*")))
57054
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
884 "List of schemes for generating the URL of a BibTeX entry.
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
885 These schemes are used by `bibtex-url'.
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
886
61247
d11749d2bcff (bibtex-url): Use format to generate the url.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59733
diff changeset
887 Each scheme should have one of these forms:
d11749d2bcff (bibtex-url): Use format to generate the url.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59733
diff changeset
888
d11749d2bcff (bibtex-url): Use format to generate the url.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59733
diff changeset
889 ((FIELD . REGEXP))
d11749d2bcff (bibtex-url): Use format to generate the url.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59733
diff changeset
890 ((FIELD . REGEXP) STEP...)
d11749d2bcff (bibtex-url): Use format to generate the url.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59733
diff changeset
891 ((FIELD . REGEXP) STRING STEP...)
57054
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
892
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
893 FIELD is a field name as returned by `bibtex-parse-entry'.
61247
d11749d2bcff (bibtex-url): Use format to generate the url.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59733
diff changeset
894 REGEXP is matched against the text of FIELD. If the match succeeds,
d11749d2bcff (bibtex-url): Use format to generate the url.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59733
diff changeset
895 then this scheme is used. If no STRING and STEPs are specified
d11749d2bcff (bibtex-url): Use format to generate the url.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59733
diff changeset
896 the matched text is used as the URL, otherwise the URL is built
d11749d2bcff (bibtex-url): Use format to generate the url.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59733
diff changeset
897 by evaluating STEPs. If no STRING is specified the STEPs must result
d11749d2bcff (bibtex-url): Use format to generate the url.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59733
diff changeset
898 in strings which are concatenated. Otherwise the resulting objects
d11749d2bcff (bibtex-url): Use format to generate the url.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59733
diff changeset
899 are passed through `format' using STRING as format control string.
d11749d2bcff (bibtex-url): Use format to generate the url.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59733
diff changeset
900
d11749d2bcff (bibtex-url): Use format to generate the url.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59733
diff changeset
901 A STEP is a list (FIELD REGEXP REPLACE). The text of FIELD
d11749d2bcff (bibtex-url): Use format to generate the url.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59733
diff changeset
902 is matched against REGEXP, and is replaced with REPLACE.
d11749d2bcff (bibtex-url): Use format to generate the url.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59733
diff changeset
903 REPLACE can be a string, or a number (which selects the corresponding
d11749d2bcff (bibtex-url): Use format to generate the url.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59733
diff changeset
904 submatch), or a function called with the field's text as argument
d11749d2bcff (bibtex-url): Use format to generate the url.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59733
diff changeset
905 and with the `match-data' properly set.
d11749d2bcff (bibtex-url): Use format to generate the url.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59733
diff changeset
906
d11749d2bcff (bibtex-url): Use format to generate the url.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59733
diff changeset
907 Case is always ignored. Always remove the field delimiters.
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
908 If `bibtex-expand-strings' is non-nil, BibTeX strings are expanded
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
909 for generating the URL.
61247
d11749d2bcff (bibtex-url): Use format to generate the url.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59733
diff changeset
910
d11749d2bcff (bibtex-url): Use format to generate the url.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59733
diff changeset
911 The following is a complex example, see http://link.aps.org/linkfaq.html.
d11749d2bcff (bibtex-url): Use format to generate the url.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59733
diff changeset
912
d11749d2bcff (bibtex-url): Use format to generate the url.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59733
diff changeset
913 (((\"journal\" . \"\\\\=<\\(PR[ABCDEL]?\\|RMP\\)\\\\=>\")
d11749d2bcff (bibtex-url): Use format to generate the url.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59733
diff changeset
914 \"http://link.aps.org/abstract/%s/v%s/p%s\"
d11749d2bcff (bibtex-url): Use format to generate the url.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59733
diff changeset
915 (\"journal\" \".*\" downcase)
d11749d2bcff (bibtex-url): Use format to generate the url.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59733
diff changeset
916 (\"volume\" \".*\" 0)
d11749d2bcff (bibtex-url): Use format to generate the url.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59733
diff changeset
917 (\"pages\" \"\\`[A-Z]?[0-9]+\" 0)))"
57054
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
918 :group 'bibtex
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
919 :type '(repeat
61247
d11749d2bcff (bibtex-url): Use format to generate the url.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59733
diff changeset
920 (cons :tag "Scheme"
57054
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
921 (cons :tag "Matcher" :extra-offset 4
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
922 (string :tag "BibTeX field")
57070
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
923 (regexp :tag "Regexp"))
61247
d11749d2bcff (bibtex-url): Use format to generate the url.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59733
diff changeset
924 (choice
d11749d2bcff (bibtex-url): Use format to generate the url.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59733
diff changeset
925 (const :tag "Take match as is" nil)
d11749d2bcff (bibtex-url): Use format to generate the url.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59733
diff changeset
926 (cons :tag "Formatted"
d11749d2bcff (bibtex-url): Use format to generate the url.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59733
diff changeset
927 (string :tag "Format control string")
d11749d2bcff (bibtex-url): Use format to generate the url.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59733
diff changeset
928 (repeat :tag "Steps to generate URL"
d11749d2bcff (bibtex-url): Use format to generate the url.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59733
diff changeset
929 (list (string :tag "BibTeX field")
d11749d2bcff (bibtex-url): Use format to generate the url.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59733
diff changeset
930 (regexp :tag "Regexp")
d11749d2bcff (bibtex-url): Use format to generate the url.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59733
diff changeset
931 (choice (string :tag "Replacement")
d11749d2bcff (bibtex-url): Use format to generate the url.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59733
diff changeset
932 (integer :tag "Sub-match")
d11749d2bcff (bibtex-url): Use format to generate the url.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59733
diff changeset
933 (function :tag "Filter")))))
d11749d2bcff (bibtex-url): Use format to generate the url.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59733
diff changeset
934 (repeat :tag "Concatenated"
57054
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
935 (list (string :tag "BibTeX field")
57070
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
936 (regexp :tag "Regexp")
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
937 (choice (string :tag "Replacement")
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
938 (integer :tag "Sub-match")
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
939 (function :tag "Filter"))))))))
69581
98eee222dceb * textmodes/bibtex.el (bibtex-include-OPTkey)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 68648
diff changeset
940 (put 'bibtex-generate-url-list 'risky-local-variable t)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
941
81591
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
942 (defcustom bibtex-cite-matcher-alist
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
943 '(("\\\\cite[ \t\n]*{\\([^}]+\\)}" . 1))
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
944 "Alist of rules to identify cited keys in a BibTeX entry.
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
945 Each rule should be of the form (REGEXP . SUBEXP), where SUBEXP
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
946 specifies which parenthesized expression in REGEXP is a cited key.
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
947 Case is significant.
91913
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
948 Used by `bibtex-search-crossref' and for font-locking."
81591
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
949 :group 'bibtex
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
950 :type '(repeat (cons (regexp :tag "Regexp")
100439
5de002dfa264 * face-remap.el (text-scale-mode-step, buffer-face-mode-face):
Juanma Barranquero <lekktu@gmail.com>
parents: 97521
diff changeset
951 (integer :tag "Number")))
5de002dfa264 * face-remap.el (text-scale-mode-step, buffer-face-mode-face):
Juanma Barranquero <lekktu@gmail.com>
parents: 97521
diff changeset
952 :version "23.1")
81591
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
953
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
954 (defcustom bibtex-expand-strings nil
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
955 "If non-nil, expand strings when extracting the content of a BibTeX field."
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
956 :group 'bibtex
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
957 :type 'boolean)
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
958
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
959 ;; `bibtex-font-lock-keywords' is a user option, too. But since the
14789
d68b71228abd (bibtex-pop): New generic function which unifies the
Richard M. Stallman <rms@gnu.org>
parents: 14410
diff changeset
960 ;; patterns used to define this variable are defined in a later
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
961 ;; section of this file, it is defined later.
26711
eac840d283b6 (bibtex-hs-forward-sexp): Added to support
Gerd Moellmann <gerd@gnu.org>
parents: 25444
diff changeset
962
eac840d283b6 (bibtex-hs-forward-sexp): Added to support
Gerd Moellmann <gerd@gnu.org>
parents: 25444
diff changeset
963
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
964 ;; Syntax Table and Keybindings
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
965 (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
966 (let ((st (make-syntax-table)))
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
967 (modify-syntax-entry ?\" "\"" st)
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
968 (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
969 (modify-syntax-entry ?% "< " st)
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
970 (modify-syntax-entry ?' "w " st)
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
971 (modify-syntax-entry ?@ "w " st)
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
972 (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
973 (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
974 (modify-syntax-entry ?\n "> " st)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
975 ;; Keys cannot have = in them (wrong font-lock of @string{foo=bar}).
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
976 (modify-syntax-entry ?= "." st)
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
977 (modify-syntax-entry ?~ " " st)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
978 st)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
979 "Syntax table used in BibTeX mode buffers.")
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
980
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 (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
982 (let ((km (make-sparse-keymap)))
26711
eac840d283b6 (bibtex-hs-forward-sexp): Added to support
Gerd Moellmann <gerd@gnu.org>
parents: 25444
diff changeset
983 ;; The Key `C-c&' is reserved for reftex.el
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
984 (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
985 (define-key km "\n" 'bibtex-next-field)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
986 (define-key km "\M-\t" 'bibtex-complete)
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
987 (define-key km "\C-c\"" 'bibtex-remove-delimiters)
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
988 (define-key km "\C-c{" 'bibtex-remove-delimiters)
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
989 (define-key km "\C-c}" 'bibtex-remove-delimiters)
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
990 (define-key km "\C-c\C-c" 'bibtex-clean-entry)
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
991 (define-key km "\C-c\C-q" 'bibtex-fill-entry)
91913
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
992 (define-key km "\C-c\C-s" 'bibtex-search-entry)
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
993 (define-key km "\C-c\C-x" 'bibtex-search-crossref)
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
994 (define-key km "\C-c\C-t" 'bibtex-copy-summary-as-kill)
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
995 (define-key km "\C-c?" 'bibtex-print-help-message)
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
996 (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
997 (define-key km "\C-c\C-n" 'bibtex-pop-next)
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
998 (define-key km "\C-c\C-k" 'bibtex-kill-field)
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
999 (define-key km "\C-c\M-k" 'bibtex-copy-field-as-kill)
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1000 (define-key km "\C-c\C-w" 'bibtex-kill-entry)
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1001 (define-key km "\C-c\M-w" 'bibtex-copy-entry-as-kill)
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1002 (define-key km "\C-c\C-y" 'bibtex-yank)
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1003 (define-key km "\C-c\M-y" 'bibtex-yank-pop)
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
1004 (define-key km "\C-c\C-d" 'bibtex-empty-field)
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1005 (define-key km "\C-c\C-f" 'bibtex-make-field)
55348
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1006 (define-key km "\C-c\C-u" 'bibtex-entry-update)
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1007 (define-key km "\C-c$" 'bibtex-ispell-abstract)
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1008 (define-key km "\M-\C-a" 'bibtex-beginning-of-entry)
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1009 (define-key km "\M-\C-e" 'bibtex-end-of-entry)
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1010 (define-key km "\C-\M-l" 'bibtex-reposition-window)
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1011 (define-key km "\C-\M-h" 'bibtex-mark-entry)
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1012 (define-key km "\C-c\C-b" 'bibtex-entry)
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
1013 (define-key km "\C-c\C-rn" 'bibtex-narrow-to-entry)
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
1014 (define-key km "\C-c\C-rw" 'widen)
57054
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
1015 (define-key km "\C-c\C-l" 'bibtex-url)
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1016 (define-key km "\C-c\C-o" 'bibtex-remove-OPT-or-ALT)
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
1017 (define-key km "\C-c\C-e\C-i" 'bibtex-InProceedings)
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
1018 (define-key km "\C-c\C-ei" 'bibtex-InCollection)
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
1019 (define-key km "\C-c\C-eI" 'bibtex-InBook)
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
1020 (define-key km "\C-c\C-e\C-a" 'bibtex-Article)
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
1021 (define-key km "\C-c\C-e\C-b" 'bibtex-InBook)
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
1022 (define-key km "\C-c\C-eb" 'bibtex-Book)
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
1023 (define-key km "\C-c\C-eB" 'bibtex-Booklet)
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
1024 (define-key km "\C-c\C-e\C-c" 'bibtex-InCollection)
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
1025 (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
1026 (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
1027 (define-key km "\C-c\C-eM" 'bibtex-Misc)
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
1028 (define-key km "\C-c\C-e\C-p" 'bibtex-InProceedings)
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
1029 (define-key km "\C-c\C-ep" 'bibtex-Proceedings)
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
1030 (define-key km "\C-c\C-eP" 'bibtex-PhdThesis)
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1031 (define-key km "\C-c\C-e\M-p" 'bibtex-Preamble)
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1032 (define-key km "\C-c\C-e\C-s" 'bibtex-String)
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
1033 (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
1034 (define-key km "\C-c\C-e\C-u" 'bibtex-Unpublished)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1035 km)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1036 "Keymap used in BibTeX mode.")
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
1037
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1038 (easy-menu-define
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1039 bibtex-edit-menu bibtex-mode-map "BibTeX-Edit Menu in BibTeX mode"
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1040 '("BibTeX-Edit"
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1041 ("Moving inside an Entry"
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1042 ["End of Field" bibtex-find-text t]
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1043 ["Next Field" bibtex-next-field t]
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1044 ["Beginning of Entry" bibtex-beginning-of-entry t]
58772
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
1045 ["End of Entry" bibtex-end-of-entry t]
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
1046 "--"
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
1047 ["Make Entry Visible" bibtex-reposition-window t])
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
1048 ("Moving in BibTeX Buffers"
91913
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1049 ["Search Entry" bibtex-search-entry t]
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1050 ["Search Crossref Entry" bibtex-search-crossref t])
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
1051 "--"
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1052 ("Operating on Current Field"
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1053 ["Fill Field" fill-paragraph t]
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1054 ["Remove Delimiters" bibtex-remove-delimiters t]
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1055 ["Remove OPT or ALT Prefix" bibtex-remove-OPT-or-ALT t]
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1056 ["Clear Field" bibtex-empty-field t]
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1057 "--"
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1058 ["Kill Field" bibtex-kill-field t]
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1059 ["Copy Field to Kill Ring" bibtex-copy-field-as-kill t]
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1060 ["Paste Most Recently Killed Field" bibtex-yank t]
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1061 ["Paste Previously Killed Field" bibtex-yank-pop t]
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1062 "--"
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1063 ["Make New Field" bibtex-make-field t]
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1064 "--"
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1065 ["Snatch from Similar Following Field" bibtex-pop-next t]
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1066 ["Snatch from Similar Preceding Field" bibtex-pop-previous t]
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1067 "--"
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1068 ["String or Key Complete" bibtex-complete t]
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1069 "--"
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1070 ["Help about Current Field" bibtex-print-help-message t])
57054
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
1071 ("Operating on Current Entry"
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
1072 ["Fill Entry" bibtex-fill-entry t]
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
1073 ["Clean Entry" bibtex-clean-entry t]
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
1074 ["Update Entry" bibtex-entry-update t]
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
1075 "--"
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
1076 ["Kill Entry" bibtex-kill-entry t]
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
1077 ["Copy Entry to Kill Ring" bibtex-copy-entry-as-kill t]
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
1078 ["Paste Most Recently Killed Entry" bibtex-yank t]
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
1079 ["Paste Previously Killed Entry" bibtex-yank-pop t]
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
1080 "--"
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
1081 ["Copy Summary to Kill Ring" bibtex-copy-summary-as-kill t]
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
1082 ["Browse URL" bibtex-url t]
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
1083 "--"
57054
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
1084 ["Ispell Entry" bibtex-ispell-entry t]
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
1085 ["Ispell Entry Abstract" bibtex-ispell-abstract t]
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
1086 "--"
57054
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
1087 ["Narrow to Entry" bibtex-narrow-to-entry t]
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
1088 ["Mark Entry" bibtex-mark-entry t]
57054
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
1089 "--"
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
1090 ["View Cite Locations (RefTeX)" reftex-view-crossref-from-bibtex
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
1091 (fboundp 'reftex-view-crossref-from-bibtex)])
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1092 ("Operating on Buffer or Region"
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1093 ["Validate Entries" bibtex-validate t]
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1094 ["Sort Entries" bibtex-sort-buffer t]
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1095 ["Reformat Entries" bibtex-reformat t]
57054
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
1096 ["Count Entries" bibtex-count-entries t]
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
1097 "--"
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
1098 ["Convert Alien Buffer" bibtex-convert-alien t])
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
1099 ("Operating on Multiple Buffers"
87650
29fbecdf9527 (bibtex-initialize): New autoloaded command. Rename from function
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87649
diff changeset
1100 ["(Re)Initialize BibTeX Buffers" bibtex-initialize t]
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
1101 ["Validate Entries" bibtex-validate-globally 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
1102
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1103 (easy-menu-define
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1104 bibtex-entry-menu bibtex-mode-map "Entry-Types Menu in BibTeX mode"
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1105 (list "Entry-Types"
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1106 ["Article in Journal" bibtex-Article t]
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1107 ["Article in Conference Proceedings" bibtex-InProceedings t]
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1108 ["Article in a Collection" bibtex-InCollection t]
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1109 ["Chapter or Pages in a Book" bibtex-InBook t]
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1110 ["Conference Proceedings" bibtex-Proceedings t]
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1111 ["Book" bibtex-Book t]
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1112 ["Booklet (Bound, but no Publisher/Institution)" bibtex-Booklet t]
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1113 ["PhD. Thesis" bibtex-PhdThesis t]
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1114 ["Master's Thesis" bibtex-MastersThesis t]
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1115 ["Technical Report" bibtex-TechReport t]
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1116 ["Technical Manual" bibtex-Manual t]
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1117 ["Unpublished" bibtex-Unpublished t]
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1118 ["Miscellaneous" bibtex-Misc t]
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
1119 "--"
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1120 ["String" bibtex-String t]
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1121 ["Preamble" bibtex-Preamble 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
1122
14789
d68b71228abd (bibtex-pop): New generic function which unifies the
Richard M. Stallman <rms@gnu.org>
parents: 14410
diff changeset
1123
12700
b3a8ee2da96a Add keywords and comments as per conventions.
Richard M. Stallman <rms@gnu.org>
parents: 12028
diff changeset
1124 ;; Internal 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
1125
81591
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
1126 (defvar bibtex-field-braces-opt nil
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
1127 "Optimized value of `bibtex-field-braces-alist'.
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
1128 Created by `bibtex-field-re-init'.
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
1129 It is a an alist with elements (FIELD . REGEXP).")
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
1130
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
1131 (defvar bibtex-field-strings-opt nil
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
1132 "Optimized value of `bibtex-field-strings-alist'.
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
1133 Created by `bibtex-field-re-init'.
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
1134 It is a an alist with elements (FIELD RULE1 RULE2 ...),
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
1135 where each RULE is (REGEXP . TO-STR).")
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
1136
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1137 (defvar bibtex-pop-previous-search-point nil
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1138 "Next point where `bibtex-pop-previous' starts looking for a similar entry.")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1139
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1140 (defvar bibtex-pop-next-search-point nil
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1141 "Next point where `bibtex-pop-next' starts looking for a similar entry.")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1142
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1143 (defvar bibtex-field-kill-ring nil
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1144 "Ring of least recently killed fields.
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1145 At most `bibtex-field-kill-ring-max' items are kept here.")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1146
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1147 (defvar bibtex-field-kill-ring-yank-pointer nil
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1148 "The tail of `bibtex-field-kill-ring' whose car is the last item yanked.")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1149
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1150 (defvar bibtex-entry-kill-ring nil
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1151 "Ring of least recently killed entries.
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1152 At most `bibtex-entry-kill-ring-max' items are kept here.")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1153
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1154 (defvar bibtex-entry-kill-ring-yank-pointer nil
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1155 "The tail of `bibtex-entry-kill-ring' whose car is the last item yanked.")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1156
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1157 (defvar bibtex-last-kill-command nil
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1158 "Type of the last kill command (either 'field or 'entry).")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1159
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1160 (defvar bibtex-strings
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1161 (lazy-completion-table bibtex-strings
67816
d195eef388b8 (bibtex-strings, bibtex-reference-keys):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 67575
diff changeset
1162 (lambda ()
d195eef388b8 (bibtex-strings, bibtex-reference-keys):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 67575
diff changeset
1163 (bibtex-parse-strings (bibtex-string-files-init))))
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1164 "Completion table for BibTeX string keys.
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1165 Initialized from `bibtex-predefined-strings' and `bibtex-string-files'.")
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1166 (make-variable-buffer-local 'bibtex-strings)
68265
9e0c23ab13f9 (bibtex-strings, bibtex-reference-keys): Mark as risky.
Richard M. Stallman <rms@gnu.org>
parents: 68065
diff changeset
1167 (put 'bibtex-strings 'risky-local-variable t)
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1168
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1169 (defvar bibtex-reference-keys
67816
d195eef388b8 (bibtex-strings, bibtex-reference-keys):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 67575
diff changeset
1170 (lazy-completion-table bibtex-reference-keys
d195eef388b8 (bibtex-strings, bibtex-reference-keys):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 67575
diff changeset
1171 (lambda () (bibtex-parse-keys nil t)))
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
1172 "Completion table for BibTeX reference keys.
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
1173 The CDRs of the elements are t for header keys and nil for crossref keys.")
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1174 (make-variable-buffer-local 'bibtex-reference-keys)
68265
9e0c23ab13f9 (bibtex-strings, bibtex-reference-keys): Mark as risky.
Richard M. Stallman <rms@gnu.org>
parents: 68065
diff changeset
1175 (put 'bibtex-reference-keys 'risky-local-variable t)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1176
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1177 (defvar bibtex-buffer-last-parsed-tick nil
57070
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
1178 "Value of `buffer-modified-tick' last time buffer was parsed for keys.")
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1179
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1180 (defvar bibtex-parse-idle-timer nil
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1181 "Stores if timer is already installed.")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1182
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1183 (defvar bibtex-progress-lastperc nil
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1184 "Last reported percentage for the progress message.")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1185
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1186 (defvar bibtex-progress-lastmes nil
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1187 "Last reported progress message.")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1188
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1189 (defvar bibtex-progress-interval nil
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1190 "Interval for progress messages.")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1191
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1192 (defvar bibtex-key-history nil
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1193 "History list for reading keys.")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1194
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1195 (defvar bibtex-entry-type-history nil
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1196 "History list for reading entry types.")
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1197
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1198 (defvar bibtex-field-history nil
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1199 "History list for reading field names.")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1200
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1201 (defvar bibtex-reformat-previous-options nil
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1202 "Last reformat options given.")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1203
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1204 (defvar bibtex-reformat-previous-reference-keys nil
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1205 "Last reformat reference keys option given.")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1206
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1207 (defconst bibtex-field-name "[^\"#%'(),={} \t\n0-9][^\"#%'(),={} \t\n]*"
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1208 "Regexp matching the name of a BibTeX field.")
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1209
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1210 (defconst bibtex-name-part
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1211 (concat ",[ \t\n]*\\(" bibtex-field-name "\\)")
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1212 "Regexp matching the name part of a BibTeX field.")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1213
61439
267229876c56 (bibtex-autokey-titleword-ignore, bibtex-reference-key)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61247
diff changeset
1214 (defconst bibtex-reference-key "[][[:alnum:].:;?!`'/*@+|()<>&_^$-]+"
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1215 "Regexp matching the reference key part of a BibTeX entry.")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1216
61439
267229876c56 (bibtex-autokey-titleword-ignore, bibtex-reference-key)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61247
diff changeset
1217 (defconst bibtex-field-const "[][[:alnum:].:;?!`'/*@+=|<>&_^$-]+"
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1218 "Regexp matching a BibTeX field constant.")
27701
5e135f0faf1d (bibtex-mode): Replaced manual splitting of path
Gerd Moellmann <gerd@gnu.org>
parents: 26711
diff changeset
1219
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1220 (defvar bibtex-entry-type
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1221 (concat "@[ \t]*\\(?:"
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1222 (regexp-opt (mapcar 'car bibtex-entry-field-alist)) "\\)")
92218
1d8a03656f39 (bibtex-format-entry): Handle error message refering to a missing
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 92217
diff changeset
1223 "Regexp matching the type of a BibTeX entry.")
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1224
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1225 (defvar bibtex-entry-head
15637
405b1ecbf8ba (bibtex-reference-head): Allow spaces and tabs between
Karl Heuer <kwzh@gnu.org>
parents: 15565
diff changeset
1226 (concat "^[ \t]*\\("
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1227 bibtex-entry-type
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1228 "\\)[ \t]*[({][ \t\n]*\\("
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1229 bibtex-reference-key
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1230 "\\)")
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1231 "Regexp matching the header line of a BibTeX entry (including key).")
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1232
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1233 (defvar bibtex-entry-maybe-empty-head
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1234 (concat bibtex-entry-head "?")
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1235 "Regexp matching the header line of a BibTeX entry (possibly without key).")
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1236
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1237 (defconst bibtex-any-entry-maybe-empty-head
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1238 (concat "^[ \t]*\\(@[ \t]*" bibtex-field-name "\\)[ \t]*[({][ \t\n]*\\("
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1239 bibtex-reference-key "\\)?")
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1240 "Regexp matching the header line of any BibTeX entry (possibly without key).")
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1241
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1242 (defvar bibtex-any-valid-entry-type
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1243 (concat "^[ \t]*@[ \t]*\\(?:"
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1244 (regexp-opt (append '("String" "Preamble")
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1245 (mapcar 'car bibtex-entry-field-alist))) "\\)")
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1246 "Regexp matching any valid BibTeX entry (including String and Preamble).")
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1247
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1248 (defconst bibtex-type-in-head 1
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1249 "Regexp subexpression number of the type part in `bibtex-entry-head'.")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1250
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1251 (defconst bibtex-key-in-head 2
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1252 "Regexp subexpression number of the key part in `bibtex-entry-head'.")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1253
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1254 (defconst bibtex-string-type "^[ \t]*\\(@[ \t]*String\\)[ \t]*[({][ \t\n]*"
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1255 "Regexp matching the name of a BibTeX String entry.")
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1256
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1257 (defconst bibtex-string-maybe-empty-head
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1258 (concat bibtex-string-type "\\(" bibtex-reference-key "\\)?")
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1259 "Regexp matching the header line of a BibTeX String entry.")
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1260
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1261 (defconst bibtex-preamble-prefix
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1262 "[ \t]*\\(@[ \t]*Preamble\\)[ \t]*[({][ \t\n]*"
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1263 "Regexp matching the prefix part of a BibTeX Preamble entry.")
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1264
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1265 (defconst bibtex-font-lock-syntactic-keywords
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1266 `((,(concat "^[ \t]*\\(" (substring bibtex-comment-start 0 1) "\\)"
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1267 (substring bibtex-comment-start 1) "\\>")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1268 1 '(11))))
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
1269
14789
d68b71228abd (bibtex-pop): New generic function which unifies the
Richard M. Stallman <rms@gnu.org>
parents: 14410
diff changeset
1270 (defvar bibtex-font-lock-keywords
57054
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
1271 ;; entry type and reference key
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1272 `((,bibtex-any-entry-maybe-empty-head
57054
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
1273 (,bibtex-type-in-head font-lock-function-name-face)
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
1274 (,bibtex-key-in-head font-lock-constant-face nil t))
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
1275 ;; optional field names (treated as comments)
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
1276 (,(concat "^[ \t]*\\(OPT" bibtex-field-name "\\)[ \t]*=")
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
1277 1 font-lock-comment-face)
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
1278 ;; field names
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
1279 (,(concat "^[ \t]*\\(" bibtex-field-name "\\)[ \t]*=")
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
1280 1 font-lock-variable-name-face)
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
1281 ;; url
81591
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
1282 (bibtex-font-lock-url) (bibtex-font-lock-crossref)
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
1283 ;; cite
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
1284 ,@(mapcar (lambda (matcher)
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
1285 `((lambda (bound) (bibtex-font-lock-cite ',matcher bound))))
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
1286 bibtex-cite-matcher-alist))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1287 "*Default expressions to highlight in BibTeX mode.")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1288
57054
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
1289 (defvar bibtex-font-lock-url-regexp
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
1290 ;; Assume that field names begin at the beginning of a line.
58772
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
1291 (concat "^[ \t]*"
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
1292 (regexp-opt (delete-dups (mapcar 'caar bibtex-generate-url-list)) t)
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
1293 "[ \t]*=[ \t]*")
81591
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
1294 "Regexp for `bibtex-font-lock-url' derived from `bibtex-generate-url-list'.")
57054
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
1295
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1296 (defvar bibtex-string-empty-key nil
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1297 "If non-nil, `bibtex-parse-string' accepts empty key.")
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1298
71044
da5fa425123d (bibtex-autokey-name-case-convert-function)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70841
diff changeset
1299 (defvar bibtex-sort-entry-class-alist nil
57070
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
1300 "Alist mapping entry types to their sorting index.
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
1301 Auto-generated from `bibtex-sort-entry-class'.
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
1302 Used when `bibtex-maintain-sorted-entries' is `entry-class'.")
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1303
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1304
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1305 (defun bibtex-parse-association (parse-lhs parse-rhs)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1306 "Parse a string of the format <left-hand-side = right-hand-side>.
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1307 The functions PARSE-LHS and PARSE-RHS are used to parse the corresponding
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1308 substrings. These functions are expected to return nil if parsing is not
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1309 successful. If the returned values of both functions are non-nil,
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1310 return a cons pair of these values. Do not move point."
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1311 (save-match-data
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1312 (save-excursion
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1313 (let ((left (funcall parse-lhs))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1314 right)
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1315 (if (and left
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1316 (looking-at "[ \t\n]*=[ \t\n]*")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1317 (goto-char (match-end 0))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1318 (setq right (funcall parse-rhs)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1319 (cons left right))))))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1320
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1321 (defun bibtex-parse-field-name ()
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1322 "Parse the name part of a BibTeX field.
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1323 If the field name is found, return a triple consisting of the position of the
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1324 very first character of the match, the actual starting position of the name
57070
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
1325 part and end position of the match. Move point to end of field name.
59733
96d73eb02751 (bibtex-format-entry): Use `bibtex-empty-field-re' only on the text of
Lute Kamstra <lute@gnu.org>
parents: 58772
diff changeset
1326 If `bibtex-autoadd-commas' is non-nil add missing comma at end of preceding
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1327 BibTeX field as necessary."
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1328 (cond ((looking-at bibtex-name-part)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1329 (goto-char (match-end 0))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1330 (list (match-beginning 0) (match-beginning 1) (match-end 0)))
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1331 ;; Maybe add a missing comma.
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1332 ((and bibtex-autoadd-commas
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1333 (looking-at (concat "[ \t\n]*\\(?:" bibtex-field-name
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1334 "\\)[ \t\n]*=")))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1335 (skip-chars-backward " \t\n")
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1336 ;; It can be confusing if non-editing commands try to
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1337 ;; modify the buffer.
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1338 (if buffer-read-only
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1339 (error "Comma missing at buffer position %s" (point)))
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1340 (insert ",")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1341 (forward-char -1)
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1342 ;; Now try again.
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1343 (bibtex-parse-field-name))))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1344
55348
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1345 (defconst bibtex-braced-string-syntax-table
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1346 (let ((st (make-syntax-table)))
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1347 (modify-syntax-entry ?\{ "(}" st)
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1348 (modify-syntax-entry ?\} "){" st)
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1349 (modify-syntax-entry ?\[ "." st)
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1350 (modify-syntax-entry ?\] "." st)
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1351 (modify-syntax-entry ?\( "." st)
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1352 (modify-syntax-entry ?\) "." st)
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1353 (modify-syntax-entry ?\\ "." st)
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1354 (modify-syntax-entry ?\" "." st)
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1355 st)
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1356 "Syntax-table to parse matched braces.")
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1357
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1358 (defconst bibtex-quoted-string-syntax-table
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1359 (let ((st (make-syntax-table)))
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1360 (modify-syntax-entry ?\\ "\\" st)
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1361 (modify-syntax-entry ?\" "\"" st)
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1362 st)
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1363 "Syntax-table to parse matched quotes.")
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1364
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1365 (defun bibtex-parse-field-string ()
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
1366 "Parse a BibTeX field string enclosed by braces or quotes.
55348
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1367 If a syntactically correct string is found, a pair containing the start and
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1368 end position of the field string is returned, nil otherwise.
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1369 Do not move point."
55348
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1370 (let ((end-point
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1371 (or (and (eq (following-char) ?\")
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1372 (save-excursion
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1373 (with-syntax-table bibtex-quoted-string-syntax-table
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1374 (forward-sexp 1))
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1375 (point)))
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1376 (and (eq (following-char) ?\{)
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1377 (save-excursion
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1378 (with-syntax-table bibtex-braced-string-syntax-table
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1379 (forward-sexp 1))
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1380 (point))))))
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1381 (if end-point
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1382 (cons (point) end-point))))
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1383
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1384 (defun bibtex-parse-field-text ()
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1385 "Parse the text part of a BibTeX field.
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1386 The text part is either a string, or an empty string, or a constant followed
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1387 by one or more <# (string|constant)> pairs. If a syntactically correct text
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1388 is found, a pair containing the start and end position of the text is
57070
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
1389 returned, nil otherwise. Move point to end of field text."
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1390 (let ((starting-point (point))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1391 end-point failure boundaries)
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1392 (while (not (or end-point failure))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1393 (cond ((looking-at bibtex-field-const)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1394 (goto-char (match-end 0)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1395 ((setq boundaries (bibtex-parse-field-string))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1396 (goto-char (cdr boundaries)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1397 ((setq failure t)))
57054
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
1398 (if (looking-at "[ \t\n]*#[ \t\n]*")
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
1399 (goto-char (match-end 0))
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
1400 (setq end-point (point))))
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1401 (skip-chars-forward " \t\n")
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1402 (if (and (not failure)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1403 end-point)
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1404 (list starting-point end-point (point)))))
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1405
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1406 (defun bibtex-parse-field ()
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1407 "Parse the BibTeX field beginning at the position of point.
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1408 If a syntactically correct field is found, return a cons pair containing
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1409 the boundaries of the name and text parts of the field. Do not move point."
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1410 (bibtex-parse-association 'bibtex-parse-field-name
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1411 'bibtex-parse-field-text))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1412
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1413 (defsubst bibtex-start-of-field (bounds)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1414 (nth 0 (car bounds)))
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1415 (defsubst bibtex-start-of-name-in-field (bounds)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1416 (nth 1 (car bounds)))
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1417 (defsubst bibtex-end-of-name-in-field (bounds)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1418 (nth 2 (car bounds)))
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1419 (defsubst bibtex-start-of-text-in-field (bounds)
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1420 (nth 1 bounds))
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1421 (defsubst bibtex-end-of-text-in-field (bounds)
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1422 (nth 2 bounds))
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1423 (defsubst bibtex-end-of-field (bounds)
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1424 (nth 3 bounds))
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1425
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1426 (defun bibtex-search-forward-field (name &optional bound)
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1427 "Search forward to find a BibTeX field of name NAME.
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1428 If a syntactically correct field is found, return a pair containing
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1429 the boundaries of the name and text parts of the field. The search
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1430 is limited by optional arg BOUND. If BOUND is t the search is limited
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1431 by the end of the current entry. Do not move point."
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1432 (save-match-data
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1433 (save-excursion
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1434 (if (eq bound t)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1435 (let ((regexp (concat bibtex-name-part "[ \t\n]*=\\|"
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1436 bibtex-any-entry-maybe-empty-head))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1437 (case-fold-search t) bounds)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1438 (catch 'done
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1439 (if (looking-at "[ \t]*@") (goto-char (match-end 0)))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1440 (while (and (not bounds)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1441 (re-search-forward regexp nil t))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1442 (if (match-beginning 2)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1443 ;; We found a new entry
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1444 (throw 'done nil)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1445 ;; We found a field
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1446 (goto-char (match-beginning 0))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1447 (setq bounds (bibtex-parse-field))))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1448 ;; Step through all fields so that we cannot overshoot.
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1449 (while bounds
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1450 (goto-char (bibtex-start-of-name-in-field bounds))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1451 (if (looking-at name) (throw 'done bounds))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1452 (goto-char (bibtex-end-of-field bounds))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1453 (setq bounds (bibtex-parse-field)))))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1454 ;; Bounded search or bound is nil (i.e. we cannot overshoot).
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1455 ;; Indeed, the search is bounded when `bibtex-search-forward-field'
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1456 ;; is called many times. So we optimize this part of this function.
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1457 (let ((name-part (concat ",[ \t\n]*\\(" name "\\)[ \t\n]*=[ \t\n]*"))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1458 (case-fold-search t) left right)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1459 (while (and (not right)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1460 (re-search-forward name-part bound t))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1461 (setq left (list (match-beginning 0) (match-beginning 1)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1462 (match-end 1))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1463 ;; Don't worry that the field text could be past bound.
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1464 right (bibtex-parse-field-text)))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1465 (if right (cons left right)))))))
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1466
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1467 (defun bibtex-search-backward-field (name &optional bound)
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1468 "Search backward to find a BibTeX field of name NAME.
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1469 If a syntactically correct field is found, return a pair containing
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1470 the boundaries of the name and text parts of the field. The search
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1471 is limited by the optional arg BOUND. If BOUND is t the search is
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1472 limited by the beginning of the current entry. Do not move point."
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1473 (save-match-data
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1474 (if (eq bound t)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1475 (setq bound (save-excursion (bibtex-beginning-of-entry))))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1476 (let ((name-part (concat ",[ \t\n]*\\(" name "\\)[ \t\n]*=[ \t\n]*"))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1477 (case-fold-search t) left right)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1478 (save-excursion
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1479 ;; the parsing functions are not designed for parsing backwards :-(
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1480 (when (search-backward "," bound t)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1481 (or (save-excursion
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1482 (when (looking-at name-part)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1483 (setq left (list (match-beginning 0) (match-beginning 1)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1484 (match-end 1)))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1485 (goto-char (match-end 0))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1486 (setq right (bibtex-parse-field-text))))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1487 (while (and (not right)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1488 (re-search-backward name-part bound t))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1489 (setq left (list (match-beginning 0) (match-beginning 1)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1490 (match-end 1)))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1491 (save-excursion
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1492 (goto-char (match-end 0))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1493 (setq right (bibtex-parse-field-text)))))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1494 (if right (cons left right)))))))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1495
57054
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
1496 (defun bibtex-name-in-field (bounds &optional remove-opt-alt)
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
1497 "Get content of name in BibTeX field defined via BOUNDS.
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
1498 If optional arg REMOVE-OPT-ALT is non-nil remove \"OPT\" and \"ALT\"."
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1499 (let ((name (buffer-substring-no-properties
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1500 (bibtex-start-of-name-in-field bounds)
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1501 (bibtex-end-of-name-in-field bounds))))
57054
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
1502 (if (and remove-opt-alt
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
1503 (string-match "\\`\\(OPT\\|ALT\\)" name))
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
1504 (substring name 3)
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
1505 name)))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1506
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1507 (defun bibtex-text-in-field-bounds (bounds &optional content)
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1508 "Get text in BibTeX field defined via BOUNDS.
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1509 If optional arg CONTENT is non-nil extract content of field
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1510 by removing field delimiters and concatenating the resulting string.
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1511 If `bibtex-expand-strings' is non-nil, also expand BibTeX strings."
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1512 (if content
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1513 (save-excursion
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1514 (goto-char (bibtex-start-of-text-in-field bounds))
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1515 (let ((epoint (bibtex-end-of-text-in-field bounds))
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1516 content opoint)
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1517 (while (< (setq opoint (point)) epoint)
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1518 (if (looking-at bibtex-field-const)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1519 (let ((mtch (match-string-no-properties 0)))
67897
823f54b91fe2 (bibtex-text-in-field-bounds): Handle case that assoc-string returns
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67894
diff changeset
1520 (push (or (if bibtex-expand-strings
823f54b91fe2 (bibtex-text-in-field-bounds): Handle case that assoc-string returns
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67894
diff changeset
1521 (cdr (assoc-string mtch (bibtex-strings) t)))
823f54b91fe2 (bibtex-text-in-field-bounds): Handle case that assoc-string returns
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67894
diff changeset
1522 mtch) content)
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1523 (goto-char (match-end 0)))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1524 (let ((bounds (bibtex-parse-field-string)))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1525 (push (buffer-substring-no-properties
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1526 (1+ (car bounds)) (1- (cdr bounds))) content)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1527 (goto-char (cdr bounds))))
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1528 (re-search-forward "\\=[ \t\n]*#[ \t\n]*" nil t))
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1529 (apply 'concat (nreverse content))))
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1530 (buffer-substring-no-properties (bibtex-start-of-text-in-field bounds)
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1531 (bibtex-end-of-text-in-field bounds))))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1532
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1533 (defun bibtex-text-in-field (field &optional follow-crossref)
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
1534 "Get content of field FIELD of current BibTeX entry.
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
1535 Return nil if not found.
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1536 If optional arg FOLLOW-CROSSREF is non-nil, follow crossref."
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1537 (save-excursion
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1538 (let* ((end (if follow-crossref (bibtex-end-of-entry) t))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1539 (beg (bibtex-beginning-of-entry)) ; move point
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1540 (bounds (bibtex-search-forward-field field end)))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1541 (cond (bounds (bibtex-text-in-field-bounds bounds t))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1542 ((and follow-crossref
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1543 (progn (goto-char beg)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1544 (setq bounds (bibtex-search-forward-field
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1545 "\\(OPT\\)?crossref" end))))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1546 (let ((crossref-field (bibtex-text-in-field-bounds bounds t)))
91913
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1547 (if (bibtex-search-crossref crossref-field)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1548 ;; Do not pass FOLLOW-CROSSREF because we want
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1549 ;; to follow crossrefs only one level of recursion.
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1550 (bibtex-text-in-field field))))))))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1551
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1552 (defun bibtex-parse-string-prefix ()
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1553 "Parse the prefix part of a BibTeX string entry, including reference key.
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1554 If the string prefix is found, return a triple consisting of the position of
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1555 the very first character of the match, the actual starting position of the
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1556 reference key and the end position of the match.
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1557 If `bibtex-string-empty-key' is non-nil accept empty string key."
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1558 (let ((case-fold-search t))
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1559 (if (looking-at bibtex-string-type)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1560 (let ((start (point)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1561 (goto-char (match-end 0))
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1562 (cond ((looking-at bibtex-reference-key)
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1563 (goto-char (match-end 0))
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1564 (list start
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1565 (match-beginning 0)
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1566 (match-end 0)))
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1567 ((and bibtex-string-empty-key
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1568 (looking-at "="))
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1569 (skip-chars-backward " \t\n")
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1570 (list start (point) (point))))))))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1571
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1572 (defun bibtex-parse-string-postfix ()
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1573 "Parse the postfix part of a BibTeX string entry, including the text.
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1574 If the string postfix is found, return a triple consisting of the position of
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1575 the actual starting and ending position of the text and the very last
57070
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
1576 character of the string entry. Move point past BibTeX string entry."
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1577 (let* ((case-fold-search t)
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1578 (bounds (bibtex-parse-field-text)))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1579 (when bounds
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1580 (goto-char (nth 1 bounds))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1581 (when (looking-at "[ \t\n]*[})]")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1582 (goto-char (match-end 0))
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1583 (list (car bounds)
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1584 (nth 1 bounds)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1585 (match-end 0))))))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1586
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1587 (defun bibtex-parse-string (&optional empty-key)
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1588 "Parse a BibTeX string entry beginning at the position of point.
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1589 If a syntactically correct entry is found, return a cons pair containing
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1590 the boundaries of the reference key and text parts of the entry.
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1591 If EMPTY-KEY is non-nil, key may be empty. Do not move point."
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1592 (let ((bibtex-string-empty-key empty-key))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1593 (bibtex-parse-association 'bibtex-parse-string-prefix
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1594 'bibtex-parse-string-postfix)))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1595
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1596 (defun bibtex-search-forward-string (&optional empty-key)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1597 "Search forward to find a BibTeX string entry.
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1598 If a syntactically correct entry is found, a pair containing the boundaries of
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1599 the reference key and text parts of the string is returned.
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1600 If EMPTY-KEY is non-nil, key may be empty. Do not move point."
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1601 (save-excursion
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1602 (save-match-data
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1603 (let ((case-fold-search t) bounds)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1604 (while (and (not bounds)
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1605 (search-forward-regexp bibtex-string-type nil t))
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1606 (save-excursion (goto-char (match-beginning 0))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1607 (setq bounds (bibtex-parse-string empty-key))))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1608 bounds))))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1609
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1610 (defun bibtex-reference-key-in-string (bounds)
81591
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
1611 "Return the key part of a BibTeX string defined via BOUNDS."
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1612 (buffer-substring-no-properties (nth 1 (car bounds))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1613 (nth 2 (car bounds))))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1614
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1615 (defun bibtex-text-in-string (bounds &optional content)
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1616 "Get text in BibTeX string field defined via BOUNDS.
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1617 If optional arg CONTENT is non-nil extract content
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1618 by removing field delimiters and concatenating the resulting string.
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1619 If `bibtex-expand-strings' is non-nil, also expand BibTeX strings."
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1620 (bibtex-text-in-field-bounds bounds content))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1621
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1622 (defsubst bibtex-start-of-text-in-string (bounds)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1623 (nth 0 (cdr bounds)))
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1624 (defsubst bibtex-end-of-text-in-string (bounds)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1625 (nth 1 (cdr bounds)))
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1626 (defsubst bibtex-end-of-string (bounds)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1627 (nth 2 (cdr bounds)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1628
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1629 (defsubst bibtex-type-in-head ()
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1630 "Extract BibTeX type in head."
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1631 ;; ignore @
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1632 (buffer-substring-no-properties (1+ (match-beginning bibtex-type-in-head))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1633 (match-end bibtex-type-in-head)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1634
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
1635 (defsubst bibtex-key-in-head (&optional empty)
57070
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
1636 "Extract BibTeX key in head. Return optional arg EMPTY if key is empty."
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
1637 (or (match-string-no-properties bibtex-key-in-head)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
1638 empty))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1639
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1640 (defun bibtex-parse-preamble ()
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1641 "Parse BibTeX preamble.
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1642 Point must be at beginning of preamble. Do not move point."
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1643 (let ((case-fold-search t))
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1644 (when (looking-at bibtex-preamble-prefix)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1645 (let ((start (match-beginning 0)) (pref-start (match-beginning 1))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1646 (bounds (save-excursion (goto-char (match-end 0))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1647 (bibtex-parse-string-postfix))))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1648 (if bounds (cons (list start pref-start) bounds))))))
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1649
12700
b3a8ee2da96a Add keywords and comments as per conventions.
Richard M. Stallman <rms@gnu.org>
parents: 12028
diff changeset
1650 ;; Helper Functions
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
1651
57054
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
1652 (defsubst bibtex-string= (str1 str2)
57070
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
1653 "Return t if STR1 and STR2 are equal, ignoring case."
57054
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
1654 (eq t (compare-strings str1 0 nil str2 0 nil t)))
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
1655
18247
ae094c1a4334 (bibtex-delete-whitespace, bibtex-current-line)
Richard M. Stallman <rms@gnu.org>
parents: 18212
diff changeset
1656 (defun bibtex-delete-whitespace ()
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1657 "Delete all whitespace starting at point."
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1658 (if (looking-at "[ \t\n]+")
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1659 (delete-region (point) (match-end 0))))
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1660
18247
ae094c1a4334 (bibtex-delete-whitespace, bibtex-current-line)
Richard M. Stallman <rms@gnu.org>
parents: 18212
diff changeset
1661 (defun bibtex-current-line ()
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1662 "Compute line number of point regardless whether the buffer is narrowed."
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1663 (+ (count-lines 1 (point))
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
1664 (if (bolp) 1 0)))
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1665
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1666 (defun bibtex-valid-entry (&optional empty-key)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1667 "Parse a valid BibTeX entry (maybe without key if EMPTY-KEY is t).
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1668 A valid entry is a syntactical correct one with type contained in
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1669 `bibtex-entry-field-alist'. Ignore @String and @Preamble entries.
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1670 Return a cons pair with buffer positions of beginning and end of entry
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1671 if a valid entry is found, nil otherwise. Do not move point.
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1672 After a call to this function `match-data' corresponds to the header
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1673 of the entry, see regexp `bibtex-entry-head'."
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1674 (let ((case-fold-search t) end)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1675 (if (looking-at (if empty-key bibtex-entry-maybe-empty-head
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1676 bibtex-entry-head))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1677 (save-excursion
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1678 (save-match-data
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1679 (goto-char (match-end 0))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1680 (let ((entry-closer
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1681 (if (save-excursion
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1682 (goto-char (match-end bibtex-type-in-head))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1683 (looking-at "[ \t]*("))
81591
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
1684 ",?[ \t\n]*)" ; entry opened with `('
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
1685 ",?[ \t\n]*}")) ; entry opened with `{'
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1686 bounds)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1687 (skip-chars-forward " \t\n")
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1688 ;; loop over all BibTeX fields
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1689 (while (setq bounds (bibtex-parse-field))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1690 (goto-char (bibtex-end-of-field bounds)))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1691 ;; This matches the infix* part.
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1692 (if (looking-at entry-closer) (setq end (match-end 0)))))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1693 (if end (cons (match-beginning 0) end))))))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1694
18247
ae094c1a4334 (bibtex-delete-whitespace, bibtex-current-line)
Richard M. Stallman <rms@gnu.org>
parents: 18212
diff changeset
1695 (defun bibtex-skip-to-valid-entry (&optional backward)
57070
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
1696 "Move point to beginning of the next valid BibTeX entry.
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
1697 Do not move if we are already at beginning of a valid BibTeX entry.
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
1698 With optional argument BACKWARD non-nil, move backward to
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
1699 beginning of previous valid one. A valid entry is a syntactical correct one
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1700 with type contained in `bibtex-entry-field-alist' or, if
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1701 `bibtex-sort-ignore-string-entries' is nil, a syntactical correct string
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1702 entry. Return buffer position of beginning and end of entry if a valid
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1703 entry is found, nil otherwise."
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1704 (interactive "P")
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1705 (let ((case-fold-search t)
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1706 found bounds)
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1707 (beginning-of-line)
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1708 ;; Loop till we look at a valid entry.
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1709 (while (not (or found (if backward (bobp) (eobp))))
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1710 (cond ((setq found (or (bibtex-valid-entry)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1711 (and (not bibtex-sort-ignore-string-entries)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1712 (setq bounds (bibtex-parse-string))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1713 (cons (bibtex-start-of-field bounds)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1714 (bibtex-end-of-string bounds))))))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1715 (backward (re-search-backward "^[ \t]*@" nil 'move))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1716 (t (if (re-search-forward "\n\\([ \t]*@\\)" nil 'move)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1717 (goto-char (match-beginning 1))))))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1718 found))
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
1719
18247
ae094c1a4334 (bibtex-delete-whitespace, bibtex-current-line)
Richard M. Stallman <rms@gnu.org>
parents: 18212
diff changeset
1720 (defun bibtex-map-entries (fun)
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
1721 "Call FUN for each BibTeX entry in buffer (possibly narrowed).
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
1722 FUN is called with three arguments, the key of the entry and the buffer
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1723 positions of beginning and end of entry. Also, point is at beginning of
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1724 entry and `match-data' corresponds to the header of the entry,
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1725 see regexp `bibtex-entry-head'. If `bibtex-sort-ignore-string-entries'
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1726 is non-nil, FUN is not called for @String entries."
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1727 (let ((case-fold-search t)
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1728 found)
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
1729 (save-excursion
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
1730 (goto-char (point-min))
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1731 (while (setq found (bibtex-skip-to-valid-entry))
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1732 (looking-at bibtex-any-entry-maybe-empty-head)
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1733 (funcall fun (bibtex-key-in-head "") (car found) (cdr found))
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1734 (goto-char (cdr found))))))
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1735
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1736 (defun bibtex-progress-message (&optional flag interval)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1737 "Echo a message about progress of current buffer.
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1738 If FLAG is a string, the message is initialized (in this case a
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1739 value for INTERVAL may be given as well (if not this is set to 5)).
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
1740 If FLAG is `done', the message is deinitialized.
55348
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1741 If FLAG is nil, a message is echoed if point was incremented at least
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1742 `bibtex-progress-interval' percent since last message was echoed."
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1743 (cond ((stringp flag)
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
1744 (setq bibtex-progress-lastmes flag
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
1745 bibtex-progress-interval (or interval 5)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1746 bibtex-progress-lastperc 0))
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
1747 ((eq flag 'done)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1748 (message "%s (done)" bibtex-progress-lastmes)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1749 (setq bibtex-progress-lastmes nil))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1750 (t
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1751 (let* ((size (- (point-max) (point-min)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1752 (perc (if (= size 0)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1753 100
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1754 (/ (* 100 (- (point) (point-min))) size))))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1755 (when (>= perc (+ bibtex-progress-lastperc
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1756 bibtex-progress-interval))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1757 (setq bibtex-progress-lastperc perc)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1758 (message "%s (%d%%)" bibtex-progress-lastmes perc))))))
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1759
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1760 (defun bibtex-field-left-delimiter ()
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1761 "Return a string dependent on `bibtex-field-delimiters'."
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
1762 (if (eq bibtex-field-delimiters 'braces)
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1763 "{"
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1764 "\""))
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1765
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1766 (defun bibtex-field-right-delimiter ()
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1767 "Return a string dependent on `bibtex-field-delimiters'."
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
1768 (if (eq bibtex-field-delimiters 'braces)
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1769 "}"
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1770 "\""))
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1771
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1772 (defun bibtex-entry-left-delimiter ()
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
1773 "Return a string dependent on `bibtex-entry-delimiters'."
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
1774 (if (eq bibtex-entry-delimiters 'braces)
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1775 "{"
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1776 "("))
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1777
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1778 (defun bibtex-entry-right-delimiter ()
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
1779 "Return a string dependent on `bibtex-entry-delimiters'."
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
1780 (if (eq bibtex-entry-delimiters 'braces)
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1781 "}"
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1782 ")"))
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1783
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1784 (defun bibtex-flash-head (prompt)
87650
29fbecdf9527 (bibtex-initialize): New autoloaded command. Rename from function
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87649
diff changeset
1785 "Flash at BibTeX entry head before point, if it exists."
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1786 (let ((case-fold-search t)
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1787 (pnt (point)))
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1788 (save-excursion
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1789 (bibtex-beginning-of-entry)
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1790 (when (and (looking-at bibtex-any-entry-maybe-empty-head)
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1791 (< (point) pnt))
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1792 (goto-char (match-beginning bibtex-type-in-head))
87650
29fbecdf9527 (bibtex-initialize): New autoloaded command. Rename from function
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87649
diff changeset
1793 (if (and (< 0 blink-matching-delay)
29fbecdf9527 (bibtex-initialize): New autoloaded command. Rename from function
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87649
diff changeset
1794 (pos-visible-in-window-p (point)))
81591
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
1795 (sit-for blink-matching-delay)
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1796 (message "%s%s" prompt (buffer-substring-no-properties
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1797 (point) (match-end bibtex-key-in-head))))))))
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1798
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1799 (defun bibtex-make-optional-field (field)
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1800 "Make an optional field named FIELD in current BibTeX entry."
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1801 (if (consp field)
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1802 (bibtex-make-field (cons (concat "OPT" (car field)) (cdr field)))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1803 (bibtex-make-field (concat "OPT" field))))
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1804
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
1805 (defun bibtex-move-outside-of-entry ()
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1806 "Make sure point is outside of a BibTeX entry."
22563
2e2a71dfec63 Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents: 21169
diff changeset
1807 (let ((orig-point (point)))
26711
eac840d283b6 (bibtex-hs-forward-sexp): Added to support
Gerd Moellmann <gerd@gnu.org>
parents: 25444
diff changeset
1808 (bibtex-end-of-entry)
52891
a6806242012a (bibtex-move-outside-of-entry):
Richard M. Stallman <rms@gnu.org>
parents: 52401
diff changeset
1809 (when (< (point) orig-point)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1810 ;; We moved backward, so we weren't inside an entry to begin with.
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1811 ;; Leave point at the beginning of a line, and preferably
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1812 ;; at the beginning of a paragraph.
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1813 (goto-char orig-point)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1814 (beginning-of-line 1)
52891
a6806242012a (bibtex-move-outside-of-entry):
Richard M. Stallman <rms@gnu.org>
parents: 52401
diff changeset
1815 (unless (= ?\n (char-before (1- (point))))
a6806242012a (bibtex-move-outside-of-entry):
Richard M. Stallman <rms@gnu.org>
parents: 52401
diff changeset
1816 (re-search-forward "^[ \t]*[@\n]" nil 'move)
a6806242012a (bibtex-move-outside-of-entry):
Richard M. Stallman <rms@gnu.org>
parents: 52401
diff changeset
1817 (backward-char 1)))
22563
2e2a71dfec63 Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents: 21169
diff changeset
1818 (skip-chars-forward " \t\n")))
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1819
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1820 (defun bibtex-beginning-of-first-entry ()
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1821 "Go to beginning of line of first BibTeX entry in buffer.
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1822 If `bibtex-sort-ignore-string-entries' is non-nil, @String entries
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1823 are ignored. Return point"
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1824 (goto-char (point-min))
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
1825 (bibtex-skip-to-valid-entry)
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1826 (point))
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
1827
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1828 (defun bibtex-enclosing-field (&optional comma noerr)
57054
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
1829 "Search for BibTeX field enclosing point.
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1830 For `bibtex-mode''s internal algorithms, a field begins at the comma
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1831 following the preceding field. Usually, this is not what the user expects.
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1832 Thus if COMMA is non-nil, the \"current field\" includes the terminating comma.
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
1833 Unless NOERR is non-nil, signal an error if no enclosing field is found.
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
1834 On success return bounds, nil otherwise. Do not move point."
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1835 (save-excursion
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1836 (when comma
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1837 (end-of-line)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1838 (skip-chars-backward " \t")
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1839 (if (= (preceding-char) ?,) (forward-char -1)))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1840
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1841 (let ((bounds (bibtex-search-backward-field bibtex-field-name t)))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1842 (cond ((and bounds
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1843 (<= (bibtex-start-of-field bounds) (point))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1844 (>= (bibtex-end-of-field bounds) (point)))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1845 bounds)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1846 ((not noerr)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1847 (error "Can't find enclosing BibTeX field"))))))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1848
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1849 (defun bibtex-beginning-first-field (&optional beg)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1850 "Move point to beginning of first field.
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1851 Optional arg BEG is beginning of entry."
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1852 (if beg (goto-char beg) (bibtex-beginning-of-entry))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1853 (looking-at bibtex-any-entry-maybe-empty-head)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1854 (goto-char (match-end 0)))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1855
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1856 (defun bibtex-insert-kill (n &optional comma)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1857 "Reinsert the Nth stretch of killed BibTeX text (field or entry).
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1858 Optional arg COMMA is as in `bibtex-enclosing-field'."
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1859 (unless bibtex-last-kill-command (error "BibTeX kill ring is empty"))
81591
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
1860 (let ((fun (lambda (kryp kr) ; adapted from `current-kill'
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1861 (car (set kryp (nthcdr (mod (- n (length (eval kryp)))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1862 (length kr)) kr))))))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1863 (if (eq bibtex-last-kill-command 'field)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1864 (progn
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1865 ;; insert past the current field
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1866 (goto-char (bibtex-end-of-field (bibtex-enclosing-field comma)))
81591
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
1867 (push-mark)
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1868 (bibtex-make-field (funcall fun 'bibtex-field-kill-ring-yank-pointer
77206
389303f02afc (bibtex-insert-kill): Pass non-nil NODELIM arg to bibtex-make-field.
Glenn Morris <rgm@gnu.org>
parents: 75356
diff changeset
1869 bibtex-field-kill-ring) t nil t))
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1870 ;; insert past the current entry
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1871 (bibtex-skip-to-valid-entry)
81591
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
1872 (push-mark)
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1873 (insert (funcall fun 'bibtex-entry-kill-ring-yank-pointer
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
1874 bibtex-entry-kill-ring)))))
27701
5e135f0faf1d (bibtex-mode): Replaced manual splitting of path
Gerd Moellmann <gerd@gnu.org>
parents: 26711
diff changeset
1875
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1876 (defun bibtex-format-entry ()
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1877 "Helper function for `bibtex-clean-entry'.
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1878 Formats current entry according to variable `bibtex-entry-format'."
87650
29fbecdf9527 (bibtex-initialize): New autoloaded command. Rename from function
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87649
diff changeset
1879 ;; initialize `bibtex-field-braces-opt' if necessary
29fbecdf9527 (bibtex-initialize): New autoloaded command. Rename from function
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87649
diff changeset
1880 (if (and bibtex-field-braces-alist (not bibtex-field-braces-opt))
29fbecdf9527 (bibtex-initialize): New autoloaded command. Rename from function
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87649
diff changeset
1881 (setq bibtex-field-braces-opt
29fbecdf9527 (bibtex-initialize): New autoloaded command. Rename from function
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87649
diff changeset
1882 (bibtex-field-re-init bibtex-field-braces-alist 'braces)))
29fbecdf9527 (bibtex-initialize): New autoloaded command. Rename from function
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87649
diff changeset
1883 ;; initialize `bibtex-field-strings-opt' if necessary
29fbecdf9527 (bibtex-initialize): New autoloaded command. Rename from function
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87649
diff changeset
1884 (if (and bibtex-field-strings-alist (not bibtex-field-strings-opt))
29fbecdf9527 (bibtex-initialize): New autoloaded command. Rename from function
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87649
diff changeset
1885 (setq bibtex-field-strings-opt
29fbecdf9527 (bibtex-initialize): New autoloaded command. Rename from function
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87649
diff changeset
1886 (bibtex-field-re-init bibtex-field-strings-alist 'strings)))
29fbecdf9527 (bibtex-initialize): New autoloaded command. Rename from function
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87649
diff changeset
1887
91913
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1888 (let ((case-fold-search t)
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1889 (format (if (eq bibtex-entry-format t)
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1890 '(realign opts-or-alts required-fields numerical-fields
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1891 page-dashes whitespace inherit-booktitle
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1892 last-comma delimiters unify-case braces
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1893 strings)
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1894 bibtex-entry-format))
101233
680e69b3c8ed (bibtex-format-entry): For updating field delimiters, allow
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 101166
diff changeset
1895 (left-delim-re (regexp-quote (bibtex-field-left-delimiter)))
91913
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1896 bounds crossref-key req-field-list default-field-list field-list
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1897 alt-fields error-field-name)
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1898 (unwind-protect
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1899 ;; formatting (undone if error occurs)
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1900 (atomic-change-group
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1901 (save-excursion
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1902 (save-restriction
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1903 (bibtex-narrow-to-entry)
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1904
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1905 ;; There are more elegant high-level functions for several tasks
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1906 ;; done by `bibtex-format-entry'. However, they contain some
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1907 ;; redundancy compared with what we need to do anyway.
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1908 ;; So for speed-up we avoid using them.
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1909 ;; (`bibtex-format-entry' is called often by `bibtex-reformat'.)
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1910
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1911 ;; identify entry type
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1912 (goto-char (point-min))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1913 (or (re-search-forward bibtex-entry-type nil t)
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1914 (error "Not inside a BibTeX entry"))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1915 (let* ((beg-type (1+ (match-beginning 0)))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1916 (end-type (match-end 0))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1917 (entry-list (assoc-string (buffer-substring-no-properties
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1918 beg-type end-type)
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1919 bibtex-entry-field-alist t)))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1920
92218
1d8a03656f39 (bibtex-format-entry): Handle error message refering to a missing
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 92217
diff changeset
1921 ;; unify case of entry type
91913
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1922 (when (memq 'unify-case format)
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1923 (delete-region beg-type end-type)
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1924 (insert (car entry-list)))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1925
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1926 ;; update left entry delimiter
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1927 (when (memq 'delimiters format)
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1928 (goto-char end-type)
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1929 (skip-chars-forward " \t\n")
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1930 (delete-char 1)
91913
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1931 (insert (bibtex-entry-left-delimiter)))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1932
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1933 ;; Do we have a crossref key?
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1934 (goto-char (point-min))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1935 (if (setq bounds (bibtex-search-forward-field "crossref"))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1936 (let ((text (bibtex-text-in-field-bounds bounds t)))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1937 (unless (equal "" text)
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1938 (setq crossref-key text))))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1939
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1940 ;; list of required fields appropriate for an entry with
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1941 ;; or without crossref key.
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1942 (setq req-field-list (if (and crossref-key (nth 2 entry-list))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1943 (car (nth 2 entry-list))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1944 (car (nth 1 entry-list)))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1945 ;; default list of fields that may appear in this entry
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1946 default-field-list (append (nth 0 (nth 1 entry-list))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1947 (nth 1 (nth 1 entry-list))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1948 bibtex-user-optional-fields)))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1949
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1950 ;; process all fields
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1951 (bibtex-beginning-first-field (point-min))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1952 (while (setq bounds (bibtex-parse-field))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1953 (let* ((beg-field (copy-marker (bibtex-start-of-field bounds)))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1954 (end-field (copy-marker (bibtex-end-of-field bounds) t))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1955 (beg-name (copy-marker (bibtex-start-of-name-in-field bounds)))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1956 (end-name (copy-marker (bibtex-end-of-name-in-field bounds)))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1957 (beg-text (copy-marker (bibtex-start-of-text-in-field bounds)))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1958 (end-text (copy-marker (bibtex-end-of-text-in-field bounds) t))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1959 (opt-alt (string-match "OPT\\|ALT"
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1960 (buffer-substring-no-properties
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1961 beg-name (+ beg-name 3))))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1962 (field-name (buffer-substring-no-properties
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1963 (if opt-alt (+ beg-name 3) beg-name) end-name))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1964 (empty-field (equal "" (bibtex-text-in-field-bounds bounds t)))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1965 deleted)
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1966
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1967 ;; keep track of alternatives
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1968 (if (nth 3 (assoc-string field-name req-field-list t))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1969 (push field-name alt-fields))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1970
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1971 (if (memq 'opts-or-alts format)
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1972 ;; delete empty optional and alternative fields
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1973 ;; (but keep empty required fields)
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1974 (cond ((and empty-field
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1975 (or opt-alt
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1976 (let ((field (assoc-string
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1977 field-name req-field-list t)))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1978 (or (not field) ; OPT field
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1979 (nth 3 field))))) ; ALT field
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1980 (delete-region beg-field end-field)
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1981 (setq deleted t))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1982 ;; otherwise nonempty field: delete "OPT" or "ALT"
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1983 (opt-alt
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1984 (goto-char beg-name)
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1985 (delete-char 3))))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1986
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1987 (unless deleted
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1988 (push field-name field-list)
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1989
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1990 ;; remove delimiters from purely numerical fields
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1991 (when (and (memq 'numerical-fields format)
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1992 (progn (goto-char beg-text)
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1993 (looking-at "\\(\"[0-9]+\"\\)\\|\\({[0-9]+}\\)")))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1994 (goto-char end-text)
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1995 (delete-char -1)
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1996 (goto-char beg-text)
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1997 (delete-char 1))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1998
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
1999 ;; update delimiters
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2000 (when (memq 'delimiters format)
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2001 (goto-char beg-text)
101233
680e69b3c8ed (bibtex-format-entry): For updating field delimiters, allow
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 101166
diff changeset
2002 ;; simplified from `bibtex-parse-field-text', as we
680e69b3c8ed (bibtex-format-entry): For updating field delimiters, allow
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 101166
diff changeset
2003 ;; already checked that the field format is correct
680e69b3c8ed (bibtex-format-entry): For updating field delimiters, allow
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 101166
diff changeset
2004 (while (< (point) end-text)
680e69b3c8ed (bibtex-format-entry): For updating field delimiters, allow
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 101166
diff changeset
2005 (if (looking-at bibtex-field-const)
680e69b3c8ed (bibtex-format-entry): For updating field delimiters, allow
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 101166
diff changeset
2006 (goto-char (match-end 0))
680e69b3c8ed (bibtex-format-entry): For updating field delimiters, allow
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 101166
diff changeset
2007 (let ((boundaries (bibtex-parse-field-string)))
101248
372dac1d4b95 (bibtex-format-entry): Simplify previous change.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 101236
diff changeset
2008 (if (looking-at left-delim-re)
372dac1d4b95 (bibtex-format-entry): Simplify previous change.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 101236
diff changeset
2009 (goto-char (cdr boundaries))
101233
680e69b3c8ed (bibtex-format-entry): For updating field delimiters, allow
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 101166
diff changeset
2010 (delete-char 1)
101248
372dac1d4b95 (bibtex-format-entry): Simplify previous change.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 101236
diff changeset
2011 (insert (bibtex-field-left-delimiter))
372dac1d4b95 (bibtex-format-entry): Simplify previous change.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 101236
diff changeset
2012 (goto-char (1- (cdr boundaries)))
101233
680e69b3c8ed (bibtex-format-entry): For updating field delimiters, allow
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 101166
diff changeset
2013 (delete-char 1)
680e69b3c8ed (bibtex-format-entry): For updating field delimiters, allow
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 101166
diff changeset
2014 (insert (bibtex-field-right-delimiter)))))
680e69b3c8ed (bibtex-format-entry): For updating field delimiters, allow
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 101166
diff changeset
2015 (if (looking-at "[ \t\n]*#[ \t\n]*")
680e69b3c8ed (bibtex-format-entry): For updating field delimiters, allow
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 101166
diff changeset
2016 (goto-char (match-end 0)))))
91913
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2017
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2018 ;; update page dashes
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2019 (if (and (memq 'page-dashes format)
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2020 (bibtex-string= field-name "pages")
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2021 (progn (goto-char beg-text)
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2022 (looking-at
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2023 "\\([\"{][0-9]+\\)[ \t\n]*--?[ \t\n]*\\([0-9]+[\"}]\\)")))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2024 (replace-match "\\1-\\2"))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2025
101233
680e69b3c8ed (bibtex-format-entry): For updating field delimiters, allow
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 101166
diff changeset
2026 ;; Remove whitespace at beginning and end of field.
680e69b3c8ed (bibtex-format-entry): For updating field delimiters, allow
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 101166
diff changeset
2027 ;; We do not look at individual parts of the field
680e69b3c8ed (bibtex-format-entry): For updating field delimiters, allow
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 101166
diff changeset
2028 ;; as {foo } # bar # { baz} is a fine field.
91913
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2029 (when (memq 'whitespace format)
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2030 (goto-char beg-text)
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2031 (if (looking-at "\\([{\"]\\)[ \t\n]+")
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2032 (replace-match "\\1"))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2033 (goto-char end-text)
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2034 (if (looking-back "[ \t\n]+\\([}\"]\\)" beg-text t)
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2035 (replace-match "\\1")))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2036
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2037 ;; enclose field text by braces according to
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2038 ;; `bibtex-field-braces-alist'.
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2039 (let (case-fold-search temp) ; Case-sensitive search
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2040 (when (and (memq 'braces format)
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2041 (setq temp (cdr (assoc-string field-name
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2042 bibtex-field-braces-opt t))))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2043 (goto-char beg-text)
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2044 (while (re-search-forward temp end-text t)
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2045 (let ((beg (match-beginning 0))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2046 (bounds (bibtex-find-text-internal nil t)))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2047 (unless (or (nth 4 bounds) ; string constant
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2048 ;; match already surrounded by braces
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2049 ;; (braces are inside field delimiters)
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2050 (and (< (point) (1- (nth 2 bounds)))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2051 (< (1+ (nth 1 bounds)) beg)
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2052 (looking-at "}")
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2053 (save-excursion (goto-char (1- beg))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2054 (looking-at "{"))))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2055 (insert "}")
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2056 (goto-char beg)
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2057 (insert "{")))))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2058
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2059 ;; replace field text by BibTeX string constants
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2060 ;; according to `bibtex-field-strings-alist'.
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2061 (when (and (memq 'strings format)
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2062 (setq temp (cdr (assoc-string field-name
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2063 bibtex-field-strings-opt t))))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2064 (goto-char beg-text)
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2065 (dolist (re temp)
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2066 (while (re-search-forward (car re) end-text t)
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2067 (let ((bounds (save-match-data
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2068 (bibtex-find-text-internal nil t))))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2069 (unless (nth 4 bounds)
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2070 ;; if match not at right subfield boundary...
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2071 (if (< (match-end 0) (1- (nth 2 bounds)))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2072 (insert " # " (bibtex-field-left-delimiter))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2073 (delete-char 1))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2074 (replace-match (cdr re))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2075 (goto-char (match-beginning 0))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2076 ;; if match not at left subfield boundary...
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2077 (if (< (1+ (nth 1 bounds)) (match-beginning 0))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2078 (insert (bibtex-field-right-delimiter) " # ")
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2079 (delete-backward-char 1))))))))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2080
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2081 ;; use book title of crossref'd entry
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2082 (if (and (memq 'inherit-booktitle format)
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2083 empty-field
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2084 (bibtex-string= field-name "booktitle")
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2085 crossref-key)
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2086 (let ((title (save-excursion
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2087 (save-restriction
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2088 (widen)
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2089 (if (bibtex-search-entry crossref-key t)
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2090 (bibtex-text-in-field "title"))))))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2091 (when title
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2092 (setq empty-field nil)
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2093 (goto-char (1+ beg-text))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2094 (insert title))))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2095
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2096 ;; if empty field is a required field, complain
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2097 (when (and empty-field
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2098 (memq 'required-fields format)
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2099 (assoc-string field-name req-field-list t))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2100 (setq error-field-name field-name)
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2101 (error "Mandatory field `%s' is empty" field-name))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2102
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2103 ;; unify case of field name
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2104 (if (memq 'unify-case format)
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2105 (let ((fname (car (assoc-string field-name
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2106 default-field-list t))))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2107 (if fname
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2108 (progn
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2109 (delete-region beg-name end-name)
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2110 (goto-char beg-name)
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2111 (insert fname))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2112 ;; there are no rules we could follow
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2113 (downcase-region beg-name end-name))))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2114
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2115 ;; update point
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2116 (goto-char end-field))))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2117
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2118 ;; check whether all required fields are present
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2119 (if (memq 'required-fields format)
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2120 (let ((found 0) alt-list)
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2121 (dolist (fname req-field-list)
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2122 (cond ((nth 3 fname) ; t if field has alternative flag
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2123 (push (car fname) alt-list)
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2124 (if (member-ignore-case (car fname) field-list)
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2125 (setq found (1+ found))))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2126 ((not (member-ignore-case (car fname) field-list))
92218
1d8a03656f39 (bibtex-format-entry): Handle error message refering to a missing
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 92217
diff changeset
2127 ;; If we use the crossref field, a required field
1d8a03656f39 (bibtex-format-entry): Handle error message refering to a missing
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 92217
diff changeset
2128 ;; can have the OPT prefix. So if it was empty,
1d8a03656f39 (bibtex-format-entry): Handle error message refering to a missing
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 92217
diff changeset
2129 ;; we have deleted by now. Nonetheless we can
1d8a03656f39 (bibtex-format-entry): Handle error message refering to a missing
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 92217
diff changeset
2130 ;; move point on this empty field.
1d8a03656f39 (bibtex-format-entry): Handle error message refering to a missing
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 92217
diff changeset
2131 (setq error-field-name (car fname))
91913
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2132 (error "Mandatory field `%s' is missing" (car fname)))))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2133 (if alt-list
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2134 (cond ((= found 0)
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2135 (if alt-fields
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2136 (setq error-field-name (car (last alt-fields))))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2137 (error "Alternative mandatory field `%s' is missing"
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2138 alt-list))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2139 ((> found 1)
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2140 (if alt-fields
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2141 (setq error-field-name (car (last alt-fields))))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2142 (error "Alternative fields `%s' are defined %s times"
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2143 alt-list found))))))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2144
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2145 ;; update comma after last field
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2146 (if (memq 'last-comma format)
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2147 (cond ((and bibtex-comma-after-last-field
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2148 (not (looking-at ",")))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2149 (insert ","))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2150 ((and (not bibtex-comma-after-last-field)
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2151 (looking-at ","))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2152 (delete-char 1))))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2153
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2154 ;; update right entry delimiter
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2155 (if (looking-at ",")
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2156 (forward-char))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2157 (when (memq 'delimiters format)
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2158 (skip-chars-forward " \t\n")
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2159 (delete-char 1)
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2160 (insert (bibtex-entry-right-delimiter)))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2161
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2162 ;; realign and fill entry
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2163 (if (memq 'realign format)
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2164 (bibtex-fill-entry)))))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2165
92218
1d8a03656f39 (bibtex-format-entry): Handle error message refering to a missing
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 92217
diff changeset
2166 ;; Unwindform: move point to location where error occured if possible
1d8a03656f39 (bibtex-format-entry): Handle error message refering to a missing
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 92217
diff changeset
2167 (if error-field-name
1d8a03656f39 (bibtex-format-entry): Handle error message refering to a missing
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 92217
diff changeset
2168 (let (bounds)
1d8a03656f39 (bibtex-format-entry): Handle error message refering to a missing
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 92217
diff changeset
2169 (when (save-excursion
1d8a03656f39 (bibtex-format-entry): Handle error message refering to a missing
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 92217
diff changeset
2170 (bibtex-beginning-of-entry)
1d8a03656f39 (bibtex-format-entry): Handle error message refering to a missing
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 92217
diff changeset
2171 (setq bounds
1d8a03656f39 (bibtex-format-entry): Handle error message refering to a missing
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 92217
diff changeset
2172 (bibtex-search-forward-field
1d8a03656f39 (bibtex-format-entry): Handle error message refering to a missing
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 92217
diff changeset
2173 ;; If we use the crossref field, a required field
1d8a03656f39 (bibtex-format-entry): Handle error message refering to a missing
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 92217
diff changeset
2174 ;; can have the OPT prefix
1d8a03656f39 (bibtex-format-entry): Handle error message refering to a missing
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 92217
diff changeset
2175 (concat "\\(OPT\\|ALT\\)?" error-field-name) t)))
1d8a03656f39 (bibtex-format-entry): Handle error message refering to a missing
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 92217
diff changeset
2176 (goto-char (bibtex-start-of-text-in-field bounds))
1d8a03656f39 (bibtex-format-entry): Handle error message refering to a missing
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 92217
diff changeset
2177 (bibtex-find-text)))))))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2178
81591
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2179 (defun bibtex-field-re-init (regexp-alist type)
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2180 "Calculate optimized value for bibtex-regexp-TYPE-opt.
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2181 This value is based on bibtex-regexp-TYPE-alist. TYPE is 'braces or 'strings.
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2182 Return optimized value to be used by `bibtex-format-entry'."
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2183 (setq regexp-alist
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2184 (mapcar (lambda (e)
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2185 (list (car e)
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2186 (replace-regexp-in-string "[ \t\n]+" "[ \t\n]+" (nth 1 e))
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2187 (nth 2 e))) ; nil for 'braces'.
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2188 regexp-alist))
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2189 (let (opt-list)
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2190 ;; Loop over field names
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2191 (dolist (field (delete-dups (apply 'append (mapcar 'car regexp-alist))))
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2192 (let (rules)
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2193 ;; Collect all matches we have for this field name
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2194 (dolist (e regexp-alist)
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2195 (if (assoc-string field (car e) t)
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2196 (push (cons (nth 1 e) (nth 2 e)) rules)))
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2197 (if (eq type 'braces)
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2198 ;; concatenate all regexps to a single regexp
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2199 (setq rules (concat "\\(?:" (mapconcat 'car rules "\\|") "\\)")))
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2200 ;; create list of replacement rules.
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2201 (push (cons field rules) opt-list)))
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2202 opt-list))
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2203
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2204
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
2205 (defun bibtex-autokey-abbrev (string len)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2206 "Return an abbreviation of STRING with at least LEN characters.
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2207 If LEN is positive the abbreviation is terminated only after a consonant
57070
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
2208 or at the word end. If LEN is negative the abbreviation is strictly
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
2209 enforced using abs (LEN) characters. If LEN is not a number, STRING
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2210 is returned unchanged."
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2211 (cond ((or (not (numberp len))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2212 (<= (length string) (abs len)))
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2213 string)
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2214 ((equal len 0)
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2215 "")
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2216 ((< len 0)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2217 (substring string 0 (abs len)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2218 (t (let* ((case-fold-search t)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2219 (abort-char (string-match "[^aeiou]" string (1- len))))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2220 (if abort-char
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2221 (substring string 0 (1+ abort-char))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2222 string)))))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2223
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2224 (defun bibtex-autokey-get-field (field &optional change-list)
57070
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
2225 "Get content of BibTeX field FIELD. Return empty string if not found.
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2226 Optional arg CHANGE-LIST is a list of substitution patterns that is
57070
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
2227 applied to the content of FIELD. It is an alist with pairs
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2228 \(OLD-REGEXP . NEW-STRING\)."
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
2229 (let* ((bibtex-expand-strings bibtex-autokey-expand-strings)
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
2230 (content (bibtex-text-in-field field bibtex-autokey-use-crossref))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2231 case-fold-search)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2232 (unless content (setq content ""))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2233 (dolist (pattern change-list content)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2234 (setq content (replace-regexp-in-string (car pattern)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2235 (cdr pattern)
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2236 content t)))))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2237
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2238 (defun bibtex-autokey-get-names ()
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2239 "Get contents of the name field of the current entry.
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2240 Do some modifications based on `bibtex-autokey-name-change-strings'.
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2241 Return the names as a concatenated string obeying `bibtex-autokey-names'
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2242 and `bibtex-autokey-names-stretch'."
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2243 (let ((names (bibtex-autokey-get-field "author\\|editor"
57054
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
2244 bibtex-autokey-name-change-strings)))
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
2245 ;; Some entries do not have a name field.
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2246 (if (string= "" names)
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2247 names
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2248 (let* ((case-fold-search t)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2249 (name-list (mapcar 'bibtex-autokey-demangle-name
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2250 (split-string names "[ \t\n]+and[ \t\n]+")))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2251 additional-names)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2252 (unless (or (not (numberp bibtex-autokey-names))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2253 (<= (length name-list)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2254 (+ bibtex-autokey-names
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2255 bibtex-autokey-names-stretch)))
81591
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2256 ;; Take `bibtex-autokey-names' elements from beginning of name-list
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2257 (setq name-list (nreverse (nthcdr (- (length name-list)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2258 bibtex-autokey-names)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2259 (nreverse name-list)))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2260 additional-names bibtex-autokey-additional-names))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2261 (concat (mapconcat 'identity name-list
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2262 bibtex-autokey-name-separator)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2263 additional-names)))))
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2264
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2265 (defun bibtex-autokey-demangle-name (fullname)
57070
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
2266 "Get the last part from a well-formed FULLNAME and perform abbreviations."
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2267 (let* (case-fold-search
61439
267229876c56 (bibtex-autokey-titleword-ignore, bibtex-reference-key)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61247
diff changeset
2268 (name (cond ((string-match "\\([[:upper:]][^, ]*\\)[^,]*," fullname)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2269 ;; Name is of the form "von Last, First" or
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2270 ;; "von Last, Jr, First"
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2271 ;; --> Take the first capital part before the comma
51416
83476384bebd (bibtex-member-of-regexp, bibtex-assoc-of-regexp, bibtex-format-entry)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51415
diff changeset
2272 (match-string 1 fullname))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2273 ((string-match "\\([^, ]*\\)," fullname)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2274 ;; Strange name: we have a comma, but nothing capital
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2275 ;; So we accept even lowercase names
51416
83476384bebd (bibtex-member-of-regexp, bibtex-assoc-of-regexp, bibtex-format-entry)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51415
diff changeset
2276 (match-string 1 fullname))
61439
267229876c56 (bibtex-autokey-titleword-ignore, bibtex-reference-key)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61247
diff changeset
2277 ((string-match "\\(\\<[[:lower:]][^ ]* +\\)+\\([[:upper:]][^ ]*\\)"
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2278 fullname)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2279 ;; name is of the form "First von Last", "von Last",
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2280 ;; "First von von Last", or "d'Last"
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2281 ;; --> take the first capital part after the "von" parts
51416
83476384bebd (bibtex-member-of-regexp, bibtex-assoc-of-regexp, bibtex-format-entry)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51415
diff changeset
2282 (match-string 2 fullname))
83476384bebd (bibtex-member-of-regexp, bibtex-assoc-of-regexp, bibtex-format-entry)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51415
diff changeset
2283 ((string-match "\\([^ ]+\\) *\\'" fullname)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2284 ;; name is of the form "First Middle Last" or "Last"
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2285 ;; --> take the last token
51416
83476384bebd (bibtex-member-of-regexp, bibtex-assoc-of-regexp, bibtex-format-entry)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51415
diff changeset
2286 (match-string 1 fullname))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2287 (t (error "Name `%s' is incorrectly formed" fullname)))))
69581
98eee222dceb * textmodes/bibtex.el (bibtex-include-OPTkey)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 68648
diff changeset
2288 (funcall bibtex-autokey-name-case-convert-function
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2289 (bibtex-autokey-abbrev name bibtex-autokey-name-length))))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2290
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2291 (defun bibtex-autokey-get-year ()
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2292 "Return year field contents as a string obeying `bibtex-autokey-year-length'."
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2293 (let ((yearfield (bibtex-autokey-get-field "year")))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2294 (substring yearfield (max 0 (- (length yearfield)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2295 bibtex-autokey-year-length)))))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2296
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2297 (defun bibtex-autokey-get-title ()
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2298 "Get title field contents up to a terminator.
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2299 Return the result as a string"
57054
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
2300 (let ((case-fold-search t)
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
2301 (titlestring
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2302 (bibtex-autokey-get-field "title"
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2303 bibtex-autokey-titleword-change-strings)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2304 ;; ignore everything past a terminator
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2305 (if (string-match bibtex-autokey-title-terminators titlestring)
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2306 (setq titlestring (substring titlestring 0 (match-beginning 0))))
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2307 ;; gather words from titlestring into a list. Ignore
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2308 ;; specific words and use only a specific amount of words.
55348
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
2309 (let ((counter 0)
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2310 titlewords titlewords-extra word)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2311 (while (and (or (not (numberp bibtex-autokey-titlewords))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2312 (< counter (+ bibtex-autokey-titlewords
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2313 bibtex-autokey-titlewords-stretch)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2314 (string-match "\\b\\w+" titlestring))
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2315 (setq word (match-string 0 titlestring)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2316 titlestring (substring titlestring (match-end 0)))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2317 ;; Ignore words matched by one of the elements of
81591
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2318 ;; `bibtex-autokey-titleword-ignore'
57054
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
2319 (unless (let ((lst bibtex-autokey-titleword-ignore))
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
2320 (while (and lst
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
2321 (not (string-match (concat "\\`\\(?:" (car lst)
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2322 "\\)\\'") word)))
57054
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
2323 (setq lst (cdr lst)))
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
2324 lst)
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2325 (setq counter (1+ counter))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2326 (if (or (not (numberp bibtex-autokey-titlewords))
58772
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
2327 (<= counter bibtex-autokey-titlewords))
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2328 (push word titlewords)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2329 (push word titlewords-extra))))
81591
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2330 ;; Obey `bibtex-autokey-titlewords-stretch':
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2331 ;; If by now we have processed all words in titlestring, we include
81591
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2332 ;; titlewords-extra in titlewords. Otherwise, we ignore titlewords-extra.
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2333 (unless (string-match "\\b\\w+" titlestring)
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2334 (setq titlewords (append titlewords-extra titlewords)))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2335 (mapconcat 'bibtex-autokey-demangle-title (nreverse titlewords)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2336 bibtex-autokey-titleword-separator))))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2337
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2338 (defun bibtex-autokey-demangle-title (titleword)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2339 "Do some abbreviations on TITLEWORD.
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2340 The rules are defined in `bibtex-autokey-titleword-abbrevs'
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2341 and `bibtex-autokey-titleword-length'."
57054
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
2342 (let ((case-fold-search t)
55348
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
2343 (alist bibtex-autokey-titleword-abbrevs))
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
2344 (while (and alist
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
2345 (not (string-match (concat "\\`\\(?:" (caar alist) "\\)\\'")
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
2346 titleword)))
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
2347 (setq alist (cdr alist)))
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
2348 (if alist
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
2349 (cdar alist)
69581
98eee222dceb * textmodes/bibtex.el (bibtex-include-OPTkey)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 68648
diff changeset
2350 (funcall bibtex-autokey-titleword-case-convert-function
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2351 (bibtex-autokey-abbrev titleword bibtex-autokey-titleword-length)))))
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
2352
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
2353 (defun bibtex-generate-autokey ()
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2354 "Generate automatically a key for a BibTeX entry.
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2355 Use the author/editor, the year and the title field.
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2356 The algorithm works as follows.
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2357
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2358 The name part:
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2359 1. Use the author or editor field to generate the name part of the key.
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
2360 Expand BibTeX strings if `bibtex-autokey-expand-strings' is non-nil.
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2361 2. Change the content of the name field according to
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2362 `bibtex-autokey-name-change-strings' (see there for further detail).
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2363 3. Use the first `bibtex-autokey-names' names in the name field. If there
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2364 are up to `bibtex-autokey-names' + `bibtex-autokey-names-stretch' names,
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2365 use all names.
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2366 4. Use only the last names to form the name part. From these last names,
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2367 take at least `bibtex-autokey-name-length' characters (truncate only
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2368 after a consonant or at a word end).
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2369 5. Convert all last names using the function
69581
98eee222dceb * textmodes/bibtex.el (bibtex-include-OPTkey)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 68648
diff changeset
2370 `bibtex-autokey-name-case-convert-function'.
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2371 6. Build the name part of the key by concatenating all abbreviated last
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2372 names with the string `bibtex-autokey-name-separator' between any two.
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2373 If there are more names in the name field than names used in the name
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2374 part, append the string `bibtex-autokey-additional-names'.
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2375
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2376 The year part:
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2377 1. Build the year part of the key by truncating the content of the year
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2378 field to the rightmost `bibtex-autokey-year-length' digits (useful
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2379 values are 2 and 4).
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2380 2. If the year field (or any other field required to generate the key)
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2381 is absent, but the entry has a valid crossref field and
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2382 `bibtex-autokey-use-crossref' is non-nil, use the field of the
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2383 crossreferenced entry instead.
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2384
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2385 The title part
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2386 1. Change the content of the title field according to
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2387 `bibtex-autokey-titleword-change-strings' (see there for further detail).
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2388 2. Truncate the title before the first match of
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2389 `bibtex-autokey-title-terminators' and delete those words which appear
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2390 in `bibtex-autokey-titleword-ignore'. Build the title part using the
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2391 first `bibtex-autokey-titlewords' words from this truncated title.
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2392 If the truncated title ends after up to `bibtex-autokey-titlewords' +
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2393 `bibtex-autokey-titlewords-stretch' words, use all words from the
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2394 truncated title.
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2395 3. For every title word that appears in `bibtex-autokey-titleword-abbrevs'
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2396 use the corresponding abbreviation (see documentation of this variable
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2397 for further detail).
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2398 4. From every title word not generated by an abbreviation, take at least
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2399 `bibtex-autokey-titleword-length' characters (truncate only after
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2400 a consonant or at a word end).
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2401 5. Convert all title words using the function
69581
98eee222dceb * textmodes/bibtex.el (bibtex-include-OPTkey)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 68648
diff changeset
2402 `bibtex-autokey-titleword-case-convert-function'.
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2403 6. Build the title part by concatenating all abbreviated title words with
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2404 the string `bibtex-autokey-titleword-separator' between any two.
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2405
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2406 Concatenate the key:
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2407 1. Concatenate `bibtex-autokey-prefix-string', the name part, the year
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2408 part and the title part. If the name part and the year part are both
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2409 non-empty insert `bibtex-autokey-name-year-separator' between the two.
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2410 If the title part and the year (or name) part are non-empty, insert
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2411 `bibtex-autokey-year-title-separator' between the two.
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2412 2. If `bibtex-autokey-before-presentation-function' is non-nil, it must be
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2413 a function taking one argument. Call this function with the generated
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2414 key as the argument. Use the return value of this function (a string)
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2415 as the key.
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2416 3. If `bibtex-autokey-edit-before-use' is non-nil, present the key in the
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2417 minibuffer to the user for editing. Insert the key given by the user."
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2418 (let* ((names (bibtex-autokey-get-names))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2419 (year (bibtex-autokey-get-year))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2420 (title (bibtex-autokey-get-title))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2421 (autokey (concat bibtex-autokey-prefix-string
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2422 names
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2423 (unless (or (equal names "")
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2424 (equal year ""))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2425 bibtex-autokey-name-year-separator)
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2426 year
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2427 (unless (or (and (equal names "")
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2428 (equal year ""))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2429 (equal title ""))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2430 bibtex-autokey-year-title-separator)
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2431 title)))
20907
9a55a557cb5a (bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents: 20866
diff changeset
2432 (if bibtex-autokey-before-presentation-function
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2433 (funcall bibtex-autokey-before-presentation-function autokey)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2434 autokey)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2435
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2436
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2437 (defun bibtex-global-key-alist ()
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2438 "Return global key alist based on `bibtex-files'."
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2439 (if bibtex-files
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2440 (apply 'append
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2441 (mapcar (lambda (buf)
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2442 (with-current-buffer buf bibtex-reference-keys))
87650
29fbecdf9527 (bibtex-initialize): New autoloaded command. Rename from function
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87649
diff changeset
2443 (bibtex-initialize t)))
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2444 bibtex-reference-keys))
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2445
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2446 (defun bibtex-read-key (prompt &optional key global)
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2447 "Read BibTeX key from minibuffer using PROMPT and default KEY.
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2448 If optional arg GLOBAL is non-nil, completion is based on the keys in
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2449 `bibtex-reference-keys' of `bibtex-files',"
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2450 (let (completion-ignore-case)
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2451 (completing-read prompt (if global (bibtex-global-key-alist)
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2452 bibtex-reference-keys)
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2453 nil nil key 'bibtex-key-history)))
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2454
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2455 (defun bibtex-read-string-key (&optional key)
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2456 "Read BibTeX string key from minibuffer using default KEY."
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2457 (let ((completion-ignore-case t))
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2458 (completing-read "String key: " bibtex-strings
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2459 nil nil key 'bibtex-key-history)))
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2460
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2461 (defun bibtex-parse-keys (&optional abortable verbose)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2462 "Set `bibtex-reference-keys' to the keys used in the whole buffer.
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2463 Find both entry keys and crossref entries. If ABORTABLE is non-nil abort
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2464 on user input. If VERBOSE is non-nil give messages about progress.
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
2465 Return alist of keys if parsing was completed, `aborted' otherwise.
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
2466 If `bibtex-parse-keys-fast' is non-nil, use fast but simplified algorithm
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
2467 for parsing BibTeX keys. If parsing fails, try to set this variable to nil."
91913
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2468 (if (eq major-mode 'bibtex-mode)
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2469 (let (ref-keys crossref-keys)
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2470 (save-excursion
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2471 (save-match-data
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2472 (if verbose
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2473 (bibtex-progress-message
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2474 (concat (buffer-name) ": parsing reference keys")))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2475 (catch 'userkey
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2476 (goto-char (point-min))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2477 (if bibtex-parse-keys-fast
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2478 (let ((case-fold-search t)
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2479 (re (concat bibtex-entry-head "\\|"
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2480 ",[ \t\n]*crossref[ \t\n]*=[ \t\n]*"
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2481 "\\(\"[^\"]*\"\\|{[^}]*}\\)[ \t\n]*[,})]")))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2482 (while (re-search-forward re nil t)
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2483 (if (and abortable (input-pending-p))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2484 ;; user has aborted by typing a key: return `aborted'
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2485 (throw 'userkey 'aborted))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2486 (cond ((match-end 3)
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2487 ;; This is a crossref.
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2488 (let ((key (buffer-substring-no-properties
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2489 (1+ (match-beginning 3)) (1- (match-end 3)))))
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2490 (unless (assoc key crossref-keys)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2491 (push (list key) crossref-keys))))
91913
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2492 ;; only keys of known entries
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2493 ((assoc-string (bibtex-type-in-head)
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2494 bibtex-entry-field-alist t)
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2495 ;; This is an entry.
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2496 (let ((key (bibtex-key-in-head)))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2497 (unless (assoc key ref-keys)
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2498 (push (cons key t) ref-keys)))))))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2499
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2500 (let (;; ignore @String entries because they are handled
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2501 ;; separately by `bibtex-parse-strings'
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2502 (bibtex-sort-ignore-string-entries t)
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2503 bounds)
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2504 (bibtex-map-entries
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2505 (lambda (key beg end)
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2506 (if (and abortable
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2507 (input-pending-p))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2508 ;; user has aborted by typing a key: return `aborted'
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2509 (throw 'userkey 'aborted))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2510 (if verbose (bibtex-progress-message))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2511 (unless (assoc key ref-keys)
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2512 (push (cons key t) ref-keys))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2513 (if (and (setq bounds (bibtex-search-forward-field "crossref" end))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2514 (setq key (bibtex-text-in-field-bounds bounds t))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2515 (not (assoc key crossref-keys)))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2516 (push (list key) crossref-keys))))))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2517
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2518 (dolist (key crossref-keys)
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2519 (unless (assoc (car key) ref-keys) (push key ref-keys)))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2520 (if verbose
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2521 (bibtex-progress-message 'done))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2522 ;; successful operation --> return `bibtex-reference-keys'
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2523 (setq bibtex-reference-keys ref-keys)))))))
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2524
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2525 (defun bibtex-parse-strings (&optional add abortable)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2526 "Set `bibtex-strings' to the string definitions in the whole buffer.
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2527 If ADD is non-nil add the new strings to `bibtex-strings' instead of
57070
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
2528 simply resetting it. If ADD is an alist of strings, also add ADD to
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
2529 `bibtex-strings'. If ABORTABLE is non-nil abort on user input.
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2530 Return alist of strings if parsing was completed, `aborted' otherwise."
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2531 (save-excursion
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2532 (save-match-data
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2533 (goto-char (point-min))
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2534 (let ((strings (if (and add
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2535 (listp bibtex-strings))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2536 bibtex-strings))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2537 bounds key)
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2538 (if (listp add)
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2539 (dolist (string add)
57054
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
2540 (unless (assoc-string (car string) strings t)
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2541 (push string strings))))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2542 (catch 'userkey
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2543 (while (setq bounds (bibtex-search-forward-string))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2544 (if (and abortable
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2545 (input-pending-p))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2546 ;; user has aborted by typing a key --> return `aborted'
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2547 (throw 'userkey 'aborted))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2548 (setq key (bibtex-reference-key-in-string bounds))
57054
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
2549 (unless (assoc-string key strings t)
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
2550 (push (cons key (bibtex-text-in-string bounds t))
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
2551 strings))
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2552 (goto-char (bibtex-end-of-text-in-string bounds)))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2553 ;; successful operation --> return `bibtex-strings'
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2554 (setq bibtex-strings strings))))))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2555
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
2556 (defun bibtex-strings ()
81591
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2557 "Return `bibtex-strings'. Initialize this variable if necessary."
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
2558 (if (listp bibtex-strings) bibtex-strings
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
2559 (bibtex-parse-strings (bibtex-string-files-init))))
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
2560
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2561 (defun bibtex-string-files-init ()
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2562 "Return initialization for `bibtex-strings'.
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2563 Use `bibtex-predefined-strings' and BibTeX files `bibtex-string-files'."
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2564 (save-match-data
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2565 (let ((dirlist (split-string (or bibtex-string-file-path default-directory)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2566 ":+"))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2567 (case-fold-search)
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2568 string-files fullfilename compl bounds found)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2569 ;; collect absolute file names of valid string files
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2570 (dolist (filename bibtex-string-files)
51416
83476384bebd (bibtex-member-of-regexp, bibtex-assoc-of-regexp, bibtex-format-entry)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51415
diff changeset
2571 (unless (string-match "\\.bib\\'" filename)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2572 (setq filename (concat filename ".bib")))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2573 ;; test filenames
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2574 (if (file-name-absolute-p filename)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2575 (if (file-readable-p filename)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2576 (push filename string-files)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2577 (error "BibTeX strings file %s not found" filename))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2578 (dolist (dir dirlist)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2579 (when (file-readable-p
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2580 (setq fullfilename (expand-file-name filename dir)))
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2581 (push fullfilename string-files)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2582 (setq found t)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2583 (unless found
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2584 (error "File %s not in paths defined via bibtex-string-file-path"
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2585 filename))))
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2586 ;; parse string files
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2587 (dolist (filename string-files)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2588 (with-temp-buffer
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2589 (insert-file-contents filename)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2590 (goto-char (point-min))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2591 (while (setq bounds (bibtex-search-forward-string))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2592 (push (cons (bibtex-reference-key-in-string bounds)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2593 (bibtex-text-in-string bounds t))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2594 compl)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2595 (goto-char (bibtex-end-of-string bounds)))))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2596 (append bibtex-predefined-strings (nreverse compl)))))
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
2597
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2598 (defun bibtex-parse-buffers-stealthily ()
57070
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
2599 "Parse buffer in the background during idle time.
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2600 Called by `run-with-idle-timer'. Whenever Emacs has been idle
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2601 for `bibtex-parse-keys-timeout' seconds, parse all BibTeX buffers
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2602 which have been modified after last parsing.
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2603 Parsing initializes `bibtex-reference-keys' and `bibtex-strings'."
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2604 (save-excursion
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2605 (let ((buffers (buffer-list))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2606 (strings-init (bibtex-string-files-init)))
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2607 (while (and buffers (not (input-pending-p)))
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2608 (set-buffer (car buffers))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2609 (if (and (eq major-mode 'bibtex-mode)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2610 (not (eq (buffer-modified-tick)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2611 bibtex-buffer-last-parsed-tick)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2612 (save-restriction
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2613 (widen)
81591
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2614 ;; Output no progress messages in `bibtex-parse-keys'
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2615 ;; because when in `y-or-n-p' that can hide the question.
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2616 (if (and (listp (bibtex-parse-keys t))
81591
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2617 ;; update `bibtex-strings'
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2618 (listp (bibtex-parse-strings strings-init t)))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2619
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2620 ;; remember that parsing was successful
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2621 (setq bibtex-buffer-last-parsed-tick (buffer-modified-tick)))))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2622 (setq buffers (cdr buffers))))))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2623
87650
29fbecdf9527 (bibtex-initialize): New autoloaded command. Rename from function
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87649
diff changeset
2624 ;;;###autoload
29fbecdf9527 (bibtex-initialize): New autoloaded command. Rename from function
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87649
diff changeset
2625 (defun bibtex-initialize (&optional current force select)
29fbecdf9527 (bibtex-initialize): New autoloaded command. Rename from function
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87649
diff changeset
2626 "(Re)Initialize BibTeX buffers.
29fbecdf9527 (bibtex-initialize): New autoloaded command. Rename from function
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87649
diff changeset
2627 Visit the BibTeX files defined by `bibtex-files' and return a list
29fbecdf9527 (bibtex-initialize): New autoloaded command. Rename from function
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87649
diff changeset
2628 of corresponding buffers.
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2629 Initialize in these buffers `bibtex-reference-keys' if not yet set.
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2630 List of BibTeX buffers includes current buffer if CURRENT is non-nil.
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2631 If FORCE is non-nil, (re)initialize `bibtex-reference-keys' even if
87650
29fbecdf9527 (bibtex-initialize): New autoloaded command. Rename from function
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87649
diff changeset
2632 already set. If SELECT is non-nil interactively select a BibTeX buffer.
29fbecdf9527 (bibtex-initialize): New autoloaded command. Rename from function
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87649
diff changeset
2633 When called interactively, FORCE is t, CURRENT is t if current buffer uses
29fbecdf9527 (bibtex-initialize): New autoloaded command. Rename from function
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87649
diff changeset
2634 `bibtex-mode', and SELECT is t if current buffer does not use `bibtex-mode',"
29fbecdf9527 (bibtex-initialize): New autoloaded command. Rename from function
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87649
diff changeset
2635 (interactive (list (eq major-mode 'bibtex-mode) t
29fbecdf9527 (bibtex-initialize): New autoloaded command. Rename from function
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87649
diff changeset
2636 (not (eq major-mode 'bibtex-mode))))
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2637 (let ((file-path (split-string (or bibtex-file-path default-directory) ":+"))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2638 file-list dir-list buffer-list)
87650
29fbecdf9527 (bibtex-initialize): New autoloaded command. Rename from function
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87649
diff changeset
2639 ;; generate list of BibTeX files
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2640 (dolist (file bibtex-files)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2641 (cond ((eq file 'bibtex-file-path)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2642 (setq dir-list (append dir-list file-path)))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2643 ((file-accessible-directory-p file)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2644 (push file dir-list))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2645 ((progn (unless (string-match "\\.bib\\'" file)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2646 (setq file (concat file ".bib")))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2647 (file-name-absolute-p file))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2648 (push file file-list))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2649 (t
87650
29fbecdf9527 (bibtex-initialize): New autoloaded command. Rename from function
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87649
diff changeset
2650 (let (expanded-file-name found)
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2651 (dolist (dir file-path)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2652 (when (file-readable-p
87650
29fbecdf9527 (bibtex-initialize): New autoloaded command. Rename from function
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87649
diff changeset
2653 (setq expanded-file-name (expand-file-name file dir)))
29fbecdf9527 (bibtex-initialize): New autoloaded command. Rename from function
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87649
diff changeset
2654 (push expanded-file-name file-list)
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2655 (setq found t)))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2656 (unless found
87650
29fbecdf9527 (bibtex-initialize): New autoloaded command. Rename from function
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87649
diff changeset
2657 (error "File `%s' not in paths defined via bibtex-file-path"
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2658 file))))))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2659 (dolist (file file-list)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2660 (unless (file-readable-p file)
87650
29fbecdf9527 (bibtex-initialize): New autoloaded command. Rename from function
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87649
diff changeset
2661 (error "BibTeX file `%s' not found" file)))
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2662 ;; expand dir-list
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2663 (dolist (dir dir-list)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2664 (setq file-list
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2665 (append file-list (directory-files dir t "\\.bib\\'" t))))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2666 (delete-dups file-list)
87650
29fbecdf9527 (bibtex-initialize): New autoloaded command. Rename from function
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87649
diff changeset
2667 ;; visit files in FILE-LIST
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2668 (dolist (file file-list)
87650
29fbecdf9527 (bibtex-initialize): New autoloaded command. Rename from function
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87649
diff changeset
2669 (if (file-readable-p file)
29fbecdf9527 (bibtex-initialize): New autoloaded command. Rename from function
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87649
diff changeset
2670 (push (find-file-noselect file) buffer-list)))
29fbecdf9527 (bibtex-initialize): New autoloaded command. Rename from function
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87649
diff changeset
2671 ;; include current buffer iff we want it
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2672 (cond ((and current (not (memq (current-buffer) buffer-list)))
87650
29fbecdf9527 (bibtex-initialize): New autoloaded command. Rename from function
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87649
diff changeset
2673 (push (current-buffer) buffer-list))
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2674 ((and (not current) (memq (current-buffer) buffer-list))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2675 (setq buffer-list (delq (current-buffer) buffer-list))))
87650
29fbecdf9527 (bibtex-initialize): New autoloaded command. Rename from function
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87649
diff changeset
2676 ;; parse keys
29fbecdf9527 (bibtex-initialize): New autoloaded command. Rename from function
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87649
diff changeset
2677 (dolist (buffer buffer-list)
29fbecdf9527 (bibtex-initialize): New autoloaded command. Rename from function
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87649
diff changeset
2678 (with-current-buffer buffer
29fbecdf9527 (bibtex-initialize): New autoloaded command. Rename from function
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87649
diff changeset
2679 (if (or force (nlistp bibtex-reference-keys))
29fbecdf9527 (bibtex-initialize): New autoloaded command. Rename from function
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87649
diff changeset
2680 (bibtex-parse-keys))))
29fbecdf9527 (bibtex-initialize): New autoloaded command. Rename from function
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87649
diff changeset
2681 ;; select BibTeX buffer
29fbecdf9527 (bibtex-initialize): New autoloaded command. Rename from function
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87649
diff changeset
2682 (if select
29fbecdf9527 (bibtex-initialize): New autoloaded command. Rename from function
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87649
diff changeset
2683 (if buffer-list
29fbecdf9527 (bibtex-initialize): New autoloaded command. Rename from function
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87649
diff changeset
2684 (switch-to-buffer
29fbecdf9527 (bibtex-initialize): New autoloaded command. Rename from function
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87649
diff changeset
2685 (completing-read "Switch to BibTeX buffer: "
29fbecdf9527 (bibtex-initialize): New autoloaded command. Rename from function
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87649
diff changeset
2686 (mapcar 'buffer-name buffer-list)
29fbecdf9527 (bibtex-initialize): New autoloaded command. Rename from function
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87649
diff changeset
2687 nil t
29fbecdf9527 (bibtex-initialize): New autoloaded command. Rename from function
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87649
diff changeset
2688 (if current (buffer-name (current-buffer)))))
29fbecdf9527 (bibtex-initialize): New autoloaded command. Rename from function
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87649
diff changeset
2689 (message "No BibTeX buffers defined")))
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2690 buffer-list))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2691
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2692 (defun bibtex-complete-internal (completions)
57070
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
2693 "Complete word fragment before point to longest prefix of COMPLETIONS.
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2694 COMPLETIONS is an alist of strings. If point is not after the part
57070
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
2695 of a word, all strings are listed. Return completion."
67933
679e4542aaa9 (bibtex-mode): Make completion-ignore-case
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67897
diff changeset
2696 ;; Return value is used by cleanup functions.
81591
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2697 ;; Code inspired by `lisp-complete-symbol'.
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2698 (let* ((case-fold-search t)
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2699 (beg (save-excursion
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2700 (re-search-backward "[ \t{\"]")
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2701 (forward-char)
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2702 (point)))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2703 (end (point))
81591
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2704 (pattern (buffer-substring-no-properties beg end))
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2705 (completion (try-completion pattern completions)))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2706 (cond ((not completion)
81591
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2707 (error "Can't find completion for `%s'" pattern))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2708 ((eq completion t)
81591
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2709 pattern)
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2710 ((not (string= pattern completion))
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2711 (delete-region beg end)
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2712 (insert completion)
81591
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2713 ;; Don't leave around a completions buffer that's out of date.
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2714 (let ((win (get-buffer-window "*Completions*" 0)))
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2715 (if win (with-selected-window win (bury-buffer))))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2716 completion)
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2717 (t
81591
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2718 (let ((minibuf-is-in-use
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2719 (eq (minibuffer-window) (selected-window))))
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2720 (unless minibuf-is-in-use (message "Making completion list..."))
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2721 (with-output-to-temp-buffer "*Completions*"
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2722 (display-completion-list
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2723 (sort (all-completions pattern completions) 'string<) pattern))
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2724 (unless minibuf-is-in-use
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2725 (message "Making completion list...done")))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2726 nil))))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2727
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2728 (defun bibtex-complete-string-cleanup (str compl)
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2729 "Cleanup after inserting string STR.
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2730 Remove enclosing field delimiters for STR. Display message with
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2731 expansion of STR using expansion list COMPL."
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
2732 ;; point is at position inside field where completion was requested
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2733 (save-excursion
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
2734 (let ((abbr (cdr (if (stringp str)
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2735 (assoc-string str compl t)))))
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2736 (if abbr (message "Abbreviation for `%s'" abbr))
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
2737 (bibtex-remove-delimiters))))
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2738
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2739 (defun bibtex-complete-crossref-cleanup (key)
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2740 "Display summary message on entry KEY after completion of a crossref key.
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2741 Use `bibtex-summary-function' to generate summary."
57054
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
2742 (save-excursion
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2743 (if (and (stringp key)
91913
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2744 (bibtex-search-entry key t))
62077
e233a73cbf79 (bibtex-summary): Use current BibTeX entry to avoid calling
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61439
diff changeset
2745 (message "Ref: %s" (funcall bibtex-summary-function)))))
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2746
81591
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2747 (defun bibtex-copy-summary-as-kill (&optional arg)
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2748 "Push summery of current BibTeX entry to kill ring.
81591
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2749 Use `bibtex-summary-function' to generate summary.
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2750 If prefix ARG is non-nil push BibTeX entry's URL to kill ring
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2751 that is generated by calling `bibtex-url'."
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2752 (interactive "P")
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2753 (if arg (let ((url (bibtex-url nil t)))
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2754 (if url (kill-new (message "%s" url))
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2755 (message "No URL known")))
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2756 (save-excursion
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2757 (bibtex-beginning-of-entry)
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2758 (if (looking-at bibtex-entry-maybe-empty-head)
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2759 (kill-new (message "%s" (funcall bibtex-summary-function)))
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2760 (error "No entry found")))))
62077
e233a73cbf79 (bibtex-summary): Use current BibTeX entry to avoid calling
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61439
diff changeset
2761
e233a73cbf79 (bibtex-summary): Use current BibTeX entry to avoid calling
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61439
diff changeset
2762 (defun bibtex-summary ()
e233a73cbf79 (bibtex-summary): Use current BibTeX entry to avoid calling
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61439
diff changeset
2763 "Return summary of current BibTeX entry.
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2764 Used as default value of `bibtex-summary-function'."
81591
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2765 ;; It would be neat to make this function customizable. How?
65776
a2bc28552d90 2005-10-01 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Romain Francoise <romain@orebokech.com>
parents: 65583
diff changeset
2766 (if (looking-at bibtex-entry-maybe-empty-head)
69581
98eee222dceb * textmodes/bibtex.el (bibtex-include-OPTkey)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 68648
diff changeset
2767 (let* ((bibtex-autokey-name-case-convert-function 'identity)
65776
a2bc28552d90 2005-10-01 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Romain Francoise <romain@orebokech.com>
parents: 65583
diff changeset
2768 (bibtex-autokey-name-length 'infty)
a2bc28552d90 2005-10-01 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Romain Francoise <romain@orebokech.com>
parents: 65583
diff changeset
2769 (bibtex-autokey-names 1)
a2bc28552d90 2005-10-01 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Romain Francoise <romain@orebokech.com>
parents: 65583
diff changeset
2770 (bibtex-autokey-names-stretch 0)
a2bc28552d90 2005-10-01 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Romain Francoise <romain@orebokech.com>
parents: 65583
diff changeset
2771 (bibtex-autokey-name-separator " ")
a2bc28552d90 2005-10-01 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Romain Francoise <romain@orebokech.com>
parents: 65583
diff changeset
2772 (bibtex-autokey-additional-names " etal")
a2bc28552d90 2005-10-01 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Romain Francoise <romain@orebokech.com>
parents: 65583
diff changeset
2773 (names (bibtex-autokey-get-names))
a2bc28552d90 2005-10-01 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Romain Francoise <romain@orebokech.com>
parents: 65583
diff changeset
2774 (bibtex-autokey-year-length 4)
a2bc28552d90 2005-10-01 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Romain Francoise <romain@orebokech.com>
parents: 65583
diff changeset
2775 (year (bibtex-autokey-get-year))
a2bc28552d90 2005-10-01 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Romain Francoise <romain@orebokech.com>
parents: 65583
diff changeset
2776 (bibtex-autokey-titlewords 5)
a2bc28552d90 2005-10-01 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Romain Francoise <romain@orebokech.com>
parents: 65583
diff changeset
2777 (bibtex-autokey-titlewords-stretch 2)
69581
98eee222dceb * textmodes/bibtex.el (bibtex-include-OPTkey)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 68648
diff changeset
2778 (bibtex-autokey-titleword-case-convert-function 'identity)
65776
a2bc28552d90 2005-10-01 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Romain Francoise <romain@orebokech.com>
parents: 65583
diff changeset
2779 (bibtex-autokey-titleword-length 5)
a2bc28552d90 2005-10-01 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Romain Francoise <romain@orebokech.com>
parents: 65583
diff changeset
2780 (bibtex-autokey-titleword-separator " ")
a2bc28552d90 2005-10-01 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Romain Francoise <romain@orebokech.com>
parents: 65583
diff changeset
2781 (title (bibtex-autokey-get-title))
a2bc28552d90 2005-10-01 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Romain Francoise <romain@orebokech.com>
parents: 65583
diff changeset
2782 (journal (bibtex-autokey-get-field
a2bc28552d90 2005-10-01 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Romain Francoise <romain@orebokech.com>
parents: 65583
diff changeset
2783 "journal" bibtex-autokey-transcriptions))
a2bc28552d90 2005-10-01 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Romain Francoise <romain@orebokech.com>
parents: 65583
diff changeset
2784 (volume (bibtex-autokey-get-field "volume"))
a2bc28552d90 2005-10-01 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Romain Francoise <romain@orebokech.com>
parents: 65583
diff changeset
2785 (pages (bibtex-autokey-get-field "pages" '(("-.*\\'" . "")))))
a2bc28552d90 2005-10-01 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Romain Francoise <romain@orebokech.com>
parents: 65583
diff changeset
2786 (mapconcat (lambda (arg)
a2bc28552d90 2005-10-01 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Romain Francoise <romain@orebokech.com>
parents: 65583
diff changeset
2787 (if (not (string= "" (cdr arg)))
a2bc28552d90 2005-10-01 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Romain Francoise <romain@orebokech.com>
parents: 65583
diff changeset
2788 (concat (car arg) (cdr arg))))
a2bc28552d90 2005-10-01 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Romain Francoise <romain@orebokech.com>
parents: 65583
diff changeset
2789 `((" " . ,names) (" " . ,year) (": " . ,title)
a2bc28552d90 2005-10-01 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Romain Francoise <romain@orebokech.com>
parents: 65583
diff changeset
2790 (", " . ,journal) (" " . ,volume) (":" . ,pages))
a2bc28552d90 2005-10-01 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Romain Francoise <romain@orebokech.com>
parents: 65583
diff changeset
2791 ""))
a2bc28552d90 2005-10-01 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Romain Francoise <romain@orebokech.com>
parents: 65583
diff changeset
2792 (error "Entry not found")))
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2793
14789
d68b71228abd (bibtex-pop): New generic function which unifies the
Richard M. Stallman <rms@gnu.org>
parents: 14410
diff changeset
2794 (defun bibtex-pop (arg direction)
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2795 "Fill current field from the ARGth same field's text in DIRECTION.
57070
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
2796 Generic function used by `bibtex-pop-previous' and `bibtex-pop-next'."
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
2797 ;; parse current field
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
2798 (let* ((bounds (bibtex-enclosing-field t))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
2799 (start-old-field (bibtex-start-of-field bounds))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
2800 (start-old-text (bibtex-start-of-text-in-field bounds))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
2801 (end-old-text (bibtex-end-of-text-in-field bounds))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
2802 (field-name (bibtex-name-in-field bounds t))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
2803 failure)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
2804 (save-excursion
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2805 ;; if executed several times in a row, start each search where
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2806 ;; the last one was finished
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
2807 (cond ((eq last-command 'bibtex-pop)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
2808 (goto-char (if (eq direction 'previous)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
2809 bibtex-pop-previous-search-point
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
2810 bibtex-pop-next-search-point)))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
2811 ((eq direction 'previous)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
2812 (bibtex-beginning-of-entry))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
2813 (t (bibtex-end-of-entry)))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
2814 ;; Search for arg'th previous/next similar field
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
2815 (while (and (not failure)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
2816 (>= (setq arg (1- arg)) 0))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
2817 ;; The search of BibTeX fields is not bounded by entry boundaries
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
2818 (if (eq direction 'previous)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
2819 (if (setq bounds (bibtex-search-backward-field field-name))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
2820 (goto-char (bibtex-start-of-field bounds))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
2821 (setq failure t))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
2822 (if (setq bounds (bibtex-search-forward-field field-name))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
2823 (goto-char (bibtex-end-of-field bounds))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
2824 (setq failure t))))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
2825 (if failure
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
2826 (error "No %s matching BibTeX field"
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
2827 (if (eq direction 'previous) "previous" "next"))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
2828 ;; Found a matching field. Remember boundaries.
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
2829 (let ((new-text (bibtex-text-in-field-bounds bounds))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
2830 (nbeg (copy-marker (bibtex-start-of-field bounds)))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
2831 (nend (copy-marker (bibtex-end-of-field bounds))))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
2832 (bibtex-flash-head "From: ")
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2833 ;; Go back to where we started, delete old text, and pop new.
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
2834 (goto-char end-old-text)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
2835 (delete-region start-old-text end-old-text)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
2836 (if (= nbeg start-old-field)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
2837 (insert (bibtex-field-left-delimiter)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
2838 (bibtex-field-right-delimiter))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
2839 (insert new-text))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
2840 (setq bibtex-pop-previous-search-point (marker-position nbeg)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
2841 bibtex-pop-next-search-point (marker-position nend))))))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
2842 (bibtex-find-text nil nil nil t)
14789
d68b71228abd (bibtex-pop): New generic function which unifies the
Richard M. Stallman <rms@gnu.org>
parents: 14410
diff changeset
2843 (setq this-command 'bibtex-pop))
d68b71228abd (bibtex-pop): New generic function which unifies the
Richard M. Stallman <rms@gnu.org>
parents: 14410
diff changeset
2844
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2845 (defun bibtex-beginning-of-field ()
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2846 "Move point backward to beginning of field.
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2847 This function uses a simple, fast algorithm assuming that the field
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2848 begins at the beginning of a line. We use this function for font-locking."
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2849 (let ((field-reg (concat "^[ \t]*" bibtex-field-name "[ \t]*=")))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2850 (beginning-of-line)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2851 (unless (looking-at field-reg)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2852 (re-search-backward field-reg nil t))))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2853
81591
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2854 (defun bibtex-font-lock-url (bound &optional no-button)
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2855 "Font-lock for URLs. BOUND limits the search.
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2856 If NO-BUTTON is non-nil do not generate buttons."
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2857 (let ((case-fold-search t)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2858 (pnt (point))
81591
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2859 name bounds start end found)
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2860 (bibtex-beginning-of-field)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2861 (while (and (not found)
66116
cff7c706ba17 (bibtex-font-lock-url): Catch when point past bound of search.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66114
diff changeset
2862 (<= (point) bound)
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2863 (prog1 (re-search-forward bibtex-font-lock-url-regexp bound t)
81591
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2864 (setq name (match-string-no-properties 1)))
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2865 (setq bounds (bibtex-parse-field-text))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2866 (progn
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
2867 (setq start (car bounds) end (nth 1 bounds))
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2868 ;; Always ignore field delimiters
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2869 (if (memq (char-before end) '(?\} ?\"))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2870 (setq end (1- end)))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2871 (if (memq (char-after start) '(?\{ ?\"))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2872 (setq start (1+ start)))
81591
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2873 (if (< start pnt) (setq start (min pnt end)))
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2874 (<= start bound)))
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2875 (if (<= pnt start)
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2876 (let ((lst bibtex-generate-url-list) url)
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2877 (while (and (not found) (setq url (car (pop lst))))
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2878 (goto-char start)
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2879 (setq found (and (bibtex-string= name (car url))
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2880 (re-search-forward (cdr url) end t))))))
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2881 (unless found (goto-char end)))
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2882 (if (and found (not no-button))
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2883 (bibtex-button (match-beginning 0) (match-end 0)
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2884 'bibtex-url (match-beginning 0)))
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2885 found))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2886
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2887 (defun bibtex-font-lock-crossref (bound)
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2888 "Font-lock for crossref fields. BOUND limits the search."
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2889 (let ((case-fold-search t)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2890 (pnt (point))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2891 (crossref-reg (concat "^[ \t]*crossref[ \t]*=[ \t\n]*"
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2892 "\\(\"[^\"]*\"\\|{[^}]*}\\)[ \t\n]*[,})]"))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2893 start end found)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2894 (bibtex-beginning-of-field)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2895 (while (and (not found)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2896 (re-search-forward crossref-reg bound t))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2897 (setq start (1+ (match-beginning 1))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2898 end (1- (match-end 1))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2899 found (>= start pnt)))
91913
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2900 (if found (bibtex-button start end 'bibtex-search-crossref
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2901 (buffer-substring-no-properties start end)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2902 start t))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2903 found))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2904
81591
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2905 (defun bibtex-font-lock-cite (matcher bound)
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2906 "Font-lock for cited keys.
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2907 MATCHER identifies the cited key, see `bibtex-cite-matcher-alist'.
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2908 BOUND limits the search."
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2909 (let (case-fold-search)
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2910 (if (re-search-forward (car matcher) bound t)
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2911 (let ((start (match-beginning (cdr matcher)))
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2912 (end (match-end (cdr matcher))))
91913
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2913 (bibtex-button start end 'bibtex-search-crossref
81591
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2914 (buffer-substring-no-properties start end)
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2915 start t t)
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2916 t))))
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
2917
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2918 (defun bibtex-button-action (button)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2919 "Call BUTTON's BibTeX function."
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2920 (apply (button-get button 'bibtex-function)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2921 (button-get button 'bibtex-args)))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2922
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2923 (define-button-type 'bibtex-url
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2924 'action 'bibtex-button-action
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2925 'bibtex-function 'bibtex-url
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2926 'help-echo (purecopy "mouse-2, RET: follow URL"))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2927
91913
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2928 (define-button-type 'bibtex-search-crossref
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2929 'action 'bibtex-button-action
91913
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
2930 'bibtex-function 'bibtex-search-crossref
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2931 'help-echo (purecopy "mouse-2, RET: follow crossref"))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2932
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2933 (defun bibtex-button (beg end type &rest args)
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2934 "Make a BibTeX button from BEG to END of type TYPE in the current buffer."
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2935 (make-text-button beg end 'type type 'bibtex-args args))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
2936
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2937
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2938 ;; Interactive Functions:
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2939
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2940 ;;;###autoload
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2941 (defun bibtex-mode ()
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2942 "Major mode for editing BibTeX files.
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2943
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2944 General information on working with BibTeX mode:
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2945
101233
680e69b3c8ed (bibtex-format-entry): For updating field delimiters, allow
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 101166
diff changeset
2946 Use commands such as \\<bibtex-mode-map>\\[bibtex-Book] to get a template for a specific entry.
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2947 Then fill in all desired fields using \\[bibtex-next-field] to jump from field
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2948 to field. After having filled in all desired fields in the entry, clean the
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2949 new entry with the command \\[bibtex-clean-entry].
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2950
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2951 Some features of BibTeX mode are available only by setting the variable
58772
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
2952 `bibtex-maintain-sorted-entries' to non-nil. However, then BibTeX mode
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
2953 works only with buffers containing valid (syntactical correct) and sorted
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
2954 entries. This is usually the case, if you have created a buffer completely
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
2955 with BibTeX mode and finished every new entry with \\[bibtex-clean-entry].
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2956
62077
e233a73cbf79 (bibtex-summary): Use current BibTeX entry to avoid calling
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61439
diff changeset
2957 For third party BibTeX files, call the command \\[bibtex-convert-alien]
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2958 to fully take advantage of all features of BibTeX mode.
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2959
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2960
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2961 Special information:
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2962
58772
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
2963 A command such as \\[bibtex-Book] outlines the fields for a BibTeX book entry.
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2964
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2965 The names of optional fields start with the string OPT, and are thus ignored
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2966 by BibTeX. The names of alternative fields from which only one is required
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2967 start with the string ALT. The OPT or ALT string may be removed from
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2968 the name of a field with \\[bibtex-remove-OPT-or-ALT].
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2969 \\[bibtex-make-field] inserts a new field after the current one.
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2970 \\[bibtex-kill-field] kills the current field entirely.
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2971 \\[bibtex-yank] yanks the last recently killed field after the current field.
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2972 \\[bibtex-remove-delimiters] removes the double-quotes or braces around the text of the current field.
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2973 \\[bibtex-empty-field] replaces the text of the current field with the default \"\" or {}.
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2974 \\[bibtex-find-text] moves point to the end of the current field.
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2975 \\[bibtex-complete] completes word fragment before point according to context.
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2976
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2977 The command \\[bibtex-clean-entry] cleans the current entry, i.e. it removes OPT/ALT
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2978 from the names of all non-empty optional or alternative fields, checks that
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2979 no required fields are empty, and does some formatting dependent on the value
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2980 of `bibtex-entry-format'. Furthermore, it can automatically generate a key
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2981 for the BibTeX entry, see `bibtex-generate-autokey'.
22563
2e2a71dfec63 Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents: 21169
diff changeset
2982 Note: some functions in BibTeX mode depend on entries being in a special
2e2a71dfec63 Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents: 21169
diff changeset
2983 format (all fields beginning on separate lines), so it is usually a bad
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2984 idea to remove `realign' from `bibtex-entry-format'.
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2985
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2986 BibTeX mode supports Imenu and hideshow minor mode (`hs-minor-mode').
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2987
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2988 ----------------------------------------------------------
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2989 Entry to BibTeX mode calls the value of `bibtex-mode-hook'
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
2990 if that value is non-nil.
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2991
22563
2e2a71dfec63 Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents: 21169
diff changeset
2992 \\{bibtex-mode-map}"
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2993 (interactive)
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2994 (kill-all-local-variables)
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2995 (use-local-map bibtex-mode-map)
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2996 (setq major-mode 'bibtex-mode)
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2997 (setq mode-name "BibTeX")
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2998 (set-syntax-table bibtex-mode-syntax-table)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2999 (make-local-variable 'bibtex-buffer-last-parsed-tick)
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3000 ;; Install stealthy parse function if not already installed
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3001 (unless bibtex-parse-idle-timer
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3002 (setq bibtex-parse-idle-timer (run-with-idle-timer
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3003 bibtex-parse-keys-timeout t
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3004 'bibtex-parse-buffers-stealthily)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3005 (set (make-local-variable 'paragraph-start) "[ \f\n\t]*$")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3006 (set (make-local-variable 'comment-start) bibtex-comment-start)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3007 (set (make-local-variable 'comment-start-skip)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3008 (concat (regexp-quote bibtex-comment-start) "\\>[ \t]*"))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3009 (set (make-local-variable 'comment-column) 0)
61439
267229876c56 (bibtex-autokey-titleword-ignore, bibtex-reference-key)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61247
diff changeset
3010 (set (make-local-variable 'defun-prompt-regexp) "^[ \t]*@[[:alnum:]]+[ \t]*")
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3011 (set (make-local-variable 'outline-regexp) "[ \t]*@")
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3012 (set (make-local-variable 'fill-paragraph-function) 'bibtex-fill-field)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3013 (set (make-local-variable 'fill-prefix) (make-string (+ bibtex-entry-offset
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3014 bibtex-contline-indentation)
64054
23a07b9b6687 (bibtex, bibtex-autokey): Finish `defgroup' description with period.
Juanma Barranquero <lekktu@gmail.com>
parents: 63470
diff changeset
3015 ?\s))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3016 (set (make-local-variable 'font-lock-defaults)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3017 '(bibtex-font-lock-keywords
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3018 nil t ((?$ . "\"")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3019 ;; Mathematical expressions should be fontified as strings
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3020 (?\" . ".")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3021 ;; Quotes are field delimiters and quote-delimited
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3022 ;; entries should be fontified in the same way as
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3023 ;; brace-delimited ones
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3024 )
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3025 nil
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3026 (font-lock-syntactic-keywords . bibtex-font-lock-syntactic-keywords)
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3027 (font-lock-extra-managed-props . (category))
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3028 (font-lock-mark-block-function
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3029 . (lambda ()
57054
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
3030 (set-mark (bibtex-end-of-entry))
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3031 (bibtex-beginning-of-entry)))))
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3032 (setq imenu-generic-expression
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3033 (list (list nil bibtex-entry-head bibtex-key-in-head))
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3034 imenu-case-fold-search t)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3035 (make-local-variable 'choose-completion-string-functions)
81591
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
3036 ;; XEmacs needs `easy-menu-add', Emacs does not care
20907
9a55a557cb5a (bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents: 20866
diff changeset
3037 (easy-menu-add bibtex-edit-menu)
9a55a557cb5a (bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents: 20866
diff changeset
3038 (easy-menu-add bibtex-entry-menu)
61439
267229876c56 (bibtex-autokey-titleword-ignore, bibtex-reference-key)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61247
diff changeset
3039 (run-mode-hooks 'bibtex-mode-hook))
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3040
55348
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
3041 (defun bibtex-field-list (entry-type)
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
3042 "Return list of allowed fields for entry ENTRY-TYPE.
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
3043 More specifically, the return value is a cons pair (REQUIRED . OPTIONAL),
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
3044 where REQUIRED and OPTIONAL are lists of the required and optional field
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3045 names for ENTRY-TYPE according to `bibtex-entry-field-alist',
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3046 `bibtex-include-OPTkey', `bibtex-include-OPTcrossref',
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3047 and `bibtex-user-optional-fields'."
55730
b4eeb441c089 Use assoc-string, not assoc-ignore-case.
Richard M. Stallman <rms@gnu.org>
parents: 55348
diff changeset
3048 (let ((e (assoc-string entry-type bibtex-entry-field-alist t))
55348
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
3049 required optional)
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
3050 (unless e
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3051 (error "Fields for BibTeX entry type %s not defined" entry-type))
55348
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
3052 (if (and (member-ignore-case entry-type bibtex-include-OPTcrossref)
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
3053 (nth 2 e))
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
3054 (setq required (nth 0 (nth 2 e))
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
3055 optional (nth 1 (nth 2 e)))
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
3056 (setq required (nth 0 (nth 1 e))
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
3057 optional (nth 1 (nth 1 e))))
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
3058 (if bibtex-include-OPTkey
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
3059 (push (list "key"
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
3060 "Used for reference key creation if author and editor fields are missing"
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
3061 (if (or (stringp bibtex-include-OPTkey)
77217
f00e4356c78d (bibtex-field-list): Use functionp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77206
diff changeset
3062 (functionp bibtex-include-OPTkey))
55348
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
3063 bibtex-include-OPTkey))
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
3064 optional))
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
3065 (if (member-ignore-case entry-type bibtex-include-OPTcrossref)
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
3066 (push '("crossref" "Reference key of the cross-referenced entry")
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
3067 optional))
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
3068 (setq optional (append optional bibtex-user-optional-fields))
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
3069 (cons required optional)))
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
3070
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3071 (defun bibtex-entry (entry-type)
57070
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
3072 "Insert a new BibTeX entry of type ENTRY-TYPE.
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3073 After insertion call the value of `bibtex-add-entry-hook' if that value
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3074 is non-nil."
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3075 (interactive
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3076 (let ((completion-ignore-case t))
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3077 (list (completing-read "Entry Type: " bibtex-entry-field-alist
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3078 nil t nil 'bibtex-entry-type-history))))
55348
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
3079 (let ((key (if bibtex-maintain-sorted-entries
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
3080 (bibtex-read-key (format "%s key: " entry-type))))
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
3081 (field-list (bibtex-field-list entry-type)))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3082 (unless (bibtex-prepare-new-entry (list key nil entry-type))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3083 (error "Entry with key `%s' already exists" key))
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3084 (indent-to-column bibtex-entry-offset)
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3085 (insert "@" entry-type (bibtex-entry-left-delimiter))
55348
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
3086 (if key (insert key))
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3087 (save-excursion
57070
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
3088 (mapc 'bibtex-make-field (car field-list))
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
3089 (mapc 'bibtex-make-optional-field (cdr field-list))
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3090 (if bibtex-comma-after-last-field
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3091 (insert ","))
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3092 (insert "\n")
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3093 (indent-to-column bibtex-entry-offset)
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3094 (insert (bibtex-entry-right-delimiter) "\n\n"))
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3095 (bibtex-next-field t)
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3096 (if (member-ignore-case entry-type bibtex-autofill-types)
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3097 (bibtex-autofill-entry))
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3098 (run-hooks 'bibtex-add-entry-hook)))
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3099
69887
14e2e318d372 (bibtex-entry-update): New optional arg entry-type. Add field
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 69886
diff changeset
3100 (defun bibtex-entry-update (&optional entry-type)
55348
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
3101 "Update an existing BibTeX entry.
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
3102 In the BibTeX entry at point, make new fields for those items that may occur
69887
14e2e318d372 (bibtex-entry-update): New optional arg entry-type. Add field
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 69886
diff changeset
3103 according to `bibtex-field-list', but are not yet present.
14e2e318d372 (bibtex-entry-update): New optional arg entry-type. Add field
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 69886
diff changeset
3104 Also, add field delimiters to numerical fields if they are not present.
14e2e318d372 (bibtex-entry-update): New optional arg entry-type. Add field
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 69886
diff changeset
3105 If ENTRY-TYPE is non-nil, change first the entry type to ENTRY-TYPE.
14e2e318d372 (bibtex-entry-update): New optional arg entry-type. Add field
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 69886
diff changeset
3106 When called interactively with a prefix arg, query for a value of ENTRY-TYPE."
14e2e318d372 (bibtex-entry-update): New optional arg entry-type. Add field
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 69886
diff changeset
3107 (interactive
14e2e318d372 (bibtex-entry-update): New optional arg entry-type. Add field
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 69886
diff changeset
3108 (list (if current-prefix-arg
14e2e318d372 (bibtex-entry-update): New optional arg entry-type. Add field
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 69886
diff changeset
3109 (let ((completion-ignore-case t))
14e2e318d372 (bibtex-entry-update): New optional arg entry-type. Add field
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 69886
diff changeset
3110 (completing-read "New entry type: " bibtex-entry-field-alist
14e2e318d372 (bibtex-entry-update): New optional arg entry-type. Add field
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 69886
diff changeset
3111 nil t nil 'bibtex-entry-type-history)))))
55348
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
3112 (save-excursion
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
3113 (bibtex-beginning-of-entry)
69887
14e2e318d372 (bibtex-entry-update): New optional arg entry-type. Add field
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 69886
diff changeset
3114 (when (looking-at bibtex-entry-maybe-empty-head)
14e2e318d372 (bibtex-entry-update): New optional arg entry-type. Add field
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 69886
diff changeset
3115 (goto-char (match-end 0))
14e2e318d372 (bibtex-entry-update): New optional arg entry-type. Add field
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 69886
diff changeset
3116 (if entry-type
14e2e318d372 (bibtex-entry-update): New optional arg entry-type. Add field
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 69886
diff changeset
3117 (save-excursion
14e2e318d372 (bibtex-entry-update): New optional arg entry-type. Add field
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 69886
diff changeset
3118 (replace-match (concat "@" entry-type) nil nil nil 1))
14e2e318d372 (bibtex-entry-update): New optional arg entry-type. Add field
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 69886
diff changeset
3119 (setq entry-type (bibtex-type-in-head)))
14e2e318d372 (bibtex-entry-update): New optional arg entry-type. Add field
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 69886
diff changeset
3120 (let* ((field-list (bibtex-field-list entry-type))
14e2e318d372 (bibtex-entry-update): New optional arg entry-type. Add field
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 69886
diff changeset
3121 (required (copy-tree (car field-list)))
14e2e318d372 (bibtex-entry-update): New optional arg entry-type. Add field
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 69886
diff changeset
3122 (optional (copy-tree (cdr field-list)))
14e2e318d372 (bibtex-entry-update): New optional arg entry-type. Add field
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 69886
diff changeset
3123 bounds)
14e2e318d372 (bibtex-entry-update): New optional arg entry-type. Add field
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 69886
diff changeset
3124 (while (setq bounds (bibtex-parse-field))
14e2e318d372 (bibtex-entry-update): New optional arg entry-type. Add field
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 69886
diff changeset
3125 (let ((fname (bibtex-name-in-field bounds t))
14e2e318d372 (bibtex-entry-update): New optional arg entry-type. Add field
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 69886
diff changeset
3126 (end (copy-marker (bibtex-end-of-field bounds) t)))
14e2e318d372 (bibtex-entry-update): New optional arg entry-type. Add field
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 69886
diff changeset
3127 (setq required (delete (assoc-string fname required t) required)
14e2e318d372 (bibtex-entry-update): New optional arg entry-type. Add field
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 69886
diff changeset
3128 optional (delete (assoc-string fname optional t) optional))
14e2e318d372 (bibtex-entry-update): New optional arg entry-type. Add field
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 69886
diff changeset
3129 (when (string-match "\\`[0-9]+\\'"
14e2e318d372 (bibtex-entry-update): New optional arg entry-type. Add field
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 69886
diff changeset
3130 (bibtex-text-in-field-bounds bounds))
14e2e318d372 (bibtex-entry-update): New optional arg entry-type. Add field
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 69886
diff changeset
3131 (goto-char (bibtex-end-of-text-in-field bounds))
14e2e318d372 (bibtex-entry-update): New optional arg entry-type. Add field
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 69886
diff changeset
3132 (insert (bibtex-field-right-delimiter))
14e2e318d372 (bibtex-entry-update): New optional arg entry-type. Add field
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 69886
diff changeset
3133 (goto-char (bibtex-start-of-text-in-field bounds))
14e2e318d372 (bibtex-entry-update): New optional arg entry-type. Add field
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 69886
diff changeset
3134 (insert (bibtex-field-left-delimiter)))
14e2e318d372 (bibtex-entry-update): New optional arg entry-type. Add field
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 69886
diff changeset
3135 (goto-char end)))
14e2e318d372 (bibtex-entry-update): New optional arg entry-type. Add field
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 69886
diff changeset
3136 (skip-chars-backward " \t\n")
14e2e318d372 (bibtex-entry-update): New optional arg entry-type. Add field
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 69886
diff changeset
3137 (dolist (field required) (bibtex-make-field field))
14e2e318d372 (bibtex-entry-update): New optional arg entry-type. Add field
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 69886
diff changeset
3138 (dolist (field optional) (bibtex-make-optional-field field))))))
55348
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
3139
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
3140 (defun bibtex-parse-entry (&optional content)
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3141 "Parse entry at point, return an alist.
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3142 The alist elements have the form (FIELD . TEXT), where FIELD can also be
57054
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
3143 the special strings \"=type=\" and \"=key=\". For the FIELD \"=key=\"
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
3144 TEXT may be nil. Remove \"OPT\" and \"ALT\" from FIELD.
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
3145 Move point to the end of the last field.
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
3146 If optional arg CONTENT is non-nil extract content of text fields."
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3147 (let (alist bounds)
55880
1b2cb608f18e (bibtex-format-entry): Fix regexps.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55730
diff changeset
3148 (when (looking-at bibtex-entry-maybe-empty-head)
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3149 (push (cons "=type=" (bibtex-type-in-head)) alist)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3150 (push (cons "=key=" (bibtex-key-in-head)) alist)
55880
1b2cb608f18e (bibtex-format-entry): Fix regexps.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55730
diff changeset
3151 (goto-char (match-end 0))
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
3152 (while (setq bounds (bibtex-parse-field))
57054
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
3153 (push (cons (bibtex-name-in-field bounds t)
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
3154 (bibtex-text-in-field-bounds bounds content))
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3155 alist)
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3156 (goto-char (bibtex-end-of-field bounds))))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3157 alist))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3158
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3159 (defun bibtex-autofill-entry ()
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3160 "Try to fill fields of current BibTeX entry based on neighboring entries.
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3161 The current entry must have a key. Determine the neighboring entry
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3162 \(previouse or next\) whose key is more similar to the key of the current
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3163 entry. For all empty fields of the current entry insert the corresponding
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3164 field contents of the neighboring entry. Finally try to update the text
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3165 based on the difference between the keys of the neighboring and the current
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3166 entry (for example, the year parts of the keys)."
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3167 (interactive)
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3168 (bibtex-beginning-of-entry)
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3169 (when (looking-at bibtex-entry-head)
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3170 (let ((type (bibtex-type-in-head))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3171 (key (bibtex-key-in-head))
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3172 (key-end (match-end bibtex-key-in-head))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3173 (case-fold-search t)
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3174 (bibtex-sort-ignore-string-entries t)
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3175 tmp other-key other bounds)
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3176 ;; The fields we want to change start right after the key.
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3177 (goto-char key-end)
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3178 ;; First see whether to use the previous or the next entry
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3179 ;; for "inspiration".
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3180 (save-excursion
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3181 (goto-char (1- (match-beginning 0)))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3182 (bibtex-beginning-of-entry)
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3183 (if (and (looking-at bibtex-entry-head)
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3184 (bibtex-string= type (bibtex-type-in-head))
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3185 ;; In case we found ourselves :-(
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3186 (not (equal key (setq tmp (bibtex-key-in-head)))))
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3187 (setq other-key tmp
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3188 other (point))))
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3189 (save-excursion
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3190 (bibtex-end-of-entry)
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3191 (bibtex-skip-to-valid-entry)
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3192 (if (and (looking-at bibtex-entry-head)
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3193 (bibtex-string= type (bibtex-type-in-head))
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3194 ;; In case we found ourselves :-(
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3195 (not (equal key (setq tmp (bibtex-key-in-head))))
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3196 (or (not other-key)
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3197 ;; Check which is the best match.
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3198 (< (length (try-completion "" (list key other-key)))
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3199 (length (try-completion "" (list key tmp))))))
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3200 (setq other-key tmp
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3201 other (point))))
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3202 ;; Then fill the new entry's fields with the chosen other entry.
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3203 (when other
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3204 (setq other (save-excursion (goto-char other) (bibtex-parse-entry)))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3205 (setq key-end (point)) ;In case parse-entry changed the buffer.
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
3206 (while (setq bounds (bibtex-parse-field))
57054
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
3207 (let ((text (assoc-string (bibtex-name-in-field bounds t)
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
3208 other t)))
59733
96d73eb02751 (bibtex-format-entry): Use `bibtex-empty-field-re' only on the text of
Lute Kamstra <lute@gnu.org>
parents: 58772
diff changeset
3209 (if (not (and text
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
3210 (equal "" (bibtex-text-in-field-bounds bounds t))))
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3211 (goto-char (bibtex-end-of-field bounds))
59733
96d73eb02751 (bibtex-format-entry): Use `bibtex-empty-field-re' only on the text of
Lute Kamstra <lute@gnu.org>
parents: 58772
diff changeset
3212 (goto-char (bibtex-start-of-text-in-field bounds))
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3213 (delete-region (point) (bibtex-end-of-text-in-field bounds))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3214 (insert (cdr text)))))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3215 ;; Finally try to update the text based on the difference between
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3216 ;; the two keys.
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3217 (let* ((prefix (try-completion "" (list key other-key)))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3218 ;; If the keys are foo91 and foo92, don't replace 1 for 2
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3219 ;; but 91 for 92 instead.
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3220 (_ (if (string-match "[0-9]+\\'" prefix)
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3221 (setq prefix (substring prefix 0 (match-beginning 0)))))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3222 (suffix (substring key (length prefix)))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3223 (other-suffix (substring other-key (length prefix))))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3224 (while (re-search-backward (regexp-quote other-suffix) key-end 'move)
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3225 (replace-match suffix)))))))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3226
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3227 (defun bibtex-print-help-message (&optional field comma)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3228 "Print helpful information about current FIELD in current BibTeX entry.
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3229 Optional arg COMMA is as in `bibtex-enclosing-field'. It is t for
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3230 interactive calls."
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3231 (interactive (list nil t))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3232 (unless field (setq field (car (bibtex-find-text-internal nil nil comma))))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3233 (if (string-match "@" field)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3234 (cond ((bibtex-string= field "@string")
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3235 (message "String definition"))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3236 ((bibtex-string= field "@preamble")
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3237 (message "Preamble definition"))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3238 (t (message "Entry key")))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3239 (let* ((case-fold-search t)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3240 (type (save-excursion
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3241 (bibtex-beginning-of-entry)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3242 (looking-at bibtex-entry-maybe-empty-head)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3243 (bibtex-type-in-head)))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3244 (field-list (bibtex-field-list type))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3245 (comment (assoc-string field (append (car field-list)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3246 (cdr field-list)) t)))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3247 (if comment (message "%s" (nth 1 comment))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3248 (message "No comment available")))))
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3249
77206
389303f02afc (bibtex-insert-kill): Pass non-nil NODELIM arg to bibtex-make-field.
Glenn Morris <rgm@gnu.org>
parents: 75356
diff changeset
3250 (defun bibtex-make-field (field &optional move interactive nodelim)
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3251 "Make a field named FIELD in current BibTeX entry.
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3252 FIELD is either a string or a list of the form
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3253 \(FIELD-NAME COMMENT-STRING INIT ALTERNATIVE-FLAG) as in
57070
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
3254 `bibtex-entry-field-alist'.
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3255 If MOVE is non-nil, move point past the present field before making
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3256 the new field. If INTERACTIVE is non-nil, move point to the end of
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3257 the new field. Otherwise move point past the new field.
77206
389303f02afc (bibtex-insert-kill): Pass non-nil NODELIM arg to bibtex-make-field.
Glenn Morris <rgm@gnu.org>
parents: 75356
diff changeset
3258 MOVE and INTERACTIVE are t when called interactively.
77217
f00e4356c78d (bibtex-field-list): Use functionp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77206
diff changeset
3259 INIT is surrounded by field delimiters, unless NODELIM is non-nil."
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3260 (interactive
55348
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
3261 (list (let ((completion-ignore-case t)
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
3262 (field-list (bibtex-field-list
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3263 (save-excursion
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3264 (bibtex-beginning-of-entry)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3265 (looking-at bibtex-any-entry-maybe-empty-head)
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3266 (bibtex-type-in-head)))))
55348
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
3267 (completing-read "BibTeX field name: "
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
3268 (append (car field-list) (cdr field-list))
57819
cc6cd5062afb (bibtex-make-field): Don't use interactive-p.
Richard M. Stallman <rms@gnu.org>
parents: 57815
diff changeset
3269 nil nil nil bibtex-field-history))
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3270 t t))
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3271 (unless (consp field)
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3272 (setq field (list field)))
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
3273 (when move
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
3274 (bibtex-find-text)
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
3275 (if (looking-at "[}\"]")
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
3276 (forward-char)))
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3277 (insert ",\n")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3278 (indent-to-column (+ bibtex-entry-offset bibtex-field-indentation))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3279 (if (nth 3 field) (insert "ALT"))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3280 (insert (car field) " ")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3281 (if bibtex-align-at-equal-sign
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3282 (indent-to-column (+ bibtex-entry-offset
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3283 (- bibtex-text-indentation 2))))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3284 (insert "= ")
57054
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
3285 (unless bibtex-align-at-equal-sign
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
3286 (indent-to-column (+ bibtex-entry-offset
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
3287 bibtex-text-indentation)))
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3288 (let ((init (nth 2 field)))
77217
f00e4356c78d (bibtex-field-list): Use functionp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77206
diff changeset
3289 (if (not init) (setq init "")
f00e4356c78d (bibtex-field-list): Use functionp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77206
diff changeset
3290 (if (functionp init) (setq init (funcall init)))
f00e4356c78d (bibtex-field-list): Use functionp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77206
diff changeset
3291 (unless (stringp init) (error "`%s' is not a string" init)))
f00e4356c78d (bibtex-field-list): Use functionp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77206
diff changeset
3292 ;; NODELIM is required by `bibtex-insert-kill'
f00e4356c78d (bibtex-field-list): Use functionp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77206
diff changeset
3293 (if nodelim (insert init)
f00e4356c78d (bibtex-field-list): Use functionp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77206
diff changeset
3294 (insert (bibtex-field-left-delimiter) init
77206
389303f02afc (bibtex-insert-kill): Pass non-nil NODELIM arg to bibtex-make-field.
Glenn Morris <rgm@gnu.org>
parents: 75356
diff changeset
3295 (bibtex-field-right-delimiter))))
57833
1a602333ec1d (bibtex-make-field): Fix typo.
John Paul Wallington <jpw@pobox.com>
parents: 57819
diff changeset
3296 (when interactive
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3297 ;; (bibtex-find-text nil nil bibtex-help-message)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3298 (if (memq (preceding-char) '(?} ?\")) (forward-char -1))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3299 (if bibtex-help-message (bibtex-print-help-message (car field)))))
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3300
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3301 (defun bibtex-beginning-of-entry ()
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3302 "Move to beginning of BibTeX entry (beginning of line).
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3303 If inside an entry, move to the beginning of it, otherwise move to the
57070
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
3304 beginning of the previous entry. If point is ahead of all BibTeX entries
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
3305 move point to the beginning of buffer. Return the new location of point."
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3306 (interactive)
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3307 (skip-chars-forward " \t")
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3308 (if (looking-at "@")
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3309 (forward-char))
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3310 (re-search-backward "^[ \t]*@" nil 'move)
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3311 (point))
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3312
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3313 (defun bibtex-end-of-entry ()
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3314 "Move to end of BibTeX entry (past the closing brace).
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3315 If inside an entry, move to the end of it, otherwise move to the end
57070
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
3316 of the previous entry. Do not move if ahead of first entry.
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3317 Return the new location of point."
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3318 (interactive)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3319 (let ((case-fold-search t)
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3320 (pnt (point))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3321 (_ (bibtex-beginning-of-entry))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3322 (bounds (bibtex-valid-entry t)))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3323 (cond (bounds (goto-char (cdr bounds))) ; regular entry
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3324 ;; @String or @Preamble
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3325 ((setq bounds (or (bibtex-parse-string t) (bibtex-parse-preamble)))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3326 (goto-char (bibtex-end-of-string bounds)))
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3327 ((looking-at bibtex-any-valid-entry-type)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3328 ;; Parsing of entry failed
81591
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
3329 (error "Syntactically incorrect BibTeX entry starts here"))
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3330 (t (if (interactive-p) (message "Not on a known BibTeX entry."))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3331 (goto-char pnt)))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3332 (point)))
22563
2e2a71dfec63 Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents: 21169
diff changeset
3333
58772
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
3334 (defun bibtex-goto-line (arg)
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
3335 "Goto line ARG, counting from beginning of (narrowed) buffer."
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
3336 ;; code adapted from `goto-line'
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
3337 (goto-char (point-min))
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
3338 (if (eq selective-display t)
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
3339 (re-search-forward "[\n\C-m]" nil 'end (1- arg))
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
3340 (forward-line (1- arg))))
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
3341
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
3342 (defun bibtex-reposition-window ()
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3343 "Make the current BibTeX entry visible.
58772
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
3344 If entry is smaller than `window-body-height', entry is centered in window.
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
3345 Otherwise display the beginning of entry."
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
3346 (interactive)
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
3347 (let ((pnt (point))
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
3348 (beg (line-number-at-pos (bibtex-beginning-of-entry)))
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
3349 (end (line-number-at-pos (bibtex-end-of-entry))))
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
3350 (if (> (window-body-height) (- end beg))
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
3351 ;; entry fits in current window
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
3352 (progn
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
3353 (bibtex-goto-line (/ (+ 1 beg end) 2))
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
3354 (recenter)
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
3355 (goto-char pnt))
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
3356 ;; entry too large for current window
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
3357 (bibtex-goto-line beg)
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
3358 (recenter 0)
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
3359 (if (> (1+ (- (line-number-at-pos pnt) beg))
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
3360 (window-body-height))
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
3361 (bibtex-goto-line beg)
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
3362 (goto-char pnt)))))
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3363
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3364 (defun bibtex-mark-entry ()
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3365 "Put mark at beginning, point at end of current BibTeX entry."
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3366 (interactive)
81591
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
3367 (push-mark (bibtex-beginning-of-entry))
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3368 (bibtex-end-of-entry))
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3369
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3370 (defun bibtex-count-entries (&optional count-string-entries)
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3371 "Count number of entries in current buffer or region.
58772
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
3372 With prefix argument COUNT-STRING-ENTRIES count all entries,
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
3373 otherwise count all entries except @String entries.
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
3374 If mark is active count entries in region, if not in whole buffer."
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3375 (interactive "P")
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3376 (let ((number 0)
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
3377 (bibtex-sort-ignore-string-entries (not count-string-entries)))
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
3378 (save-restriction
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
3379 (if mark-active (narrow-to-region (region-beginning) (region-end)))
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
3380 (bibtex-map-entries (lambda (key beg end) (setq number (1+ number)))))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3381 (message "%s contains %d entries."
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3382 (if mark-active "Region" "Buffer")
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3383 number)))
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3384
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3385 (defun bibtex-ispell-entry ()
58772
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
3386 "Check BibTeX entry for spelling errors."
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3387 (interactive)
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3388 (ispell-region (save-excursion (bibtex-beginning-of-entry))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3389 (save-excursion (bibtex-end-of-entry))))
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3390
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3391 (defun bibtex-ispell-abstract ()
58772
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
3392 "Check abstract of BibTeX entry for spelling errors."
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3393 (interactive)
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3394 (let ((bounds (save-excursion
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3395 (bibtex-beginning-of-entry)
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3396 (bibtex-search-forward-field "abstract" t))))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3397 (if bounds
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3398 (ispell-region (bibtex-start-of-text-in-field bounds)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3399 (bibtex-end-of-text-in-field bounds))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3400 (error "No abstract in entry"))))
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3401
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3402 (defun bibtex-narrow-to-entry ()
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3403 "Narrow buffer to current BibTeX entry."
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3404 (interactive)
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3405 (save-excursion
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3406 (widen)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3407 (narrow-to-region (bibtex-beginning-of-entry)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3408 (bibtex-end-of-entry))))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3409
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3410 (defun bibtex-entry-index ()
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3411 "Return index of BibTeX entry head at or past position of point.
92218
1d8a03656f39 (bibtex-format-entry): Handle error message refering to a missing
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 92217
diff changeset
3412 The index is a list (KEY CROSSREF-KEY ENTRY-TYPE) that is used for sorting
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3413 the entries of the BibTeX buffer. CROSSREF-KEY is nil unless the value
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3414 of `bibtex-maintain-sorted-entries' is `crossref'. Move point to the end
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3415 of the head of the entry found. Return nil if no entry found."
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3416 (let ((case-fold-search t))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3417 (if (re-search-forward bibtex-entry-maybe-empty-head nil t)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3418 (let ((key (bibtex-key-in-head))
92218
1d8a03656f39 (bibtex-format-entry): Handle error message refering to a missing
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 92217
diff changeset
3419 ;; all entry types should be downcase (for ease of comparison)
1d8a03656f39 (bibtex-format-entry): Handle error message refering to a missing
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 92217
diff changeset
3420 (entry-type (downcase (bibtex-type-in-head))))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3421 ;; Don't search CROSSREF-KEY if we don't need it.
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3422 (if (eq bibtex-maintain-sorted-entries 'crossref)
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3423 (let ((bounds (bibtex-search-forward-field
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3424 "\\(OPT\\)?crossref" t)))
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3425 (list key
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3426 (if bounds (bibtex-text-in-field-bounds bounds t))
92218
1d8a03656f39 (bibtex-format-entry): Handle error message refering to a missing
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 92217
diff changeset
3427 entry-type))
1d8a03656f39 (bibtex-format-entry): Handle error message refering to a missing
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 92217
diff changeset
3428 (list key nil entry-type))))))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3429
71044
da5fa425123d (bibtex-autokey-name-case-convert-function)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70841
diff changeset
3430 (defun bibtex-init-sort-entry-class-alist ()
81591
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
3431 "Initialize `bibtex-sort-entry-class-alist' (buffer-local)."
71044
da5fa425123d (bibtex-autokey-name-case-convert-function)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70841
diff changeset
3432 (unless (local-variable-p 'bibtex-sort-entry-class-alist)
da5fa425123d (bibtex-autokey-name-case-convert-function)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70841
diff changeset
3433 (set (make-local-variable 'bibtex-sort-entry-class-alist)
da5fa425123d (bibtex-autokey-name-case-convert-function)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70841
diff changeset
3434 (let ((i -1) alist)
da5fa425123d (bibtex-autokey-name-case-convert-function)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70841
diff changeset
3435 (dolist (class bibtex-sort-entry-class alist)
da5fa425123d (bibtex-autokey-name-case-convert-function)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70841
diff changeset
3436 (setq i (1+ i))
da5fa425123d (bibtex-autokey-name-case-convert-function)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70841
diff changeset
3437 (dolist (entry class)
92218
1d8a03656f39 (bibtex-format-entry): Handle error message refering to a missing
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 92217
diff changeset
3438 ;; All entry types should be downcase (for ease of comparison).
71044
da5fa425123d (bibtex-autokey-name-case-convert-function)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70841
diff changeset
3439 (push (cons (if (stringp entry) (downcase entry) entry) i)
da5fa425123d (bibtex-autokey-name-case-convert-function)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70841
diff changeset
3440 alist)))))))
da5fa425123d (bibtex-autokey-name-case-convert-function)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70841
diff changeset
3441
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3442 (defun bibtex-lessp (index1 index2)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3443 "Predicate for sorting BibTeX entries with indices INDEX1 and INDEX2.
92218
1d8a03656f39 (bibtex-format-entry): Handle error message refering to a missing
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 92217
diff changeset
3444 Each index is a list (KEY CROSSREF-KEY ENTRY-TYPE).
55348
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
3445 The predicate depends on the variable `bibtex-maintain-sorted-entries'.
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
3446 If its value is nil use plain sorting."
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3447 (cond ((not index1) (not index2)) ; indices can be nil
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3448 ((not index2) nil)
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3449 ((eq bibtex-maintain-sorted-entries 'crossref)
87650
29fbecdf9527 (bibtex-initialize): New autoloaded command. Rename from function
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87649
diff changeset
3450 ;; CROSSREF-KEY may be nil or it can point to an entry
29fbecdf9527 (bibtex-initialize): New autoloaded command. Rename from function
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87649
diff changeset
3451 ;; in another BibTeX file. In both cases we ignore CROSSREF-KEY.
29fbecdf9527 (bibtex-initialize): New autoloaded command. Rename from function
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87649
diff changeset
3452 (if (and (nth 1 index1)
29fbecdf9527 (bibtex-initialize): New autoloaded command. Rename from function
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87649
diff changeset
3453 (cdr (assoc-string (nth 1 index1) bibtex-reference-keys)))
29fbecdf9527 (bibtex-initialize): New autoloaded command. Rename from function
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87649
diff changeset
3454 (if (and (nth 1 index2)
29fbecdf9527 (bibtex-initialize): New autoloaded command. Rename from function
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87649
diff changeset
3455 (cdr (assoc-string (nth 1 index2) bibtex-reference-keys)))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3456 (or (string-lessp (nth 1 index1) (nth 1 index2))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3457 (and (string-equal (nth 1 index1) (nth 1 index2))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3458 (string-lessp (nth 0 index1) (nth 0 index2))))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3459 (not (string-lessp (nth 0 index2) (nth 1 index1))))
87650
29fbecdf9527 (bibtex-initialize): New autoloaded command. Rename from function
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87649
diff changeset
3460 (if (and (nth 1 index2)
29fbecdf9527 (bibtex-initialize): New autoloaded command. Rename from function
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87649
diff changeset
3461 (cdr (assoc-string (nth 1 index2) bibtex-reference-keys)))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3462 (string-lessp (nth 0 index1) (nth 1 index2))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3463 (string-lessp (nth 0 index1) (nth 0 index2)))))
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3464 ((eq bibtex-maintain-sorted-entries 'entry-class)
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3465 (let ((n1 (cdr (or (assoc (nth 2 index1) bibtex-sort-entry-class-alist)
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3466 (assoc 'catch-all bibtex-sort-entry-class-alist)
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3467 '(nil . 1000)))) ; if there is nothing else
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3468 (n2 (cdr (or (assoc (nth 2 index2) bibtex-sort-entry-class-alist)
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3469 (assoc 'catch-all bibtex-sort-entry-class-alist)
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3470 '(nil . 1000))))) ; if there is nothing else
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3471 (or (< n1 n2)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3472 (and (= n1 n2)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3473 (string-lessp (car index1) (car index2))))))
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3474 (t ; (eq bibtex-maintain-sorted-entries 'plain)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3475 (string-lessp (car index1) (car index2)))))
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3476
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3477 (defun bibtex-sort-buffer ()
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3478 "Sort BibTeX buffer alphabetically by key.
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3479 The predicate for sorting is defined via `bibtex-maintain-sorted-entries'.
57070
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
3480 If its value is nil use plain sorting. Text outside of BibTeX entries is not
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
3481 affected. If `bibtex-sort-ignore-string-entries' is non-nil, @String entries
58772
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
3482 are ignored."
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3483 (interactive)
71044
da5fa425123d (bibtex-autokey-name-case-convert-function)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70841
diff changeset
3484 (bibtex-beginning-of-first-entry) ; Needed by `sort-subr'
da5fa425123d (bibtex-autokey-name-case-convert-function)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70841
diff changeset
3485 (bibtex-init-sort-entry-class-alist) ; Needed by `bibtex-lessp'.
87650
29fbecdf9527 (bibtex-initialize): New autoloaded command. Rename from function
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87649
diff changeset
3486 (if (and (eq bibtex-maintain-sorted-entries 'crossref)
29fbecdf9527 (bibtex-initialize): New autoloaded command. Rename from function
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87649
diff changeset
3487 (nlistp bibtex-reference-keys))
29fbecdf9527 (bibtex-initialize): New autoloaded command. Rename from function
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87649
diff changeset
3488 (bibtex-parse-keys)) ; Needed by `bibtex-lessp'.
71044
da5fa425123d (bibtex-autokey-name-case-convert-function)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70841
diff changeset
3489 (sort-subr nil
da5fa425123d (bibtex-autokey-name-case-convert-function)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70841
diff changeset
3490 'bibtex-skip-to-valid-entry ; NEXTREC function
da5fa425123d (bibtex-autokey-name-case-convert-function)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70841
diff changeset
3491 'bibtex-end-of-entry ; ENDREC function
da5fa425123d (bibtex-autokey-name-case-convert-function)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70841
diff changeset
3492 'bibtex-entry-index ; STARTKEY function
da5fa425123d (bibtex-autokey-name-case-convert-function)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70841
diff changeset
3493 nil ; ENDKEY function
da5fa425123d (bibtex-autokey-name-case-convert-function)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70841
diff changeset
3494 'bibtex-lessp)) ; PREDICATE
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3495
91913
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
3496 (defun bibtex-search-crossref (crossref-key &optional pnt split noerror)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3497 "Move point to the beginning of BibTeX entry CROSSREF-KEY.
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3498 If `bibtex-files' is non-nil, search all these files.
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3499 Otherwise the search is limited to the current buffer.
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3500 Return position of entry if CROSSREF-KEY is found or nil otherwise.
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3501 If CROSSREF-KEY is in the same buffer like current entry but before it
81591
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
3502 an error is signaled. If NOERRER is non-nil this error is suppressed.
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
3503 Optional arg PNT is the position of the referencing entry. It defaults
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
3504 to position of point. If optional arg SPLIT is non-nil, split window
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
3505 so that both the referencing and the crossrefed entry are displayed.
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
3506
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
3507 If called interactively, CROSSREF-KEY defaults to either the crossref key
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
3508 of current entry or a key matched by `bibtex-cite-matcher-alist',
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
3509 whatever is nearer to the position of point. SPLIT is t. NOERROR is nil
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
3510 for a crossref key, t otherwise."
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3511 (interactive
81591
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
3512 (save-excursion
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
3513 (let* ((pnt (point))
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
3514 (_ (bibtex-beginning-of-entry))
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
3515 (end (cdr (bibtex-valid-entry t)))
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
3516 (_ (unless end (error "Not inside valid entry")))
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
3517 (beg (match-end 0)) ; set by `bibtex-valid-entry'
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
3518 (bounds (bibtex-search-forward-field "crossref" end))
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
3519 case-fold-search best temp crossref-key)
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
3520 (if bounds
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
3521 (setq crossref-key (bibtex-text-in-field-bounds bounds t)
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
3522 best (cons (bibtex-dist pnt (bibtex-end-of-field bounds)
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
3523 (bibtex-start-of-field bounds))
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
3524 crossref-key)))
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
3525 (dolist (matcher bibtex-cite-matcher-alist)
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
3526 (goto-char beg)
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
3527 (while (re-search-forward (car matcher) end t)
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
3528 (setq temp (bibtex-dist pnt (match-end (cdr matcher))
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
3529 (match-beginning (cdr matcher))))
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
3530 ;; Accept the key closest to the position of point.
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
3531 (if (or (not best) (< temp (car best)))
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
3532 (setq best (cons temp (match-string-no-properties
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
3533 (cdr matcher)))))))
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
3534 (goto-char pnt)
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
3535 (setq temp (bibtex-read-key "Find crossref key: " (cdr best) t))
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
3536 (list temp (point) t (not (and crossref-key
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
3537 (string= temp crossref-key)))))))
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
3538
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3539 (let (buffer pos eqb)
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3540 (save-excursion
91913
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
3541 (setq pos (bibtex-search-entry crossref-key t)
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3542 buffer (current-buffer)))
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3543 (setq eqb (eq buffer (current-buffer)))
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3544 (cond ((not pos)
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3545 (if split (message "Crossref key `%s' not found" crossref-key)))
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3546 (split ; called (quasi) interactively
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3547 (unless pnt (setq pnt (point)))
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3548 (goto-char pnt)
81591
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
3549 (if (and eqb (= pos (save-excursion (bibtex-beginning-of-entry))))
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
3550 (message "Key `%s' is current entry" crossref-key)
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
3551 (if eqb (select-window (split-window))
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
3552 (pop-to-buffer buffer))
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
3553 (goto-char pos)
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
3554 (bibtex-reposition-window)
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
3555 (beginning-of-line)
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
3556 (if (and eqb (> pnt pos) (not noerror))
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
3557 (error "The referencing entry must precede the crossrefed entry!"))))
91913
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
3558 ;; `bibtex-search-crossref' is called noninteractively during
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3559 ;; clean-up of an entry. Then it is not possible to check
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3560 ;; whether the current entry and the crossrefed entry have
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3561 ;; the correct sorting order.
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3562 (eqb (goto-char pos))
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3563 (t (set-buffer buffer) (goto-char pos)))
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3564 pos))
91913
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
3565 ;; backward compatibility
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
3566 (defalias 'bibtex-find-crossref 'bibtex-search-crossref)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3567
81591
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
3568 (defun bibtex-dist (pos beg end)
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
3569 "Return distance between POS and region delimited by BEG and END."
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
3570 (cond ((and (<= beg pos) (<= pos end)) 0)
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
3571 ((< pos beg) (- beg pos))
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
3572 (t (- pos end))))
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
3573
91913
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
3574 ;;;###autoload
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
3575 (defun bibtex-search-entry (key &optional global start display)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3576 "Move point to the beginning of BibTeX entry named KEY.
57054
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
3577 Return position of entry if KEY is found or nil if not found.
91913
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
3578 With GLOBAL non-nil, search KEY in `bibtex-files'. Otherwise the search
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
3579 is limited to the current buffer. Optional arg START is buffer position
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
3580 where the search starts. If it is nil, start search at beginning of buffer.
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3581 If DISPLAY is non-nil, display the buffer containing KEY.
91913
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
3582 Otherwise, use `set-buffer'.
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
3583 When called interactively, GLOBAL is t if there is a prefix arg or the current
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
3584 mode is not `bibtex-mode', START is nil, and DISPLAY is t."
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
3585 (interactive
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
3586 (let ((global (or current-prefix-arg (not (eq major-mode 'bibtex-mode)))))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
3587 (list (bibtex-read-key "Find key: " nil global) global nil t)))
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3588 (if (and global bibtex-files)
87650
29fbecdf9527 (bibtex-initialize): New autoloaded command. Rename from function
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87649
diff changeset
3589 (let ((buffer-list (bibtex-initialize t))
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3590 buffer found)
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3591 (while (and (not found)
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3592 (setq buffer (pop buffer-list)))
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3593 (with-current-buffer buffer
91913
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
3594 (if (and (listp bibtex-reference-keys)
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
3595 (cdr (assoc-string key bibtex-reference-keys)))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
3596 ;; `bibtex-search-entry' moves point if key found
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
3597 (setq found (bibtex-search-entry key)))))
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3598 (cond ((and found display)
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3599 (let ((same-window-buffer-names
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3600 (cons (buffer-name buffer) same-window-buffer-names)))
58772
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
3601 (pop-to-buffer buffer)
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
3602 (bibtex-reposition-window)))
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3603 (found (set-buffer buffer))
58772
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
3604 (display (message "Key `%s' not found" key)))
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3605 found)
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3606
70210
83aa98a17215 (bibtex-find-entry): Don't demand matching case for @Article, etc.
J.D. Smith <jdsmith@as.arizona.edu>
parents: 69887
diff changeset
3607 (let* ((case-fold-search t)
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3608 (pnt (save-excursion
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3609 (goto-char (or start (point-min)))
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3610 (if (re-search-forward (concat "^[ \t]*\\("
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3611 bibtex-entry-type
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3612 "\\)[ \t]*[({][ \t\n]*\\("
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3613 (regexp-quote key)
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3614 "\\)[ \t\n]*[,=]")
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3615 nil t)
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3616 (match-beginning 0)))))
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3617 (cond (pnt
58772
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
3618 (goto-char pnt)
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
3619 (if display (bibtex-reposition-window)))
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
3620 (display (message "Key `%s' not found" key)))
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
3621 pnt)))
91913
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
3622 ;; backward compatibility
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
3623 (defalias 'bibtex-find-entry 'bibtex-search-entry)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3624
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3625 (defun bibtex-prepare-new-entry (index)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3626 "Prepare a new BibTeX entry with index INDEX.
92218
1d8a03656f39 (bibtex-format-entry): Handle error message refering to a missing
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 92217
diff changeset
3627 INDEX is a list (KEY CROSSREF-KEY ENTRY-TYPE).
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3628 Move point where the entry KEY should be placed.
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3629 If `bibtex-maintain-sorted-entries' is non-nil, perform a binary
58772
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
3630 search to look for place for KEY. This requires that buffer is sorted,
62077
e233a73cbf79 (bibtex-summary): Use current BibTeX entry to avoid calling
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61439
diff changeset
3631 see `bibtex-validate'.
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3632 Return t if preparation was successful or nil if entry KEY already exists."
71044
da5fa425123d (bibtex-autokey-name-case-convert-function)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70841
diff changeset
3633 (bibtex-init-sort-entry-class-alist) ; Needed by `bibtex-lessp'.
87650
29fbecdf9527 (bibtex-initialize): New autoloaded command. Rename from function
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87649
diff changeset
3634 (if (and (eq bibtex-maintain-sorted-entries 'crossref)
29fbecdf9527 (bibtex-initialize): New autoloaded command. Rename from function
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87649
diff changeset
3635 (nlistp bibtex-reference-keys))
29fbecdf9527 (bibtex-initialize): New autoloaded command. Rename from function
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87649
diff changeset
3636 (bibtex-parse-keys)) ; Needed by `bibtex-lessp'.
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3637 (let ((key (nth 0 index))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3638 key-exist)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3639 (cond ((or (null key)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3640 (and (stringp key)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3641 (string-equal key ""))
91913
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
3642 (and (not (setq key-exist (bibtex-search-entry key)))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3643 (not bibtex-maintain-sorted-entries)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3644 (bibtex-move-outside-of-entry))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3645 ;; if key-exist is non-nil due to the previous cond clause
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3646 ;; then point will be at beginning of entry named key.
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3647 (key-exist)
81591
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
3648 (t ; `bibtex-maintain-sorted-entries' is non-nil
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3649 (let* ((case-fold-search t)
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
3650 (left (save-excursion (bibtex-beginning-of-first-entry)))
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
3651 (bounds (save-excursion (goto-char (point-max))
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
3652 (bibtex-skip-to-valid-entry t)))
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
3653 (right (if bounds (cdr bounds) (point-min)))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3654 (found (if (>= left right) left))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3655 actual-index new)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3656 (save-excursion
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3657 ;; Binary search
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3658 (while (not found)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3659 (goto-char (/ (+ left right) 2))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3660 (bibtex-skip-to-valid-entry t)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3661 (setq actual-index (bibtex-entry-index))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3662 (cond ((bibtex-lessp index actual-index)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3663 (setq new (bibtex-beginning-of-entry))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3664 (if (equal right new)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3665 (setq found right)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3666 (setq right new)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3667 (t
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3668 (bibtex-end-of-entry)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3669 (bibtex-skip-to-valid-entry)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3670 (setq new (point))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3671 (if (equal left new)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3672 (setq found right)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3673 (setq left new))))))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3674 (goto-char found)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3675 (bibtex-beginning-of-entry)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3676 (setq actual-index (save-excursion (bibtex-entry-index)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3677 (when (or (not actual-index)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3678 (bibtex-lessp actual-index index))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3679 ;; buffer contains no valid entries or
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3680 ;; greater than last entry --> append
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3681 (bibtex-end-of-entry)
57054
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
3682 (unless (bobp) (newline (forward-line 2)))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3683 (beginning-of-line)))))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3684 (unless key-exist t)))
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3685
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3686 (defun bibtex-validate (&optional test-thoroughly)
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3687 "Validate if buffer or region is syntactically correct.
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3688 Check also for duplicate keys and correct sort order provided
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3689 `bibtex-maintain-sorted-entries' is non-nil.
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3690 With optional argument TEST-THOROUGHLY non-nil check also for
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3691 the absence of required fields and for questionable month fields.
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3692 If mark is active, validate current region, if not the whole buffer.
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3693 Only check known entry types, so you can put comments outside of entries.
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3694 Return t if test was successful, nil otherwise."
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3695 (interactive "P")
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3696 (let* ((case-fold-search t)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3697 error-list syntax-error)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3698 (save-excursion
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3699 (save-restriction
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3700 (if mark-active (narrow-to-region (region-beginning) (region-end)))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3701
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3702 ;; Check syntactical structure of entries
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3703 (goto-char (point-min))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3704 (bibtex-progress-message "Checking syntactical structure")
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3705 (let (bounds end)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3706 (while (setq end (re-search-forward "^[ \t]*@" nil t))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3707 (bibtex-progress-message)
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3708 (goto-char (match-beginning 0))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3709 (cond ((setq bounds (bibtex-valid-entry))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3710 (goto-char (cdr bounds)))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3711 ((setq bounds (or (bibtex-parse-string)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3712 (bibtex-parse-preamble)))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3713 (goto-char (bibtex-end-of-string bounds)))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3714 ((looking-at bibtex-any-valid-entry-type)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3715 (push (cons (bibtex-current-line)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3716 "Syntax error (check esp. commas, braces, and quotes)")
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3717 error-list)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3718 (goto-char (match-end 0)))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3719 (t (goto-char end)))))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3720 (bibtex-progress-message 'done)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3721
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3722 (if error-list
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3723 ;; Continue only if there were no syntax errors.
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3724 (setq syntax-error t)
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3725
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3726 ;; Check for duplicate keys and correct sort order
87650
29fbecdf9527 (bibtex-initialize): New autoloaded command. Rename from function
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87649
diff changeset
3727 (bibtex-init-sort-entry-class-alist) ; Needed by `bibtex-lessp'.
29fbecdf9527 (bibtex-initialize): New autoloaded command. Rename from function
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87649
diff changeset
3728 (bibtex-parse-keys) ; Possibly needed by `bibtex-lessp'.
29fbecdf9527 (bibtex-initialize): New autoloaded command. Rename from function
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87649
diff changeset
3729 ; Always needed by subsequent global key check.
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3730 (let (previous current key-list)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3731 (bibtex-progress-message "Checking for duplicate keys")
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3732 (bibtex-map-entries
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3733 (lambda (key beg end)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3734 (bibtex-progress-message)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3735 (setq current (bibtex-entry-index))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3736 (cond ((not previous))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3737 ((member key key-list)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3738 (push (cons (bibtex-current-line)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3739 (format "Duplicate key `%s'" key))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3740 error-list))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3741 ((and bibtex-maintain-sorted-entries
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3742 (not (bibtex-lessp previous current)))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3743 (push (cons (bibtex-current-line)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3744 "Entries out of order")
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3745 error-list)))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3746 (push key key-list)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3747 (setq previous current)))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3748 (bibtex-progress-message 'done))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3749
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3750 ;; Check for duplicate keys in `bibtex-files'.
87650
29fbecdf9527 (bibtex-initialize): New autoloaded command. Rename from function
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87649
diff changeset
3751 ;; `bibtex-validate' only compares keys in current buffer with keys
29fbecdf9527 (bibtex-initialize): New autoloaded command. Rename from function
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87649
diff changeset
3752 ;; in `bibtex-files'. `bibtex-validate-globally' compares keys for
29fbecdf9527 (bibtex-initialize): New autoloaded command. Rename from function
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87649
diff changeset
3753 ;; each file in `bibtex-files' with keys of all other files in
29fbecdf9527 (bibtex-initialize): New autoloaded command. Rename from function
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87649
diff changeset
3754 ;; `bibtex-files'.
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3755 ;; We don't want to be fooled by outdated `bibtex-reference-keys'.
87650
29fbecdf9527 (bibtex-initialize): New autoloaded command. Rename from function
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87649
diff changeset
3756 (dolist (buffer (bibtex-initialize nil t))
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3757 (dolist (key (with-current-buffer buffer bibtex-reference-keys))
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3758 (when (and (cdr key)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3759 (cdr (assoc-string (car key) bibtex-reference-keys)))
91913
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
3760 (bibtex-search-entry (car key))
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3761 (push (cons (bibtex-current-line)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3762 (format "Duplicate key `%s' in %s" (car key)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3763 (abbreviate-file-name (buffer-file-name buffer))))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3764 error-list))))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3765
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3766 (when test-thoroughly
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3767 (bibtex-progress-message
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3768 "Checking required fields and month fields")
57054
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
3769 (let ((bibtex-sort-ignore-string-entries t))
18247
ae094c1a4334 (bibtex-delete-whitespace, bibtex-current-line)
Richard M. Stallman <rms@gnu.org>
parents: 18212
diff changeset
3770 (bibtex-map-entries
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3771 (lambda (key beg end)
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3772 (bibtex-progress-message)
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3773 (let* ((entry-list (assoc-string (bibtex-type-in-head)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3774 bibtex-entry-field-alist t))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3775 (req (copy-sequence (elt (elt entry-list 1) 0)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3776 (creq (copy-sequence (elt (elt entry-list 2) 0)))
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3777 crossref-there bounds alt-there field)
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3778 (bibtex-beginning-first-field beg)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3779 (while (setq bounds (bibtex-parse-field))
57054
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
3780 (let ((field-name (bibtex-name-in-field bounds)))
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
3781 (if (and (bibtex-string= field-name "month")
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3782 ;; Check only abbreviated month fields.
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3783 (let ((month (bibtex-text-in-field-bounds bounds)))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3784 (not (or (string-match "\\`[\"{].+[\"}]\\'" month)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3785 (assoc-string
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3786 month
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3787 bibtex-predefined-month-strings t)))))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3788 (push (cons (bibtex-current-line)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3789 "Questionable month field")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3790 error-list))
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3791 (setq field (assoc-string field-name req t)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3792 req (delete field req)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3793 creq (delete (assoc-string field-name creq t) creq))
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3794 (if (nth 3 field)
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3795 (if alt-there
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3796 (push (cons (bibtex-current-line)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3797 "More than one non-empty alternative")
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3798 error-list)
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3799 (setq alt-there t)))
57054
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
3800 (if (bibtex-string= field-name "crossref")
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3801 (setq crossref-there t)))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3802 (goto-char (bibtex-end-of-field bounds)))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3803 (if crossref-there (setq req creq))
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3804 (let (alt)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3805 (dolist (field req)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3806 (if (nth 3 field)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3807 (push (car field) alt)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3808 (push (cons (save-excursion (goto-char beg)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3809 (bibtex-current-line))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3810 (format "Required field `%s' missing"
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3811 (car field)))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3812 error-list)))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3813 ;; The following fails if there are more than two
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3814 ;; alternatives in a BibTeX entry, which isn't
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3815 ;; the case momentarily.
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3816 (if (cdr alt)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3817 (push (cons (save-excursion (goto-char beg)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3818 (bibtex-current-line))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3819 (format "Alternative fields `%s'/`%s' missing"
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3820 (car alt) (cadr alt)))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3821 error-list)))))))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3822 (bibtex-progress-message 'done)))))
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3823
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3824 (if error-list
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3825 (let ((file (file-name-nondirectory (buffer-file-name)))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3826 (dir default-directory)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3827 (err-buf "*BibTeX validation errors*"))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3828 (setq error-list (sort error-list 'car-less-than-car))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3829 (with-current-buffer (get-buffer-create err-buf)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3830 (setq default-directory dir)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3831 (unless (eq major-mode 'compilation-mode) (compilation-mode))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3832 (toggle-read-only -1)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3833 (delete-region (point-min) (point-max))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3834 (insert "BibTeX mode command `bibtex-validate'\n"
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3835 (if syntax-error
81591
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
3836 "Maybe undetected errors due to syntax errors. Correct and validate again.\n"
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3837 "\n"))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3838 (dolist (err error-list)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3839 (insert (format "%s:%d: %s\n" file (car err) (cdr err))))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3840 (set-buffer-modified-p nil)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3841 (toggle-read-only 1)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3842 (goto-line 3)) ; first error message
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3843 (display-buffer err-buf)
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3844 nil) ; return `nil' (i.e., buffer is invalid)
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3845 (message "%s is syntactically correct"
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3846 (if mark-active "Region" "Buffer"))
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3847 t))) ; return `t' (i.e., buffer is valid)
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3848
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3849 (defun bibtex-validate-globally (&optional strings)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3850 "Check for duplicate keys in `bibtex-files'.
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3851 With optional prefix arg STRINGS, check for duplicate strings, too.
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3852 Return t if test was successful, nil otherwise."
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3853 (interactive "P")
87650
29fbecdf9527 (bibtex-initialize): New autoloaded command. Rename from function
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87649
diff changeset
3854 (let ((buffer-list (bibtex-initialize t))
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3855 buffer-key-list current-buf current-keys error-list)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3856 ;; Check for duplicate keys within BibTeX buffer
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3857 (dolist (buffer buffer-list)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3858 (save-excursion
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3859 (set-buffer buffer)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3860 (let (entry-type key key-list)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3861 (goto-char (point-min))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3862 (while (re-search-forward bibtex-entry-head nil t)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3863 (setq entry-type (bibtex-type-in-head)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3864 key (bibtex-key-in-head))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3865 (if (or (and strings (bibtex-string= entry-type "string"))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3866 (assoc-string entry-type bibtex-entry-field-alist t))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3867 (if (member key key-list)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3868 (push (format "%s:%d: Duplicate key `%s'\n"
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3869 (buffer-file-name)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3870 (bibtex-current-line) key)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3871 error-list)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3872 (push key key-list))))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3873 (push (cons buffer key-list) buffer-key-list))))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3874
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3875 ;; Check for duplicate keys among BibTeX buffers
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3876 (while (setq current-buf (pop buffer-list))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3877 (setq current-keys (cdr (assq current-buf buffer-key-list)))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3878 (with-current-buffer current-buf
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3879 (dolist (buffer buffer-list)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3880 (dolist (key (cdr (assq buffer buffer-key-list)))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3881 (when (assoc-string key current-keys)
91913
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
3882 (bibtex-search-entry key)
68065
0624a54493b5 (bibtex-validate-globally): Fix typo in a message text:
Eli Zaretskii <eliz@gnu.org>
parents: 67933
diff changeset
3883 (push (format "%s:%d: Duplicate key `%s' in %s\n"
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3884 (buffer-file-name) (bibtex-current-line) key
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3885 (abbreviate-file-name (buffer-file-name buffer)))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3886 error-list))))))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3887
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3888 ;; Process error list
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3889 (if error-list
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3890 (let ((err-buf "*BibTeX validation errors*"))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3891 (with-current-buffer (get-buffer-create err-buf)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3892 (unless (eq major-mode 'compilation-mode) (compilation-mode))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3893 (toggle-read-only -1)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3894 (delete-region (point-min) (point-max))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3895 (insert "BibTeX mode command `bibtex-validate-globally'\n\n")
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3896 (dolist (err (sort error-list 'string-lessp)) (insert err))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3897 (set-buffer-modified-p nil)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3898 (toggle-read-only 1)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3899 (goto-line 3)) ; first error message
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3900 (display-buffer err-buf)
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3901 nil) ; return `nil' (i.e., buffer is invalid)
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
3902 (message "No duplicate keys.")
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3903 t))) ; return `t' (i.e., buffer is valid)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3904
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3905 (defun bibtex-next-field (begin &optional comma)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3906 "Move point to end of text of next BibTeX field or entry head.
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3907 With prefix BEGIN non-nil, move point to its beginning. Optional arg COMMA
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3908 is as in `bibtex-enclosing-field'. It is t for interactive calls."
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3909 (interactive (list current-prefix-arg t))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3910 (let ((bounds (bibtex-find-text-internal t nil comma))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3911 end-of-entry)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3912 (if (not bounds)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3913 (setq end-of-entry t)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3914 (goto-char (nth 3 bounds))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3915 (if (assoc-string (car bounds) '("@String" "@Preamble") t)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3916 (setq end-of-entry t)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3917 ;; BibTeX key or field
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3918 (if (looking-at ",[ \t\n]*") (goto-char (match-end 0)))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3919 ;; end of entry
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3920 (if (looking-at "[)}][ \t\n]*") (setq end-of-entry t))))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3921 (if (and end-of-entry
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3922 (re-search-forward bibtex-any-entry-maybe-empty-head nil t))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3923 (goto-char (match-beginning 0)))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3924 (bibtex-find-text begin nil bibtex-help-message)))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3925
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3926 (defun bibtex-find-text (&optional begin noerror help comma)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3927 "Move point to end of text of current BibTeX field or entry head.
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3928 With optional prefix BEGIN non-nil, move point to its beginning.
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3929 Unless NOERROR is non-nil, an error is signaled if point is not
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
3930 on a BibTeX field. If optional arg HELP is non-nil print help message.
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3931 When called interactively, the value of HELP is `bibtex-help-message'.
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3932 Optional arg COMMA is as in `bibtex-enclosing-field'. It is t for
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3933 interactive calls."
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3934 (interactive (list current-prefix-arg nil bibtex-help-message t))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3935 (let ((bounds (bibtex-find-text-internal t nil comma)))
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3936 (cond (bounds
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3937 (if begin
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
3938 (progn (goto-char (nth 1 bounds))
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3939 (if (looking-at "[{\"]")
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3940 (forward-char)))
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
3941 (goto-char (nth 2 bounds))
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
3942 (if (memq (preceding-char) '(?} ?\"))
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
3943 (forward-char -1)))
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3944 (if help (bibtex-print-help-message (car bounds))))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3945 ((not noerror) (error "Not on BibTeX field")))))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3946
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3947 (defun bibtex-find-text-internal (&optional noerror subfield comma)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3948 "Find text part of current BibTeX field or entry head.
92218
1d8a03656f39 (bibtex-format-entry): Handle error message refering to a missing
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 92217
diff changeset
3949 Return list (NAME START-TEXT END-TEXT END STRING-CONST) with field name
1d8a03656f39 (bibtex-format-entry): Handle error message refering to a missing
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 92217
diff changeset
3950 or entry type, start and end of text, and end of field or entry head.
69886
0da18bcb2c37 (bibtex-find-text-internal): Add new element string-const to return value.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 69581
diff changeset
3951 STRING-CONST is a flag which is non-nil if current subfield delimited by #
0da18bcb2c37 (bibtex-find-text-internal): Add new element string-const to return value.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 69581
diff changeset
3952 is a BibTeX string constant. Return value is nil if field or entry head
0da18bcb2c37 (bibtex-find-text-internal): Add new element string-const to return value.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 69581
diff changeset
3953 are not found.
0da18bcb2c37 (bibtex-find-text-internal): Add new element string-const to return value.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 69581
diff changeset
3954 If optional arg NOERROR is non-nil, an error message is suppressed
0da18bcb2c37 (bibtex-find-text-internal): Add new element string-const to return value.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 69581
diff changeset
3955 if text is not found. If optional arg SUBFIELD is non-nil START-TEXT
0da18bcb2c37 (bibtex-find-text-internal): Add new element string-const to return value.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 69581
diff changeset
3956 and END-TEXT correspond to the current subfield delimited by #.
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3957 Optional arg COMMA is as in `bibtex-enclosing-field'."
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
3958 (save-excursion
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
3959 (let ((pnt (point))
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3960 (bounds (bibtex-enclosing-field comma t))
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
3961 (case-fold-search t)
69886
0da18bcb2c37 (bibtex-find-text-internal): Add new element string-const to return value.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 69581
diff changeset
3962 name start-text end-text end failure done no-sub string-const)
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
3963 (bibtex-beginning-of-entry)
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
3964 (cond (bounds
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
3965 (setq name (bibtex-name-in-field bounds t)
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3966 start-text (bibtex-start-of-text-in-field bounds)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3967 end-text (bibtex-end-of-text-in-field bounds)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3968 end (bibtex-end-of-field bounds)))
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
3969 ;; @String
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3970 ((setq bounds (bibtex-parse-string t))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3971 (if (<= pnt (bibtex-end-of-string bounds))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3972 (setq name "@String" ;; not a field name!
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3973 start-text (bibtex-start-of-text-in-string bounds)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3974 end-text (bibtex-end-of-text-in-string bounds)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3975 end (bibtex-end-of-string bounds))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3976 (setq failure t)))
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
3977 ;; @Preamble
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3978 ((setq bounds (bibtex-parse-preamble))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3979 (if (<= pnt (bibtex-end-of-string bounds))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3980 (setq name "@Preamble" ;; not a field name!
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3981 start-text (bibtex-start-of-text-in-string bounds)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3982 end-text (bibtex-end-of-text-in-string bounds)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3983 end (bibtex-end-of-string bounds))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3984 (setq failure t)))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3985 ;; BibTeX head
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3986 ((looking-at bibtex-entry-maybe-empty-head)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3987 (goto-char (match-end 0))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3988 (if comma (save-match-data
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3989 (re-search-forward "\\=[ \t\n]*," nil t)))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3990 (if (<= pnt (point))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3991 (setq name (match-string-no-properties bibtex-type-in-head)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3992 start-text (or (match-beginning bibtex-key-in-head)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3993 (match-end 0))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3994 end-text (or (match-end bibtex-key-in-head)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3995 (match-end 0))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3996 end end-text
81591
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
3997 no-sub t) ; subfields do not make sense
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3998 (setq failure t)))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
3999 (t (setq failure t)))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
4000 (when (and subfield (not failure))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
4001 (setq failure no-sub)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
4002 (unless failure
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
4003 (goto-char start-text)
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
4004 (while (not done)
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
4005 (if (or (prog1 (looking-at bibtex-field-const)
69886
0da18bcb2c37 (bibtex-find-text-internal): Add new element string-const to return value.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 69581
diff changeset
4006 (setq end-text (match-end 0)
0da18bcb2c37 (bibtex-find-text-internal): Add new element string-const to return value.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 69581
diff changeset
4007 string-const t))
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
4008 (prog1 (setq bounds (bibtex-parse-field-string))
69886
0da18bcb2c37 (bibtex-find-text-internal): Add new element string-const to return value.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 69581
diff changeset
4009 (setq end-text (cdr bounds)
0da18bcb2c37 (bibtex-find-text-internal): Add new element string-const to return value.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 69581
diff changeset
4010 string-const nil)))
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
4011 (progn
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
4012 (if (and (<= start-text pnt) (<= pnt end-text))
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
4013 (setq done t)
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
4014 (goto-char end-text))
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
4015 (if (looking-at "[ \t\n]*#[ \t\n]*")
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
4016 (setq start-text (goto-char (match-end 0)))))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
4017 (setq done t failure t)))))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
4018 (cond ((not failure)
69886
0da18bcb2c37 (bibtex-find-text-internal): Add new element string-const to return value.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 69581
diff changeset
4019 (list name start-text end-text end string-const))
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
4020 ((and no-sub (not noerror))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
4021 (error "Not on text part of BibTeX field"))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
4022 ((not noerror) (error "Not on BibTeX field"))))))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
4023
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
4024 (defun bibtex-remove-OPT-or-ALT (&optional comma)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4025 "Remove the string starting optional/alternative fields.
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
4026 Align text and go thereafter to end of text. Optional arg COMMA
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
4027 is as in `bibtex-enclosing-field'. It is t for interactive calls."
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
4028 (interactive (list t))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4029 (let ((case-fold-search t)
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
4030 (bounds (bibtex-enclosing-field comma)))
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
4031 (save-excursion
27701
5e135f0faf1d (bibtex-mode): Replaced manual splitting of path
Gerd Moellmann <gerd@gnu.org>
parents: 26711
diff changeset
4032 (goto-char (bibtex-start-of-name-in-field bounds))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4033 (when (looking-at "OPT\\|ALT")
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
4034 (delete-region (match-beginning 0) (match-end 0))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4035 ;; make field non-OPT
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4036 (search-forward "=")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4037 (forward-char -1)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4038 (delete-horizontal-space)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4039 (if bibtex-align-at-equal-sign
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4040 (indent-to-column (- bibtex-text-indentation 2))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4041 (insert " "))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4042 (search-forward "=")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4043 (delete-horizontal-space)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4044 (if bibtex-align-at-equal-sign
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4045 (insert " ")
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
4046 (indent-to-column bibtex-text-indentation))))))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
4047
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
4048 (defun bibtex-remove-delimiters (&optional comma)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
4049 "Remove \"\" or {} around current BibTeX field text.
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
4050 Optional arg COMMA is as in `bibtex-enclosing-field'. It is t for
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
4051 interactive calls."
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
4052 (interactive (list t))
69886
0da18bcb2c37 (bibtex-find-text-internal): Add new element string-const to return value.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 69581
diff changeset
4053 (let ((bounds (bibtex-find-text-internal nil t comma)))
0da18bcb2c37 (bibtex-find-text-internal): Add new element string-const to return value.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 69581
diff changeset
4054 (unless (nth 4 bounds)
0da18bcb2c37 (bibtex-find-text-internal): Add new element string-const to return value.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 69581
diff changeset
4055 (delete-region (1- (nth 2 bounds)) (nth 2 bounds))
0da18bcb2c37 (bibtex-find-text-internal): Add new element string-const to return value.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 69581
diff changeset
4056 (delete-region (nth 1 bounds) (1+ (nth 1 bounds))))))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4057
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
4058 (defun bibtex-kill-field (&optional copy-only comma)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4059 "Kill the entire enclosing BibTeX field.
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4060 With prefix arg COPY-ONLY, copy the current field to `bibtex-field-kill-ring',
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
4061 but do not actually kill it. Optional arg COMMA is as in
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
4062 `bibtex-enclosing-field'. It is t for interactive calls."
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
4063 (interactive (list current-prefix-arg t))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4064 (save-excursion
27701
5e135f0faf1d (bibtex-mode): Replaced manual splitting of path
Gerd Moellmann <gerd@gnu.org>
parents: 26711
diff changeset
4065 (let* ((case-fold-search t)
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
4066 (bounds (bibtex-enclosing-field comma))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4067 (end (bibtex-end-of-field bounds))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4068 (beg (bibtex-start-of-field bounds)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4069 (goto-char end)
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
4070 (skip-chars-forward ",")
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
4071 (push (list (bibtex-name-in-field bounds) nil
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4072 (bibtex-text-in-field-bounds bounds))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4073 bibtex-field-kill-ring)
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
4074 (if (> (length bibtex-field-kill-ring) bibtex-field-kill-ring-max)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4075 (setcdr (nthcdr (1- bibtex-field-kill-ring-max)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4076 bibtex-field-kill-ring)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4077 nil))
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
4078 (setq bibtex-field-kill-ring-yank-pointer bibtex-field-kill-ring)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4079 (unless copy-only
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4080 (delete-region beg end))))
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
4081 (setq bibtex-last-kill-command 'field))
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
4082
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
4083 (defun bibtex-copy-field-as-kill (&optional comma)
101166
bd632099967a (bibtex-copy-field-as-kill): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
4084 "Copy the BibTeX field at point to `bibtex-field-kill-ring'.
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
4085 Optional arg COMMA is as in `bibtex-enclosing-field'. It is t for
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
4086 interactive calls."
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
4087 (interactive (list t))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
4088 (bibtex-kill-field t comma))
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
4089
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
4090 (defun bibtex-kill-entry (&optional copy-only)
27701
5e135f0faf1d (bibtex-mode): Replaced manual splitting of path
Gerd Moellmann <gerd@gnu.org>
parents: 26711
diff changeset
4091 "Kill the entire enclosing BibTeX entry.
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
4092 With prefix arg COPY-ONLY, copy the current entry to `bibtex-entry-kill-ring',
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
4093 but do not actually kill it."
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
4094 (interactive "P")
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4095 (save-excursion
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4096 (let* ((case-fold-search t)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4097 (beg (bibtex-beginning-of-entry))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4098 (end (progn (bibtex-end-of-entry)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4099 (if (re-search-forward
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
4100 bibtex-any-entry-maybe-empty-head nil 'move)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4101 (goto-char (match-beginning 0)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4102 (point))))
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
4103 (push (buffer-substring-no-properties beg end)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4104 bibtex-entry-kill-ring)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4105 (if (> (length bibtex-entry-kill-ring) bibtex-entry-kill-ring-max)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4106 (setcdr (nthcdr (1- bibtex-entry-kill-ring-max)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4107 bibtex-entry-kill-ring)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4108 nil))
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
4109 (setq bibtex-entry-kill-ring-yank-pointer bibtex-entry-kill-ring)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
4110 (unless copy-only
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
4111 (delete-region beg end))))
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
4112 (setq bibtex-last-kill-command 'entry))
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
4113
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
4114 (defun bibtex-copy-entry-as-kill ()
57054
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
4115 "Copy the entire enclosing BibTeX entry to `bibtex-entry-kill-ring'."
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
4116 (interactive)
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
4117 (bibtex-kill-entry t))
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
4118
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
4119 (defun bibtex-yank (&optional n)
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
4120 "Reinsert the last BibTeX item.
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
4121 More precisely, reinsert the field or entry killed or yanked most recently.
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
4122 With argument N, reinsert the Nth most recently killed BibTeX item.
62077
e233a73cbf79 (bibtex-summary): Use current BibTeX entry to avoid calling
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 61439
diff changeset
4123 See also the command \\[bibtex-yank-pop]."
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
4124 (interactive "*p")
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
4125 (bibtex-insert-kill (1- n) t)
22563
2e2a71dfec63 Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents: 21169
diff changeset
4126 (setq this-command 'bibtex-yank))
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
4127
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
4128 (defun bibtex-yank-pop (n)
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
4129 "Replace just-yanked killed BibTeX item with a different item.
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
4130 This command is allowed only immediately after a `bibtex-yank' or a
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
4131 `bibtex-yank-pop'. In this case, the region contains a reinserted
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
4132 previously killed BibTeX item. `bibtex-yank-pop' deletes that item
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
4133 and inserts in its place a different killed BibTeX item.
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
4134
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
4135 With no argument, the previous kill is inserted.
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
4136 With argument N, insert the Nth previous kill.
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
4137 If N is negative, this is a more recent kill.
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
4138
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
4139 The sequence of kills wraps around, so that after the oldest one
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
4140 comes the newest one."
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
4141 (interactive "*p")
57054
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
4142 (unless (eq last-command 'bibtex-yank)
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
4143 (error "Previous command was not a BibTeX yank"))
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
4144 (setq this-command 'bibtex-yank)
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
4145 (let ((inhibit-read-only t))
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
4146 (delete-region (point) (mark t))
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
4147 (bibtex-insert-kill n t)))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
4148
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
4149 (defun bibtex-empty-field (&optional comma)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
4150 "Delete the text part of the current field, replace with empty text.
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
4151 Optional arg COMMA is as in `bibtex-enclosing-field'. It is t for
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
4152 interactive calls."
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
4153 (interactive (list t))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
4154 (let ((bounds (bibtex-enclosing-field comma)))
27701
5e135f0faf1d (bibtex-mode): Replaced manual splitting of path
Gerd Moellmann <gerd@gnu.org>
parents: 26711
diff changeset
4155 (goto-char (bibtex-start-of-text-in-field bounds))
5e135f0faf1d (bibtex-mode): Replaced manual splitting of path
Gerd Moellmann <gerd@gnu.org>
parents: 26711
diff changeset
4156 (delete-region (point) (bibtex-end-of-text-in-field bounds))
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
4157 (insert (bibtex-field-left-delimiter)
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
4158 (bibtex-field-right-delimiter))
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
4159 (bibtex-find-text t nil bibtex-help-message)))
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
4160
14789
d68b71228abd (bibtex-pop): New generic function which unifies the
Richard M. Stallman <rms@gnu.org>
parents: 14410
diff changeset
4161 (defun bibtex-pop-previous (arg)
19461
6b67f20dd710 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 19460
diff changeset
4162 "Replace text of current field with the similar field in previous entry.
22563
2e2a71dfec63 Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents: 21169
diff changeset
4163 With arg, goes up ARG entries. Repeated, goes up so many times. May be
14789
d68b71228abd (bibtex-pop): New generic function which unifies the
Richard M. Stallman <rms@gnu.org>
parents: 14410
diff changeset
4164 intermixed with \\[bibtex-pop-next] (bibtex-pop-next)."
d68b71228abd (bibtex-pop): New generic function which unifies the
Richard M. Stallman <rms@gnu.org>
parents: 14410
diff changeset
4165 (interactive "p")
d68b71228abd (bibtex-pop): New generic function which unifies the
Richard M. Stallman <rms@gnu.org>
parents: 14410
diff changeset
4166 (bibtex-pop arg 'previous))
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4167
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4168 (defun bibtex-pop-next (arg)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4169 "Replace text of current field with the text of similar field in next entry.
22563
2e2a71dfec63 Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents: 21169
diff changeset
4170 With arg, goes down ARG entries. Repeated, goes down so many times. May be
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4171 intermixed with \\[bibtex-pop-previous] (bibtex-pop-previous)."
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4172 (interactive "p")
14789
d68b71228abd (bibtex-pop): New generic function which unifies the
Richard M. Stallman <rms@gnu.org>
parents: 14410
diff changeset
4173 (bibtex-pop arg 'next))
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4174
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4175 (defun bibtex-clean-entry (&optional new-key called-by-reformat)
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
4176 "Finish editing the current BibTeX entry and clean it up.
97521
c383ec0fd021 (bibtex-entry-format): Mark as safe.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94670
diff changeset
4177 Check that no required fields are empty and format entry dependent
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4178 on the value of `bibtex-entry-format'.
27701
5e135f0faf1d (bibtex-mode): Replaced manual splitting of path
Gerd Moellmann <gerd@gnu.org>
parents: 26711
diff changeset
4179 If the reference key of the entry is empty or a prefix argument is given,
58772
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
4180 calculate a new reference key. (Note: this works only if fields in entry
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4181 begin on separate lines prior to calling `bibtex-clean-entry' or if
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4182 'realign is contained in `bibtex-entry-format'.)
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
4183 Don't call `bibtex-clean-entry' on @Preamble entries.
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
4184 At end of the cleaning process, the functions in
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4185 `bibtex-clean-entry-hook' are called with region narrowed to entry."
81591
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4186 ;; Opt. arg CALLED-BY-REFORMAT is t if `bibtex-clean-entry'
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4187 ;; is called by `bibtex-reformat'
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
4188 (interactive "P")
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4189 (let ((case-fold-search t)
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
4190 (start (bibtex-beginning-of-entry))
70841
2a874a2efaf4 (bibtex-format-entry, bibtex-clean-entry):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70837
diff changeset
4191 (_ (or (looking-at bibtex-any-entry-maybe-empty-head)
2a874a2efaf4 (bibtex-format-entry, bibtex-clean-entry):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70837
diff changeset
4192 (error "Not inside a BibTeX entry")))
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
4193 (entry-type (bibtex-type-in-head))
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
4194 (key (bibtex-key-in-head)))
91913
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
4195 (cond ((bibtex-string= entry-type "preamble")
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
4196 ;; (bibtex-format-preamble)
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
4197 (error "No clean up of @Preamble entries"))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
4198 ((bibtex-string= entry-type "string")
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
4199 (setq entry-type 'string))
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
4200 ;; (bibtex-format-string)
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
4201 (t (bibtex-format-entry)))
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
4202 ;; set key
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4203 (when (or new-key (not key))
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
4204 (setq key (bibtex-generate-autokey))
81591
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4205 ;; Sometimes `bibtex-generate-autokey' returns an empty string
57054
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
4206 (if (or bibtex-autokey-edit-before-use (string= "" key))
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
4207 (setq key (if (eq entry-type 'string)
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
4208 (bibtex-read-string-key key)
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
4209 (bibtex-read-key "Key to use: " key))))
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
4210 (save-excursion
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
4211 (re-search-forward (if (eq entry-type 'string)
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
4212 bibtex-string-maybe-empty-head
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
4213 bibtex-entry-maybe-empty-head))
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
4214 (if (match-beginning bibtex-key-in-head)
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
4215 (delete-region (match-beginning bibtex-key-in-head)
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
4216 (match-end bibtex-key-in-head)))
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
4217 (insert key)))
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
4218
55312
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
4219 (unless called-by-reformat
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
4220 (let* ((end (save-excursion
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
4221 (bibtex-end-of-entry)
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
4222 (if (re-search-forward
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
4223 bibtex-entry-maybe-empty-head nil 'move)
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
4224 (goto-char (match-beginning 0)))
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
4225 (point)))
55312
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
4226 (entry (buffer-substring start end))
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
4227 ;; include the crossref key in index
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
4228 (index (let ((bibtex-maintain-sorted-entries 'crossref))
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
4229 (bibtex-entry-index))) ; moves point to end of head
57054
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
4230 error)
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
4231 ;; sorting
55312
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
4232 (if (and bibtex-maintain-sorted-entries
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
4233 (not (and bibtex-sort-ignore-string-entries
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
4234 (eq entry-type 'string))))
55312
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
4235 (progn
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
4236 (delete-region start end)
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
4237 (setq error (not (bibtex-prepare-new-entry index))
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
4238 start (point)) ; update start
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
4239 (save-excursion (insert entry)))
91913
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
4240 (bibtex-search-entry key)
57054
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
4241 (setq error (or (/= (point) start)
91913
ec78aa675c78 (bibtex-search-entry): Rename from bibtex-find-entry.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87650
diff changeset
4242 (bibtex-search-entry key nil end))))
57054
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
4243 (if error
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
4244 (error "New inserted entry yields duplicate key"))
87650
29fbecdf9527 (bibtex-initialize): New autoloaded command. Rename from function
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 87649
diff changeset
4245 (dolist (buffer (bibtex-initialize))
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
4246 (with-current-buffer buffer
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
4247 (if (cdr (assoc-string key bibtex-reference-keys))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
4248 (error "Duplicate key in %s" (buffer-file-name)))))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
4249
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
4250 ;; Only update the list of keys if it has been built already.
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
4251 (cond ((eq entry-type 'string)
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
4252 (if (and (listp bibtex-strings)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
4253 (not (assoc key bibtex-strings)))
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
4254 (push (cons key (bibtex-text-in-string
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
4255 (bibtex-parse-string) t))
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
4256 bibtex-strings)))
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
4257 ;; We have a normal entry.
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
4258 ((listp bibtex-reference-keys)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
4259 (cond ((not (assoc key bibtex-reference-keys))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
4260 (push (cons key t) bibtex-reference-keys))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
4261 ((not (cdr (assoc key bibtex-reference-keys)))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
4262 ;; Turn a crossref key into a header key
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
4263 (setq bibtex-reference-keys
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
4264 (cons (cons key t)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
4265 (delete (list key) bibtex-reference-keys)))))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
4266 ;; Handle crossref key.
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
4267 (if (and (nth 1 index)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
4268 (not (assoc (nth 1 index) bibtex-reference-keys)))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
4269 (push (list (nth 1 index)) bibtex-reference-keys)))))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
4270
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
4271 ;; final clean up
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
4272 (if bibtex-clean-entry-hook
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
4273 (save-excursion
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
4274 (save-restriction
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
4275 (bibtex-narrow-to-entry)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
4276 (run-hooks 'bibtex-clean-entry-hook)))))))
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
4277
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
4278 (defun bibtex-fill-field-bounds (bounds justify &optional move)
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
4279 "Fill BibTeX field delimited by BOUNDS.
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
4280 If JUSTIFY is non-nil justify as well.
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
4281 If optional arg MOVE is non-nil move point to end of field."
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
4282 (let ((end-field (copy-marker (bibtex-end-of-field bounds))))
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
4283 (if (not justify)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
4284 (goto-char (bibtex-start-of-text-in-field bounds))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
4285 (goto-char (bibtex-start-of-field bounds))
81591
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4286 (forward-char) ; leading comma
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
4287 (bibtex-delete-whitespace)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
4288 (open-line 1)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
4289 (forward-char)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
4290 (indent-to-column (+ bibtex-entry-offset
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
4291 bibtex-field-indentation))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
4292 (re-search-forward "[ \t\n]*=" end-field)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
4293 (replace-match "=")
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
4294 (forward-char -1)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
4295 (if bibtex-align-at-equal-sign
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
4296 (indent-to-column
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
4297 (+ bibtex-entry-offset (- bibtex-text-indentation 2)))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
4298 (insert " "))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
4299 (forward-char)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
4300 (bibtex-delete-whitespace)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
4301 (if bibtex-align-at-equal-sign
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
4302 (insert " ")
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
4303 (indent-to-column bibtex-text-indentation)))
81591
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4304 ;; Paragraphs within fields are not preserved. Bother?
65776
a2bc28552d90 2005-10-01 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Romain Francoise <romain@orebokech.com>
parents: 65583
diff changeset
4305 (fill-region-as-paragraph (line-beginning-position) end-field
a2bc28552d90 2005-10-01 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Romain Francoise <romain@orebokech.com>
parents: 65583
diff changeset
4306 default-justification nil (point))
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
4307 (if move (goto-char end-field))))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
4308
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
4309 (defun bibtex-fill-field (&optional justify)
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
4310 "Like \\[fill-paragraph], but fill current BibTeX field.
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
4311 If optional prefix JUSTIFY is non-nil justify as well.
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
4312 In BibTeX mode this function is bound to `fill-paragraph-function'."
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
4313 (interactive "*P")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
4314 (let ((pnt (copy-marker (point)))
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
4315 (bounds (bibtex-enclosing-field t)))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
4316 (bibtex-fill-field-bounds bounds justify)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
4317 (goto-char pnt)))
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
4318
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
4319 (defun bibtex-fill-entry ()
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4320 "Fill current BibTeX entry.
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4321 Realign entry, so that every field starts on a separate line. Field
19461
6b67f20dd710 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 19460
diff changeset
4322 names appear in column `bibtex-field-indentation', field text starts in
22563
2e2a71dfec63 Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents: 21169
diff changeset
4323 column `bibtex-text-indentation' and continuation lines start here, too.
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
4324 If `bibtex-align-at-equal-sign' is non-nil, align equal signs, too."
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
4325 (interactive "*")
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
4326 (let ((pnt (copy-marker (point)))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4327 (end (copy-marker (bibtex-end-of-entry)))
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
4328 (beg (bibtex-beginning-of-entry)) ; move point
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4329 bounds)
18247
ae094c1a4334 (bibtex-delete-whitespace, bibtex-current-line)
Richard M. Stallman <rms@gnu.org>
parents: 18212
diff changeset
4330 (bibtex-delete-whitespace)
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
4331 (indent-to-column bibtex-entry-offset)
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
4332 (bibtex-beginning-first-field beg)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
4333 (while (setq bounds (bibtex-parse-field))
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
4334 (bibtex-fill-field-bounds bounds t t))
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
4335 (if (looking-at ",")
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
4336 (forward-char))
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
4337 (skip-chars-backward " \t\n")
18247
ae094c1a4334 (bibtex-delete-whitespace, bibtex-current-line)
Richard M. Stallman <rms@gnu.org>
parents: 18212
diff changeset
4338 (bibtex-delete-whitespace)
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
4339 (open-line 1)
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
4340 (forward-char)
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
4341 (indent-to-column bibtex-entry-offset)
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
4342 (goto-char pnt)))
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
4343
55312
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
4344 (defun bibtex-realign ()
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
4345 "Realign BibTeX entries such that they are separated by one blank line."
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
4346 (goto-char (point-min))
65776
a2bc28552d90 2005-10-01 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Romain Francoise <romain@orebokech.com>
parents: 65583
diff changeset
4347 (let ((case-fold-search t)
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
4348 (entry-type (concat "[ \t\n]*\\(" bibtex-entry-type "\\)")))
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
4349 ;; No blank lines prior to the first entry if there no
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
4350 ;; non-white characters in front of it.
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
4351 (when (looking-at entry-type)
55312
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
4352 (replace-match "\\1"))
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
4353 ;; Entries are separated by one blank line.
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
4354 (while (re-search-forward entry-type nil t)
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
4355 (replace-match "\n\n\\1"))
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
4356 ;; One blank line past the last entry if it is followed by
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
4357 ;; non-white characters, no blank line otherwise.
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
4358 (beginning-of-line)
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
4359 (when (re-search-forward bibtex-entry-type nil t)
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
4360 (bibtex-end-of-entry)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
4361 (bibtex-delete-whitespace)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
4362 (open-line (if (eobp) 1 2)))))
55312
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
4363
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
4364 (defun bibtex-reformat (&optional read-options)
19461
6b67f20dd710 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 19460
diff changeset
4365 "Reformat all BibTeX entries in buffer or region.
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
4366 Without prefix argument, reformatting is based on `bibtex-entry-format'.
19461
6b67f20dd710 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 19460
diff changeset
4367 With prefix argument, read options for reformatting from minibuffer.
22563
2e2a71dfec63 Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents: 21169
diff changeset
4368 With \\[universal-argument] \\[universal-argument] prefix argument, reuse previous answers (if any) again.
55312
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
4369 If mark is active reformat entries in region, if not in whole buffer."
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
4370 (interactive "*P")
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
4371 (let* ((pnt (point))
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
4372 (use-previous-options
55312
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
4373 (and (equal (prefix-numeric-value read-options) 16)
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
4374 (or bibtex-reformat-previous-options
27701
5e135f0faf1d (bibtex-mode): Replaced manual splitting of path
Gerd Moellmann <gerd@gnu.org>
parents: 26711
diff changeset
4375 bibtex-reformat-previous-reference-keys)))
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
4376 (bibtex-entry-format
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
4377 (cond (read-options
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
4378 (if use-previous-options
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
4379 bibtex-reformat-previous-options
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
4380 (setq bibtex-reformat-previous-options
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
4381 (mapcar (lambda (option)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
4382 (if (y-or-n-p (car option)) (cdr option)))
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
4383 `(("Realign entries (recommended)? " . 'realign)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
4384 ("Remove empty optional and alternative fields? " . 'opts-or-alts)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
4385 ("Remove delimiters around pure numerical fields? " . 'numerical-fields)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
4386 (,(concat (if bibtex-comma-after-last-field "Insert" "Remove")
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
4387 " comma at end of entry? ") . 'last-comma)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
4388 ("Replace double page dashes by single ones? " . 'page-dashes)
81591
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4389 ("Delete whitespace at the beginning and end of fields? " . 'whitespace)
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
4390 ("Inherit booktitle? " . 'inherit-booktitle)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
4391 ("Force delimiters? " . 'delimiters)
81591
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4392 ("Unify case of entry types and field names? " . 'unify-case)
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4393 ("Enclose parts of field entries by braces? " . 'braces)
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4394 ("Replace parts of field entries by string constants? " . 'strings))))))
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
4395 ;; Do not include required-fields because `bibtex-reformat'
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
4396 ;; cannot handle the error messages of `bibtex-format-entry'.
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
4397 ;; Use `bibtex-validate' to check for required fields.
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
4398 ((eq t bibtex-entry-format)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
4399 '(realign opts-or-alts numerical-fields delimiters
81591
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4400 last-comma page-dashes unify-case inherit-booktitle
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4401 whitespace braces strings))
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
4402 (t
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
4403 (remove 'required-fields (push 'realign bibtex-entry-format)))))
55312
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
4404 (reformat-reference-keys
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
4405 (if read-options
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
4406 (if use-previous-options
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
4407 bibtex-reformat-previous-reference-keys
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
4408 (setq bibtex-reformat-previous-reference-keys
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
4409 (y-or-n-p "Generate new reference keys automatically? ")))))
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
4410 (bibtex-sort-ignore-string-entries t)
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
4411 bibtex-autokey-edit-before-use)
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
4412
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
4413 (save-restriction
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
4414 (if mark-active (narrow-to-region (region-beginning) (region-end)))
55312
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
4415 (if (memq 'realign bibtex-entry-format)
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
4416 (bibtex-realign))
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
4417 (bibtex-progress-message "Formatting" 1)
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
4418 (bibtex-map-entries (lambda (key beg end)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4419 (bibtex-progress-message)
55312
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
4420 (bibtex-clean-entry reformat-reference-keys t)))
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
4421 (bibtex-progress-message 'done))
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
4422 (when reformat-reference-keys
55312
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
4423 (kill-local-variable 'bibtex-reference-keys)
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
4424 (when bibtex-maintain-sorted-entries
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
4425 (bibtex-progress-message "Sorting" 1)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
4426 (bibtex-sort-buffer)
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
4427 (bibtex-progress-message 'done)))
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
4428 (goto-char pnt)))
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
4429
55312
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
4430 (defun bibtex-convert-alien (&optional read-options)
58772
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
4431 "Make an alien BibTeX buffer fully usable by BibTeX mode.
55312
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
4432 If a file does not conform with all standards used by BibTeX mode,
58772
4de7ab2c086e (bibtex-font-lock-url-regexp):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58556
diff changeset
4433 some of the high-level features of BibTeX mode are not available.
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4434 This function tries to convert current buffer to conform with these standards.
55312
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
4435 With prefix argument READ-OPTIONS non-nil, read options for reformatting
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
4436 entries from minibuffer."
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
4437 (interactive "*P")
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
4438 (message "Starting to validate buffer...")
91992
d490a1f4c1b9 (bibtex-convert-alien): Do not use optional args in calls of sit-for.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 91913
diff changeset
4439 (sit-for 1)
55312
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
4440 (bibtex-realign)
81591
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4441 (deactivate-mark) ; So `bibtex-validate' works on the whole buffer.
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
4442 (if (not (let (bibtex-maintain-sorted-entries)
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
4443 (bibtex-validate)))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
4444 (message "Correct errors and call `bibtex-convert-alien' again")
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4445 (message "Starting to reformat entries...")
91992
d490a1f4c1b9 (bibtex-convert-alien): Do not use optional args in calls of sit-for.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 91913
diff changeset
4446 (sit-for 2)
55312
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
4447 (bibtex-reformat read-options)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4448 (goto-char (point-max))
81591
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4449 (message "Buffer is now parsable. Please save it.")))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4450
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4451 (defun bibtex-complete ()
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4452 "Complete word fragment before point according to context.
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
4453 If point is inside key or crossref field perform key completion based on
57054
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
4454 `bibtex-reference-keys'. Inside a month field perform key completion
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
4455 based on `bibtex-predefined-month-strings'. Inside any other field
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
4456 \(including a String or Preamble definition) perform string completion
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
4457 based on `bibtex-strings'.
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
4458 An error is signaled if point is outside key or BibTeX field."
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4459 (interactive)
57054
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
4460 (let ((pnt (point))
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
4461 (case-fold-search t)
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
4462 bounds name compl)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4463 (save-excursion
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
4464 (if (and (setq bounds (bibtex-enclosing-field nil t))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4465 (>= pnt (bibtex-start-of-text-in-field bounds))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4466 (<= pnt (bibtex-end-of-text-in-field bounds)))
57054
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
4467 (setq name (bibtex-name-in-field bounds t)
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
4468 compl (cond ((bibtex-string= name "crossref")
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
4469 ;; point is in crossref field
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
4470 'crossref-key)
57054
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
4471 ((bibtex-string= name "month")
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
4472 ;; point is in month field
57054
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
4473 bibtex-predefined-month-strings)
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
4474 ;; point is in other field
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
4475 (t (bibtex-strings))))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4476 (bibtex-beginning-of-entry)
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
4477 (cond ((setq bounds (bibtex-parse-string t))
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
4478 ;; point is inside a @String key
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
4479 (cond ((and (>= pnt (nth 1 (car bounds)))
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
4480 (<= pnt (nth 2 (car bounds))))
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
4481 (setq compl 'string))
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
4482 ;; point is inside a @String field
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
4483 ((and (>= pnt (bibtex-start-of-text-in-string bounds))
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
4484 (<= pnt (bibtex-end-of-text-in-string bounds)))
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
4485 (setq compl (bibtex-strings)))))
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
4486 ;; point is inside a @Preamble field
67894
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
4487 ((setq bounds (bibtex-parse-preamble))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
4488 (if (and (>= pnt (bibtex-start-of-text-in-string bounds))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
4489 (<= pnt (bibtex-end-of-text-in-string bounds)))
d742983a2136 (bibtex-entry-type-whitespace)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67816
diff changeset
4490 (setq compl (bibtex-strings))))
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
4491 ((and (looking-at bibtex-entry-maybe-empty-head)
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
4492 ;; point is inside a key
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
4493 (or (and (match-beginning bibtex-key-in-head)
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
4494 (>= pnt (match-beginning bibtex-key-in-head))
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
4495 (<= pnt (match-end bibtex-key-in-head)))
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
4496 ;; or point is on empty key
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
4497 (and (not (match-beginning bibtex-key-in-head))
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
4498 (= pnt (match-end 0)))))
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
4499 (setq compl 'key)))))
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
4500
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
4501 (cond ((eq compl 'key)
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
4502 ;; key completion: no cleanup needed
69581
98eee222dceb * textmodes/bibtex.el (bibtex-include-OPTkey)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 68648
diff changeset
4503 (setq choose-completion-string-functions nil)
98eee222dceb * textmodes/bibtex.el (bibtex-include-OPTkey)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 68648
diff changeset
4504 (let (completion-ignore-case)
98eee222dceb * textmodes/bibtex.el (bibtex-include-OPTkey)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 68648
diff changeset
4505 (bibtex-complete-internal (bibtex-global-key-alist))))
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
4506
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
4507 ((eq compl 'crossref-key)
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
4508 ;; crossref key completion
67933
679e4542aaa9 (bibtex-mode): Make completion-ignore-case
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67897
diff changeset
4509 ;;
679e4542aaa9 (bibtex-mode): Make completion-ignore-case
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67897
diff changeset
4510 ;; If we quit the *Completions* buffer without requesting
679e4542aaa9 (bibtex-mode): Make completion-ignore-case
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67897
diff changeset
4511 ;; a completion, `choose-completion-string-functions' is still
81591
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4512 ;; non-nil. Therefore, `choose-completion-string-functions' is
67933
679e4542aaa9 (bibtex-mode): Make completion-ignore-case
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67897
diff changeset
4513 ;; always set (either to non-nil or nil) when a new completion
679e4542aaa9 (bibtex-mode): Make completion-ignore-case
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67897
diff changeset
4514 ;; is requested.
69581
98eee222dceb * textmodes/bibtex.el (bibtex-include-OPTkey)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 68648
diff changeset
4515 (let (completion-ignore-case)
98eee222dceb * textmodes/bibtex.el (bibtex-include-OPTkey)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 68648
diff changeset
4516 (setq choose-completion-string-functions
98eee222dceb * textmodes/bibtex.el (bibtex-include-OPTkey)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 68648
diff changeset
4517 (lambda (choice buffer mini-p base-size)
98eee222dceb * textmodes/bibtex.el (bibtex-include-OPTkey)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 68648
diff changeset
4518 (setq choose-completion-string-functions nil)
98eee222dceb * textmodes/bibtex.el (bibtex-include-OPTkey)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 68648
diff changeset
4519 (choose-completion-string choice buffer base-size)
98eee222dceb * textmodes/bibtex.el (bibtex-include-OPTkey)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 68648
diff changeset
4520 (bibtex-complete-crossref-cleanup choice)
98eee222dceb * textmodes/bibtex.el (bibtex-include-OPTkey)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 68648
diff changeset
4521 t)) ; needed by choose-completion-string-functions
98eee222dceb * textmodes/bibtex.el (bibtex-include-OPTkey)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 68648
diff changeset
4522 (bibtex-complete-crossref-cleanup
98eee222dceb * textmodes/bibtex.el (bibtex-include-OPTkey)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 68648
diff changeset
4523 (bibtex-complete-internal (bibtex-global-key-alist)))))
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
4524
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
4525 ((eq compl 'string)
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
4526 ;; string key completion: no cleanup needed
69581
98eee222dceb * textmodes/bibtex.el (bibtex-include-OPTkey)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 68648
diff changeset
4527 (setq choose-completion-string-functions nil)
98eee222dceb * textmodes/bibtex.el (bibtex-include-OPTkey)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 68648
diff changeset
4528 (let ((completion-ignore-case t))
98eee222dceb * textmodes/bibtex.el (bibtex-include-OPTkey)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 68648
diff changeset
4529 (bibtex-complete-internal bibtex-strings)))
57054
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
4530
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
4531 (compl
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4532 ;; string completion
69581
98eee222dceb * textmodes/bibtex.el (bibtex-include-OPTkey)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 68648
diff changeset
4533 (let ((completion-ignore-case t))
98eee222dceb * textmodes/bibtex.el (bibtex-include-OPTkey)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 68648
diff changeset
4534 (setq choose-completion-string-functions
98eee222dceb * textmodes/bibtex.el (bibtex-include-OPTkey)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 68648
diff changeset
4535 `(lambda (choice buffer mini-p base-size)
98eee222dceb * textmodes/bibtex.el (bibtex-include-OPTkey)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 68648
diff changeset
4536 (setq choose-completion-string-functions nil)
98eee222dceb * textmodes/bibtex.el (bibtex-include-OPTkey)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 68648
diff changeset
4537 (choose-completion-string choice buffer base-size)
98eee222dceb * textmodes/bibtex.el (bibtex-include-OPTkey)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 68648
diff changeset
4538 (bibtex-complete-string-cleanup choice ',compl)
81591
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4539 t)) ; needed by `choose-completion-string-functions'
69581
98eee222dceb * textmodes/bibtex.el (bibtex-include-OPTkey)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 68648
diff changeset
4540 (bibtex-complete-string-cleanup (bibtex-complete-internal compl)
98eee222dceb * textmodes/bibtex.el (bibtex-include-OPTkey)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 68648
diff changeset
4541 compl)))
98eee222dceb * textmodes/bibtex.el (bibtex-include-OPTkey)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 68648
diff changeset
4542
98eee222dceb * textmodes/bibtex.el (bibtex-include-OPTkey)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 68648
diff changeset
4543 (t (setq choose-completion-string-functions nil)
67933
679e4542aaa9 (bibtex-mode): Make completion-ignore-case
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 67897
diff changeset
4544 (error "Point outside key or BibTeX field")))))
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
4545
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
4546 (defun bibtex-Article ()
22563
2e2a71dfec63 Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents: 21169
diff changeset
4547 "Insert a new BibTeX @Article entry; see also `bibtex-entry'."
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4548 (interactive "*")
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
4549 (bibtex-entry "Article"))
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
4550
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
4551 (defun bibtex-Book ()
22563
2e2a71dfec63 Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents: 21169
diff changeset
4552 "Insert a new BibTeX @Book entry; see also `bibtex-entry'."
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4553 (interactive "*")
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
4554 (bibtex-entry "Book"))
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
4555
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
4556 (defun bibtex-Booklet ()
22563
2e2a71dfec63 Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents: 21169
diff changeset
4557 "Insert a new BibTeX @Booklet entry; see also `bibtex-entry'."
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4558 (interactive "*")
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
4559 (bibtex-entry "Booklet"))
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
4560
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
4561 (defun bibtex-InBook ()
22563
2e2a71dfec63 Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents: 21169
diff changeset
4562 "Insert a new BibTeX @InBook entry; see also `bibtex-entry'."
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4563 (interactive "*")
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
4564 (bibtex-entry "InBook"))
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
4565
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
4566 (defun bibtex-InCollection ()
22563
2e2a71dfec63 Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents: 21169
diff changeset
4567 "Insert a new BibTeX @InCollection entry; see also `bibtex-entry'."
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4568 (interactive "*")
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
4569 (bibtex-entry "InCollection"))
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
4570
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
4571 (defun bibtex-InProceedings ()
22563
2e2a71dfec63 Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents: 21169
diff changeset
4572 "Insert a new BibTeX @InProceedings entry; see also `bibtex-entry'."
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4573 (interactive "*")
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
4574 (bibtex-entry "InProceedings"))
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
4575
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
4576 (defun bibtex-Manual ()
22563
2e2a71dfec63 Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents: 21169
diff changeset
4577 "Insert a new BibTeX @Manual entry; see also `bibtex-entry'."
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4578 (interactive "*")
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
4579 (bibtex-entry "Manual"))
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
4580
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
4581 (defun bibtex-MastersThesis ()
22563
2e2a71dfec63 Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents: 21169
diff changeset
4582 "Insert a new BibTeX @MastersThesis entry; see also `bibtex-entry'."
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4583 (interactive "*")
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
4584 (bibtex-entry "MastersThesis"))
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
4585
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
4586 (defun bibtex-Misc ()
22563
2e2a71dfec63 Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents: 21169
diff changeset
4587 "Insert a new BibTeX @Misc entry; see also `bibtex-entry'."
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4588 (interactive "*")
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
4589 (bibtex-entry "Misc"))
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
4590
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
4591 (defun bibtex-PhdThesis ()
22563
2e2a71dfec63 Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents: 21169
diff changeset
4592 "Insert a new BibTeX @PhdThesis entry; see also `bibtex-entry'."
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4593 (interactive "*")
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
4594 (bibtex-entry "PhdThesis"))
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
4595
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
4596 (defun bibtex-Proceedings ()
22563
2e2a71dfec63 Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents: 21169
diff changeset
4597 "Insert a new BibTeX @Proceedings entry; see also `bibtex-entry'."
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4598 (interactive "*")
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
4599 (bibtex-entry "Proceedings"))
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
4600
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
4601 (defun bibtex-TechReport ()
22563
2e2a71dfec63 Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents: 21169
diff changeset
4602 "Insert a new BibTeX @TechReport entry; see also `bibtex-entry'."
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4603 (interactive "*")
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
4604 (bibtex-entry "TechReport"))
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
4605
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
4606 (defun bibtex-Unpublished ()
22563
2e2a71dfec63 Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents: 21169
diff changeset
4607 "Insert a new BibTeX @Unpublished entry; see also `bibtex-entry'."
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4608 (interactive "*")
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
4609 (bibtex-entry "Unpublished"))
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
4610
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4611 (defun bibtex-String (&optional key)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4612 "Insert a new BibTeX @String entry with key KEY."
58556
8ff63943e93e (bibtex-sort-entry-class)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57833
diff changeset
4613 (interactive (list (bibtex-read-string-key)))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4614 (let ((bibtex-maintain-sorted-entries
57054
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
4615 (unless bibtex-sort-ignore-string-entries
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
4616 bibtex-maintain-sorted-entries))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4617 endpos)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4618 (unless (bibtex-prepare-new-entry (list key nil "String"))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4619 (error "Entry with key `%s' already exists" key))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4620 (if (zerop (length key)) (setq key nil))
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
4621 (indent-to-column bibtex-entry-offset)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4622 (insert "@String"
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4623 (bibtex-entry-left-delimiter))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4624 (if key
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4625 (insert key)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4626 (setq endpos (point)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4627 (insert " = "
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4628 (bibtex-field-left-delimiter))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4629 (if key
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4630 (setq endpos (point)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4631 (insert (bibtex-field-right-delimiter)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4632 (bibtex-entry-right-delimiter)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4633 "\n")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4634 (goto-char endpos)))
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
4635
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
4636 (defun bibtex-Preamble ()
22563
2e2a71dfec63 Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents: 21169
diff changeset
4637 "Insert a new BibTeX @Preamble entry."
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4638 (interactive "*")
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
4639 (bibtex-move-outside-of-entry)
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
4640 (indent-to-column bibtex-entry-offset)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
4641 (insert "@Preamble"
63470
c318ec40e95f (bibtex-Preamble): Enclose BibTeX preamble by field delimiters.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 62077
diff changeset
4642 (bibtex-entry-left-delimiter)
c318ec40e95f (bibtex-Preamble): Enclose BibTeX preamble by field delimiters.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 62077
diff changeset
4643 (bibtex-field-left-delimiter))
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
4644 (let ((endpos (point)))
67575
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
4645 (insert (bibtex-field-right-delimiter)
d0f7b15488df (bibtex-expand-strings)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66116
diff changeset
4646 (bibtex-entry-right-delimiter)
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
4647 "\n")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
4648 (goto-char endpos)))
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4649
70250
5d4423d8a6f5 (bibtex-url): New optional arg no-browse. Return the URL or nil if
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 70249
diff changeset
4650 (defun bibtex-url (&optional pos no-browse)
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
4651 "Browse a URL for the BibTeX entry at point.
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
4652 Optional POS is the location of the BibTeX entry.
57054
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
4653 The URL is generated using the schemes defined in `bibtex-generate-url-list'
81591
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4654 \(see there\). If multiple schemes match for this entry, or the same scheme
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4655 matches more than once, use the one for which the first step's match is the
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4656 closest to POS. The URL is passed to `browse-url' unless NO-BROWSE is t.
70250
5d4423d8a6f5 (bibtex-url): New optional arg no-browse. Return the URL or nil if
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 70249
diff changeset
4657 Return the URL or nil if none can be generated."
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
4658 (interactive)
81591
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4659 (unless pos (setq pos (point)))
57054
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
4660 (save-excursion
81591
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4661 (goto-char pos)
57054
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
4662 (bibtex-beginning-of-entry)
81591
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4663 (let ((end (save-excursion (bibtex-end-of-entry)))
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4664 (fields-alist (save-excursion (bibtex-parse-entry t)))
57815
3e586af3d7eb Use `button's.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57070
diff changeset
4665 ;; Always ignore case,
57054
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
4666 (case-fold-search t)
81591
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4667 text url scheme obj fmt fl-match step)
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4668 ;; The return value of `bibtex-parse-entry' (i.e., FIELDS-ALIST)
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4669 ;; is always used to generate the URL. However, if the BibTeX
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4670 ;; entry contains more than one URL, we have multiple matches
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4671 ;; for the first step defining the generation of the URL.
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4672 ;; Therefore, we try to initiate the generation of the URL
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4673 ;; based on the match of `bibtex-font-lock-url' that is the
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4674 ;; closest to POS. If that fails (no match found) we try to
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4675 ;; initiate the generation of the URL based on the properly
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4676 ;; concatenated CONTENT of the field as returned by
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4677 ;; `bibtex-text-in-field-bounds'. The latter approach can
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4678 ;; differ from the former because `bibtex-font-lock-url' uses
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4679 ;; the buffer itself.
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4680 (while (bibtex-font-lock-url end t)
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4681 (push (list (bibtex-dist pos (match-beginning 0) (match-end 0))
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4682 (match-beginning 0)
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4683 (buffer-substring-no-properties
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4684 (match-beginning 0) (match-end 0)))
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4685 fl-match)
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4686 ;; `bibtex-font-lock-url' moves point to end of match.
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4687 (forward-char))
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4688 (when fl-match
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4689 (setq fl-match (car (sort fl-match (lambda (x y) (< (car x) (car y))))))
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4690 (goto-char (nth 1 fl-match))
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4691 (bibtex-beginning-of-field) (re-search-backward ",")
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4692 (let* ((bounds (bibtex-parse-field))
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4693 (name (bibtex-name-in-field bounds))
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4694 (content (bibtex-text-in-field-bounds bounds t))
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4695 (lst bibtex-generate-url-list))
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4696 ;; This match can fail when CONTENT differs from text in buffer.
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4697 (when (string-match (regexp-quote (nth 2 fl-match)) content)
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4698 ;; TEXT is the part of CONTENT that starts with the match
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4699 ;; of `bibtex-font-lock-url' we are looking for.
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4700 (setq text (substring content (match-beginning 0)))
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4701 (while (and (not url) (setq scheme (pop lst)))
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4702 ;; Verify the match of `bibtex-font-lock-url' by
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4703 ;; comparing with TEXT.
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4704 (when (and (bibtex-string= (caar scheme) name)
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4705 (string-match (cdar scheme) text))
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4706 (setq url t scheme (cdr scheme)))))))
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4707
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4708 ;; If the match of `bibtex-font-lock-url' was not approved
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4709 ;; parse FIELDS-ALIST, i.e., the output of `bibtex-parse-entry'.
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4710 (unless url
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4711 (let ((lst bibtex-generate-url-list))
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4712 (while (and (not url) (setq scheme (pop lst)))
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4713 (when (and (setq text (cdr (assoc-string (caar scheme)
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4714 fields-alist t)))
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4715 (string-match (cdar scheme) text))
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4716 (setq url t scheme (cdr scheme))))))
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4717
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4718 (when url
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4719 (setq url (if (null scheme) (match-string 0 text)
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4720 (if (stringp (car scheme))
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4721 (setq fmt (pop scheme)))
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4722 (dotimes (i (length scheme))
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4723 (setq step (nth i scheme))
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4724 ;; The first step shall use TEXT as obtained earlier.
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4725 (unless (= i 0)
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4726 (setq text (cdr (assoc-string (car step) fields-alist t))))
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4727 (if (string-match (nth 1 step) text)
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4728 (push (cond ((functionp (nth 2 step))
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4729 (funcall (nth 2 step) text))
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4730 ((numberp (nth 2 step))
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4731 (match-string (nth 2 step) text))
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4732 (t
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4733 (replace-match (nth 2 step) t nil text)))
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4734 obj)
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4735 ;; If SCHEME is set up correctly,
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4736 ;; we should never reach this point
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4737 (error "Match failed: %s" text)))
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4738 (if fmt (apply 'format fmt (nreverse obj))
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4739 (apply 'concat (nreverse obj)))))
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4740 (if (interactive-p) (message "%s" url))
33952a25e52a (bibtex-entry-format): New options `whitespace', `braces', and `string'.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 77281
diff changeset
4741 (unless no-browse (browse-url url)))
70250
5d4423d8a6f5 (bibtex-url): New optional arg no-browse. Return the URL or nil if
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 70249
diff changeset
4742 (if (and (not url) (interactive-p)) (message "No URL known."))
5d4423d8a6f5 (bibtex-url): New optional arg no-browse. Return the URL or nil if
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 70249
diff changeset
4743 url)))
57054
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
4744
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4745
12700
b3a8ee2da96a Add keywords and comments as per conventions.
Richard M. Stallman <rms@gnu.org>
parents: 12028
diff changeset
4746 ;; Make BibTeX a Feature
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4747
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
4748 (provide 'bibtex)
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
4749
55348
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
4750 ;; arch-tag: ee2be3af-caad-427f-b42a-d20fad630d04
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
4751 ;;; bibtex.el ends here