annotate lisp/textmodes/bibtex.el @ 57279:c8797551b3a0

(diff-file-header-re): Tighten up regexp a tiny bit. (diff-fixup-modifs): Catch unified-diff file-headers.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Wed, 29 Sep 2004 17:42:50 +0000
parents 3d9707888790
children 3e586af3d7eb 566253900690
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
57070
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
3 ;; Copyright (C) 1992, 1994, 1995, 1996, 1997, 1998, 1999, 2003, 2004
55348
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
4 ;; 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>
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
8 ;; Mark Shapiro <shapiro@corto.inria.fr>
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
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
17 ;; GNU Emacs is free software; you can redistribute it and/or modify
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
1851
b3ce1eae3eb0 Update GPL version.
Richard M. Stallman <rms@gnu.org>
parents: 845
diff changeset
19 ;; the Free Software Foundation; either version 2, or (at your option)
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
20 ;; any later version.
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
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13968
diff changeset
28 ;; along with GNU Emacs; see the file COPYING. If not, write to the
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13968
diff changeset
29 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13968
diff changeset
30 ;; Boston, MA 02111-1307, USA.
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
31
12700
b3a8ee2da96a Add keywords and comments as per conventions.
Richard M. Stallman <rms@gnu.org>
parents: 12028
diff changeset
32 ;;; Commentary:
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13968
diff changeset
33
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
34 ;; Major mode for editing and validating BibTeX files.
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
35
12700
b3a8ee2da96a Add keywords and comments as per conventions.
Richard M. Stallman <rms@gnu.org>
parents: 12028
diff changeset
36 ;; Usage:
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
37 ;; See documentation for function bibtex-mode (or type "\M-x describe-mode"
19461
6b67f20dd710 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 19460
diff changeset
38 ;; 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
39
12700
b3a8ee2da96a Add keywords and comments as per conventions.
Richard M. Stallman <rms@gnu.org>
parents: 12028
diff changeset
40 ;; Todo:
b3a8ee2da96a Add keywords and comments as per conventions.
Richard M. Stallman <rms@gnu.org>
parents: 12028
diff changeset
41 ;; Distribute texinfo file.
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
42
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
43 ;;; Code:
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
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
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
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
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
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
57070
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
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
57070
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
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")
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
76 "*List of 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
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
81 "*If non-nil, all entries will have an OPTkey field.
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
82 If this is a string, it will be used as the initial field text.
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
83 If this is a function, it will be called to generate the initial field text."
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")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
87 (function :tag "Initialize Function" :value fun)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
88 (other :tag "Default" t)))
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
89
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
90 (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
91 '(("annote" "Personal annotation (ignored)"))
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
92 "*List of optional fields the user wants to have always present.
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
93 Entries should be of the same form as the OPTIONAL and
19461
6b67f20dd710 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 19460
diff changeset
94 CROSSREF-OPTIONAL lists in `bibtex-entry-field-alist' (see documentation
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
95 of this variable for details)."
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")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
99 (option (group :inline t
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
100 :extra-offset -4
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
101 (choice :tag "Init" :value ""
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
102 string
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
103 function))))))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
104
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
105 (defcustom bibtex-entry-format
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
106 '(opts-or-alts required-fields numerical-fields)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
107 "*Type of formatting performed by `bibtex-clean-entry'.
22563
2e2a71dfec63 Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents: 21169
diff changeset
108 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
109 opts-or-alts Delete empty optional and alternative fields and
6b67f20dd710 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 19460
diff changeset
110 remove OPT and ALT prefixes from used fields.
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
111 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
112 numerical-fields Delete delimiters around numeral fields.
6b67f20dd710 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 19460
diff changeset
113 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
114 (for scribe compatibility).
6b67f20dd710 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 19460
diff changeset
115 inherit-booktitle If entry contains a crossref field and booktitle
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
116 field is empty, it is set to the contents of the
19461
6b67f20dd710 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 19460
diff changeset
117 title field of the crossreferenced entry.
6b67f20dd710 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 19460
diff changeset
118 Caution: this will work only if buffer is
6b67f20dd710 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 19460
diff changeset
119 correctly sorted.
6b67f20dd710 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 19460
diff changeset
120 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
121 signs (depending on the value of
22563
2e2a71dfec63 Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents: 21169
diff changeset
122 `bibtex-align-at-equal-sign') begin in the same column.
19461
6b67f20dd710 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 19460
diff changeset
123 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
124 according to value of `bibtex-comma-after-last-field'.
6b67f20dd710 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 19460
diff changeset
125 delimiters Change delimiters according to variables
6b67f20dd710 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 19460
diff changeset
126 `bibtex-field-delimiters' and `bibtex-entry-delimiters'.
6b67f20dd710 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 19460
diff changeset
127 unify-case Change case of entry and field names.
6b67f20dd710 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 19460
diff changeset
128
6b67f20dd710 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 19460
diff changeset
129 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
130 The value nil means do no formatting at all."
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
131 :group 'bibtex
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
132 :type '(choice (const :tag "None" nil)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
133 (const :tag "All" t)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
134 (set :menu-tag "Some"
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
135 (const opts-or-alts)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
136 (const required-fields)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
137 (const numerical-fields)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
138 (const page-dashes)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
139 (const inherit-booktitle)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
140 (const realign)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
141 (const last-comma)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
142 (const delimiters)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
143 (const unify-case))))
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
144
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
145 (defcustom bibtex-clean-entry-hook nil
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
146 "*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
147 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
148 narrowed to just the entry."
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
149 :group 'bibtex
20907
9a55a557cb5a (bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents: 20866
diff changeset
150 :type 'hook)
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
151
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
152 (defcustom bibtex-maintain-sorted-entries nil
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
153 "*If non-nil, BibTeX mode maintains all BibTeX 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
154 Allowed non-nil values are:
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
155 plain All entries are sorted alphabetically.
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
156 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
157 crossref field. These crossrefed entries are placed in
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
158 alphabetical order immediately preceding the main entry.
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
159 entry-class The entries are divided into classes according to their
57070
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
160 entry name, see `bibtex-sort-entry-class'. Within each class
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
161 the entries are sorted alphabetically.
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
162 See also `bibtex-sort-ignore-string-entries'."
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
163 :group 'bibtex
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
164 :type '(choice (const nil)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
165 (const plain)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
166 (const crossref)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
167 (const entry-class)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
168
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
169 (defvar bibtex-sort-entry-class
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
170 '(("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
171 (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
172 ("Book" "Proceedings"))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
173 "*List of classes of BibTeX entry names, 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
174 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
175 entries are ordered according to the classes they belong to. Each
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
176 class contains a list of entry names. An entry `catch-all' applies
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
177 to all entries not explicitely mentioned.")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
178
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
179 (defcustom bibtex-sort-ignore-string-entries t
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
180 "*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
181 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
182 \(e.g., sorting, locating alphabetical position for new entries, etc.)."
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
183 :group 'bibtex
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
184 :type 'boolean)
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
185
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
186 (defcustom bibtex-field-kill-ring-max 20
19461
6b67f20dd710 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 19460
diff changeset
187 "*Max length of `bibtex-field-kill-ring' before discarding oldest elements."
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
188 :group 'bibtex
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
189 :type 'integer)
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
190
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
191 (defcustom bibtex-entry-kill-ring-max 20
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
192 "*Max length of `bibtex-entry-kill-ring' before discarding oldest elements."
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
193 :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
194 :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
195
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
196 (defcustom bibtex-parse-keys-timeout 60
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
197 "*Specify interval for parsing BibTeX buffers.
22563
2e2a71dfec63 Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents: 21169
diff changeset
198 All BibTeX buffers in Emacs are parsed if Emacs has been idle
19461
6b67f20dd710 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 19460
diff changeset
199 `bibtex-parse-keys-timeout' seconds. Only buffers which were modified
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
200 after last parsing and which are maintained in sorted order are parsed."
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
201 :group 'bibtex
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
202 :type 'integer)
15637
405b1ecbf8ba (bibtex-reference-head): Allow spaces and tabs between
Karl Heuer <kwzh@gnu.org>
parents: 15565
diff changeset
203
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
204 (defcustom bibtex-parse-keys-fast t
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
205 "*If non-nil, use fast but simplified algorithm for parsing BibTeX keys.
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
206 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
207 :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
208 :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
209
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
210 (defvar bibtex-entry-field-alist
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
211 '(
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
212 ("Article"
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
213 ((("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
214 ("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
215 ("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
216 ("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
217 (("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
218 ("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
219 ("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
220 ("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
221 ("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
222 ((("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
223 ("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
224 (("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
225 ("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
226 ("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
227 ("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
228 ("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
229 ("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
230 ("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
231 ("Book"
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
232 ((("author" "Author1 [and Author2 ...] [and others]" "" 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
233 ("editor" "Editor1 [and Editor2 ...] [and others]" "" t)
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
234 ("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
235 ("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
236 ("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
237 (("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
238 ("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
239 ("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
240 ("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
241 ("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
242 ("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
243 ("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
244 ((("author" "Author1 [and Author2 ...] [and others]" "" t)
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
245 ("editor" "Editor1 [and Editor2 ...] [and others]" "" t)
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
246 ("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
247 (("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
248 ("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
249 ("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
250 ("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
251 ("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
252 ("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
253 ("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
254 ("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
255 ("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
256 ("Booklet"
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
257 ((("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
258 (("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
259 ("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
260 ("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
261 ("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
262 ("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
263 ("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
264 ("InBook"
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
265 ((("author" "Author1 [and Author2 ...] [and others]" "" 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
266 ("editor" "Editor1 [and Editor2 ...] [and others]" "" t)
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 book")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
268 ("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
269 ("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
270 ("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
271 (("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
272 ("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
273 ("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
274 ("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
275 ("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
276 ("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
277 ("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
278 ("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
279 ("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
280 ((("author" "Author1 [and Author2 ...] [and others]" "" t)
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
281 ("editor" "Editor1 [and Editor2 ...] [and others]" "" t)
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
282 ("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
283 ("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
284 (("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
285 ("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
286 ("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
287 ("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
288 ("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
289 ("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
290 ("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
291 ("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
292 ("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
293 ("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
294 ("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
295 ("InCollection"
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
296 ((("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
297 ("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
298 ("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
299 ("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
300 ("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
301 (("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
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 ("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
306 ("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
307 ("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
308 ("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
309 ("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
310 ("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
311 ("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
312 ((("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
313 ("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
314 ("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
315 (("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
316 ("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
317 ("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
318 ("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
319 ("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
320 ("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
321 ("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
322 ("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
323 ("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
324 ("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
325 ("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
326 ("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
327 ("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
328 ("InProceedings"
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
329 ((("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
330 ("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
331 ("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
332 ("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
333 (("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
334 ("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
335 ("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
336 ("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
337 ("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
338 ("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
339 ("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
340 ("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
341 ("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
342 ("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
343 ((("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
344 ("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
345 (("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
346 ("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
347 ("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
348 ("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
349 ("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
350 ("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
351 ("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
352 ("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
353 ("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
354 ("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
355 ("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
356 ("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
357 ("Manual"
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
358 ((("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
359 (("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
360 ("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
361 ("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
362 ("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
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 ("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
365 ("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
366 ("MastersThesis"
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
367 ((("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
368 ("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
369 ("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
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 (("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
372 ("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
373 ("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
374 ("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
375 ("Misc"
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
376 (()
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
377 (("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
378 ("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
379 ("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
380 ("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
381 ("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
382 ("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
383 ("PhdThesis"
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
384 ((("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
385 ("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
386 ("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
387 ("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
388 (("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
389 ("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
390 ("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
391 ("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
392 ("Proceedings"
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
393 ((("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
394 ("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
395 (("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
396 ("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
397 ("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
398 ("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
399 ("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
400 ("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
401 ("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
402 ("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
403 ("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
404 ("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
405 ("TechReport"
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
406 ((("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
407 ("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
408 ("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
409 ("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
410 (("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
411 ("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
412 ("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
413 ("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
414 ("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
415 ("Unpublished"
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
416 ((("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
417 ("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
418 ("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
419 (("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
420 ("year" "Year of publication"))))
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
421 )
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
422
27701
5e135f0faf1d (bibtex-mode): Replaced manual splitting of path
Gerd Moellmann <gerd@gnu.org>
parents: 26711
diff changeset
423 "Defines entry types and their associated fields.
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
424 List of
43950
5ef8be2a8db1 (bibtex-sort-ignore-string-entries)
Pavel Janík <Pavel@Janik.cz>
parents: 43758
diff changeset
425 \(ENTRY-NAME (REQUIRED OPTIONAL) (CROSSREF-REQUIRED CROSSREF-OPTIONAL))
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
426 triples.
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
427 If the third element is nil, the first pair is always used.
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
428 If not, the second pair is used in the case of presence of a crossref
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
429 field and the third in the case of absence.
22563
2e2a71dfec63 Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents: 21169
diff changeset
430 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
431 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
432 \(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
433 COMMENT-STRING, INIT, and ALTERNATIVE-FLAG are optional.
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
434 FIELD-NAME is the name of the field, COMMENT-STRING the comment to
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
435 appear in the echo area, INIT is either the initial content of the
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
436 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
437 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
438 field is an alternative. ALTERNATIVE-FLAG may be t only in the
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
439 REQUIRED or CROSSREF-REQUIRED lists.")
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
440
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
441 (defvar bibtex-comment-start "@Comment"
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
442 "String starting a BibTeX comment.")
20907
9a55a557cb5a (bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents: 20866
diff changeset
443
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
444 (defcustom bibtex-add-entry-hook nil
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
445 "List of functions to call when entry has been inserted."
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
446 :group 'bibtex
20907
9a55a557cb5a (bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents: 20866
diff changeset
447 :type 'hook)
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
448
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
449 (defcustom bibtex-predefined-month-strings
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
450 '(("jan" . "January")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
451 ("feb" . "February")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
452 ("mar" . "March")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
453 ("apr" . "April")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
454 ("may" . "May")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
455 ("jun" . "June")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
456 ("jul" . "July")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
457 ("aug" . "August")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
458 ("sep" . "September")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
459 ("oct" . "October")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
460 ("nov" . "November")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
461 ("dec" . "December"))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
462 "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
463 Each element is a pair of strings (ABBREVIATION . EXPANSION)."
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
464 :group 'bibtex
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
465 :type '(repeat (cons (string :tag "Month abbreviation")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
466 (string :tag "Month expansion"))))
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
467
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
468 (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
469 (append
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
470 bibtex-predefined-month-strings
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
471 '(("acmcs" . "ACM Computing Surveys")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
472 ("acta" . "Acta Informatica")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
473 ("cacm" . "Communications of the ACM")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
474 ("ibmjrd" . "IBM Journal of Research and Development")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
475 ("ibmsj" . "IBM Systems Journal")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
476 ("ieeese" . "IEEE Transactions on Software Engineering")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
477 ("ieeetc" . "IEEE Transactions on Computers")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
478 ("ieeetcad" . "IEEE Transactions on Computer-Aided Design of Integrated Circuits")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
479 ("ipl" . "Information Processing Letters")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
480 ("jacm" . "Journal of the ACM")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
481 ("jcss" . "Journal of Computer and System Sciences")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
482 ("scp" . "Science of Computer Programming")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
483 ("sicomp" . "SIAM Journal on Computing")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
484 ("tcs" . "Theoretical Computer Science")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
485 ("tocs" . "ACM Transactions on Computer Systems")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
486 ("tods" . "ACM Transactions on Database Systems")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
487 ("tog" . "ACM Transactions on Graphics")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
488 ("toms" . "ACM Transactions on Mathematical Software")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
489 ("toois" . "ACM Transactions on Office Information Systems")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
490 ("toplas" . "ACM Transactions on Programming Languages and Systems")))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
491 "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
492 Each element is a pair of strings (ABBREVIATION . EXPANSION)."
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
493 :group 'bibtex
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
494 :type '(repeat (cons (string :tag "String")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
495 (string :tag "String expansion"))))
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
496
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
497 (defcustom bibtex-string-files nil
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
498 "*List of BibTeX files containing string definitions.
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
499 Those files must be specified using pathnames relative to the
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
500 directories specified in `bibtex-string-file-path'."
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
501 :group 'bibtex
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
502 :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
503
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
504 (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
505 "*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
506
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
507 (defcustom bibtex-help-message 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
508 "*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
509 :group 'bibtex
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
510 :type 'boolean)
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
511
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
512 (defcustom bibtex-autokey-prefix-string ""
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
513 "*String to use as a prefix for all generated 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
514 See `bibtex-generate-autokey' for details."
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
515 :group 'bibtex-autokey
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
516 :type 'string)
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
517
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
518 (defcustom bibtex-autokey-names 1
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
519 "*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
520 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
521 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
522 See `bibtex-generate-autokey' for details."
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
523 :group 'bibtex-autokey
20907
9a55a557cb5a (bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents: 20866
diff changeset
524 :type '(choice (const :tag "All" infty)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
525 integer))
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
526
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
527 (defcustom bibtex-autokey-names-stretch 0
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
528 "*Number of names that can additionally be used.
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
529 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
530 See `bibtex-generate-autokey' for details."
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
531 :group 'bibtex-autokey
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
532 :type 'integer)
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-autokey-additional-names ""
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
535 "*String to prepend 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
536 See `bibtex-generate-autokey' for details."
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
537 :group 'bibtex-autokey
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
538 :type 'string)
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
539
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
540 (defvar bibtex-autokey-transcriptions
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
541 '(;; language specific characters
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
542 ("\\\\aa" . "a") ; \aa -> a
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
543 ("\\\\AA" . "A") ; \AA -> A
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
544 ("\\\"a\\|\\\\\\\"a\\|\\\\ae" . "ae") ; "a,\"a,\ae -> ae
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
545 ("\\\"A\\|\\\\\\\"A\\|\\\\AE" . "Ae") ; "A,\"A,\AE -> Ae
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
546 ("\\\\i" . "i") ; \i -> i
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
547 ("\\\\j" . "j") ; \j -> j
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
548 ("\\\\l" . "l") ; \l -> l
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
549 ("\\\\L" . "L") ; \L -> L
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
550 ("\\\"o\\|\\\\\\\"o\\|\\\\o\\|\\\\oe" . "oe") ; "o,\"o,\o,\oe -> oe
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
551 ("\\\"O\\|\\\\\\\"O\\|\\\\O\\|\\\\OE" . "Oe") ; "O,\"O,\O,\OE -> Oe
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
552 ("\\\"s\\|\\\\\\\"s\\|\\\\3" . "ss") ; "s,\"s,\3 -> ss
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
553 ("\\\"u\\|\\\\\\\"u" . "ue") ; "u,\"u -> ue
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
554 ("\\\"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
555 ;; accents
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
556 ("\\\\`\\|\\\\'\\|\\\\\\^\\|\\\\~\\|\\\\=\\|\\\\\\.\\|\\\\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
557 ;; 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
558 ("[`'\"{}#]" . "")
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
559 ;; spaces
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
560 ("[ \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
561 "Alist of (OLD-REGEXP . NEW-STRING) pairs.
19461
6b67f20dd710 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 19460
diff changeset
562 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
563 `bibtex-autokey-titleword-change-strings'. Defaults to translating some
6b67f20dd710 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 19460
diff changeset
564 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
565 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
566
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
567 (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
568 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
569 "Alist of (OLD-REGEXP . NEW-STRING) pairs.
19461
6b67f20dd710 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 19460
diff changeset
570 Any part of name matching a OLD-REGEXP is replaced by NEW-STRING.
6b67f20dd710 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 19460
diff changeset
571 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
572 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
573 See `bibtex-generate-autokey' for details."
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
574 :group 'bibtex-autokey
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
575 :type '(repeat (cons (regexp :tag "Old")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
576 (string :tag "New"))))
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
577
20907
9a55a557cb5a (bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents: 20866
diff changeset
578 (defcustom bibtex-autokey-name-case-convert 'downcase
9a55a557cb5a (bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents: 20866
diff changeset
579 "*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
580 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
581 :group 'bibtex-autokey
9a55a557cb5a (bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents: 20866
diff changeset
582 :type '(choice (const :tag "Preserve case" identity)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
583 (const :tag "Downcase" downcase)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
584 (const :tag "Capitalize" capitalize)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
585 (const :tag "Upcase" upcase)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
586 (function :tag "Conversion function")))
20907
9a55a557cb5a (bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents: 20866
diff changeset
587
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
588 (defcustom bibtex-autokey-name-length 'infty
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
589 "*Number of characters from name to incorporate into key.
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
590 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
591 See `bibtex-generate-autokey' for details."
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
592 :group 'bibtex-autokey
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
593 :type '(choice (const :tag "All" infty)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
594 integer))
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
595
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
596 (defcustom bibtex-autokey-name-separator ""
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
597 "*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
598 See `bibtex-generate-autokey' for details."
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
599 :group 'bibtex-autokey
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
600 :type 'string)
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
601
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
602 (defcustom bibtex-autokey-year-length 2
20866
2501e131622d (bibtex-autokey-year-length): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 20459
diff changeset
603 "*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
604 See `bibtex-generate-autokey' for details."
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
605 :group 'bibtex-autokey
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
606 :type 'integer)
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
607
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
608 (defcustom bibtex-autokey-use-crossref t
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
609 "*If non-nil use fields from crossreferenced entry if necessary.
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
610 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
611 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
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 'boolean)
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
615
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
616 (defcustom bibtex-autokey-titlewords 5
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
617 "*Number of title words to use for the automatically generated reference key.
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
618 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
619 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
620 `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
621 See `bibtex-generate-autokey' for details."
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
622 :group 'bibtex-autokey
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
623 :type '(choice (const :tag "All" infty)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
624 integer))
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
625
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
626 (defcustom bibtex-autokey-title-terminators
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
627 '("\\." "!" "\\?" ":" ";" "--")
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
628 "*Regexp list defining the termination of the main part of the title.
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
629 Case of the regexps is ignored.
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
630 See `bibtex-generate-autokey' for details."
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
631 :group 'bibtex-autokey
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
632 :type '(repeat regexp))
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
633
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
634 (defcustom bibtex-autokey-titlewords-stretch 2
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
635 "*Number of words that can additionally be used from the title.
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
636 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
637 See `bibtex-generate-autokey' for details."
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
638 :group 'bibtex-autokey
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
639 :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
640
20907
9a55a557cb5a (bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents: 20866
diff changeset
641 (defcustom bibtex-autokey-titleword-ignore
9a55a557cb5a (bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents: 20866
diff changeset
642 '("A" "An" "On" "The" "Eine?" "Der" "Die" "Das"
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
643 "[^A-Z].*" ".*[^A-Z0-9].*")
20907
9a55a557cb5a (bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents: 20866
diff changeset
644 "*Determines words from the title that are not to be used in the key.
9a55a557cb5a (bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents: 20866
diff changeset
645 Each item of the list is a regexp. If a word of the title matchs a
9a55a557cb5a (bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents: 20866
diff changeset
646 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
647 See `bibtex-generate-autokey' for details."
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
648 :group 'bibtex-autokey
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
649 :type '(repeat regexp))
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
650
20907
9a55a557cb5a (bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents: 20866
diff changeset
651 (defcustom bibtex-autokey-titleword-case-convert 'downcase
9a55a557cb5a (bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents: 20866
diff changeset
652 "*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
653 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
654 :group 'bibtex-autokey
9a55a557cb5a (bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents: 20866
diff changeset
655 :type '(choice (const :tag "Preserve case" identity)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
656 (const :tag "Downcase" downcase)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
657 (const :tag "Capitalize" capitalize)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
658 (const :tag "Upcase" upcase)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
659 (function :tag "Conversion function")))
20907
9a55a557cb5a (bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents: 20866
diff changeset
660
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
661 (defcustom bibtex-autokey-titleword-abbrevs nil
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
662 "*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
663 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
664 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
665 See `bibtex-generate-autokey' for details."
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
666 :group 'bibtex-autokey
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
667 :type '(repeat (cons (regexp :tag "Old")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
668 (string :tag "New"))))
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
669
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
670 (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
671 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
672 "Alist of (OLD-REGEXP . NEW-STRING) pairs.
19461
6b67f20dd710 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 19460
diff changeset
673 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
674 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
675 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
676 See `bibtex-generate-autokey' for details."
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
677 :group 'bibtex-autokey
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
678 :type '(repeat (cons (regexp :tag "Old")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
679 (string :tag "New"))))
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
680
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
681 (defcustom bibtex-autokey-titleword-length 5
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
682 "*Number of characters from title words to incorporate into key.
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
683 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
684 See `bibtex-generate-autokey' for details."
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
685 :group 'bibtex-autokey
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
686 :type '(choice (const :tag "All" infty)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
687 integer))
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
688
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
689 (defcustom bibtex-autokey-titleword-separator "_"
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
690 "*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
691 See `bibtex-generate-autokey' for details."
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
692 :group 'bibtex-autokey
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
693 :type 'string)
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
694
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
695 (defcustom bibtex-autokey-name-year-separator ""
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
696 "*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
697 See `bibtex-generate-autokey' for details."
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
698 :group 'bibtex-autokey
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
699 :type 'string)
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
700
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
701 (defcustom bibtex-autokey-year-title-separator ":_"
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
702 "*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
703 See `bibtex-generate-autokey' for details."
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
704 :group 'bibtex-autokey
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
705 :type 'string)
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
706
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
707 (defcustom bibtex-autokey-edit-before-use t
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
708 "*If non-nil, user is allowed to edit the generated key before it is used."
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
709 :group 'bibtex-autokey
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
710 :type 'boolean)
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
711
20907
9a55a557cb5a (bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents: 20866
diff changeset
712 (defcustom bibtex-autokey-before-presentation-function nil
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
713 "*Function to call before the generated key is presented.
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
714 If non-nil this should be a function which is called before the generated key
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
715 is presented. The function must take one argument (the automatically
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
716 generated key), and must return a string (the key to use)."
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
717 :group 'bibtex-autokey
35962
ad7104908c16 (bibtex-autokey-before-presentation-function): Fix :type.
Dave Love <fx@gnu.org>
parents: 27701
diff changeset
718 :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
719
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
720 (defcustom bibtex-entry-offset 0
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
721 "*Offset for BibTeX entries.
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
722 Added to the value of all other variables which determine colums."
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
723 :group 'bibtex
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
724 :type 'integer)
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
725
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
726 (defcustom bibtex-field-indentation 2
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
727 "*Starting column for the name part in BibTeX fields."
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
728 :group 'bibtex
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
729 :type 'integer)
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
730
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
731 (defcustom bibtex-text-indentation
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
732 (+ bibtex-field-indentation
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
733 (length "organization = "))
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
734 "*Starting column for the text part in BibTeX fields.
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
735 Should be equal to the space needed for the longest name part."
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
736 :group 'bibtex
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
737 :type 'integer)
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
738
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
739 (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
740 (+ bibtex-text-indentation 1)
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
741 "*Starting column for continuation lines of BibTeX fields."
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
742 :group 'bibtex
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
743 :type 'integer)
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
744
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
745 (defcustom bibtex-align-at-equal-sign nil
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
746 "*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
747 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
748 `bibtex-text-indentation', minus 2."
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
749 :group 'bibtex
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
750 :type 'boolean)
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
751
19460
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
752 (defcustom bibtex-comma-after-last-field nil
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
753 "*If non-nil, a comma is put at end of last field in the entry template."
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
754 :group 'bibtex
f15d80b084d8 Customized.
Richard M. Stallman <rms@gnu.org>
parents: 18502
diff changeset
755 :type 'boolean)
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
756
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
757 (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
758 "If non-nil automatically add missing commas at end of BibTeX fields."
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
759 :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
760
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
761 (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
762 "Automatically fill fields if possible for those BibTeX entry types."
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
763 :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
764
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
765 (defcustom bibtex-generate-url-list
57070
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
766 '((("url" . ".*:.*"))
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
767 ;; Example of a complex setup.
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
768 (("journal" . "\\<\\(PR[ABCDEL]?\\|RMP\\)\\>")
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
769 "http://publish.aps.org/abstract/"
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
770 ("journal" ".*" downcase)
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
771 "/v"
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
772 ("volume" ".*" 0)
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
773 "/p"
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
774 ("pages" "\\`\\([0-9]+\\)" 1)))
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
775 "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
776 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
777
57070
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
778 Each scheme is of the form ((FIELD . REGEXP) 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
779
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
780 FIELD is a field name as returned by `bibtex-parse-entry'.
57070
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
781 REGEXP is matched against the text of FIELD. If the match succeed, then
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
782 this scheme will be used. If no STEPS are specified the matched text is used
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
783 as the URL, otherwise the URL is built by concatenating the STEPS.
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
784
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
785 A STEP can be a string or a list (FIELD REGEXP REPLACE) in which case
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
786 the text of FIELD is matched against REGEXP, and is replaced with REPLACE.
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
787 REPLACE can be a string, or a number (which selects the corresponding submatch)
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
788 or a function called with the field's text as argument and with the
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
789 `match-data' properly set.
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
790
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
791 Case is always ignored. Always remove the field delimiters."
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
792 :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
793 :type '(repeat
57070
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
794 (list :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
795 (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
796 (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
797 (regexp :tag "Regexp"))
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
798 (repeat :tag "Steps to generate URL" :inline 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
799 (choice
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
800 (string :tag "Literal text")
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
801 (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
802 (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
803 (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
804 (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
805 (function :tag "Filter"))))))))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
806
14789
d68b71228abd (bibtex-pop): New generic function which unifies the
Richard M. Stallman <rms@gnu.org>
parents: 14410
diff changeset
807 ;; bibtex-font-lock-keywords is a user option as well, but since the
d68b71228abd (bibtex-pop): New generic function which unifies the
Richard M. Stallman <rms@gnu.org>
parents: 14410
diff changeset
808 ;; 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
809 ;; 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
810
eac840d283b6 (bibtex-hs-forward-sexp): Added to support
Gerd Moellmann <gerd@gnu.org>
parents: 25444
diff changeset
811
12700
b3a8ee2da96a Add keywords and comments as per conventions.
Richard M. Stallman <rms@gnu.org>
parents: 12028
diff changeset
812 ;; Syntax Table, Keybindings and BibTeX Entry List
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
813 (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
814 (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
815 (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
816 (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
817 (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
818 (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
819 (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
820 (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
821 (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
822 (modify-syntax-entry ?\n "> " st)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
823 ;; 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
824 (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
825 (modify-syntax-entry ?~ " " st)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
826 st)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
827 "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
828
2465861025cd Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
829 (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
830 (let ((km (make-sparse-keymap)))
26711
eac840d283b6 (bibtex-hs-forward-sexp): Added to support
Gerd Moellmann <gerd@gnu.org>
parents: 25444
diff changeset
831 ;; 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
832 (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
833 (define-key km "\n" 'bibtex-next-field)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
834 (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
835 (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
836 (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
837 (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
838 (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
839 (define-key km "\C-c\C-q" 'bibtex-fill-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
840 (define-key km "\C-c\C-s" 'bibtex-find-entry)
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
841 (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
842 (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
843 (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
844 (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
845 (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
846 (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
847 (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
848 (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
849 (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
850 (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
851 (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
852 (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
853 (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
854 (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
855 (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
856 (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
857 (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
858 (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
859 (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
860 (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
861 (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
862 (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
863 (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
864 (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
865 (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
866 (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
867 (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
868 (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
869 (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
870 (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
871 (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
872 (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
873 (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
874 (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
875 (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
876 (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
877 (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
878 (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
879 (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
880 (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
881 km)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
882 "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
883
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
884 (easy-menu-define
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
885 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
886 '("BibTeX-Edit"
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
887 ("Moving inside an Entry"
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
888 ["End of Field" bibtex-find-text t]
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
889 ["Next Field" bibtex-next-field t]
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
890 ["Beginning of Entry" bibtex-beginning-of-entry t]
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
891 ["End of Entry" bibtex-end-of-entry 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
892 ("Moving in BibTeX Buffer"
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
893 ["Find Entry" bibtex-find-entry t]
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
894 ["Find Crossref Entry" bibtex-find-crossref t])
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
895 "--"
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
896 ("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
897 ["Fill Field" fill-paragraph t]
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
898 ["Remove Delimiters" bibtex-remove-delimiters t]
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
899 ["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
900 ["Clear Field" bibtex-empty-field t]
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
901 "--"
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
902 ["Kill Field" bibtex-kill-field t]
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
903 ["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
904 ["Paste Most Recently Killed Field" bibtex-yank t]
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
905 ["Paste Previously Killed Field" bibtex-yank-pop t]
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
906 "--"
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
907 ["Make New Field" bibtex-make-field t]
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
908 "--"
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
909 ["Snatch from Similar Following Field" bibtex-pop-next t]
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
910 ["Snatch from Similar Preceding Field" bibtex-pop-previous t]
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
911 "--"
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
912 ["String or Key Complete" bibtex-complete t]
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
913 "--"
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
914 ["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
915 ("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
916 ["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
917 ["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
918 ["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
919 "--"
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
920 ["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
921 ["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
922 ["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
923 ["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
924 "--"
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
925 ["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
926 ["Ispell Entry Abstract" bibtex-ispell-abstract 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
927 ["Narrow to Entry" bibtex-narrow-to-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
928 "--"
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
929 ["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
930 (fboundp 'reftex-view-crossref-from-bibtex)])
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
931 ("Operating on Buffer or Region"
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
932 ["Validate Entries" bibtex-validate t]
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
933 ["Sort Entries" bibtex-sort-buffer t]
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
934 ["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
935 ["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
936 "--"
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
937 ["Convert Alien Buffer" bibtex-convert-alien 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
938
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
939 (easy-menu-define
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
940 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
941 (list "Entry-Types"
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
942 ["Article in Journal" bibtex-Article t]
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
943 ["Article in Conference Proceedings" bibtex-InProceedings t]
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
944 ["Article in a Collection" bibtex-InCollection t]
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
945 ["Chapter or Pages in a Book" bibtex-InBook t]
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
946 ["Conference Proceedings" bibtex-Proceedings t]
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
947 ["Book" bibtex-Book t]
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
948 ["Booklet (Bound, but no Publisher/Institution)" bibtex-Booklet t]
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
949 ["PhD. Thesis" bibtex-PhdThesis t]
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
950 ["Master's Thesis" bibtex-MastersThesis t]
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
951 ["Technical Report" bibtex-TechReport t]
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
952 ["Technical Manual" bibtex-Manual t]
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
953 ["Unpublished" bibtex-Unpublished t]
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
954 ["Miscellaneous" bibtex-Misc t]
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
955 ["String" bibtex-String t]
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
956 ["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
957
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
958 (defvar bibtex-url-map
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
959 (let ((km (make-sparse-keymap)))
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
960 (define-key km [(mouse-2)] '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
961 km)
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
962 "Local keymap for clickable URLs.")
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
963 (fset 'bibtex-url-map bibtex-url-map)
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
964
14789
d68b71228abd (bibtex-pop): New generic function which unifies the
Richard M. Stallman <rms@gnu.org>
parents: 14410
diff changeset
965
12700
b3a8ee2da96a Add keywords and comments as per conventions.
Richard M. Stallman <rms@gnu.org>
parents: 12028
diff changeset
966 ;; 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
967
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
968 (defvar bibtex-pop-previous-search-point nil
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
969 "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
970
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
971 (defvar bibtex-pop-next-search-point nil
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
972 "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
973
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
974 (defvar bibtex-field-kill-ring nil
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
975 "Ring of least recently killed fields.
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
976 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
977
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
978 (defvar bibtex-field-kill-ring-yank-pointer nil
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
979 "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
980
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
981 (defvar bibtex-entry-kill-ring nil
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
982 "Ring of least recently killed entries.
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
983 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
984
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
985 (defvar bibtex-entry-kill-ring-yank-pointer nil
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
986 "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
987
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
988 (defvar bibtex-last-kill-command nil
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
989 "Type of the last kill command (either 'field or 'entry).")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
990
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
991 (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
992 (lazy-completion-table 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
993 bibtex-parse-strings (bibtex-string-files-init))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
994 "Completion table for BibTeX string keys.
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
995 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
996 (make-variable-buffer-local '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
997
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
998 (defvar bibtex-reference-keys
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
999 (lazy-completion-table bibtex-reference-keys bibtex-parse-keys nil nil t)
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1000 "Completion table for BibTeX reference keys.")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1001 (make-variable-buffer-local 'bibtex-reference-keys)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1002
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1003 (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
1004 "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
1005
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1006 (defvar bibtex-parse-idle-timer nil
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1007 "Stores if timer is already installed.")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1008
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1009 (defvar bibtex-progress-lastperc nil
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1010 "Last reported percentage for the progress message.")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1011
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1012 (defvar bibtex-progress-lastmes nil
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1013 "Last reported progress message.")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1014
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1015 (defvar bibtex-progress-interval nil
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1016 "Interval for progress messages.")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1017
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1018 (defvar bibtex-key-history nil
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1019 "History list for reading keys.")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1020
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1021 (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
1022 "History list for reading entry types.")
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1023
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1024 (defvar bibtex-field-history nil
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1025 "History list for reading field names.")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1026
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1027 (defvar bibtex-reformat-previous-options nil
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1028 "Last reformat options given.")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1029
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1030 (defvar bibtex-reformat-previous-reference-keys nil
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1031 "Last reformat reference keys option given.")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1032
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1033 (defconst bibtex-field-name "[^\"#%'(),={} \t\n0-9][^\"#%'(),={} \t\n]*"
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1034 "Regexp matching the name part of a BibTeX field.")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1035
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1036 (defconst bibtex-entry-type (concat "@" bibtex-field-name)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1037 "Regexp matching the type part of a BibTeX entry.")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1038
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1039 (defconst bibtex-reference-key "[][a-zA-Z0-9.:;?!`'/*@+|()<>&_^$-]+"
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1040 "Regexp matching the reference key part of a BibTeX entry.")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1041
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1042 (defconst bibtex-field-const "[][a-zA-Z0-9.:;?!`'/*@+=|<>&_^$-]+"
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1043 "Regexp matching a BibTeX field constant.")
27701
5e135f0faf1d (bibtex-mode): Replaced manual splitting of path
Gerd Moellmann <gerd@gnu.org>
parents: 26711
diff changeset
1044
5e135f0faf1d (bibtex-mode): Replaced manual splitting of path
Gerd Moellmann <gerd@gnu.org>
parents: 26711
diff changeset
1045 (defconst bibtex-entry-head
15637
405b1ecbf8ba (bibtex-reference-head): Allow spaces and tabs between
Karl Heuer <kwzh@gnu.org>
parents: 15565
diff changeset
1046 (concat "^[ \t]*\\("
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1047 bibtex-entry-type
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1048 "\\)[ \t]*[({][ \t\n]*\\("
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1049 bibtex-reference-key
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1050 "\\)")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1051 "Regexp matching the header line of a BibTeX entry.")
27701
5e135f0faf1d (bibtex-mode): Replaced manual splitting of path
Gerd Moellmann <gerd@gnu.org>
parents: 26711
diff changeset
1052
5e135f0faf1d (bibtex-mode): Replaced manual splitting of path
Gerd Moellmann <gerd@gnu.org>
parents: 26711
diff changeset
1053 (defconst bibtex-entry-maybe-empty-head
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1054 (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
1055 "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
1056
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1057 (defconst bibtex-type-in-head 1
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1058 "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
1059
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1060 (defconst bibtex-key-in-head 2
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1061 "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
1062
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1063 (defconst bibtex-entry-postfix "[ \t\n]*,?[ \t\n]*[})]"
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1064 "Regexp matching the postfix of a BibTeX entry.")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1065
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1066 (defvar bibtex-known-entry-type-re
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1067 (regexp-opt (mapcar 'car bibtex-entry-field-alist))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1068 "Regexp matching the name of a BibTeX entry type.")
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 (defvar bibtex-valid-entry-re
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1071 (concat "@[ \t]*\\(" bibtex-known-entry-type-re "\\)")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1072 "Regexp matching the name of a valid BibTeX entry.")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1073
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1074 (defvar bibtex-valid-entry-whitespace-re
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1075 (concat "[ \t\n]*\\(" bibtex-valid-entry-re "\\)")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1076 "Regexp matching the name of a valid BibTeX entry preceded by whitespace.")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1077
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1078 (defvar bibtex-any-valid-entry-re
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1079 (concat "@[ \t]*"
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1080 (regexp-opt (append '("String")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1081 (mapcar 'car bibtex-entry-field-alist))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1082 t))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1083 "Regexp matching the name of any valid BibTeX entry (including string).")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1084
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1085
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1086 (defconst bibtex-empty-field-re "\"\"\\|{}"
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1087 "Regexp matching an empty field.")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1088
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1089 (defconst bibtex-font-lock-syntactic-keywords
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1090 `((,(concat "^[ \t]*\\(" (substring bibtex-comment-start 0 1) "\\)"
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1091 (substring bibtex-comment-start 1) "\\>")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1092 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
1093
14789
d68b71228abd (bibtex-pop): New generic function which unifies the
Richard M. Stallman <rms@gnu.org>
parents: 14410
diff changeset
1094 (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
1095 ;; entry type and reference 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
1096 `((,bibtex-entry-maybe-empty-head
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 (,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
1098 (,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
1099 ;; 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
1100 (,(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
1101 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
1102 ;; 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
1103 (,(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
1104 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
1105 ;; url
57070
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
1106 (bibtex-font-lock-url 0 '(face nil mouse-face highlight
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
1107 keymap bibtex-url-map)))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1108 "*Default expressions to highlight in BibTeX mode.")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1109
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
1110 (defvar bibtex-font-lock-url-regexp
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
1111 (concat "\\<" (regexp-opt (mapcar 'caar bibtex-generate-url-list) 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
1112 "\\>[ \t]*=[ \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
1113 "Regexp for `bibtex-font-lock-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
1114
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1115 (defvar bibtex-field-name-for-parsing nil
57070
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
1116 "Regexp of field name to be parsed by function `bibtex-parse-field-name'.
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
1117 Passed by dynamic scoping.")
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1118
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1119 (defvar bibtex-sort-entry-class-alist
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1120 (let ((i -1) alist)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1121 (dolist (class bibtex-sort-entry-class alist)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1122 (setq i (1+ i))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1123 (dolist (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
1124 ;; all entry names should be downcase (for ease of comparison)
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1125 (push (cons (if (stringp entry) (downcase entry) entry) i) alist))))
57070
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
1126 "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
1127 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
1128 Used when `bibtex-maintain-sorted-entries' is `entry-class'.")
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1129
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1130
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1131 ;; Special support taking care of variants
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1132 (defvar zmacs-regions)
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
1133 (defalias 'bibtex-mark-active
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
1134 (if (boundp 'mark-active)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1135 ;; In Emacs mark-active indicates if mark is active.
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
1136 (lambda () mark-active)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1137 ;; In XEmacs (mark) returns nil when not active.
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
1138 (lambda () (if zmacs-regions (mark) (mark 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
1139
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
1140 (defalias 'bibtex-run-with-idle-timer
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
1141 (if (fboundp 'run-with-idle-timer)
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
1142 ;; timer.el is distributed with Emacs
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
1143 'run-with-idle-timer
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
1144 ;; timer.el is not distributed with XEmacs
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
1145 ;; Notice that this does not (yet) pass the arguments, but they
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
1146 ;; are not used (yet) in bibtex.el. Fix if needed.
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
1147 (lambda (secs repeat function &rest args)
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
1148 (start-itimer "bibtex" function secs (if repeat secs nil) t))))
51415
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
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1151 ;; Support for hideshow minor mode
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1152 (defun bibtex-hs-forward-sexp (arg)
57070
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
1153 "Replacement for `forward-sexp' to be used by `hs-minor-mode'.
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
1154 ARG is ignored."
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
1155 (if (looking-at "@\\S(*\\s(")
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
1156 (goto-char (1- (match-end 0))))
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
1157 (forward-sexp 1))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1158
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1159 (add-to-list
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1160 'hs-special-modes-alist
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1161 '(bibtex-mode "@\\S(*\\s(" "\\s)" nil bibtex-hs-forward-sexp nil))
27701
5e135f0faf1d (bibtex-mode): Replaced manual splitting of path
Gerd Moellmann <gerd@gnu.org>
parents: 26711
diff changeset
1162
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
1163
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1164 (defun bibtex-parse-association (parse-lhs parse-rhs)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1165 "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
1166 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
1167 substrings. These functions are expected to return nil if parsing is not
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1168 successfull. If both functions return non-nil, a pair containing the returned
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1169 values of the functions PARSE-LHS and PARSE-RHS is returned."
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1170 (save-match-data
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1171 (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
1172 (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
1173 right)
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1174 (if (and left
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1175 (looking-at "[ \t\n]*=[ \t\n]*")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1176 (goto-char (match-end 0))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1177 (setq right (funcall parse-rhs)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1178 (cons left right))))))
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 (defun bibtex-parse-field-name ()
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1181 "Parse the field name stored in `bibtex-field-name-for-parsing'.
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1182 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
1183 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
1184 part and end position of the match. Move point to end of 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
1185 If `bibtex-autoadd-commas' is non-nil add missing comma at end of preceeding
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1186 BibTeX field as necessary."
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1187 (cond ((looking-at ",[ \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
1188 (let ((start (point)))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1189 (goto-char (match-end 0))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1190 (when (looking-at bibtex-field-name-for-parsing)
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1191 (goto-char (match-end 0))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1192 (list start (match-beginning 0) (match-end 0)))))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1193 ;; 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
1194 ((and bibtex-autoadd-commas
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1195 (looking-at (concat "[ \t\n]*\\(?:" bibtex-field-name-for-parsing
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1196 "\\)[ \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
1197 (skip-chars-backward " \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
1198 (insert ",")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1199 (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
1200 ;; 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
1201 (bibtex-parse-field-name))))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1202
55348
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1203 (defconst bibtex-braced-string-syntax-table
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1204 (let ((st (make-syntax-table)))
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1205 (modify-syntax-entry ?\{ "(}" st)
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1206 (modify-syntax-entry ?\} "){" st)
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1207 (modify-syntax-entry ?\[ "." st)
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1208 (modify-syntax-entry ?\] "." st)
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1209 (modify-syntax-entry ?\( "." st)
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1210 (modify-syntax-entry ?\) "." st)
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1211 (modify-syntax-entry ?\\ "." st)
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1212 (modify-syntax-entry ?\" "." st)
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1213 st)
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1214 "Syntax-table to parse matched braces.")
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1215
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1216 (defconst bibtex-quoted-string-syntax-table
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1217 (let ((st (make-syntax-table)))
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1218 (modify-syntax-entry ?\\ "\\" st)
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1219 (modify-syntax-entry ?\" "\"" st)
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1220 st)
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1221 "Syntax-table to parse matched quotes.")
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1222
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1223 (defun bibtex-parse-field-string ()
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1224 "Parse a field string enclosed by braces or quotes.
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1225 If a syntactically correct string is found, a pair containing the start and
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1226 end position of the field string is returned, nil otherwise."
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1227 (let ((end-point
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1228 (or (and (eq (following-char) ?\")
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1229 (save-excursion
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1230 (with-syntax-table bibtex-quoted-string-syntax-table
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1231 (forward-sexp 1))
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1232 (point)))
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1233 (and (eq (following-char) ?\{)
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1234 (save-excursion
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1235 (with-syntax-table bibtex-braced-string-syntax-table
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1236 (forward-sexp 1))
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1237 (point))))))
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1238 (if end-point
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1239 (cons (point) end-point))))
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1240
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1241 (defun bibtex-parse-field-text ()
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1242 "Parse the text part of a BibTeX field.
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1243 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
1244 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
1245 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
1246 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
1247 (let ((starting-point (point))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1248 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
1249 (while (not (or end-point failure))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1250 (cond ((looking-at bibtex-field-const)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1251 (goto-char (match-end 0)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1252 ((setq boundaries (bibtex-parse-field-string))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1253 (goto-char (cdr boundaries)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1254 ((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
1255 (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
1256 (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
1257 (setq end-point (point))))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1258 (if (and (not failure)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1259 end-point)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1260 (cons starting-point end-point))))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1261
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1262 (defun bibtex-parse-field (name)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1263 "Parse a BibTeX field of regexp NAME.
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1264 If a syntactically correct field is found, a pair containing the boundaries of
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1265 the name and text parts of the field is returned."
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1266 (let ((bibtex-field-name-for-parsing name))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1267 (bibtex-parse-association 'bibtex-parse-field-name
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1268 'bibtex-parse-field-text)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1269
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1270 (defun bibtex-search-forward-field (name &optional bound)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1271 "Search forward to find a field of name NAME.
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1272 If a syntactically correct field is found, a pair containing the boundaries of
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1273 the name and text parts of the field is returned. The search is limited by
57070
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
1274 optional arg BOUND. If BOUND is t the search is limited by the end of the
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
1275 current entry. Do not move point."
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1276 (save-match-data
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1277 (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
1278 (unless (integer-or-marker-p bound)
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1279 (setq bound (if bound
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1280 (save-excursion (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
1281 (point-max))))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1282 (let ((case-fold-search t)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1283 (bibtex-field-name-for-parsing name)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1284 boundaries temp-boundaries)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1285 (while (and (not boundaries)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1286 (< (point) bound)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1287 (search-forward "," bound t))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1288 (goto-char (match-beginning 0))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1289 (if (and (setq temp-boundaries
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1290 (bibtex-parse-association 'bibtex-parse-field-name
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1291 'bibtex-parse-field-text))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1292 (<= (cddr temp-boundaries) bound))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1293 (setq boundaries temp-boundaries)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1294 (forward-char 1)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1295 boundaries))))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1296
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1297 (defun bibtex-search-backward-field (name &optional bound)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1298 "Search backward to find a field of name NAME.
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1299 If a syntactically correct field is found, a pair containing the boundaries of
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1300 the name and text parts of the field is returned. The search is limited by
57070
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
1301 optional arg BOUND. If BOUND is t the search is limited by the beginning of the
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
1302 current entry. Do not move point."
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1303 (save-match-data
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1304 (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
1305 (unless (integer-or-marker-p bound)
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1306 (setq bound (if bound
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1307 (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
1308 (point-min))))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1309 (let ((case-fold-search t)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1310 (bibtex-field-name-for-parsing name)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1311 boundaries temp-boundaries)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1312 (while (and (not boundaries)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1313 (>= (point) bound)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1314 (search-backward "," bound t))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1315 (if (setq temp-boundaries
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1316 (bibtex-parse-association 'bibtex-parse-field-name
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1317 'bibtex-parse-field-text))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1318 (setq boundaries temp-boundaries)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1319 boundaries))))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1320
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1321 (defsubst bibtex-start-of-field (bounds)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1322 (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
1323 (defsubst bibtex-start-of-name-in-field (bounds)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1324 (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
1325 (defsubst bibtex-end-of-name-in-field (bounds)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1326 (nth 2 (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
1327 (defsubst bibtex-end-of-field (bounds)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1328 (cddr 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
1329 (defsubst bibtex-start-of-text-in-field (bounds)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1330 (cadr 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
1331 (defsubst bibtex-end-of-text-in-field (bounds)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1332 (cddr bounds))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1333
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
1334 (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
1335 "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
1336 If optional arg REMOVE-OPT-ALT is non-nil remove \"OPT\" and \"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
1337 (let ((name (buffer-substring-no-properties (nth 1 (car 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
1338 (nth 2 (car 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
1339 (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
1340 (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
1341 (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
1342 name)))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1343
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1344 (defun bibtex-text-in-field-bounds (bounds &optional remove-delim)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1345 "Get content of text in BibTeX field defined via BOUNDS.
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1346 If optional arg REMOVE-DELIM is non-nil remove enclosing field delimiters
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1347 if present."
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1348 (let ((content (buffer-substring-no-properties (cadr bounds)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1349 (cddr bounds))))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1350 (if (and remove-delim
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1351 (string-match "\\`[{\"]\\(.*\\)[}\"]\\'" content))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1352 (substring content (match-beginning 1) (match-end 1))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1353 content)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1354
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1355 (defun bibtex-text-in-field (field &optional follow-crossref)
57070
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
1356 "Get content of field FIELD of current BibTeX entry. Return nil if not found.
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1357 If optional arg FOLLOW-CROSSREF is non-nil, follow crossref."
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1358 (save-excursion
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1359 (save-restriction
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1360 ;; We want to jump back and forth while searching FIELD
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1361 (bibtex-narrow-to-entry)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1362 (goto-char (point-min))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1363 (let ((bounds (bibtex-search-forward-field field))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1364 crossref-field)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1365 (cond (bounds (bibtex-text-in-field-bounds bounds t))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1366 ((and follow-crossref
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1367 (progn (goto-char (point-min))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1368 (setq bounds (bibtex-search-forward-field
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1369 "\\(OPT\\)?crossref"))))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1370 (setq crossref-field (bibtex-text-in-field-bounds bounds t))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1371 (widen)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1372 (if (bibtex-find-crossref crossref-field)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1373 ;; Do not pass FOLLOW-CROSSREF because we want
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1374 ;; to follow crossrefs only one level of recursion.
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1375 (bibtex-text-in-field field))))))))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1376
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1377 (defun bibtex-parse-string-prefix ()
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1378 "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
1379 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
1380 the very first character of the match, the actual starting position of the
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1381 reference key and the end position of the match."
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1382 (let ((case-fold-search t))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1383 (if (looking-at "^[ \t]*@string[ \t\n]*[({][ \t\n]*")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1384 (let ((start (point)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1385 (goto-char (match-end 0))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1386 (when (looking-at bibtex-reference-key)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1387 (goto-char (match-end 0))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1388 (list start
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1389 (match-beginning 0)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1390 (match-end 0)))))))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1391
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1392 (defun bibtex-parse-string-postfix ()
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1393 "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
1394 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
1395 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
1396 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
1397 (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
1398 (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
1399 (when bounds
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1400 (goto-char (cdr bounds))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1401 (when (looking-at "[ \t\n]*[})]")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1402 (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
1403 (list (car bounds)
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1404 (cdr bounds)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1405 (match-end 0))))))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1406
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1407 (defun bibtex-parse-string ()
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1408 "Parse a BibTeX string entry.
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1409 If a syntactically correct entry is found, a pair containing the boundaries of
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1410 the reference key and text parts of the entry is returned.
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1411 Move point past BibTeX string entry."
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1412 (bibtex-parse-association 'bibtex-parse-string-prefix
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1413 'bibtex-parse-string-postfix))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1414
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1415 (defun bibtex-search-forward-string ()
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1416 "Search forward to find a BibTeX string entry.
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1417 If a syntactically correct entry is found, a pair containing the boundaries of
57070
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
1418 the reference key and text parts of the string is returned. Do not move point."
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1419 (save-excursion
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1420 (save-match-data
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1421 (let ((case-fold-search t)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1422 boundaries)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1423 (while (and (not boundaries)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1424 (search-forward-regexp
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1425 "^[ \t]*@string[ \t\n]*[({][ \t\n]*" nil t))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1426 (goto-char (match-beginning 0))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1427 (unless (setq boundaries (bibtex-parse-string))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1428 (forward-char 1)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1429 boundaries))))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1430
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1431 (defun bibtex-search-backward-string ()
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1432 "Search backward to find a BibTeX string entry.
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1433 If a syntactically correct entry is found, a pair containing the boundaries of
57070
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
1434 the reference key and text parts of the field is returned. Do not move point."
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1435 (save-excursion
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1436 (save-match-data
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1437 (let ((case-fold-search t)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1438 boundaries)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1439 (while (and (not boundaries)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1440 (search-backward-regexp
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1441 "^[ \t]*@string[ \t\n]*[({][ \t\n]*" nil t))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1442 (goto-char (match-beginning 0))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1443 (setq boundaries (bibtex-parse-string)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1444 boundaries))))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1445
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1446 (defun bibtex-reference-key-in-string (bounds)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1447 (buffer-substring-no-properties (nth 1 (car bounds))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1448 (nth 2 (car bounds))))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1449
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1450 (defun bibtex-text-in-string (bounds &optional remove-delim)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1451 "Get content of text in BibTeX string field defined via BOUNDS.
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1452 If optional arg REMOVE-DELIM is non-nil remove enclosing field
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1453 delimiters if present."
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1454 (let ((content (buffer-substring-no-properties (nth 0 (cdr bounds))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1455 (nth 1 (cdr bounds)))))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1456 (if (and remove-delim
55348
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1457 (string-match "\\`[{\"]\\(.*\\)[}\"]\\'" content))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1458 (substring content (match-beginning 1) (match-end 1))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1459 content)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1460
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1461 (defsubst bibtex-start-of-text-in-string (bounds)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1462 (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
1463 (defsubst bibtex-end-of-text-in-string (bounds)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1464 (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
1465 (defsubst bibtex-end-of-string (bounds)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1466 (nth 2 (cdr bounds)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1467
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1468 (defsubst bibtex-type-in-head ()
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1469 "Extract BibTeX type in head."
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1470 ;; ignore @
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1471 (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
1472 (match-end bibtex-type-in-head)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1473
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1474 (defun 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
1475 "Extract BibTeX key in head. Return optional arg EMPTY if key is empty."
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1476 (if (match-beginning bibtex-key-in-head)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1477 (buffer-substring-no-properties (match-beginning bibtex-key-in-head)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1478 (match-end bibtex-key-in-head))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1479 empty))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1480
12700
b3a8ee2da96a Add keywords and comments as per conventions.
Richard M. Stallman <rms@gnu.org>
parents: 12028
diff changeset
1481 ;; 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
1482
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
1483 (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
1484 "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
1485 (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
1486
18247
ae094c1a4334 (bibtex-delete-whitespace, bibtex-current-line)
Richard M. Stallman <rms@gnu.org>
parents: 18212
diff changeset
1487 (defun bibtex-delete-whitespace ()
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1488 "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
1489 (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
1490 (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
1491
18247
ae094c1a4334 (bibtex-delete-whitespace, bibtex-current-line)
Richard M. Stallman <rms@gnu.org>
parents: 18212
diff changeset
1492 (defun bibtex-current-line ()
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1493 "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
1494 (+ (count-lines 1 (point))
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1495 (if (equal (current-column) 0) 1 0)))
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1496
18247
ae094c1a4334 (bibtex-delete-whitespace, bibtex-current-line)
Richard M. Stallman <rms@gnu.org>
parents: 18212
diff changeset
1497 (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
1498 "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
1499 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
1500 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
1501 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
1502 with type contained in `bibtex-entry-field-alist' or, if
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1503 `bibtex-sort-ignore-string-entries' is nil, a syntactical correct string
57070
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
1504 entry. Return buffer position of beginning and ending 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
1505 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
1506 (interactive "P")
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1507 (let ((case-fold-search t)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1508 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
1509 (while (not (or found (if backward (bobp) (eobp))))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1510 (let ((pnt (point))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1511 bounds)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1512 (cond ((or (and (looking-at bibtex-valid-entry-re)
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1513 (setq found (bibtex-search-entry nil nil t))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1514 (equal (match-beginning 0) pnt))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1515 (and (not bibtex-sort-ignore-string-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
1516 (setq bounds (bibtex-parse-string))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1517 (setq found (cons (bibtex-start-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
1518 (bibtex-end-of-string bounds)))))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1519 (goto-char pnt))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1520 (backward
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1521 (if (re-search-backward "^[ \t]*\\(@\\)" nil 'move)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1522 (goto-char (match-beginning 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
1523 (t (if (re-search-forward "\n[ \t]*@" nil 'move)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1524 (forward-char -1))))))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1525 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
1526
18247
ae094c1a4334 (bibtex-delete-whitespace, bibtex-current-line)
Richard M. Stallman <rms@gnu.org>
parents: 18212
diff changeset
1527 (defun bibtex-map-entries (fun)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1528 "Call FUN for each BibTeX entry starting with the current.
57070
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
1529 Do this to the end of the file. FUN is called with three arguments, the key of
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1530 the entry and the buffer positions (marker) of beginning and end of entry.
57070
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
1531 Point is inside the entry. If `bibtex-sort-ignore-string-entries' is non-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
1532 FUN will not be called for @String entries."
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1533 (let ((case-fold-search t))
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1534 (bibtex-beginning-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
1535 (while (re-search-forward bibtex-entry-head nil t)
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1536 (let ((entry-type (bibtex-type-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
1537 (key (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
1538 (beg (copy-marker (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
1539 (end (copy-marker (save-excursion (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
1540 (save-excursion
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1541 (if (or (and (not bibtex-sort-ignore-string-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
1542 (bibtex-string= entry-type "string"))
55730
b4eeb441c089 Use assoc-string, not assoc-ignore-case.
Richard M. Stallman <rms@gnu.org>
parents: 55348
diff changeset
1543 (assoc-string entry-type bibtex-entry-field-alist 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
1544 (funcall fun key beg end)))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1545 (goto-char end)))))
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1546
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1547 (defun bibtex-progress-message (&optional flag interval)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1548 "Echo a message about progress of current buffer.
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1549 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
1550 value for INTERVAL may be given as well (if not this is set to 5)).
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1551 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
1552 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
1553 `bibtex-progress-interval' percent since last message was echoed."
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1554 (cond ((stringp flag)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1555 (setq bibtex-progress-lastmes flag)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1556 (setq bibtex-progress-interval (or interval 5)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1557 bibtex-progress-lastperc 0))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1558 ((equal flag 'done)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1559 (message "%s (done)" bibtex-progress-lastmes)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1560 (setq bibtex-progress-lastmes nil))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1561 (t
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1562 (let* ((size (- (point-max) (point-min)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1563 (perc (if (= size 0)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1564 100
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1565 (/ (* 100 (- (point) (point-min))) size))))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1566 (when (>= perc (+ bibtex-progress-lastperc
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1567 bibtex-progress-interval))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1568 (setq bibtex-progress-lastperc perc)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1569 (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
1570
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1571 (defun bibtex-field-left-delimiter ()
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1572 "Return a string dependent on `bibtex-field-delimiters'."
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1573 (if (equal bibtex-field-delimiters 'braces)
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1574 "{"
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1575 "\""))
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1576
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1577 (defun bibtex-field-right-delimiter ()
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1578 "Return a string dependent on `bibtex-field-delimiters'."
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1579 (if (equal bibtex-field-delimiters 'braces)
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1580 "}"
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1581 "\""))
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1582
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1583 (defun bibtex-entry-left-delimiter ()
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1584 "Return a string dependent on `bibtex-field-delimiters'."
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1585 (if (equal bibtex-entry-delimiters 'braces)
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1586 "{"
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1587 "("))
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1588
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1589 (defun bibtex-entry-right-delimiter ()
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1590 "Return a string dependent on `bibtex-field-delimiters'."
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1591 (if (equal bibtex-entry-delimiters 'braces)
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1592 "}"
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1593 ")"))
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1594
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1595 (defun bibtex-search-entry (empty-head &optional bound noerror backward)
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1596 "Search for a BibTeX entry (maybe without reference key if EMPTY-HEAD is t).
57070
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
1597 BOUND and NOERROR are exactly as in `re-search-forward'. If BACKWARD
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
1598 is non-nil, search is done in reverse direction. Point is moved past the
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1599 closing delimiter (at the beginning of entry if BACKWARD is non-nil).
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1600 Return a cons pair with buffer positions of beginning and 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
1601 After call to this function MATCH-BEGINNING and MATCH-END functions
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1602 are defined, but only for the head part of the entry
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1603 \(especially (match-end 0) just gives the end of the head part)."
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1604 (let ((pnt (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
1605 (entry-head-re (if empty-head
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1606 bibtex-entry-maybe-empty-head
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1607 bibtex-entry-head)))
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1608 (if backward
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1609 (let (found)
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1610 (while (and (not 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
1611 (re-search-backward entry-head-re bound noerror))
27701
5e135f0faf1d (bibtex-mode): Replaced manual splitting of path
Gerd Moellmann <gerd@gnu.org>
parents: 26711
diff changeset
1612 (setq found (bibtex-search-entry empty-head pnt t)))
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1613 (if 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
1614 (progn (goto-char (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
1615 found)
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
1616 (cond ((not noerror)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1617 ;; yell
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1618 (error "Backward search of BibTeX entry failed"))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1619 ((equal noerror t)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1620 ;; don't move
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1621 (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
1622 nil))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1623 (let ((limit (or bound (point-max)))
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1624 found)
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1625 (while (and (not 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
1626 (re-search-forward entry-head-re bound noerror))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1627 (save-match-data
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1628 (let ((entry-closer
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1629 (if (save-excursion
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1630 (goto-char (match-end bibtex-type-in-head))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1631 (looking-at "[ \t]*("))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1632 ;; entry opened with parenthesis
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1633 ?\)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1634 ?\}))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1635 (infix-start (point))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1636 finished bounds)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1637 (while (not finished)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1638 (skip-chars-forward " \t\n" limit)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1639 (if (and (setq bounds (bibtex-parse-field bibtex-field-name))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1640 (<= (bibtex-end-of-field bounds) limit))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1641 (setq infix-start (bibtex-end-of-field bounds))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1642 (setq finished t))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1643 (goto-char infix-start))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1644 ;; This matches the infix* part. The AND construction assures
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1645 ;; that BOUND is respected.
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1646 (when (and (looking-at bibtex-entry-postfix)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1647 (eq (char-before (match-end 0)) entry-closer)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1648 (<= (match-end 0) limit))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1649 (goto-char (match-end 0))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1650 (setq found t)))))
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1651 (if 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
1652 (cons (match-beginning 0) (point))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1653 (cond ((not noerror)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1654 ;; yell
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1655 (error "Search of BibTeX entry failed"))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1656 ((equal noerror t)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1657 ;; don't move
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1658 (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
1659 nil)))))
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1660
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
1661 (defun bibtex-flash-head ()
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1662 "Flash at BibTeX entry head before point, if exists."
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1663 (let ((case-fold-search t)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1664 flash)
27701
5e135f0faf1d (bibtex-mode): Replaced manual splitting of path
Gerd Moellmann <gerd@gnu.org>
parents: 26711
diff changeset
1665 (cond ((re-search-backward bibtex-entry-head nil t)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1666 (goto-char (match-beginning bibtex-type-in-head))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1667 (setq flash (match-end bibtex-key-in-head)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1668 (t
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1669 (end-of-line)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1670 (skip-chars-backward " \t")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1671 (setq flash (point))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1672 (beginning-of-line)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1673 (skip-chars-forward " \t")))
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
1674 (if (pos-visible-in-window-p (point))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1675 (sit-for 1)
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
1676 (message "From: %s"
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1677 (buffer-substring (point) flash)))))
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1678
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1679 (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
1680 "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
1681 (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
1682 (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
1683 (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
1684
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
1685 (defun bibtex-move-outside-of-entry ()
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1686 "Make sure point is outside of a BibTeX entry."
22563
2e2a71dfec63 Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents: 21169
diff changeset
1687 (let ((orig-point (point)))
26711
eac840d283b6 (bibtex-hs-forward-sexp): Added to support
Gerd Moellmann <gerd@gnu.org>
parents: 25444
diff changeset
1688 (bibtex-end-of-entry)
52891
a6806242012a (bibtex-move-outside-of-entry):
Richard M. Stallman <rms@gnu.org>
parents: 52401
diff changeset
1689 (when (< (point) orig-point)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1690 ;; 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
1691 ;; Leave point at the beginning of a line, and preferably
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1692 ;; at the beginning of a paragraph.
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1693 (goto-char orig-point)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1694 (beginning-of-line 1)
52891
a6806242012a (bibtex-move-outside-of-entry):
Richard M. Stallman <rms@gnu.org>
parents: 52401
diff changeset
1695 (unless (= ?\n (char-before (1- (point))))
a6806242012a (bibtex-move-outside-of-entry):
Richard M. Stallman <rms@gnu.org>
parents: 52401
diff changeset
1696 (re-search-forward "^[ \t]*[@\n]" nil 'move)
a6806242012a (bibtex-move-outside-of-entry):
Richard M. Stallman <rms@gnu.org>
parents: 52401
diff changeset
1697 (backward-char 1)))
22563
2e2a71dfec63 Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents: 21169
diff changeset
1698 (skip-chars-forward " \t\n")))
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1699
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1700 (defun bibtex-beginning-of-first-entry ()
57070
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
1701 "Go to the beginning of the first BibTeX entry in buffer. Return point."
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
1702 (goto-char (point-min))
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1703 (if (re-search-forward "^[ \t]*@" nil 'move)
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1704 (beginning-of-line))
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1705 (point))
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1706
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1707 (defun bibtex-beginning-of-last-entry ()
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1708 "Go to the beginning of the last BibTeX entry in buffer."
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1709 (goto-char (point-max))
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1710 (if (re-search-backward "^[ \t]*@" nil 'move)
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1711 (beginning-of-line))
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1712 (point))
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
1713
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
1714 (defun bibtex-inside-field ()
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1715 "Try to avoid point being at end of a BibTeX field."
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
1716 (end-of-line)
13728
4b7903cfa7ee (bibtex-auto-fill-function): Adapted for use with
Karl Heuer <kwzh@gnu.org>
parents: 12770
diff changeset
1717 (skip-chars-backward " \t")
55348
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1718 (if (= (preceding-char) ?,)
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1719 (forward-char -2))
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1720 (if (or (= (preceding-char) ?})
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1721 (= (preceding-char) ?\"))
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1722 (forward-char -1)))
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
1723
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1724 (defun bibtex-enclosing-field (&optional 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
1725 "Search for BibTeX field enclosing point.
57070
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
1726 Use `match-beginning' and `match-end' to parse the field. If NOERR is non-nil,
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
1727 no error is signalled. In this case, bounds are returned on success,
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
1728 nil otherwise. Does not move 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
1729 (let ((bounds (bibtex-search-backward-field bibtex-field-name t)))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1730 (if (and 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
1731 (<= (bibtex-start-of-field bounds) (point))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1732 (>= (bibtex-end-of-field bounds) (point)))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1733 bounds
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1734 (unless noerr
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1735 (error "Can't find enclosing BibTeX field")))))
27701
5e135f0faf1d (bibtex-mode): Replaced manual splitting of path
Gerd Moellmann <gerd@gnu.org>
parents: 26711
diff changeset
1736
5e135f0faf1d (bibtex-mode): Replaced manual splitting of path
Gerd Moellmann <gerd@gnu.org>
parents: 26711
diff changeset
1737 (defun bibtex-enclosing-entry-maybe-empty-head ()
57070
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
1738 "Search for BibTeX entry enclosing point. Move point to end of entry.
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1739 Beginning (but not end) of entry is given by (`match-beginning' 0)."
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1740 (let ((case-fold-search t)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1741 (old-point (point)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1742 (unless (re-search-backward bibtex-entry-maybe-empty-head 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
1743 (goto-char old-point)
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1744 (error "Can't find beginning of enclosing BibTeX entry"))
13728
4b7903cfa7ee (bibtex-auto-fill-function): Adapted for use with
Karl Heuer <kwzh@gnu.org>
parents: 12770
diff changeset
1745 (goto-char (match-beginning bibtex-type-in-head))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1746 (unless (bibtex-search-entry t 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
1747 (goto-char old-point)
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1748 (error "Can't find end of enclosing BibTeX entry"))))
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1749
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1750 (defun bibtex-insert-current-kill (n)
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1751 (if (not bibtex-last-kill-command)
22563
2e2a71dfec63 Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents: 21169
diff changeset
1752 (error "BibTeX kill ring is empty")
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1753 (let* ((kr (if (equal 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
1754 'bibtex-field-kill-ring
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1755 'bibtex-entry-kill-ring))
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1756 (kryp (if (equal 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
1757 'bibtex-field-kill-ring-yank-pointer
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1758 'bibtex-entry-kill-ring-yank-pointer))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1759 (ARGth-kill-element (nthcdr (mod (- n (length (eval kryp)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1760 (length (eval kr)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1761 (eval kr)))
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1762 (current (car (set kryp ARGth-kill-element))))
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1763 (cond
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1764 ((equal 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
1765 (let (bibtex-help-message)
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1766 (bibtex-find-text nil t)
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1767 (if (looking-at "[}\"]")
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1768 (forward-char)))
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1769 (set-mark (point))
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1770 (message "Mark set")
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1771 (bibtex-make-field (list (elt current 1) nil (elt current 2)) t))
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1772 ((equal bibtex-last-kill-command '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
1773 (unless (eobp) (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
1774 (set-mark (point))
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1775 (message "Mark set")
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1776 (insert (elt current 1)))
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1777 (t
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1778 (error "Unknown tag field: %s. Please submit a bug report"
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1779 bibtex-last-kill-command))))))
27701
5e135f0faf1d (bibtex-mode): Replaced manual splitting of path
Gerd Moellmann <gerd@gnu.org>
parents: 26711
diff changeset
1780
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1781 (defun bibtex-format-entry ()
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1782 "Helper function for `bibtex-clean-entry'.
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1783 Formats current entry according to variable `bibtex-entry-format'."
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1784 (save-excursion
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1785 (save-restriction
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1786 (bibtex-narrow-to-entry)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1787 (let ((case-fold-search t)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1788 (format (if (equal bibtex-entry-format t)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1789 '(realign opts-or-alts required-fields
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1790 numerical-fields
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1791 last-comma page-dashes delimiters
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1792 unify-case inherit-booktitle)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1793 bibtex-entry-format))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1794 crossref-key bounds alternatives-there non-empty-alternative
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
1795 entry-list req-field-list field-list)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1796
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1797 ;; identify entry type
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1798 (goto-char (point-min))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1799 (re-search-forward bibtex-entry-type)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1800 (let ((beg-type (1+ (match-beginning 0)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1801 (end-type (match-end 0)))
55730
b4eeb441c089 Use assoc-string, not assoc-ignore-case.
Richard M. Stallman <rms@gnu.org>
parents: 55348
diff changeset
1802 (setq entry-list (assoc-string (buffer-substring-no-properties
b4eeb441c089 Use assoc-string, not assoc-ignore-case.
Richard M. Stallman <rms@gnu.org>
parents: 55348
diff changeset
1803 beg-type end-type)
b4eeb441c089 Use assoc-string, not assoc-ignore-case.
Richard M. Stallman <rms@gnu.org>
parents: 55348
diff changeset
1804 bibtex-entry-field-alist
b4eeb441c089 Use assoc-string, not assoc-ignore-case.
Richard M. Stallman <rms@gnu.org>
parents: 55348
diff changeset
1805 t))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1806
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1807 ;; unify case of entry name
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1808 (when (memq 'unify-case format)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1809 (delete-region beg-type end-type)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1810 (insert (car entry-list)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1811
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1812 ;; update left entry delimiter
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1813 (when (memq 'delimiters format)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1814 (goto-char end-type)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1815 (skip-chars-forward " \t\n")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1816 (delete-char 1)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1817 (insert (bibtex-entry-left-delimiter))))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1818
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1819 ;; determine if entry has crossref field and if at least
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1820 ;; one alternative is non-empty
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1821 (goto-char (point-min))
55348
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1822 (let* ((fields-alist (bibtex-parse-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
1823 (field (assoc-string "crossref" fields-alist t)))
55348
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1824 (setq crossref-key (and field
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1825 (not (string-match bibtex-empty-field-re
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1826 (cdr field)))
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1827 (cdr field))
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1828 req-field-list (if crossref-key
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1829 (nth 0 (nth 2 entry-list)) ; crossref part
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1830 (nth 0 (nth 1 entry-list)))) ; required part
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1831
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1832 (dolist (rfield req-field-list)
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1833 (when (nth 3 rfield) ; we should have an alternative
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1834 (setq alternatives-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
1835 field (assoc-string (car rfield) fields-alist t))
55348
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1836 (if (and field
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1837 (not (string-match bibtex-empty-field-re
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1838 (cdr field))))
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1839 (cond ((not non-empty-alternative)
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1840 (setq non-empty-alternative t))
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1841 ((memq 'required-fields format)
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1842 (error "More than one non-empty alternative.")))))))
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1843
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
1844 (if (and alternatives-there
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1845 (not non-empty-alternative)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1846 (memq 'required-fields format))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1847 (error "All alternatives are empty"))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1848
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1849 ;; process all fields
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1850 (goto-char (point-min))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1851 (while (setq bounds (bibtex-search-forward-field bibtex-field-name))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1852 (let* ((beg-field (copy-marker (bibtex-start-of-field bounds)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1853 (end-field (copy-marker (bibtex-end-of-field bounds)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1854 (beg-name (copy-marker (bibtex-start-of-name-in-field bounds)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1855 (end-name (copy-marker (bibtex-end-of-name-in-field bounds)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1856 (beg-text (copy-marker (bibtex-start-of-text-in-field bounds)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1857 (end-text (copy-marker (bibtex-end-of-text-in-field bounds)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1858 (opt-alt (string-match "OPT\\|ALT"
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1859 (buffer-substring-no-properties beg-name (+ beg-name 3))))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1860 (field-name (buffer-substring-no-properties
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1861 (if opt-alt (+ beg-name 3) beg-name) end-name))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1862 (empty-field (string-match bibtex-empty-field-re
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1863 (buffer-substring-no-properties beg-field end-field)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1864 deleted)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1865
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1866 ;; We have more elegant high-level functions for several
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1867 ;; tasks done by bibtex-format-entry. However, they contain
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1868 ;; quite some redundancy compared with what we need to do
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1869 ;; anyway. So for speed-up we avoid using them.
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1870
55348
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1871 (if (memq 'opts-or-alts format)
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1872 (cond ((and empty-field
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1873 (or opt-alt
55730
b4eeb441c089 Use assoc-string, not assoc-ignore-case.
Richard M. Stallman <rms@gnu.org>
parents: 55348
diff changeset
1874 (let ((field (assoc-string
b4eeb441c089 Use assoc-string, not assoc-ignore-case.
Richard M. Stallman <rms@gnu.org>
parents: 55348
diff changeset
1875 field-name req-field-list t)))
55348
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1876 (or (not field) ; OPT field
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1877 (nth 3 field))))) ; ALT field
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1878 ;; Either it is an empty ALT field. Then we have checked
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1879 ;; already that we have one non-empty alternative. Or it
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1880 ;; is an empty OPT field that we do not miss anyway.
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1881 ;; So we can safely delete this field.
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1882 (delete-region beg-field end-field)
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1883 (setq deleted t))
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1884 ;; otherwise: not empty, delete "OPT" or "ALT"
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1885 (opt-alt
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1886 (goto-char beg-name)
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1887 (delete-char 3))))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1888
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1889 (unless deleted
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1890 (push field-name field-list)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1891
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1892 ;; remove delimiters from purely numerical fields
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1893 (when (and (memq 'numerical-fields format)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1894 (progn (goto-char beg-text)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1895 (looking-at "\\(\"[0-9]+\"\\)\\|\\({[0-9]+}\\)")))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1896 (goto-char end-text)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1897 (delete-char -1)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1898 (goto-char beg-text)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1899 (delete-char 1))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1900
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1901 ;; update delimiters
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1902 (when (memq 'delimiters format)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1903 (goto-char beg-text)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1904 (when (looking-at "[{\"]")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1905 (delete-char 1)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1906 (insert (bibtex-field-left-delimiter)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1907 (goto-char (1- (marker-position end-text)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1908 (when (looking-at "[}\"]")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1909 (delete-char 1)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1910 (insert (bibtex-field-right-delimiter))))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1911
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1912 ;; update page dashes
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1913 (if (and (memq 'page-dashes format)
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
1914 (bibtex-string= field-name "pages")
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1915 (progn (goto-char beg-text)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1916 (looking-at
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1917 "\\([\"{][0-9]+\\)[ \t\n]*--?[ \t\n]*\\([0-9]+[\"}]\\)")))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1918 (replace-match "\\1-\\2"))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1919
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1920 ;; use book title of crossref'd entry
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1921 (if (and (memq 'inherit-booktitle 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
1922 empty-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
1923 (bibtex-string= field-name "booktitle")
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1924 crossref-key)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1925 (let ((title (save-restriction
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1926 (widen)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1927 (if (bibtex-find-entry crossref-key)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1928 (bibtex-text-in-field "title")))))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1929 (when title
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1930 (setq empty-field nil)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1931 (goto-char (1+ beg-text))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1932 (insert title))))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1933
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1934 ;; Use booktitle to set a missing title.
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1935 (if (and empty-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
1936 (bibtex-string= field-name "title"))
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1937 (let ((booktitle (bibtex-text-in-field "booktitle")))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1938 (when booktitle
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1939 (setq empty-field nil)
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1940 (goto-char (1+ beg-text))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
1941 (insert booktitle))))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1942
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1943 ;; if empty field, complain
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1944 (if (and empty-field
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1945 (memq 'required-fields format)
55730
b4eeb441c089 Use assoc-string, not assoc-ignore-case.
Richard M. Stallman <rms@gnu.org>
parents: 55348
diff changeset
1946 (assoc-string field-name req-field-list t))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1947 (error "Mandatory field `%s' is empty" field-name))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1948
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1949 ;; unify case of field name
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1950 (if (memq 'unify-case format)
55730
b4eeb441c089 Use assoc-string, not assoc-ignore-case.
Richard M. Stallman <rms@gnu.org>
parents: 55348
diff changeset
1951 (let ((fname (car (assoc-string
b4eeb441c089 Use assoc-string, not assoc-ignore-case.
Richard M. Stallman <rms@gnu.org>
parents: 55348
diff changeset
1952 field-name
b4eeb441c089 Use assoc-string, not assoc-ignore-case.
Richard M. Stallman <rms@gnu.org>
parents: 55348
diff changeset
1953 (append (nth 0 (nth 1 entry-list))
b4eeb441c089 Use assoc-string, not assoc-ignore-case.
Richard M. Stallman <rms@gnu.org>
parents: 55348
diff changeset
1954 (nth 1 (nth 1 entry-list))
b4eeb441c089 Use assoc-string, not assoc-ignore-case.
Richard M. Stallman <rms@gnu.org>
parents: 55348
diff changeset
1955 bibtex-user-optional-fields)
b4eeb441c089 Use assoc-string, not assoc-ignore-case.
Richard M. Stallman <rms@gnu.org>
parents: 55348
diff changeset
1956 t))))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1957 (if fname
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1958 (progn
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1959 (delete-region beg-name end-name)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1960 (goto-char beg-name)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1961 (insert fname))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1962 ;; there are no rules we could follow
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1963 (downcase-region beg-name end-name))))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1964
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1965 ;; update point
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1966 (goto-char end-field))))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1967
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1968 ;; check whether all required fields are present
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1969 (if (memq 'required-fields format)
55348
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1970 (let ((found 0) altlist)
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1971 (dolist (fname req-field-list)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1972 (if (nth 3 fname)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1973 (push (car fname) altlist))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1974 (unless (or (member (car fname) field-list)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1975 (nth 3 fname))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1976 (error "Mandatory field `%s' is missing" (car fname))))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1977 (when altlist
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1978 (dolist (fname altlist)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1979 (if (member fname field-list)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1980 (setq found (1+ found))))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1981 (cond ((= found 0)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1982 (error "Alternative mandatory field `%s' is missing"
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1983 altlist))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1984 ((> found 1)
55348
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
1985 (error "Alternative fields `%s' are defined %s times"
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1986 altlist found))))))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1987
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1988 ;; update point
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1989 (if (looking-at (bibtex-field-right-delimiter))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1990 (forward-char))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1991
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1992 ;; update comma after last field
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1993 (if (memq 'last-comma format)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1994 (cond ((and bibtex-comma-after-last-field
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1995 (not (looking-at ",")))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1996 (insert ","))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1997 ((and (not bibtex-comma-after-last-field)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1998 (looking-at ","))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
1999 (delete-char 1))))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2000
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2001 ;; update right entry delimiter
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2002 (if (looking-at ",")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2003 (forward-char))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2004 (when (memq 'delimiters format)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2005 (skip-chars-forward " \t\n")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2006 (delete-char 1)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2007 (insert (bibtex-entry-right-delimiter)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2008
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2009 ;; fill entry
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2010 (if (memq 'realign format)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2011 (bibtex-fill-entry))))))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2012
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2013
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
2014 (defun bibtex-autokey-abbrev (string len)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2015 "Return an abbreviation of STRING with at least LEN characters.
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2016 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
2017 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
2018 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
2019 is returned unchanged."
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2020 (cond ((or (not (numberp len))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2021 (<= (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
2022 string)
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2023 ((equal len 0)
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2024 "")
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2025 ((< len 0)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2026 (substring string 0 (abs len)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2027 (t (let* ((case-fold-search t)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2028 (abort-char (string-match "[^aeiou]" string (1- len))))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2029 (if abort-char
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2030 (substring string 0 (1+ abort-char))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2031 string)))))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2032
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2033 (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
2034 "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
2035 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
2036 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
2037 \(OLD-REGEXP . NEW-STRING\)."
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2038 (let ((content (bibtex-text-in-field field bibtex-autokey-use-crossref))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2039 case-fold-search)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2040 (unless content (setq content ""))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2041 (dolist (pattern change-list content)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2042 (setq content (replace-regexp-in-string (car pattern)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2043 (cdr pattern)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2044 content)))))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2045
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2046 (defun bibtex-autokey-get-names ()
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2047 "Get contents of the name field of the current entry.
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2048 Do some modifications based on `bibtex-autokey-name-change-strings'
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2049 and return results as a 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
2050 (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
2051 (names (bibtex-autokey-get-field "author\\|editor"
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
2052 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
2053 ;; Some entries do not have a name field.
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
2054 (unless (string= "" 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
2055 (mapcar 'bibtex-autokey-demangle-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
2056 (split-string names "[ \t\n]+and[ \t\n]+")))))
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2057
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2058 (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
2059 "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
2060 (let* (case-fold-search
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2061 (name (cond ((string-match "\\([A-Z][^, ]*\\)[^,]*," fullname)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2062 ;; Name is of the form "von Last, First" or
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2063 ;; "von Last, Jr, First"
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2064 ;; --> 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
2065 (match-string 1 fullname))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2066 ((string-match "\\([^, ]*\\)," fullname)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2067 ;; Strange name: we have a comma, but nothing capital
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2068 ;; 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
2069 (match-string 1 fullname))
83476384bebd (bibtex-member-of-regexp, bibtex-assoc-of-regexp, bibtex-format-entry)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51415
diff changeset
2070 ((string-match "\\(\\<[a-z][^ ]* +\\)+\\([A-Z][^ ]*\\)"
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2071 fullname)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2072 ;; name is of the form "First von Last", "von Last",
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2073 ;; "First von von Last", or "d'Last"
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2074 ;; --> 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
2075 (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
2076 ((string-match "\\([^ ]+\\) *\\'" fullname)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2077 ;; name is of the form "First Middle Last" or "Last"
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2078 ;; --> 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
2079 (match-string 1 fullname))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2080 (t (error "Name `%s' is incorrectly formed" fullname)))))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2081 (bibtex-autokey-abbrev
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2082 (funcall bibtex-autokey-name-case-convert name)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2083 bibtex-autokey-name-length)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2084
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2085 (defun bibtex-autokey-get-title ()
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2086 "Get title field contents up to a terminator."
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
2087 (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
2088 (titlestring
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2089 (bibtex-autokey-get-field "title"
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2090 bibtex-autokey-titleword-change-strings)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2091 ;; ignore everything past a terminator
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
2092 (dolist (terminator bibtex-autokey-title-terminators)
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
2093 (if (string-match terminator titlestring)
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
2094 (setq titlestring (substring titlestring 0 (match-beginning 0)))))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2095 ;; gather words from titlestring into a list. Ignore
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2096 ;; 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
2097 (let ((counter 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
2098 titlewords titlewords-extra titleword end-match)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2099 (while (and (or (not (numberp bibtex-autokey-titlewords))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2100 (< counter (+ bibtex-autokey-titlewords
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2101 bibtex-autokey-titlewords-stretch)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2102 (string-match "\\b\\w+" titlestring))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2103 (setq end-match (match-end 0)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2104 titleword (substring titlestring
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2105 (match-beginning 0) end-match))
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
2106 (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
2107 (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
2108 (not (string-match (concat "\\`\\(?:" (car 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
2109 "\\)\\'") titleword)))
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
2110 (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
2111 lst)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2112 (setq titleword
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2113 (funcall bibtex-autokey-titleword-case-convert titleword))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2114 (if (or (not (numberp bibtex-autokey-titlewords))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2115 (< counter bibtex-autokey-titlewords))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2116 (setq titlewords (append titlewords (list titleword)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2117 (setq titlewords-extra
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2118 (append titlewords-extra (list titleword))))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2119 (setq counter (1+ counter)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2120 (setq titlestring (substring titlestring end-match)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2121 (unless (string-match "\\b\\w+" titlestring)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2122 (setq titlewords (append titlewords titlewords-extra)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2123 (mapcar 'bibtex-autokey-demangle-title titlewords))))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2124
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2125 (defun bibtex-autokey-demangle-title (titleword)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2126 "Do some abbreviations on TITLEWORD.
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2127 The rules are defined in `bibtex-autokey-titleword-abbrevs'
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2128 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
2129 (let ((case-fold-search t)
55348
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
2130 (alist bibtex-autokey-titleword-abbrevs))
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
2131 (while (and alist
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
2132 (not (string-match (concat "\\`\\(?:" (caar alist) "\\)\\'")
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
2133 titleword)))
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
2134 (setq alist (cdr alist)))
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
2135 (if alist
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
2136 (cdar alist)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2137 (bibtex-autokey-abbrev titleword
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2138 bibtex-autokey-titleword-length))))
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
2139
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
2140 (defun bibtex-generate-autokey ()
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2141 "Generate automatically a key from the author/editor and the title field.
20446
4bcd559e2cb4 (bibtex-generate-autokey): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 20359
diff changeset
2142 This will only work for entries where each field begins on a separate line.
4bcd559e2cb4 (bibtex-generate-autokey): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 20359
diff changeset
2143 The generation algorithm works as follows:
4bcd559e2cb4 (bibtex-generate-autokey): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 20359
diff changeset
2144 1. Use the value of `bibtex-autokey-prefix-string' as a prefix.
4bcd559e2cb4 (bibtex-generate-autokey): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 20359
diff changeset
2145 2. If there is a non-empty author (preferred) or editor field,
4bcd559e2cb4 (bibtex-generate-autokey): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 20359
diff changeset
2146 use it as the name part of the key.
20907
9a55a557cb5a (bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents: 20866
diff changeset
2147 3. Change any substring found in
9a55a557cb5a (bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents: 20866
diff changeset
2148 `bibtex-autokey-name-change-strings' to the corresponding new
9a55a557cb5a (bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents: 20866
diff changeset
2149 one (see documentation of this variable for further detail).
9a55a557cb5a (bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents: 20866
diff changeset
2150 4. For every of at least first `bibtex-autokey-names' names in
57070
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
2151 the name field, determine the last name. If there are maximal
20446
4bcd559e2cb4 (bibtex-generate-autokey): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 20359
diff changeset
2152 `bibtex-autokey-names' + `bibtex-autokey-names-stretch'
4bcd559e2cb4 (bibtex-generate-autokey): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 20359
diff changeset
2153 names, all names are used.
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2154 5. From every last name, take at least `bibtex-autokey-name-length'
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2155 characters (abort only after a consonant or at a word end).
20907
9a55a557cb5a (bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents: 20866
diff changeset
2156 6. Convert all last names according to the conversion function
9a55a557cb5a (bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents: 20866
diff changeset
2157 `bibtex-autokey-name-case-convert'.
9a55a557cb5a (bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents: 20866
diff changeset
2158 7. Build the name part of the key by concatenating all
9a55a557cb5a (bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents: 20866
diff changeset
2159 abbreviated last names with the string
57070
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
2160 `bibtex-autokey-name-separator' between any two. If there are
20907
9a55a557cb5a (bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents: 20866
diff changeset
2161 more names than are used in the name part, prepend the string
9a55a557cb5a (bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents: 20866
diff changeset
2162 contained in `bibtex-autokey-additional-names'.
20446
4bcd559e2cb4 (bibtex-generate-autokey): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 20359
diff changeset
2163 8. Build the year part of the key by truncating the contents of
4bcd559e2cb4 (bibtex-generate-autokey): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 20359
diff changeset
2164 the year field to the rightmost `bibtex-autokey-year-length'
57070
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
2165 digits (useful values are 2 and 4). If the year field (or any
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2166 other field required to generate the key) is absent, but the entry
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2167 has a valid crossref field and the variable
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2168 `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
2169 crossreferenced entry instead.
20907
9a55a557cb5a (bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents: 20866
diff changeset
2170 9. For the title part of the key change the contents of the
27701
5e135f0faf1d (bibtex-mode): Replaced manual splitting of path
Gerd Moellmann <gerd@gnu.org>
parents: 26711
diff changeset
2171 title field of the entry according to
20907
9a55a557cb5a (bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents: 20866
diff changeset
2172 `bibtex-autokey-titleword-change-strings' to the
9a55a557cb5a (bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents: 20866
diff changeset
2173 corresponding new one (see documentation of this variable for
20446
4bcd559e2cb4 (bibtex-generate-autokey): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 20359
diff changeset
2174 further detail).
4bcd559e2cb4 (bibtex-generate-autokey): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 20359
diff changeset
2175 10. Abbreviate the result to the string up to (but not including)
4bcd559e2cb4 (bibtex-generate-autokey): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 20359
diff changeset
2176 the first occurrence of a regexp matched by the items of
20907
9a55a557cb5a (bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents: 20866
diff changeset
2177 `bibtex-autokey-title-terminators' and delete those words which
9a55a557cb5a (bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents: 20866
diff changeset
2178 appear in `bibtex-autokey-titleword-ignore'.
9a55a557cb5a (bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents: 20866
diff changeset
2179 Build the title part of the key by using at least the first
9a55a557cb5a (bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents: 20866
diff changeset
2180 `bibtex-autokey-titlewords' words from this
57070
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
2181 abbreviated title. If the abbreviated title ends after
20907
9a55a557cb5a (bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents: 20866
diff changeset
2182 maximal `bibtex-autokey-titlewords' +
9a55a557cb5a (bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents: 20866
diff changeset
2183 `bibtex-autokey-titlewords-stretch' words, all
9a55a557cb5a (bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents: 20866
diff changeset
2184 words from the abbreviated title are used.
9a55a557cb5a (bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents: 20866
diff changeset
2185 11. Convert all used titlewords according to the conversion function
9a55a557cb5a (bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents: 20866
diff changeset
2186 `bibtex-autokey-titleword-case-convert'.
9a55a557cb5a (bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents: 20866
diff changeset
2187 12. For every used title word that appears in
9a55a557cb5a (bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents: 20866
diff changeset
2188 `bibtex-autokey-titleword-abbrevs' use the corresponding
9a55a557cb5a (bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents: 20866
diff changeset
2189 abbreviation (see documentation of this variable for further
9a55a557cb5a (bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents: 20866
diff changeset
2190 detail).
9a55a557cb5a (bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents: 20866
diff changeset
2191 13. From every title word not generated by an abbreviation, take
9a55a557cb5a (bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents: 20866
diff changeset
2192 at least `bibtex-autokey-titleword-length' characters (abort
9a55a557cb5a (bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents: 20866
diff changeset
2193 only after a consonant or at a word end).
9a55a557cb5a (bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents: 20866
diff changeset
2194 14. Build the title part of the key by concatenating all
9a55a557cb5a (bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents: 20866
diff changeset
2195 abbreviated title words with the string
9a55a557cb5a (bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents: 20866
diff changeset
2196 `bibtex-autokey-titleword-separator' between any two.
9a55a557cb5a (bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents: 20866
diff changeset
2197 15. At least, to get the key, concatenate
9a55a557cb5a (bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents: 20866
diff changeset
2198 `bibtex-autokey-prefix-string', the name part, the year part
9a55a557cb5a (bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents: 20866
diff changeset
2199 and the title part with `bibtex-autokey-name-year-separator'
9a55a557cb5a (bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents: 20866
diff changeset
2200 between the name part and the year part if both are non-empty
9a55a557cb5a (bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents: 20866
diff changeset
2201 and `bibtex-autokey-year-title-separator' between the year
57070
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
2202 part and the title part if both are non-empty. If the year
20907
9a55a557cb5a (bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents: 20866
diff changeset
2203 part is empty, but not the other two parts,
9a55a557cb5a (bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents: 20866
diff changeset
2204 `bibtex-autokey-year-title-separator' is used as well.
9a55a557cb5a (bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents: 20866
diff changeset
2205 16. If the value of `bibtex-autokey-before-presentation-function'
57070
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
2206 is non-nil, it must be a function taking one argument. This
20907
9a55a557cb5a (bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents: 20866
diff changeset
2207 function is then called with the generated key as the
57070
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
2208 argument. The return value of this function (a string) is
20907
9a55a557cb5a (bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents: 20866
diff changeset
2209 used as the key.
20446
4bcd559e2cb4 (bibtex-generate-autokey): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 20359
diff changeset
2210 17. If the value of `bibtex-autokey-edit-before-use' is non-nil,
20907
9a55a557cb5a (bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents: 20866
diff changeset
2211 the key is then presented in the minibuffer to the user,
22563
2e2a71dfec63 Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents: 21169
diff changeset
2212 where it can be edited. The key given by the user is then
20907
9a55a557cb5a (bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents: 20866
diff changeset
2213 used."
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2214 (let* ((name-etal "")
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
2215 (namelist
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2216 (let ((nl (bibtex-autokey-get-names))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2217 nnl)
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2218 (if (or (not (numberp bibtex-autokey-names))
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2219 (<= (length nl)
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2220 (+ bibtex-autokey-names
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2221 bibtex-autokey-names-stretch)))
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2222 nl
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2223 (setq name-etal bibtex-autokey-additional-names)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2224 (while (< (length nnl) bibtex-autokey-names)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2225 (setq nnl (append nnl (list (car nl)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2226 nl (cdr nl)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2227 nnl)))
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2228 (namepart (concat (mapconcat 'identity
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2229 namelist
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2230 bibtex-autokey-name-separator)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2231 name-etal))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2232 (yearfield (bibtex-autokey-get-field "year"))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2233 (yearpart (if (equal yearfield "")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2234 ""
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2235 (substring yearfield
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2236 (- (length yearfield)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2237 bibtex-autokey-year-length))))
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2238 (titlepart (mapconcat 'identity
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2239 (bibtex-autokey-get-title)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2240 bibtex-autokey-titleword-separator))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2241 (autokey (concat bibtex-autokey-prefix-string
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2242 namepart
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2243 (unless (or (equal namepart "")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2244 (equal yearpart ""))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2245 bibtex-autokey-name-year-separator)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2246 yearpart
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2247 (unless (or (and (equal namepart "")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2248 (equal yearpart ""))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2249 (equal titlepart ""))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2250 bibtex-autokey-year-title-separator)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2251 titlepart)))
20907
9a55a557cb5a (bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents: 20866
diff changeset
2252 (if bibtex-autokey-before-presentation-function
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2253 (funcall bibtex-autokey-before-presentation-function autokey)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2254 autokey)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2255
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2256
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2257 (defun bibtex-parse-keys (&optional add abortable verbose)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2258 "Set `bibtex-reference-keys' to the keys used in the whole buffer.
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2259 The buffer might possibly be restricted.
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2260 Find both entry keys and crossref 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
2261 If ADD is non-nil add the new keys to `bibtex-reference-keys' 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
2262 simply resetting it. If ADD is an alist of keys, 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
2263 `bibtex-reference-keys'. If ABORTABLE is non-nil abort on user
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
2264 input. If VERBOSE is non-nil gives messages about progress.
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2265 Return alist of keys if parsing was completed, `aborted' otherwise."
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2266 (let ((reference-keys (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
2267 (listp bibtex-reference-keys))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2268 bibtex-reference-keys)))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2269 (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
2270 (dolist (key add)
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2271 (unless (assoc (car key) reference-keys)
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2272 (push key reference-keys))))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2273 (save-excursion
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2274 (save-match-data
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2275 (if verbose
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2276 (bibtex-progress-message
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2277 (concat (buffer-name) ": parsing 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
2278 (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
2279 (goto-char (point-min))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2280 (if bibtex-parse-keys-fast
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2281 (let ((case-fold-search t)
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2282 (re (concat bibtex-entry-head "\\|"
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2283 ",[ \t\n]*crossref[ \t\n]*=[ \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
2284 "\\(\"[^\"]*\"\\|{[^}]*}\\)[ \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
2285 (while (re-search-forward re nil t)
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2286 (if (and abortable (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
2287 ;; 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
2288 (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
2289 (let ((key (cond ((match-end 3)
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2290 ;; This is a crossref.
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2291 (buffer-substring-no-properties
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2292 (1+ (match-beginning 3)) (1- (match-end 3))))
55730
b4eeb441c089 Use assoc-string, not assoc-ignore-case.
Richard M. Stallman <rms@gnu.org>
parents: 55348
diff changeset
2293 ((assoc-string (bibtex-type-in-head)
b4eeb441c089 Use assoc-string, not assoc-ignore-case.
Richard M. Stallman <rms@gnu.org>
parents: 55348
diff changeset
2294 bibtex-entry-field-alist 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
2295 ;; This is an entry.
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2296 (match-string-no-properties 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
2297 (if (and (stringp key)
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2298 (not (assoc key reference-keys)))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2299 (push (list key) reference-keys)))))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2300
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2301 (let (;; ignore @String entries because they are handled
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2302 ;; separately by bibtex-parse-strings
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2303 (bibtex-sort-ignore-string-entries t)
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2304 crossref-key bounds)
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2305 (bibtex-map-entries
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2306 (lambda (key beg end)
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2307 (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
2308 (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
2309 ;; 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
2310 (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
2311 (if verbose (bibtex-progress-message))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2312 (unless (assoc key reference-keys)
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2313 (push (list key) reference-keys))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2314 (if (and (setq bounds (bibtex-search-forward-field "crossref" end))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2315 (setq crossref-key (bibtex-text-in-field-bounds bounds t))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2316 (not (assoc crossref-key reference-keys)))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2317 (push (list crossref-key) reference-keys))))))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2318
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2319 (if verbose
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2320 (bibtex-progress-message 'done))
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2321 ;; successful operation --> return `bibtex-reference-keys'
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2322 (setq bibtex-reference-keys reference-keys))))))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2323
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2324 (defun bibtex-parse-strings (&optional add abortable)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2325 "Set `bibtex-strings' to the string definitions in the whole buffer.
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2326 The buffer might possibly be restricted.
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2327 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
2328 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
2329 `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
2330 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
2331 (save-excursion
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2332 (save-match-data
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2333 (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
2334 (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
2335 (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
2336 bibtex-strings))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2337 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
2338 (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
2339 (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
2340 (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
2341 (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
2342 (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
2343 (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
2344 (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
2345 (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
2346 ;; 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
2347 (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
2348 (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
2349 (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
2350 (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
2351 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
2352 (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
2353 ;; 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
2354 (setq bibtex-strings strings))))))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2355
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2356 (defun bibtex-string-files-init ()
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2357 "Return initialization for `bibtex-strings'.
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2358 Use `bibtex-predefined-strings' and bib files `bibtex-string-files'."
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2359 (save-match-data
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2360 ;; collect pathnames
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2361 (let ((dirlist (split-string (or bibtex-string-file-path ".")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2362 ":+"))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2363 (case-fold-search)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2364 compl)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2365 (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
2366 (unless (string-match "\\.bib\\'" filename)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2367 (setq filename (concat filename ".bib")))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2368 ;; test filenames
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2369 (let (fullfilename bounds found)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2370 (dolist (dir dirlist)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2371 (when (file-readable-p
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2372 (setq fullfilename (expand-file-name filename dir)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2373 ;; file was found
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2374 (with-temp-buffer
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2375 (insert-file-contents fullfilename)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2376 (goto-char (point-min))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2377 (while (setq bounds (bibtex-search-forward-string))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2378 (push (cons (bibtex-reference-key-in-string bounds)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2379 (bibtex-text-in-string bounds t))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2380 compl)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2381 (goto-char (bibtex-end-of-string bounds))))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2382 (setq found t)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2383 (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
2384 (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
2385 filename))))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2386 (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
2387
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2388 (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
2389 "Parse buffer in the background during idle time.
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
2390 Called by `bibtex-run-with-idle-timer'. Whenever Emacs has been idle
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2391 for `bibtex-parse-keys-timeout' seconds, all BibTeX buffers (starting
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2392 with the current) are parsed."
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2393 (save-excursion
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2394 (let ((buffers (buffer-list))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2395 (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
2396 (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
2397 (set-buffer (car buffers))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2398 (if (and (eq major-mode 'bibtex-mode)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2399 (not (eq (buffer-modified-tick)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2400 bibtex-buffer-last-parsed-tick)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2401 (save-restriction
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2402 (widen)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2403 ;; Output no progress messages in bibtex-parse-keys
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2404 ;; because when in y-or-n-p that can hide the question.
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2405 (if (and (listp (bibtex-parse-keys nil t))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2406 ;; 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
2407 (listp (bibtex-parse-strings strings-init t)))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2408
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2409 ;; remember that parsing was successful
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2410 (setq bibtex-buffer-last-parsed-tick (buffer-modified-tick)))))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2411 (setq buffers (cdr buffers))))))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2412
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2413 (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
2414 "Complete word fragment before point to longest prefix of COMPLETIONS.
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
2415 COMPLETIONS should be a list of strings. If point is not after the part
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
2416 of a word, all strings are listed. Return completion."
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2417 (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
2418 (beg (save-excursion
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2419 (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
2420 (forward-char)
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2421 (point)))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2422 (end (point))
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2423 (part-of-word (buffer-substring-no-properties beg end))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2424 (completion (try-completion part-of-word completions)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2425 (cond ((not completion)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2426 (error "Can't find completion for `%s'" part-of-word))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2427 ((eq completion t)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2428 part-of-word)
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2429 ((not (string= part-of-word completion))
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2430 (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
2431 (insert completion)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2432 completion)
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2433 (t
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2434 (message "Making completion list...")
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2435 (with-output-to-temp-buffer "*Completions*"
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2436 (display-completion-list (all-completions part-of-word
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2437 completions)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2438 (message "Making completion list...done")
55348
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
2439 ;; return value is handled by choose-completion-string-functions
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2440 nil))))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2441
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
2442 (defun bibtex-complete-string-cleanup (str strings-alist)
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2443 "Cleanup after inserting string STR.
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
2444 Remove enclosing field delimiters for string STR. Display message with
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
2445 expansion of STR using expansion list STRINGS-ALIST."
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
2446 (let ((pair (if (stringp str)
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
2447 (assoc-string str strings-alist t))))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2448 (when pair
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2449 (if (cdr pair)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2450 (message "Abbreviation for `%s'" (cdr pair)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2451 (save-excursion
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2452 (bibtex-inside-field)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2453 (let ((bounds (bibtex-enclosing-field)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2454 (goto-char (bibtex-start-of-text-in-field bounds))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2455 (let ((boundaries (bibtex-parse-field-string)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2456 (if (and boundaries
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2457 (equal (cdr boundaries)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2458 (bibtex-end-of-text-in-field bounds)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2459 (bibtex-remove-delimiters))))))))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2460
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
2461 (defun bibtex-complete-key-cleanup (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
2462 "Display message on entry KEY after completion of a crossref 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
2463 (save-excursion
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
2464 ;; Don't do anything if we completed the key of an 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
2465 (let ((pnt (bibtex-beginning-of-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
2466 (if (and (stringp 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
2467 (bibtex-find-entry 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
2468 (/= 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
2469 (let* ((bibtex-autokey-name-case-convert 'identity)
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
2470 (bibtex-autokey-name-length 'infty)
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
2471 (nl (bibtex-autokey-get-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
2472 (name (concat (nth 0 nl) (if (nth 1 nl) " etal")))
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
2473 (year (bibtex-autokey-get-field "year"))
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
2474 (bibtex-autokey-titlewords 5)
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
2475 (bibtex-autokey-titlewords-stretch 2)
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
2476 (bibtex-autokey-titleword-case-convert 'identity)
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
2477 (bibtex-autokey-titleword-length 5)
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
2478 (title (mapconcat 'identity
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
2479 (bibtex-autokey-get-title) " "))
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
2480 (journal (bibtex-autokey-get-field
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
2481 "journal" bibtex-autokey-transcriptions))
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
2482 (volume (bibtex-autokey-get-field "volume"))
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
2483 (pages (bibtex-autokey-get-field "pages" '(("-.*\\'" . "")))))
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
2484 (message "Ref:%s"
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
2485 (mapconcat (lambda (arg)
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
2486 (if (not (string= "" (cdr arg)))
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
2487 (concat (car arg) (cdr arg))))
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
2488 `((" " . ,name) (" " . ,year)
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
2489 (": " . ,title) (", " . ,journal)
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
2490 (" " . ,volume) (":" . ,pages))
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
2491 "")))))))
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
2492
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2493 (defun bibtex-choose-completion-string (choice buffer mini-p base-size)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2494 ;; Code borrowed from choose-completion-string:
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2495 ;; We must duplicate the code from choose-completion-string
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2496 ;; because it runs the hook choose-completion-string-functions
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2497 ;; before it inserts the completion. But we want to do something
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2498 ;; after the completion has been inserted.
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2499 ;;
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2500 ;; Insert the completion into the buffer where it was requested.
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2501 (set-buffer buffer)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2502 (if base-size
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2503 (delete-region (+ base-size (point-min))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2504 (point))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2505 ;; Delete the longest partial match for CHOICE
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2506 ;; that can be found before point.
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2507 (choose-completion-delete-max-match choice))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2508 (insert choice)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2509 (remove-text-properties (- (point) (length choice)) (point)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2510 '(mouse-face nil))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2511 ;; Update point in the window that BUFFER is showing in.
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2512 (let ((window (get-buffer-window buffer t)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2513 (set-window-point window (point))))
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2514
14789
d68b71228abd (bibtex-pop): New generic function which unifies the
Richard M. Stallman <rms@gnu.org>
parents: 14410
diff changeset
2515 (defun bibtex-pop (arg direction)
57070
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
2516 "Fill current field from the ARG'th same field's text in DIRECTION.
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
2517 Generic function used by `bibtex-pop-previous' and `bibtex-pop-next'."
14789
d68b71228abd (bibtex-pop): New generic function which unifies the
Richard M. Stallman <rms@gnu.org>
parents: 14410
diff changeset
2518 (let (bibtex-help-message)
d68b71228abd (bibtex-pop): New generic function which unifies the
Richard M. Stallman <rms@gnu.org>
parents: 14410
diff changeset
2519 (bibtex-find-text nil))
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2520 (save-excursion
14789
d68b71228abd (bibtex-pop): New generic function which unifies the
Richard M. Stallman <rms@gnu.org>
parents: 14410
diff changeset
2521 ;; parse current field
d68b71228abd (bibtex-pop): New generic function which unifies the
Richard M. Stallman <rms@gnu.org>
parents: 14410
diff changeset
2522 (bibtex-inside-field)
27701
5e135f0faf1d (bibtex-mode): Replaced manual splitting of path
Gerd Moellmann <gerd@gnu.org>
parents: 26711
diff changeset
2523 (let* ((case-fold-search t)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2524 (bounds (bibtex-enclosing-field))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2525 (start-old-text (bibtex-start-of-text-in-field bounds))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2526 (stop-old-text (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
2527 (field-name (bibtex-name-in-field bounds t)))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2528 ;; 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
2529 ;; the last one was finished
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2530 (unless (eq last-command 'bibtex-pop)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2531 (bibtex-enclosing-entry-maybe-empty-head)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2532 (setq bibtex-pop-previous-search-point (match-beginning 0)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2533 bibtex-pop-next-search-point (point)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2534 (if (eq direction 'previous)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2535 (goto-char bibtex-pop-previous-search-point)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2536 (goto-char bibtex-pop-next-search-point))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2537 ;; Now search for arg'th previous/next similar field
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2538 (let (bounds failure new-text)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2539 (while (and (not failure)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2540 (> arg 0))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2541 (cond ((eq direction 'previous)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2542 (if (setq bounds (bibtex-search-backward-field field-name))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2543 (goto-char (bibtex-start-of-field bounds))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2544 (setq failure t)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2545 ((eq direction 'next)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2546 (if (setq bounds (bibtex-search-forward-field field-name))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2547 (goto-char (bibtex-end-of-field bounds))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2548 (setq failure t))))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2549 (setq arg (- arg 1)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2550 (if failure
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2551 (error "No %s matching BibTeX field"
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2552 (if (eq direction 'previous) "previous" "next"))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2553 ;; Found a matching field. Remember boundaries.
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2554 (setq bibtex-pop-previous-search-point (bibtex-start-of-field bounds)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2555 bibtex-pop-next-search-point (bibtex-end-of-field bounds)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2556 new-text (bibtex-text-in-field-bounds bounds))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2557 (bibtex-flash-head)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2558 ;; Go back to where we started, delete old text, and pop new.
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2559 (goto-char stop-old-text)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2560 (delete-region start-old-text stop-old-text)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2561 (insert new-text)))))
14789
d68b71228abd (bibtex-pop): New generic function which unifies the
Richard M. Stallman <rms@gnu.org>
parents: 14410
diff changeset
2562 (let (bibtex-help-message)
d68b71228abd (bibtex-pop): New generic function which unifies the
Richard M. Stallman <rms@gnu.org>
parents: 14410
diff changeset
2563 (bibtex-find-text nil))
d68b71228abd (bibtex-pop): New generic function which unifies the
Richard M. Stallman <rms@gnu.org>
parents: 14410
diff changeset
2564 (setq this-command 'bibtex-pop))
d68b71228abd (bibtex-pop): New generic function which unifies the
Richard M. Stallman <rms@gnu.org>
parents: 14410
diff changeset
2565
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2566 (defsubst bibtex-read-key (prompt &optional key)
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2567 "Read BibTeX key from minibuffer using PROMPT and default KEY."
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2568 (completing-read prompt bibtex-reference-keys
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2569 nil nil key 'bibtex-key-history))
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2570
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2571 ;; Interactive Functions:
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2572
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2573 ;;;###autoload
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2574 (defun bibtex-mode ()
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2575 "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
2576
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2577 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
2578
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2579 You should use commands such as \\[bibtex-Book] to get a template for a
57070
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
2580 specific entry. You should then fill in all desired fields using
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
2581 \\[bibtex-next-field] to jump from field to field. After having filled
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2582 in all desired fields in the entry, you should clean the new 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
2583 with the command \\[bibtex-clean-entry].
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2584
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2585 Some features of BibTeX mode are available only by setting the variable
57070
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
2586 `bibtex-maintain-sorted-entries' to non-nil. However, then BibTeX mode will
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2587 work only with buffers containing valid (syntactical correct) entries
57070
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
2588 and with entries being sorted. This is usually the case, if you have
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2589 created a buffer completely with BibTeX mode and finished every new
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2590 entry with \\[bibtex-clean-entry].
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2591
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2592 For third party BibTeX files, call the function `bibtex-convert-alien'
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2593 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
2594
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2595
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2596 Special information:
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2597
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2598 A command such as \\[bibtex-Book] will outline the fields for a BibTeX book entry.
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2599
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2600 The optional fields start with the string OPT, and are thus ignored by BibTeX.
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2601 Alternatives from which only one is required start with the string ALT.
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2602 The OPT or ALT string may be removed from a field with \\[bibtex-remove-OPT-or-ALT].
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2603 \\[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
2604 \\[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
2605 \\[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
2606 \\[bibtex-remove-delimiters] removes the double-quotes or braces around the text of the current field.
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2607 \\[bibtex-empty-field] replaces the text of the current field with the default \"\" or {}.
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2608
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2609 The command \\[bibtex-clean-entry] cleans the current entry, i.e. it removes OPT/ALT
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2610 from all non-empty optional or alternative fields, checks that no required
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2611 fields are empty, and does some formatting dependent on the value of
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2612 `bibtex-entry-format'.
22563
2e2a71dfec63 Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents: 21169
diff changeset
2613 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
2614 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
2615 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
2616
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2617 Use \\[bibtex-find-text] to position the cursor at the end of the current field.
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2618 Use \\[bibtex-next-field] to move to end of the next field.
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2619
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2620 The following may be of interest as well:
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2621
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2622 Functions:
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2623 `bibtex-entry'
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2624 `bibtex-kill-entry'
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2625 `bibtex-yank-pop'
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2626 `bibtex-pop-previous'
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2627 `bibtex-pop-next'
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2628 `bibtex-complete'
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2629 `bibtex-print-help-message'
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2630 `bibtex-generate-autokey'
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2631 `bibtex-beginning-of-entry'
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2632 `bibtex-end-of-entry'
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2633 `bibtex-reposition-window'
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2634 `bibtex-mark-entry'
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2635 `bibtex-ispell-abstract'
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2636 `bibtex-ispell-entry'
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2637 `bibtex-narrow-to-entry'
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2638 `bibtex-sort-buffer'
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2639 `bibtex-validate'
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2640 `bibtex-count'
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2641 `bibtex-fill-entry'
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2642 `bibtex-reformat'
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2643 `bibtex-convert-alien'
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2644
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2645 Variables:
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2646 `bibtex-field-delimiters'
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2647 `bibtex-include-OPTcrossref'
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2648 `bibtex-include-OPTkey'
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2649 `bibtex-user-optional-fields'
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2650 `bibtex-entry-format'
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2651 `bibtex-sort-ignore-string-entries'
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2652 `bibtex-maintain-sorted-entries'
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2653 `bibtex-entry-field-alist'
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2654 `bibtex-predefined-strings'
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2655 `bibtex-string-files'
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2656
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2657 ---------------------------------------------------------
19461
6b67f20dd710 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 19460
diff changeset
2658 Entry to BibTeX mode calls the value of `bibtex-mode-hook' if that value is
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2659 non-nil.
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2660
22563
2e2a71dfec63 Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents: 21169
diff changeset
2661 \\{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
2662 (interactive)
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2663 (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
2664 (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
2665 (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
2666 (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
2667 (set-syntax-table bibtex-mode-syntax-table)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2668 (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
2669 ;; Install stealthy parse function if not already installed
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2670 (unless bibtex-parse-idle-timer
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2671 (setq bibtex-parse-idle-timer (bibtex-run-with-idle-timer
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2672 bibtex-parse-keys-timeout t
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2673 'bibtex-parse-buffers-stealthily)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2674 (set (make-local-variable 'paragraph-start) "[ \f\n\t]*$")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2675 (set (make-local-variable 'comment-start) bibtex-comment-start)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2676 (set (make-local-variable 'comment-start-skip)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2677 (concat (regexp-quote bibtex-comment-start) "\\>[ \t]*"))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2678 (set (make-local-variable 'comment-column) 0)
51416
83476384bebd (bibtex-member-of-regexp, bibtex-assoc-of-regexp, bibtex-format-entry)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51415
diff changeset
2679 (set (make-local-variable 'defun-prompt-regexp) "^[ \t]*@[a-zA-Z0-9]+[ \t]*")
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2680 (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
2681 (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
2682 (set (make-local-variable 'fill-prefix) (make-string (+ bibtex-entry-offset
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2683 bibtex-contline-indentation)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2684 ? ))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2685 (set (make-local-variable 'font-lock-defaults)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2686 '(bibtex-font-lock-keywords
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2687 nil t ((?$ . "\"")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2688 ;; Mathematical expressions should be fontified as strings
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2689 (?\" . ".")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2690 ;; Quotes are field delimiters and quote-delimited
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2691 ;; entries should be fontified in the same way as
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2692 ;; brace-delimited ones
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2693 )
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2694 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
2695 (font-lock-syntactic-keywords . bibtex-font-lock-syntactic-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
2696 (font-lock-extra-managed-props . (mouse-face keymap))
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2697 (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
2698 . (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
2699 (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
2700 (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
2701 (setq imenu-generic-expression
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2702 (list (list nil bibtex-entry-head bibtex-key-in-head)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2703 (make-local-variable 'choose-completion-string-functions)
20459
90f306f86f5d Use imenu-case-fold-search.
Dave Love <fx@gnu.org>
parents: 20447
diff changeset
2704 (setq imenu-case-fold-search t)
20907
9a55a557cb5a (bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents: 20866
diff changeset
2705 ;; XEmacs needs easy-menu-add, Emacs does not care
9a55a557cb5a (bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents: 20866
diff changeset
2706 (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
2707 (easy-menu-add bibtex-entry-menu)
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2708 (run-hooks 'bibtex-mode-hook))
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2709
55348
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
2710 (defun bibtex-field-list (entry-type)
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
2711 "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
2712 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
2713 where REQUIRED and OPTIONAL are lists of the required and optional field
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
2714 names for ENTRY-TYPE according to `bibtex-entry-field-alist'."
55730
b4eeb441c089 Use assoc-string, not assoc-ignore-case.
Richard M. Stallman <rms@gnu.org>
parents: 55348
diff changeset
2715 (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
2716 required optional)
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
2717 (unless e
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
2718 (error "Bibtex entry type %s not defined" entry-type))
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
2719 (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
2720 (nth 2 e))
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
2721 (setq required (nth 0 (nth 2 e))
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
2722 optional (nth 1 (nth 2 e)))
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
2723 (setq required (nth 0 (nth 1 e))
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
2724 optional (nth 1 (nth 1 e))))
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
2725 (if bibtex-include-OPTkey
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
2726 (push (list "key"
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
2727 "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
2728 (if (or (stringp bibtex-include-OPTkey)
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
2729 (fboundp bibtex-include-OPTkey))
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
2730 bibtex-include-OPTkey))
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
2731 optional))
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
2732 (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
2733 (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
2734 optional))
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
2735 (setq optional (append optional bibtex-user-optional-fields))
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
2736 (cons required optional)))
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
2737
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2738 (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
2739 "Insert a new BibTeX entry of type ENTRY-TYPE.
19461
6b67f20dd710 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 19460
diff changeset
2740 After insertion it calls the functions in `bibtex-add-entry-hook'."
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2741 (interactive (let* ((completion-ignore-case t)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2742 (e-t (completing-read
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2743 "Entry Type: "
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2744 bibtex-entry-field-alist
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2745 nil t nil 'bibtex-entry-type-history)))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2746 (list e-t)))
55348
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
2747 (let ((key (if bibtex-maintain-sorted-entries
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
2748 (bibtex-read-key (format "%s key: " entry-type))))
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
2749 (field-list (bibtex-field-list entry-type)))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2750 (unless (bibtex-prepare-new-entry (list key nil entry-type))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2751 (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
2752 (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
2753 (insert "@" entry-type (bibtex-entry-left-delimiter))
55348
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
2754 (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
2755 (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
2756 (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
2757 (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
2758 (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
2759 (insert ","))
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2760 (insert "\n")
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2761 (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
2762 (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
2763 (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
2764 (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
2765 (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
2766 (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
2767
55348
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
2768 (defun bibtex-entry-update ()
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
2769 "Update an existing BibTeX entry.
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
2770 In the BibTeX entry at point, make new fields for those items that may occur
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
2771 according to `bibtex-entry-field-alist', but are not yet present."
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
2772 (interactive)
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
2773 (save-excursion
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
2774 (bibtex-beginning-of-entry)
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
2775 ;; For inserting new fields, we use the fact that
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
2776 ;; bibtex-parse-entry moves point to the end of the last field.
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
2777 (let* ((fields-alist (bibtex-parse-entry))
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
2778 (field-list (bibtex-field-list
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
2779 (substring (cdr (assoc "=type=" fields-alist))
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
2780 1)))) ; don't want @
55348
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
2781 (dolist (field (car field-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
2782 (unless (assoc-string (car field) fields-alist t)
55348
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
2783 (bibtex-make-field field)))
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
2784 (dolist (field (cdr field-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
2785 (unless (assoc-string (car field) fields-alist t)
55348
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
2786 (bibtex-make-optional-field field))))))
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
2787
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2788 (defun 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
2789 "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
2790 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
2791 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
2792 TEXT may be nil. Remove \"OPT\" and \"ALT\" from FIELD.
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
2793 Move point to the end of the last 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
2794 (let (alist bounds)
55880
1b2cb608f18e (bibtex-format-entry): Fix regexps.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55730
diff changeset
2795 (when (looking-at bibtex-entry-maybe-empty-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
2796 (push (cons "=type=" (match-string bibtex-type-in-head)) alist)
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2797 (push (cons "=key=" (match-string bibtex-key-in-head)) alist)
55880
1b2cb608f18e (bibtex-format-entry): Fix regexps.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55730
diff changeset
2798 (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
2799 (while (setq bounds (bibtex-parse-field bibtex-field-name))
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
2800 (push (cons (bibtex-name-in-field 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
2801 (bibtex-text-in-field-bounds bounds))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2802 alist)
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2803 (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
2804 alist))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2805
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2806 (defun bibtex-autofill-entry ()
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2807 "Try to fill fields based on surrounding entries."
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2808 (interactive)
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2809 (undo-boundary) ;So you can easily undo it, if it didn't work right.
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2810 (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
2811 (when (looking-at bibtex-entry-head)
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2812 (let ((type (match-string bibtex-type-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
2813 (key (match-string 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
2814 (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
2815 (case-fold-search t)
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2816 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
2817 ;; 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
2818 (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
2819 ;; 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
2820 ;; 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
2821 (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
2822 (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
2823 (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
2824 (when (and
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2825 (looking-at bibtex-entry-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
2826 (bibtex-string= type (match-string bibtex-type-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
2827 ;; In case we found ourselves :-(
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2828 (not (equal key (setq tmp (match-string 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
2829 (setq other-key tmp)
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2830 (setq other (point))))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2831 (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
2832 (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
2833 (bibtex-skip-to-valid-entry)
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2834 (when (and
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2835 (looking-at bibtex-entry-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
2836 (bibtex-string= type (match-string bibtex-type-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
2837 ;; In case we found ourselves :-(
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2838 (not (equal key (setq tmp (match-string 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
2839 (or (not 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
2840 ;; Check which is the best match.
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2841 (< (length (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
2842 (length (try-completion "" (list key tmp))))))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2843 (setq other-key tmp)
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2844 (setq other (point))))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2845 ;; 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
2846 (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
2847 (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
2848 (setq key-end (point)) ;In case parse-entry changed the buffer.
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2849 (while (setq bounds (bibtex-parse-field bibtex-field-name))
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
2850 (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
2851 other 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
2852 (goto-char (bibtex-start-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
2853 (if (not (and (looking-at bibtex-empty-field-re) text))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2854 (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
2855 (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
2856 (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
2857 ;; 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
2858 ;; 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
2859 (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
2860 ;; 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
2861 ;; 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
2862 (_ (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
2863 (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
2864 (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
2865 (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
2866 (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
2867 (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
2868
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2869 (defun bibtex-print-help-message ()
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2870 "Print helpful information about current field in current BibTeX entry."
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2871 (interactive)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2872 (save-excursion
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2873 (let* ((case-fold-search 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
2874 (field-name (bibtex-name-in-field (bibtex-enclosing-field) t))
55348
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
2875 (field-list (bibtex-field-list (progn (re-search-backward
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
2876 bibtex-entry-maybe-empty-head nil t)
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
2877 (bibtex-type-in-head))))
55730
b4eeb441c089 Use assoc-string, not assoc-ignore-case.
Richard M. Stallman <rms@gnu.org>
parents: 55348
diff changeset
2878 (comment (assoc-string field-name
b4eeb441c089 Use assoc-string, not assoc-ignore-case.
Richard M. Stallman <rms@gnu.org>
parents: 55348
diff changeset
2879 (append (car field-list)
b4eeb441c089 Use assoc-string, not assoc-ignore-case.
Richard M. Stallman <rms@gnu.org>
parents: 55348
diff changeset
2880 (cdr field-list))
b4eeb441c089 Use assoc-string, not assoc-ignore-case.
Richard M. Stallman <rms@gnu.org>
parents: 55348
diff changeset
2881 t)))
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2882 (if comment
55348
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
2883 (message (nth 1 comment))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2884 (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
2885
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2886 (defun bibtex-make-field (field &optional called-by-yank)
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2887 "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
2888 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
2889 \(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
2890 `bibtex-entry-field-alist'.
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
2891 If CALLED-BY-YANK is non-nil, don't insert delimiters."
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2892 (interactive
55348
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
2893 (list (let ((completion-ignore-case t)
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
2894 (field-list (bibtex-field-list
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
2895 (save-excursion
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
2896 (bibtex-enclosing-entry-maybe-empty-head)
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
2897 (bibtex-type-in-head)))))
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
2898 (completing-read "BibTeX field name: "
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
2899 (append (car field-list) (cdr field-list))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2900 nil nil nil bibtex-field-history))))
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2901 (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
2902 (setq field (list field)))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2903 (if (or (interactive-p) called-by-yank)
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2904 (let (bibtex-help-message)
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2905 (bibtex-find-text nil t t)
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2906 (if (looking-at "[}\"]")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2907 (forward-char))))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2908 (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
2909 (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
2910 (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
2911 (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
2912 (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
2913 (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
2914 (- 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
2915 (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
2916 (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
2917 (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
2918 bibtex-text-indentation)))
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
2919 (unless called-by-yank (insert (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
2920 (let ((init (nth 2 field)))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2921 (cond ((stringp init)
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2922 (insert init))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2923 ((fboundp init)
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2924 (insert (funcall init)))))
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
2925 (unless called-by-yank (insert (bibtex-field-right-delimiter)))
55348
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
2926 (when (interactive-p)
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
2927 (forward-char -1)
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
2928 (bibtex-print-help-message)))
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2929
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2930 (defun bibtex-beginning-of-entry ()
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2931 "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
2932 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
2933 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
2934 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
2935 (interactive)
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2936 (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
2937 (if (looking-at "@")
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2938 (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
2939 (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
2940 (point))
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2941
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2942 (defun bibtex-end-of-entry ()
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2943 "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
2944 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
2945 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
2946 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
2947 (interactive)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2948 (let ((case-fold-search t)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2949 (org (point))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2950 (pnt (bibtex-beginning-of-entry))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2951 err 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
2952 (cond ((looking-at bibtex-valid-entry-whitespace-re)
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2953 (bibtex-search-entry t nil t)
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2954 (unless (equal (match-beginning 0) pnt)
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2955 (setq err t)))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
2956 ((setq bounds (bibtex-parse-string))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2957 (goto-char (bibtex-end-of-string bounds)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2958 ((looking-at "[ \t]*@[ \t]*preamble[ \t\n]*")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2959 (goto-char (match-end 0))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2960 (cond ((looking-at "(")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2961 (unless (re-search-forward ")[ \t]*\n\n" nil 'move)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2962 (setq err t)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2963 ((looking-at "{")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2964 (unless (re-search-forward "}[ \t]*\n\n" nil 'move)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2965 (setq err t)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2966 (t
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2967 (setq err t)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2968 (unless err
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2969 (goto-char (match-beginning 0))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2970 (forward-char)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2971 (t
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2972 (if (interactive-p)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2973 (message "Not on a known BibTeX entry."))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2974 (goto-char org)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2975 (when err
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2976 (goto-char pnt)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2977 (error "Syntactically incorrect BibTeX entry starts here")))
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2978 (point))
22563
2e2a71dfec63 Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents: 21169
diff changeset
2979
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2980 (defun bibtex-reposition-window (&optional arg)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2981 "Make the current BibTeX entry visible.
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
2982 Optional argument ARG is exactly as in `recenter'."
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2983 (interactive "P")
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2984 (save-excursion
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2985 (goto-char
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2986 (/ (+ (bibtex-beginning-of-entry) (bibtex-end-of-entry)) 2))
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2987 (recenter arg)))
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2988
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2989 (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
2990 "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
2991 (interactive)
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2992 (set-mark (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
2993 (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
2994
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2995 (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
2996 "Count number of entries in current buffer or region.
22563
2e2a71dfec63 Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents: 21169
diff changeset
2997 With prefix argument COUNT-STRING-ENTRIES it counts all entries,
2e2a71dfec63 Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents: 21169
diff changeset
2998 otherwise it counts all except Strings.
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
2999 If mark is active it counts entries in region, if not in whole buffer."
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3000 (interactive "P")
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3001 (let ((number 0)
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3002 (bibtex-sort-ignore-string-entries
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3003 (not count-string-entries)))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3004 (save-excursion
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3005 (save-restriction
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3006 (narrow-to-region (if (bibtex-mark-active)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3007 (region-beginning)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3008 (bibtex-beginning-of-first-entry))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3009 (if (bibtex-mark-active)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3010 (region-end)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3011 (point-max)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3012 (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
3013 (bibtex-map-entries (lambda (key beg end)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3014 (setq number (1+ number))))))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3015 (message "%s contains %d entries."
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3016 (if (bibtex-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
3017 number)))
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3018
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3019 (defun bibtex-ispell-entry ()
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3020 "Spell whole BibTeX entry."
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3021 (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
3022 (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
3023 (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
3024
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3025 (defun bibtex-ispell-abstract ()
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3026 "Spell abstract of BibTeX entry."
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3027 (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
3028 (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
3029 (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
3030 (bibtex-search-forward-field "abstract" t))))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3031 (if bounds
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3032 (ispell-region (bibtex-start-of-text-in-field bounds)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3033 (bibtex-end-of-text-in-field bounds))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3034 (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
3035
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3036 (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
3037 "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
3038 (interactive)
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3039 (save-excursion
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3040 (widen)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3041 (narrow-to-region (bibtex-beginning-of-entry)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3042 (bibtex-end-of-entry))))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3043
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3044 (defun bibtex-entry-index ()
57070
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
3045 "Return the index of the BibTeX entry at point. Move point.
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3046 The index is a list (KEY CROSSREF-KEY ENTRY-NAME) that is used for sorting
57070
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
3047 the entries of the BibTeX buffer. Return nil if no entry found."
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3048 (let ((case-fold-search t))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3049 (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
3050 (let ((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
3051 ;; all entry names should be downcase (for ease of comparison)
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3052 (entry-name (downcase (bibtex-type-in-head))))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3053 ;; Don't search CROSSREF-KEY if we don't need it.
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3054 (if (equal bibtex-maintain-sorted-entries 'crossref)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3055 (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
3056 (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
3057 (let ((bounds (bibtex-search-forward-field
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3058 "\\(OPT\\)?crossref" t)))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3059 (list key
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3060 (if bounds (bibtex-text-in-field-bounds bounds t))
55348
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
3061 entry-name)))
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
3062 (list key nil entry-name))))))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3063
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3064 (defun bibtex-lessp (index1 index2)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3065 "Predicate for sorting BibTeX entries with indices INDEX1 and INDEX2.
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3066 Each index is a list (KEY CROSSREF-KEY ENTRY-NAME).
55348
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
3067 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
3068 If its value is nil use plain sorting."
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3069 (cond ((not index1) (not index2)) ; indices can be nil
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3070 ((not index2) nil)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3071 ((equal bibtex-maintain-sorted-entries 'crossref)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3072 (if (nth 1 index1)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3073 (if (nth 1 index2)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3074 (or (string-lessp (nth 1 index1) (nth 1 index2))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3075 (and (string-equal (nth 1 index1) (nth 1 index2))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3076 (string-lessp (nth 0 index1) (nth 0 index2))))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3077 (not (string-lessp (nth 0 index2) (nth 1 index1))))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3078 (if (nth 1 index2)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3079 (string-lessp (nth 0 index1) (nth 1 index2))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3080 (string-lessp (nth 0 index1) (nth 0 index2)))))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3081 ((equal 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
3082 (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
3083 (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
3084 '(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
3085 (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
3086 (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
3087 '(nil . 1000))))) ; if there is nothing else
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3088 (or (< n1 n2)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3089 (and (= n1 n2)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3090 (string-lessp (car index1) (car index2))))))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3091 (t ; (equal bibtex-maintain-sorted-entries 'plain)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3092 (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
3093
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3094 (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
3095 "Sort BibTeX buffer alphabetically by key.
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3096 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
3097 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
3098 affected. If `bibtex-sort-ignore-string-entries' is non-nil, @String entries
55312
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
3099 will be ignored."
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3100 (interactive)
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3101 (save-restriction
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3102 (narrow-to-region (bibtex-beginning-of-first-entry)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3103 (save-excursion (goto-char (point-max))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3104 (bibtex-end-of-entry)))
18247
ae094c1a4334 (bibtex-delete-whitespace, bibtex-current-line)
Richard M. Stallman <rms@gnu.org>
parents: 18212
diff changeset
3105 (bibtex-skip-to-valid-entry)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3106 (sort-subr nil
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3107 'bibtex-skip-to-valid-entry ; NEXTREC function
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3108 'bibtex-end-of-entry ; ENDREC function
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3109 'bibtex-entry-index ; STARTKEY function
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3110 nil ; ENDKEY function
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3111 'bibtex-lessp))) ; PREDICATE
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3112
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3113 (defun bibtex-find-crossref (crossref-key)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3114 "Move point to the beginning of BibTeX entry CROSSREF-KEY.
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3115 Return position of entry if CROSSREF-KEY is found and nil 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
3116 If position of current entry is after CROSSREF-KEY an error is signaled.
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3117 If called interactively, CROSSREF-KEY defaults to crossref key of current
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3118 entry."
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3119 (interactive
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3120 (let ((crossref-key
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3121 (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
3122 (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
3123 (let ((bounds (bibtex-search-forward-field "crossref" t)))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3124 (if bounds
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3125 (bibtex-text-in-field-bounds bounds t))))))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3126 (list (bibtex-read-key "Find crossref key: " crossref-key))))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3127 (let ((pos (save-excursion (bibtex-find-entry crossref-key))))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3128 (if (and pos (> (point) pos))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3129 (error "This entry must not follow the crossrefed entry!"))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3130 (goto-char pos)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3131
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
3132 (defun bibtex-find-entry (key &optional start)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3133 "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
3134 Return position of entry if KEY is found or nil if not found.
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
3135 Optional arg START is buffer position where the search starts.
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
3136 If it is nil, start search at beginning of buffer.
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
3137 With prefix arg, the value of START is position of 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
3138 (interactive (list (bibtex-read-key "Find 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
3139 (if current-prefix-arg (point))))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3140 (let* (case-fold-search
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3141 (pnt (save-excursion
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
3142 (goto-char (or start (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
3143 (if (re-search-forward (concat "^[ \t]*\\("
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3144 bibtex-entry-type
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3145 "\\)[ \t]*[({][ \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
3146 (regexp-quote key)
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3147 "\\)[ \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
3148 nil t)
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3149 (match-beginning 0)))))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3150 (cond (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
3151 (goto-char pnt))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3152 ((interactive-p)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3153 (message "Key `%s' not found" key)))))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3154
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3155 (defun bibtex-prepare-new-entry (index)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3156 "Prepare a new BibTeX entry with index INDEX.
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3157 INDEX is a list (KEY CROSSREF-KEY ENTRY-NAME).
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3158 Move point where the entry KEY should be placed.
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3159 If `bibtex-maintain-sorted-entries' is non-nil, perform a binary
57070
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
3160 search to look for place for KEY. This will fail if buffer is not in
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3161 sorted order, see \\[bibtex-validate].)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3162 Return t if preparation was successful or nil if entry KEY already exists."
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3163 (let ((key (nth 0 index))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3164 key-exist)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3165 (cond ((or (null key)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3166 (and (stringp key)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3167 (string-equal key ""))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3168 (and (not (setq key-exist (bibtex-find-entry key)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3169 (not bibtex-maintain-sorted-entries)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3170 (bibtex-move-outside-of-entry))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3171 ;; 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
3172 ;; then point will be at beginning of entry named key.
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3173 (key-exist)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3174 (t ; bibtex-maintain-sorted-entries is non-nil
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3175 (let* ((case-fold-search t)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3176 (left (save-excursion (bibtex-beginning-of-first-entry)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3177 (bibtex-skip-to-valid-entry)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3178 (point)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3179 (right (save-excursion (bibtex-beginning-of-last-entry)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3180 (bibtex-end-of-entry)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3181 (found (if (>= left right) left))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3182 actual-index new)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3183 (save-excursion
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3184 ;; Binary search
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3185 (while (not found)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3186 (goto-char (/ (+ left right) 2))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3187 (bibtex-skip-to-valid-entry t)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3188 (setq actual-index (bibtex-entry-index))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3189 (cond ((bibtex-lessp index actual-index)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3190 (setq new (bibtex-beginning-of-entry))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3191 (if (equal right new)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3192 (setq found right)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3193 (setq right new)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3194 (t
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3195 (bibtex-end-of-entry)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3196 (bibtex-skip-to-valid-entry)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3197 (setq new (point))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3198 (if (equal left new)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3199 (setq found right)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3200 (setq left new))))))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3201 (goto-char found)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3202 (bibtex-beginning-of-entry)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3203 (setq actual-index (save-excursion (bibtex-entry-index)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3204 (when (or (not actual-index)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3205 (bibtex-lessp actual-index index))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3206 ;; buffer contains no valid entries or
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3207 ;; greater than last entry --> append
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3208 (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
3209 (unless (bobp) (newline (forward-line 2)))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3210 (beginning-of-line)))))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3211 (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
3212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3213 (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
3214 "Validate if buffer or region is syntactically correct.
27701
5e135f0faf1d (bibtex-mode): Replaced manual splitting of path
Gerd Moellmann <gerd@gnu.org>
parents: 26711
diff changeset
3215 Only known entry types are checked, so you can put comments
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3216 outside of entries.
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3217 With optional argument TEST-THOROUGHLY non-nil it checks for absence of
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3218 required fields and questionable month fields as well.
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3219 If mark is active, validate current region, if not the whole buffer.
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3220 Returns t if test was successful, nil otherwise."
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3221 (interactive "P")
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3222 (let* ((case-fold-search t)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3223 error-list syntax-error)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3224 (save-excursion
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3225 (save-restriction
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3226 (narrow-to-region (if (bibtex-mark-active)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3227 (region-beginning)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3228 (bibtex-beginning-of-first-entry))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3229 (if (bibtex-mark-active)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3230 (region-end)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3231 (point-max)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3232
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3233 ;; looking if entries fit syntactical structure
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3234 (goto-char (point-min))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3235 (bibtex-progress-message "Checking syntactical structure")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3236 (let (bibtex-sort-ignore-string-entries)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3237 (while (re-search-forward "^[ \t]*@" nil t)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3238 (bibtex-progress-message)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3239 (forward-char -1)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3240 (let ((pnt (point)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3241 (if (not (looking-at bibtex-any-valid-entry-re))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3242 (forward-char)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3243 (bibtex-skip-to-valid-entry)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3244 (if (equal (point) pnt)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3245 (forward-char)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3246 (goto-char pnt)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3247 (push (list (bibtex-current-line)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3248 "Syntax error (check esp. commas, braces, and quotes)")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3249 error-list)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3250 (forward-char))))))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3251 (bibtex-progress-message 'done)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3252
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3253 (if error-list
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3254 (setq syntax-error t)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3255 ;; looking for correct sort order and duplicates (only if
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3256 ;; there were no syntax errors)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3257 (if bibtex-maintain-sorted-entries
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3258 (let (previous current)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3259 (goto-char (point-min))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3260 (bibtex-progress-message "Checking correct sort order")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3261 (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
3262 (lambda (key beg end)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3263 (bibtex-progress-message)
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3264 (goto-char beg)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3265 (setq current (bibtex-entry-index))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3266 (cond ((or (not previous)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3267 (bibtex-lessp previous current))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3268 (setq previous current))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3269 ((string-equal (car previous) (car current))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3270 (push (list (bibtex-current-line)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3271 "Duplicate key with previous")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3272 error-list))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3273 (t
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3274 (setq previous current)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3275 (push (list (bibtex-current-line)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3276 "Entries out of order")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3277 error-list)))))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3278 (bibtex-progress-message 'done)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3279
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3280 (when test-thoroughly
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3281 (goto-char (point-min))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3282 (bibtex-progress-message
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3283 "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
3284 (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
3285 (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
3286 (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
3287 (bibtex-progress-message)
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* ((entry-list (progn
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3289 (goto-char beg)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3290 (bibtex-search-entry nil end)
55730
b4eeb441c089 Use assoc-string, not assoc-ignore-case.
Richard M. Stallman <rms@gnu.org>
parents: 55348
diff changeset
3291 (assoc-string (bibtex-type-in-head)
b4eeb441c089 Use assoc-string, not assoc-ignore-case.
Richard M. Stallman <rms@gnu.org>
parents: 55348
diff changeset
3292 bibtex-entry-field-alist t)))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3293 (req (copy-sequence (elt (elt entry-list 1) 0)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3294 (creq (copy-sequence (elt (elt entry-list 2) 0)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3295 crossref-there bounds)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3296 (goto-char beg)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3297 (while (setq bounds (bibtex-search-forward-field
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3298 bibtex-field-name end))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3299 (goto-char (bibtex-start-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
3300 (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
3301 (if (and (bibtex-string= field-name "month")
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
3302 (not (assoc-string (bibtex-text-in-field-bounds 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
3303 bibtex-predefined-month-strings t)))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3304 (push (list (bibtex-current-line)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3305 "Questionable month field")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3306 error-list))
55730
b4eeb441c089 Use assoc-string, not assoc-ignore-case.
Richard M. Stallman <rms@gnu.org>
parents: 55348
diff changeset
3307 (setq req (delete (assoc-string field-name req t) req)
b4eeb441c089 Use assoc-string, not assoc-ignore-case.
Richard M. Stallman <rms@gnu.org>
parents: 55348
diff changeset
3308 creq (delete (assoc-string field-name creq t) creq))
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
3309 (if (bibtex-string= field-name "crossref")
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3310 (setq crossref-there t))))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3311 (if crossref-there
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3312 (setq req creq))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3313 (if (or (> (length req) 1)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3314 (and (= (length req) 1)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3315 (not (elt (car req) 3))))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3316 ;; two (or more) fields missed or one field
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3317 ;; missed and this isn't flagged alternative
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3318 ;; (notice that this fails if there are more
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3319 ;; than two alternatives in a BibTeX entry,
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3320 ;; which isn't the case momentarily)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3321 (push (list (save-excursion
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3322 (bibtex-beginning-of-entry)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3323 (bibtex-current-line))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3324 (concat "Required field `" (caar req) "' missing"))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3325 error-list))))))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3326 (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
3327 (if error-list
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3328 (let ((bufnam (buffer-name))
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3329 (dir default-directory))
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3330 (setq error-list
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3331 (sort error-list
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3332 (lambda (a b)
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3333 (< (car a) (car b)))))
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3334 (let ((pop-up-windows t))
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3335 (pop-to-buffer nil t))
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3336 (switch-to-buffer
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3337 (get-buffer-create "*BibTeX validation errors*") t)
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3338 ;; don't use switch-to-buffer-other-window, since this
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3339 ;; doesn't allow the second parameter NORECORD
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3340 (setq default-directory dir)
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3341 (toggle-read-only -1)
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3342 (compilation-mode)
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3343 (delete-region (point-min) (point-max))
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3344 (goto-char (point-min))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3345 (insert "BibTeX mode command `bibtex-validate'\n"
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3346 (if syntax-error
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3347 "Maybe undetected errors due to syntax errors. Correct and validate again."
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3348 "")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3349 "\n")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3350 (dolist (err error-list)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3351 (insert bufnam ":" (number-to-string (elt err 0))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3352 ": " (elt err 1) "\n"))
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3353 (set-buffer-modified-p nil)
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3354 (toggle-read-only 1)
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3355 (goto-char (point-min))
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3356 (other-window -1)
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3357 ;; return nil
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3358 nil)
20907
9a55a557cb5a (bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents: 20866
diff changeset
3359 (if (bibtex-mark-active)
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3360 (message "Region is syntactically correct")
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3361 (message "Buffer is syntactically correct"))
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3362 t)))
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-next-field (arg)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3365 "Find end of text of next BibTeX field; with ARG, to its beginning."
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3366 (interactive "P")
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3367 (bibtex-inside-field)
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3368 (let ((start (point)))
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3369 (condition-case ()
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3370 (let ((bounds (bibtex-enclosing-field)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3371 (goto-char (bibtex-end-of-field bounds))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3372 (forward-char 2))
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3373 (error
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3374 (goto-char start)
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3375 (end-of-line)
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3376 (forward-char))))
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3377 (bibtex-find-text arg t))
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3378
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3379 (defun bibtex-find-text (arg &optional as-if-interactive no-error)
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3380 "Go to end of text of current field; with ARG, go to beginning."
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3381 (interactive "P")
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3382 (bibtex-inside-field)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3383 (let ((bounds (bibtex-enclosing-field (or (interactive-p)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3384 as-if-interactive))))
27701
5e135f0faf1d (bibtex-mode): Replaced manual splitting of path
Gerd Moellmann <gerd@gnu.org>
parents: 26711
diff changeset
3385 (if bounds
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3386 (progn (if arg
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3387 (progn (goto-char (bibtex-start-of-text-in-field bounds))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3388 (if (looking-at "[{\"]")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3389 (forward-char)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3390 (goto-char (bibtex-end-of-text-in-field bounds))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3391 (if (or (= (preceding-char) ?})
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3392 (= (preceding-char) ?\"))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3393 (forward-char -1)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3394 (if bibtex-help-message
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3395 (bibtex-print-help-message)))
27701
5e135f0faf1d (bibtex-mode): Replaced manual splitting of path
Gerd Moellmann <gerd@gnu.org>
parents: 26711
diff changeset
3396 (beginning-of-line)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3397 (cond ((setq bounds (bibtex-parse-string))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3398 (goto-char (if arg
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3399 (bibtex-start-of-text-in-string bounds)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3400 (bibtex-end-of-text-in-string bounds))))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3401 ((looking-at bibtex-entry-maybe-empty-head)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3402 (goto-char (if arg
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3403 (match-beginning bibtex-key-in-head)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3404 (match-end 0))))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3405 (t
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3406 (unless no-error
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3407 (error "Not on BibTeX field")))))))
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3408
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3409 (defun bibtex-remove-OPT-or-ALT ()
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3410 "Remove the string starting optional/alternative fields.
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3411 Align text and go thereafter to end of text."
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3412 (interactive)
27701
5e135f0faf1d (bibtex-mode): Replaced manual splitting of path
Gerd Moellmann <gerd@gnu.org>
parents: 26711
diff changeset
3413 (bibtex-inside-field)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3414 (let ((case-fold-search t)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3415 (bounds (bibtex-enclosing-field)))
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3416 (save-excursion
27701
5e135f0faf1d (bibtex-mode): Replaced manual splitting of path
Gerd Moellmann <gerd@gnu.org>
parents: 26711
diff changeset
3417 (goto-char (bibtex-start-of-name-in-field bounds))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3418 (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
3419 (delete-region (match-beginning 0) (match-end 0))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3420 ;; make field non-OPT
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3421 (search-forward "=")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3422 (forward-char -1)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3423 (delete-horizontal-space)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3424 (if bibtex-align-at-equal-sign
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3425 (indent-to-column (- bibtex-text-indentation 2))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3426 (insert " "))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3427 (search-forward "=")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3428 (delete-horizontal-space)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3429 (if bibtex-align-at-equal-sign
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3430 (insert " ")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3431 (indent-to-column bibtex-text-indentation))))
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3432 (bibtex-inside-field)))
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3433
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3434 (defun bibtex-remove-delimiters ()
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3435 "Remove \"\" or {} around string."
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3436 (interactive)
27701
5e135f0faf1d (bibtex-mode): Replaced manual splitting of path
Gerd Moellmann <gerd@gnu.org>
parents: 26711
diff changeset
3437 (save-excursion
5e135f0faf1d (bibtex-mode): Replaced manual splitting of path
Gerd Moellmann <gerd@gnu.org>
parents: 26711
diff changeset
3438 (bibtex-inside-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
3439 (let* ((bounds (bibtex-enclosing-field))
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
3440 (end (bibtex-end-of-text-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
3441 (start (bibtex-start-of-text-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
3442 (if (memq (char-before end) '(?\} ?\"))
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
3443 (delete-region (1- end) end))
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
3444 (if (memq (char-after start) '(?\{ ?\"))
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
3445 (delete-region start (1+ start))))))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3446
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3447 (defun bibtex-kill-field (&optional copy-only)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3448 "Kill the entire enclosing BibTeX field.
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3449 With prefix arg COPY-ONLY, copy the current field to `bibtex-field-kill-ring',
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3450 but do not actually kill it."
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3451 (interactive "P")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3452 (save-excursion
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3453 (bibtex-inside-field)
27701
5e135f0faf1d (bibtex-mode): Replaced manual splitting of path
Gerd Moellmann <gerd@gnu.org>
parents: 26711
diff changeset
3454 (let* ((case-fold-search t)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3455 (bounds (bibtex-enclosing-field))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3456 (end (bibtex-end-of-field bounds))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3457 (beg (bibtex-start-of-field bounds)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3458 (goto-char end)
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3459 (skip-chars-forward " \t\n,")
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3460 (push (list 'field (bibtex-name-in-field bounds)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3461 (bibtex-text-in-field-bounds bounds))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3462 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
3463 (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
3464 (setcdr (nthcdr (1- bibtex-field-kill-ring-max)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3465 bibtex-field-kill-ring)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3466 nil))
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3467 (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
3468 (unless copy-only
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3469 (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
3470 (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
3471
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3472 (defun 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
3473 (interactive)
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3474 (bibtex-kill-field t))
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3475
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3476 (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
3477 "Kill the entire enclosing BibTeX entry.
5e135f0faf1d (bibtex-mode): Replaced manual splitting of path
Gerd Moellmann <gerd@gnu.org>
parents: 26711
diff changeset
3478 With prefix arg COPY-ONLY the current entry to
19461
6b67f20dd710 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 19460
diff changeset
3479 `bibtex-entry-kill-ring', 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
3480 (interactive "P")
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3481 (save-excursion
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3482 (let* ((case-fold-search t)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3483 (beg (bibtex-beginning-of-entry))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3484 (end (progn (bibtex-end-of-entry)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3485 (if (re-search-forward
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3486 bibtex-entry-maybe-empty-head nil 'move)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3487 (goto-char (match-beginning 0)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3488 (point))))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3489 (push (list 'entry (buffer-substring-no-properties beg end))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3490 bibtex-entry-kill-ring)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3491 (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
3492 (setcdr (nthcdr (1- bibtex-entry-kill-ring-max)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3493 bibtex-entry-kill-ring)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3494 nil))
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3495 (setq bibtex-entry-kill-ring-yank-pointer bibtex-entry-kill-ring)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3496 (unless copy-only
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3497 (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
3498 (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
3499
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3500 (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
3501 "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
3502 (interactive)
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3503 (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
3504
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3505 (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
3506 "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
3507 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
3508 With argument N, reinsert the Nth most recently killed BibTeX item.
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3509 See also the command \\[bibtex-yank-pop]]."
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3510 (interactive "*p")
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3511 (bibtex-insert-current-kill (1- n))
22563
2e2a71dfec63 Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents: 21169
diff changeset
3512 (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
3513
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3514 (defun bibtex-yank-pop (n)
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3515 "Replace just-yanked killed BibTeX item with a different.
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3516 This command is allowed only immediately after a `bibtex-yank' or a
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3517 `bibtex-yank-pop'.
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3518 At such a time, the region contains a reinserted previously killed
22563
2e2a71dfec63 Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents: 21169
diff changeset
3519 BibTeX item. `bibtex-yank-pop' deletes that item and inserts in its
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3520 place a different killed BibTeX item.
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3521
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3522 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
3523 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
3524 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
3525
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3526 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
3527 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
3528 (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
3529 (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
3530 (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
3531 (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
3532 (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
3533 (delete-region (point) (mark t))
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3534 (bibtex-insert-current-kill n)))
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3535
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3536 (defun bibtex-empty-field ()
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3537 "Delete the text part of the current field, replace with empty text."
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3538 (interactive)
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3539 (bibtex-inside-field)
27701
5e135f0faf1d (bibtex-mode): Replaced manual splitting of path
Gerd Moellmann <gerd@gnu.org>
parents: 26711
diff changeset
3540 (let ((bounds (bibtex-enclosing-field)))
5e135f0faf1d (bibtex-mode): Replaced manual splitting of path
Gerd Moellmann <gerd@gnu.org>
parents: 26711
diff changeset
3541 (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
3542 (delete-region (point) (bibtex-end-of-text-in-field bounds))
5e135f0faf1d (bibtex-mode): Replaced manual splitting of path
Gerd Moellmann <gerd@gnu.org>
parents: 26711
diff changeset
3543 (insert (concat (bibtex-field-left-delimiter)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3544 (bibtex-field-right-delimiter)) )
27701
5e135f0faf1d (bibtex-mode): Replaced manual splitting of path
Gerd Moellmann <gerd@gnu.org>
parents: 26711
diff changeset
3545 (bibtex-find-text t)))
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3546
14789
d68b71228abd (bibtex-pop): New generic function which unifies the
Richard M. Stallman <rms@gnu.org>
parents: 14410
diff changeset
3547 (defun bibtex-pop-previous (arg)
19461
6b67f20dd710 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 19460
diff changeset
3548 "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
3549 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
3550 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
3551 (interactive "p")
d68b71228abd (bibtex-pop): New generic function which unifies the
Richard M. Stallman <rms@gnu.org>
parents: 14410
diff changeset
3552 (bibtex-pop arg 'previous))
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3553
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3554 (defun bibtex-pop-next (arg)
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3555 "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
3556 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
3557 intermixed with \\[bibtex-pop-previous] (bibtex-pop-previous)."
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3558 (interactive "p")
14789
d68b71228abd (bibtex-pop): New generic function which unifies the
Richard M. Stallman <rms@gnu.org>
parents: 14410
diff changeset
3559 (bibtex-pop arg 'next))
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3560
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3561 (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
3562 "Finish editing the current BibTeX entry and clean it up.
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3563 Check that no required fields are empty and formats entry dependent
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3564 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
3565 If the reference key of the entry is empty or a prefix argument is given,
57070
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
3566 calculate a new reference key. (Note: this will only work if fields in entry
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3567 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
3568 '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
3569 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
3570 At end of the cleaning process, the functions in
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3571 `bibtex-clean-entry-hook' are called with region narrowed to entry."
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3572 ;; Opt. arg called-by-reformat is t if bibtex-clean-entry
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3573 ;; is called by bibtex-reformat
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
3574 (interactive "P")
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3575 (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
3576 entry-type key)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3577 (bibtex-beginning-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
3578 (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
3579 (when (re-search-forward bibtex-entry-maybe-empty-head nil 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
3580 (setq entry-type (bibtex-type-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
3581 (setq key (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
3582 ;; formatting
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
3583 (cond ((bibtex-string= entry-type "preamble")
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3584 ;; (bibtex-format-preamble)
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3585 (error "No clean up of @Preamble 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
3586 ((bibtex-string= entry-type "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
3587 ;; (bibtex-format-string)
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3588 (t (bibtex-format-entry)))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3589 ;; set key
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3590 (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
3591 (setq key (bibtex-generate-autokey))
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
3592 ;; Sometimes bibtex-generate-autokey returns an empty string
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
3593 (if (or bibtex-autokey-edit-before-use (string= "" 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
3594 (setq key (bibtex-read-key "Key to use: " key)))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3595 (re-search-forward bibtex-entry-maybe-empty-head)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3596 (if (match-beginning bibtex-key-in-head)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3597 (delete-region (match-beginning bibtex-key-in-head)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3598 (match-end bibtex-key-in-head)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3599 (insert 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
3600 ;; sorting
55312
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
3601 (unless called-by-reformat
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
3602 (let* ((start (bibtex-beginning-of-entry))
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
3603 (end (progn (bibtex-end-of-entry)
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
3604 (if (re-search-forward
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
3605 bibtex-entry-maybe-empty-head nil 'move)
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
3606 (goto-char (match-beginning 0)))
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
3607 (point)))
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
3608 (entry (buffer-substring start end))
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
3609 (index (progn (goto-char start)
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
3610 (bibtex-entry-index)))
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
3611 error)
55312
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
3612 (if (and bibtex-maintain-sorted-entries
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
3613 (not (and bibtex-sort-ignore-string-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
3614 (bibtex-string= entry-type "string"))))
55312
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
3615 (progn
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
3616 (delete-region start 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
3617 (setq error (not (bibtex-prepare-new-entry index)))
55312
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
3618 (insert entry)
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
3619 (forward-char -1)
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
3620 (bibtex-beginning-of-entry) ; moves backward
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
3621 (re-search-forward bibtex-entry-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
3622 (bibtex-find-entry 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
3623 (setq error (or (/= (point) start)
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
3624 (bibtex-find-entry key end))))
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
3625 (if error
55312
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
3626 (error "New inserted entry yields duplicate 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
3627 ;; final clean up
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3628 (unless called-by-reformat
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3629 (save-excursion
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3630 (save-restriction
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3631 (bibtex-narrow-to-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
3632 ;; Only update the list of keys if it has been built already.
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
3633 (cond ((bibtex-string= entry-type "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
3634 (if (listp bibtex-strings) (bibtex-parse-strings t)))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3635 ((listp bibtex-reference-keys) (bibtex-parse-keys t)))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3636 (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
3637
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3638 (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
3639 "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
3640 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
3641 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
3642 (let ((end-field (copy-marker (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
3643 (goto-char (bibtex-start-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
3644 (if justify
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3645 (progn
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3646 (forward-char)
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3647 (bibtex-delete-whitespace)
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3648 (open-line 1)
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3649 (forward-char)
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3650 (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
3651 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
3652 (re-search-forward "[ \t\n]*=" 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
3653 (replace-match "=")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3654 (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
3655 (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
3656 (indent-to-column
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3657 (+ bibtex-entry-offset (- 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
3658 (insert " "))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3659 (forward-char)
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3660 (bibtex-delete-whitespace)
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3661 (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
3662 (insert " ")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3663 (indent-to-column bibtex-text-indentation)))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3664 (re-search-forward "[ \t\n]*=[ \t\n]*" 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
3665 (while (re-search-forward "[ \t\n]+" end-field 'move)
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3666 (replace-match " "))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3667 (do-auto-fill)
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3668 (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
3669
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3670 (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
3671 "Like \\[fill-paragraph], but fill current BibTeX field.
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3672 Optional prefix arg JUSTIFY non-nil means 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
3673 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
3674 (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
3675 (let ((pnt (copy-marker (point)))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3676 (bounds (bibtex-enclosing-field)))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3677 (when bounds
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3678 (bibtex-fill-field-bounds bounds justify)
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3679 (goto-char pnt))))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3680
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3681 (defun bibtex-fill-entry ()
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3682 "Fill current BibTeX entry.
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3683 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
3684 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
3685 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
3686 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
3687 (interactive "*")
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3688 (let ((pnt (copy-marker (point)))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3689 (end (copy-marker (bibtex-end-of-entry)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3690 bounds)
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3691 (bibtex-beginning-of-entry)
18247
ae094c1a4334 (bibtex-delete-whitespace, bibtex-current-line)
Richard M. Stallman <rms@gnu.org>
parents: 18212
diff changeset
3692 (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
3693 (indent-to-column bibtex-entry-offset)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3694 (while (setq bounds (bibtex-search-forward-field bibtex-field-name end))
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3695 (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
3696 (if (looking-at ",")
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3697 (forward-char))
18247
ae094c1a4334 (bibtex-delete-whitespace, bibtex-current-line)
Richard M. Stallman <rms@gnu.org>
parents: 18212
diff changeset
3698 (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
3699 (open-line 1)
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3700 (forward-char)
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3701 (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
3702 (goto-char pnt)))
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3703
55312
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
3704 (defun bibtex-realign ()
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
3705 "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
3706 (goto-char (point-min))
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
3707 (let ((case-fold-search t))
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
3708 (when (looking-at bibtex-valid-entry-whitespace-re)
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
3709 (replace-match "\\1"))
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
3710 (while (re-search-forward bibtex-valid-entry-whitespace-re nil t)
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
3711 (replace-match "\n\n\\1"))))
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
3712
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
3713 (defun bibtex-reformat (&optional read-options)
19461
6b67f20dd710 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 19460
diff changeset
3714 "Reformat all BibTeX entries in buffer or region.
6b67f20dd710 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 19460
diff changeset
3715 With prefix argument, read options for reformatting from minibuffer.
22563
2e2a71dfec63 Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents: 21169
diff changeset
3716 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
3717 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
3718 (interactive "*P")
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3719 (let* ((pnt (point))
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3720 (use-previous-options
55312
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
3721 (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
3722 (or bibtex-reformat-previous-options
27701
5e135f0faf1d (bibtex-mode): Replaced manual splitting of path
Gerd Moellmann <gerd@gnu.org>
parents: 26711
diff changeset
3723 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
3724 (bibtex-entry-format
55312
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
3725 (if read-options
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3726 (if use-previous-options
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3727 bibtex-reformat-previous-options
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3728 (setq bibtex-reformat-previous-options
55312
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
3729 (mapcar (lambda (option)
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
3730 (if (y-or-n-p (car option)) (cdr option)))
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
3731 `(("Realign entries (recommended)? " . 'realign)
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
3732 ("Remove empty optional and alternative fields? " . 'opts-or-alts)
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
3733 ("Remove delimiters around pure numerical fields? " . 'numerical-fields)
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
3734 (,(concat (if bibtex-comma-after-last-field "Insert" "Remove")
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
3735 " comma at end of entry? ") . 'last-comma)
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
3736 ("Replace double page dashes by single ones? " . 'page-dashes)
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
3737 ("Force delimiters? " . 'delimiters)
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
3738 ("Unify case of entry types and field names? " . 'unify-case)))))
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3739 '(realign)))
55312
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
3740 (reformat-reference-keys
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
3741 (if read-options
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
3742 (if use-previous-options
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
3743 bibtex-reformat-previous-reference-keys
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
3744 (setq bibtex-reformat-previous-reference-keys
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
3745 (y-or-n-p "Generate new reference keys automatically? ")))))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3746 (start-point (if (bibtex-mark-active)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3747 (region-beginning)
55312
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
3748 (point-min)))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3749 (end-point (if (bibtex-mark-active)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3750 (region-end)
55312
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
3751 (point-max)))
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
3752 (bibtex-sort-ignore-string-entries t)
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
3753 bibtex-autokey-edit-before-use)
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
3754
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3755 (save-restriction
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3756 (narrow-to-region start-point end-point)
55312
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
3757 (if (memq 'realign bibtex-entry-format)
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
3758 (bibtex-realign))
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3759 (goto-char start-point)
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3760 (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
3761 (bibtex-map-entries (lambda (key beg end)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3762 (bibtex-progress-message)
55312
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
3763 (bibtex-clean-entry reformat-reference-keys t)))
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
3764 (when (memq 'realign bibtex-entry-format)
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
3765 (bibtex-delete-whitespace)
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
3766 (open-line (if (eobp) 1 2)))
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3767 (bibtex-progress-message 'done))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3768 (when (and reformat-reference-keys
55312
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
3769 bibtex-maintain-sorted-entries)
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
3770 (bibtex-progress-message "Sorting" 1)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3771 (bibtex-sort-buffer)
55312
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
3772 (kill-local-variable 'bibtex-reference-keys)
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
3773 (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
3774 (goto-char pnt)))
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3775
55312
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
3776 (defun bibtex-convert-alien (&optional read-options)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3777 "Convert an alien BibTeX buffer to be fully usable by BibTeX mode.
55312
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
3778 If a file does not conform with all standards used by BibTeX mode,
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3779 some of the high-level features of BibTeX mode will not be available.
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3780 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
3781 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
3782 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
3783 (interactive "*P")
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3784 (message "Starting to validate buffer...")
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3785 (sit-for 1 nil t)
55312
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
3786 (bibtex-realign)
18212
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3787 (message
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3788 "If errors occur, correct them and call `bibtex-convert-alien' again")
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3789 (sit-for 5 nil t)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3790 (deactivate-mark) ; So bibtex-validate works on the whole buffer.
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3791 (when (let (bibtex-maintain-sorted-entries)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3792 (bibtex-validate))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3793 (message "Starting to reformat entries...")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3794 (sit-for 2 nil t)
55312
3b7a4fa9b2d8 (bibtex-sort-buffer): Remove error message.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52891
diff changeset
3795 (bibtex-reformat read-options)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3796 (goto-char (point-max))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3797 (message "Buffer is now parsable. Please save it.")))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3798
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3799 (defun bibtex-complete ()
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3800 "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
3801 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
3802 `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
3803 based on `bibtex-predefined-month-strings'. Inside any other field
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
3804 perform string completion based on `bibtex-strings'. An error is
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
3805 signaled if point is outside key or BibTeX field."
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3806 (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
3807 (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
3808 (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
3809 bounds name compl)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3810 (save-excursion
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3811 (if (and (setq bounds (bibtex-enclosing-field t))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3812 (>= pnt (bibtex-start-of-text-in-field bounds))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3813 (<= 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
3814 (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
3815 compl (cond ((bibtex-string= name "crossref")
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
3816 '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
3817 ((bibtex-string= name "month")
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
3818 bibtex-predefined-month-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
3819 (t (if (listp bibtex-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
3820 bibtex-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
3821 ;; so that bibtex-complete-string-cleanup
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
3822 ;; can do its job
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
3823 (bibtex-parse-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
3824 (bibtex-string-files-init))))))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3825 (bibtex-beginning-of-entry)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3826 (if (and (re-search-forward bibtex-entry-maybe-empty-head nil t)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3827 ;; point is inside a key
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3828 (or (and (match-beginning bibtex-key-in-head)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3829 (>= pnt (match-beginning bibtex-key-in-head))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3830 (<= pnt (match-end bibtex-key-in-head)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3831 ;; or point is on empty key
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3832 (and (not (match-beginning bibtex-key-in-head))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3833 (= pnt (match-end 0)))))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3834 (setq compl 'key))))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3835
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3836 (cond ((equal compl 'key)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3837 ;; key completion
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3838 (setq choose-completion-string-functions
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3839 (lambda (choice buffer mini-p base-size)
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
3840 (bibtex-choose-completion-string choice buffer mini-p base-size)
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
3841 (bibtex-complete-key-cleanup choice)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3842 ;; return t (required by choose-completion-string-functions)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3843 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
3844 (bibtex-complete-key-cleanup (bibtex-complete-internal
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
3845 bibtex-reference-keys)))
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
3846
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
3847 (compl
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3848 ;; string completion
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3849 (setq choose-completion-string-functions
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
3850 `(lambda (choice buffer mini-p base-size)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3851 (bibtex-choose-completion-string choice buffer mini-p base-size)
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
3852 (bibtex-complete-string-cleanup choice ',compl)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3853 ;; return t (required by choose-completion-string-functions)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3854 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
3855 (bibtex-complete-string-cleanup (bibtex-complete-internal compl)
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
3856 compl))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3857
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3858 (t (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
3859
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
3860 (defun bibtex-Article ()
22563
2e2a71dfec63 Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents: 21169
diff changeset
3861 "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
3862 (interactive "*")
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
3863 (bibtex-entry "Article"))
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
3864
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
3865 (defun bibtex-Book ()
22563
2e2a71dfec63 Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents: 21169
diff changeset
3866 "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
3867 (interactive "*")
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
3868 (bibtex-entry "Book"))
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
3869
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
3870 (defun bibtex-Booklet ()
22563
2e2a71dfec63 Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents: 21169
diff changeset
3871 "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
3872 (interactive "*")
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
3873 (bibtex-entry "Booklet"))
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
3874
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
3875 (defun bibtex-InBook ()
22563
2e2a71dfec63 Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents: 21169
diff changeset
3876 "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
3877 (interactive "*")
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
3878 (bibtex-entry "InBook"))
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
3879
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
3880 (defun bibtex-InCollection ()
22563
2e2a71dfec63 Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents: 21169
diff changeset
3881 "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
3882 (interactive "*")
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
3883 (bibtex-entry "InCollection"))
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
3884
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
3885 (defun bibtex-InProceedings ()
22563
2e2a71dfec63 Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents: 21169
diff changeset
3886 "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
3887 (interactive "*")
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
3888 (bibtex-entry "InProceedings"))
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
3889
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
3890 (defun bibtex-Manual ()
22563
2e2a71dfec63 Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents: 21169
diff changeset
3891 "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
3892 (interactive "*")
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
3893 (bibtex-entry "Manual"))
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
3894
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
3895 (defun bibtex-MastersThesis ()
22563
2e2a71dfec63 Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents: 21169
diff changeset
3896 "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
3897 (interactive "*")
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
3898 (bibtex-entry "MastersThesis"))
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
3899
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
3900 (defun bibtex-Misc ()
22563
2e2a71dfec63 Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents: 21169
diff changeset
3901 "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
3902 (interactive "*")
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
3903 (bibtex-entry "Misc"))
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
3904
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
3905 (defun bibtex-PhdThesis ()
22563
2e2a71dfec63 Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents: 21169
diff changeset
3906 "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
3907 (interactive "*")
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
3908 (bibtex-entry "PhdThesis"))
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
3909
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
3910 (defun bibtex-Proceedings ()
22563
2e2a71dfec63 Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents: 21169
diff changeset
3911 "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
3912 (interactive "*")
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
3913 (bibtex-entry "Proceedings"))
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
3914
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
3915 (defun bibtex-TechReport ()
22563
2e2a71dfec63 Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents: 21169
diff changeset
3916 "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
3917 (interactive "*")
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
3918 (bibtex-entry "TechReport"))
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
3919
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
3920 (defun bibtex-Unpublished ()
22563
2e2a71dfec63 Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents: 21169
diff changeset
3921 "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
3922 (interactive "*")
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
3923 (bibtex-entry "Unpublished"))
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
3924
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3925 (defun bibtex-String (&optional key)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3926 "Insert a new BibTeX @String entry with key 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
3927 (interactive (list (completing-read "String key: " 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
3928 nil nil nil 'bibtex-key-history)))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3929 (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
3930 (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
3931 bibtex-maintain-sorted-entries))
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3932 endpos)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3933 (unless (bibtex-prepare-new-entry (list key nil "String"))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3934 (error "Entry with key `%s' already exists" key))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3935 (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
3936 (indent-to-column bibtex-entry-offset)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3937 (insert "@String"
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3938 (bibtex-entry-left-delimiter))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3939 (if key
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3940 (insert key)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3941 (setq endpos (point)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3942 (insert " = "
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3943 (bibtex-field-left-delimiter))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3944 (if key
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3945 (setq endpos (point)))
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3946 (insert (bibtex-field-right-delimiter)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3947 (bibtex-entry-right-delimiter)
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3948 "\n")
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3949 (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
3950
3864648e9b4f (bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents: 17700
diff changeset
3951 (defun bibtex-Preamble ()
22563
2e2a71dfec63 Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents: 21169
diff changeset
3952 "Insert a new BibTeX @Preamble entry."
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3953 (interactive "*")
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
3954 (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
3955 (indent-to-column bibtex-entry-offset)
51415
762217a72cae Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 49599
diff changeset
3956 (insert "@Preamble"
51743
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3957 (bibtex-entry-left-delimiter))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3958 (let ((endpos (point)))
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3959 (insert (bibtex-entry-right-delimiter)
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3960 "\n")
f63c242330b2 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 51416
diff changeset
3961 (goto-char endpos)))
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3962
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
3963 (defun bibtex-url (&optional event)
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
3964 "Browse a URL for the BibTeX entry at position PNT.
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
3965 The URL is generated using the schemes defined in `bibtex-generate-url-list'
57070
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
3966 \(see there\). Then the URL is passed to `browse-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
3967 (interactive (list last-input-event))
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
3968 (save-excursion
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
3969 (if event (posn-set-point (event-end event)))
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
3970 (bibtex-beginning-of-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
3971 (let ((fields-alist (bibtex-parse-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
3972 (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
3973 (lst bibtex-generate-url-list)
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
3974 field url scheme)
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
3975 (while (setq scheme (car lst))
57070
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
3976 (when (and (setq field (cdr (assoc-string (caar scheme)
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
3977 fields-alist t)))
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
3978 (progn
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
3979 (if (string-match "\\`[{\"]\\(.*\\)[}\"]\\'" field)
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
3980 (setq field (match-string 1 field)))
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
3981 (string-match (cdar scheme) field)))
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
3982 (setq lst nil)
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
3983 (if (null (cdr scheme))
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
3984 (setq url (match-string 0 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
3985 (dolist (step (cdr scheme))
57070
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
3986 (cond ((stringp step)
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
3987 (setq url (concat url step)))
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
3988 ((setq field (assoc-string (car step) fields-alist t))
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
3989 ;; always remove field delimiters
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
3990 (let* ((text (if (string-match "\\`[{\"]\\(.*\\)[}\"]\\'"
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
3991 (cdr field))
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
3992 (match-string 1 (cdr field))
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
3993 (cdr field)))
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
3994 (str (if (string-match (nth 1 step) text)
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
3995 (cond
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
3996 ((functionp (nth 2 step))
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
3997 (funcall (nth 2 step) text))
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
3998 ((numberp (nth 2 step))
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
3999 (match-string (nth 2 step) text))
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
4000 (t
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
4001 (replace-match (nth 2 step) nil nil text)))
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
4002 ;; If the scheme is set up correctly,
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
4003 ;; we should never reach this point
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
4004 (error "Match failed: %s" text))))
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
4005 (setq url (concat url str))))
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
4006 ;; If the scheme is set up correctly,
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
4007 ;; we should never reach this point
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
4008 (t (error "Step failed: %s" step))))
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
4009 (message "%s" 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
4010 (browse-url 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
4011 (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
4012 (unless url (message "No URL known.")))))
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
4013
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
4014 (defun bibtex-font-lock-url (bound)
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
4015 "Font-lock for URLs."
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
4016 (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
4017 (bounds (bibtex-enclosing-field 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
4018 (pnt (point))
57070
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
4019 found 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
4020 ;; We use start-of-field as syntax-begin
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
4021 (goto-char (if bounds (bibtex-start-of-field bounds) pnt))
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
4022 (while (and (not found)
57070
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
4023 (prog1 (re-search-forward bibtex-font-lock-url-regexp bound t)
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
4024 (setq field (match-string-no-properties 1)))
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
4025 (setq bounds (bibtex-parse-field-text))
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
4026 (>= bound (car bounds))
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
4027 (>= (car bounds) pnt))
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
4028 (let ((lst bibtex-generate-url-list) url)
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
4029 (goto-char (car bounds))
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
4030 (while (and (not found)
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
4031 (setq url (caar lst)))
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
4032 (when (bibtex-string= field (car url))
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
4033 (setq found (re-search-forward (cdr url) (cdr bounds) t)))
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
4034 (setq lst (cdr lst))))
3d9707888790 (bibtex-generate-url-list): Change format. Provide a sample complex default.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57054
diff changeset
4035 (goto-char (cdr 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
4036 found))
0b058857c704 (bibtex-mark-active, bibtex-run-with-idle-timer): Move `if' inside the defun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55880
diff changeset
4037
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4038
12700
b3a8ee2da96a Add keywords and comments as per conventions.
Richard M. Stallman <rms@gnu.org>
parents: 12028
diff changeset
4039 ;; Make BibTeX a Feature
257
e5ba2ba35226 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4040
10219
d97313bb6f39 (bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents: 10106
diff changeset
4041 (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
4042
55348
c1f70dc19ce5 (bibtex-progress-message): Fix docstring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55312
diff changeset
4043 ;; 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
4044 ;;; bibtex.el ends here