bibtex.el 185 KB
Newer Older
Eric S. Raymond's avatar
Eric S. Raymond committed
1 2
;;; bibtex.el --- BibTeX mode for GNU Emacs

3
;; Copyright (C) 1992, 1994, 1995, 1996, 1997, 1998, 1999, 2003, 2004
4
;;           Free Software Foundation, Inc.
Eric S. Raymond's avatar
Eric S. Raymond committed
5

6
;; Author: Stefan Schoef <schoef@offis.uni-oldenburg.de>
Stefan Monnier's avatar
Stefan Monnier committed
7 8 9 10 11
;;      Bengt Martensson <bengt@mathematik.uni-Bremen.de>
;;      Mark Shapiro <shapiro@corto.inria.fr>
;;      Mike Newton <newton@gumby.cs.caltech.edu>
;;      Aaron Larson <alarson@src.honeywell.com>
;;      Dirk Herrmann <D.Herrmann@tu-bs.de>
Richard M. Stallman's avatar
Richard M. Stallman committed
12
;; Maintainer: Roland Winkler <roland.winkler@physik.uni-erlangen.de>
13
;; Keywords: BibTeX, LaTeX, TeX
Eric S. Raymond's avatar
Eric S. Raymond committed
14

Jim Blandy's avatar
Jim Blandy committed
15 16 17 18
;; This file is part of GNU Emacs.

;; GNU Emacs is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
Richard M. Stallman's avatar
Richard M. Stallman committed
19
;; the Free Software Foundation; either version 2, or (at your option)
Jim Blandy's avatar
Jim Blandy committed
20 21 22 23 24 25 26 27
;; any later version.

;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
Erik Naggum's avatar
Erik Naggum committed
28 29 30
;; along with GNU Emacs; see the file COPYING.  If not, write to the
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.
Jim Blandy's avatar
Jim Blandy committed
31

32
;;; Commentary:
Erik Naggum's avatar
Erik Naggum committed
33

34
;;  Major mode for editing and validating BibTeX files.
Eric S. Raymond's avatar
Eric S. Raymond committed
35

36
;;  Usage:
Stefan Monnier's avatar
Stefan Monnier committed
37 38
;;  See documentation for function bibtex-mode or type "\M-x describe-mode"
;;  when you are in BibTeX mode.
Eric S. Raymond's avatar
Eric S. Raymond committed
39

40 41
;;  Todo:
;;  Distribute texinfo file.
42

43
;;; Code:
Erik Naggum's avatar
Erik Naggum committed
44

Stefan Monnier's avatar
Stefan Monnier committed
45 46
(require 'button)

47

48
;; User Options:
Eric S. Raymond's avatar
Eric S. Raymond committed
49

Richard M. Stallman's avatar
Richard M. Stallman committed
50
(defgroup bibtex nil
Stefan Monnier's avatar
Stefan Monnier committed
51
  "BibTeX mode"
Richard M. Stallman's avatar
Richard M. Stallman committed
52 53 54 55
  :group 'tex
  :prefix "bibtex-")

(defgroup bibtex-autokey nil
Stefan Monnier's avatar
Stefan Monnier committed
56
  "Generate automatically a key from the author/editor and the title field"
Richard M. Stallman's avatar
Richard M. Stallman committed
57
  :group 'bibtex
58
  :prefix "bibtex-autokey-")
Richard M. Stallman's avatar
Richard M. Stallman committed
59 60 61 62

(defcustom bibtex-mode-hook nil
  "List of functions to call on entry to BibTeX mode."
  :group 'bibtex
63
  :type 'hook)
Richard M. Stallman's avatar
Richard M. Stallman committed
64 65

(defcustom bibtex-field-delimiters 'braces
Stefan Monnier's avatar
Stefan Monnier committed
66
  "Type of field delimiters.  Allowed values are `braces' or `double-quotes'."
Richard M. Stallman's avatar
Richard M. Stallman committed
67 68
  :group 'bibtex
  :type '(choice (const braces)
Stefan Monnier's avatar
Stefan Monnier committed
69
                 (const double-quotes)))
70

Richard M. Stallman's avatar
Richard M. Stallman committed
71
(defcustom bibtex-entry-delimiters 'braces
Stefan Monnier's avatar
Stefan Monnier committed
72
  "Type of entry delimiters.  Allowed values are `braces' or `parentheses'."
Richard M. Stallman's avatar
Richard M. Stallman committed
73 74
  :group 'bibtex
  :type '(choice (const braces)
Stefan Monnier's avatar
Stefan Monnier committed
75
                 (const parentheses)))
76

Richard M. Stallman's avatar
Richard M. Stallman committed
77
(defcustom bibtex-include-OPTcrossref '("InProceedings" "InCollection")
Stefan Monnier's avatar
Stefan Monnier committed
78
  "List of BibTeX entries that get an OPTcrossref field."
Richard M. Stallman's avatar
Richard M. Stallman committed
79 80
  :group 'bibtex
  :type '(repeat string))
Eric S. Raymond's avatar
Eric S. Raymond committed
81

Richard M. Stallman's avatar
Richard M. Stallman committed
82
(defcustom bibtex-include-OPTkey t
83 84 85
  "If non-nil, all newly created entries get an OPTkey field.
If this is a string, use it as the initial field text.
If this is a function, call it to generate the initial field text."
Richard M. Stallman's avatar
Richard M. Stallman committed
86 87
  :group 'bibtex
  :type '(choice (const :tag "None" nil)
Stefan Monnier's avatar
Stefan Monnier committed
88 89 90
                 (string :tag "Initial text")
                 (function :tag "Initialize Function" :value fun)
                 (other :tag "Default" t)))
Richard M. Stallman's avatar
Richard M. Stallman committed
91 92

(defcustom bibtex-user-optional-fields
93
  '(("annote" "Personal annotation (ignored)"))
Stefan Monnier's avatar
Stefan Monnier committed
94
  "List of optional fields the user wants to have always present.
95
Entries should be of the same form as the OPTIONAL and
Stefan Monnier's avatar
Stefan Monnier committed
96
CROSSREF-OPTIONAL lists in `bibtex-entry-field-alist' (which see)."
Richard M. Stallman's avatar
Richard M. Stallman committed
97
  :group 'bibtex
Stefan Monnier's avatar
Stefan Monnier committed
98 99 100 101 102 103 104 105 106 107
  :type '(repeat (group (string :tag "Field")
                        (string :tag "Comment")
                        (option (group :inline t
                                       :extra-offset -4
                                       (choice :tag "Init" :value ""
                                               string
                                               function))))))

(defcustom bibtex-entry-format
  '(opts-or-alts required-fields numerical-fields)
Stefan Monnier's avatar
Stefan Monnier committed
108
  "Type of formatting performed by `bibtex-clean-entry'.
109
It may be t, nil, or a list of symbols out of the following:
Richard M. Stallman's avatar
Richard M. Stallman committed
110 111
opts-or-alts        Delete empty optional and alternative fields and
                      remove OPT and ALT prefixes from used fields.
Stefan Monnier's avatar
Stefan Monnier committed
112
required-fields     Signal an error if a required field is missing.
Richard M. Stallman's avatar
Richard M. Stallman committed
113 114 115
numerical-fields    Delete delimiters around numeral fields.
page-dashes         Change double dashes in page field to single dash
                      (for scribe compatibility).
116 117 118
inherit-booktitle   If entry contains a crossref field and the booktitle
                      field is empty, set the booktitle field to the content
                      of the title field of the crossreferenced entry.
Richard M. Stallman's avatar
Richard M. Stallman committed
119
realign             Realign entries, so that field texts and perhaps equal
120
                      signs (depending on the value of
121
                      `bibtex-align-at-equal-sign') begin in the same column.
Richard M. Stallman's avatar
Richard M. Stallman committed
122 123 124 125 126 127 128 129
last-comma          Add or delete comma on end of last field in entry,
                      according to value of `bibtex-comma-after-last-field'.
delimiters          Change delimiters according to variables
                      `bibtex-field-delimiters' and `bibtex-entry-delimiters'.
unify-case          Change case of entry and field names.

The value t means do all of the above formatting actions.
The value nil means do no formatting at all."
Richard M. Stallman's avatar
Richard M. Stallman committed
130 131
  :group 'bibtex
  :type '(choice (const :tag "None" nil)
Stefan Monnier's avatar
Stefan Monnier committed
132 133 134 135 136 137 138 139 140 141 142
                 (const :tag "All" t)
                 (set :menu-tag "Some"
                      (const opts-or-alts)
                      (const required-fields)
                      (const numerical-fields)
                      (const page-dashes)
                      (const inherit-booktitle)
                      (const realign)
                      (const last-comma)
                      (const delimiters)
                      (const unify-case))))
143

Richard M. Stallman's avatar
Richard M. Stallman committed
144
(defcustom bibtex-clean-entry-hook nil
Stefan Monnier's avatar
Stefan Monnier committed
145
  "List of functions to call when entry has been cleaned.
Richard M. Stallman's avatar
Richard M. Stallman committed
146
Functions are called with point inside the cleaned entry, and the buffer
Richard M. Stallman's avatar
Richard M. Stallman committed
147 148
narrowed to just the entry."
  :group 'bibtex
149
  :type 'hook)
150

Richard M. Stallman's avatar
Richard M. Stallman committed
151
(defcustom bibtex-maintain-sorted-entries nil
152
  "If non-nil, BibTeX mode maintains all entries in sorted order.
153
Allowed non-nil values are:
Stefan Monnier's avatar
Stefan Monnier committed
154 155
plain        All entries are sorted alphabetically.
crossref     All entries are sorted alphabetically unless an entry has a
156
             crossref field.  These crossrefed entries are placed in
Stefan Monnier's avatar
Stefan Monnier committed
157 158
             alphabetical order immediately preceding the main entry.
entry-class  The entries are divided into classes according to their
159
             entry name, see `bibtex-sort-entry-class'.  Within each class
Stefan Monnier's avatar
Stefan Monnier committed
160 161 162 163 164 165 166 167
             the entries are sorted alphabetically.
See also `bibtex-sort-ignore-string-entries'."
  :group 'bibtex
  :type '(choice (const nil)
                 (const plain)
                 (const crossref)
                 (const entry-class)))

Stefan Monnier's avatar
Stefan Monnier committed
168
(defcustom bibtex-sort-entry-class
Stefan Monnier's avatar
Stefan Monnier committed
169
  '(("String")
170 171
    (catch-all)
    ("Book" "Proceedings"))
172
  "List of classes of BibTeX entry names, used for sorting entries.
173
If value of `bibtex-maintain-sorted-entries' is `entry-class'
174 175
entries are ordered according to the classes they belong to.  Each
class contains a list of entry names.  An entry `catch-all' applies
176
to all entries not explicitly mentioned."
Stefan Monnier's avatar
Stefan Monnier committed
177 178 179 180
  :group 'BibTeX
  :type '(repeat (choice :tag "Class"
                         (const :tag "catch-all" (catch-all))
                         (repeat :tag "Entry name" string))))
Stefan Monnier's avatar
Stefan Monnier committed
181

182
(defcustom bibtex-sort-ignore-string-entries t
183
  "If non-nil, BibTeX @String entries are not sort-significant.
Stefan Monnier's avatar
Stefan Monnier committed
184 185
That means they are ignored when determining ordering of the buffer
\(e.g., sorting, locating alphabetical position for new entries, etc.)."
Richard M. Stallman's avatar
Richard M. Stallman committed
186 187
  :group 'bibtex
  :type 'boolean)
188

Richard M. Stallman's avatar
Richard M. Stallman committed
189
(defcustom bibtex-field-kill-ring-max 20
190
  "Max length of `bibtex-field-kill-ring' before discarding oldest elements."
Richard M. Stallman's avatar
Richard M. Stallman committed
191 192
  :group 'bibtex
  :type 'integer)
193

194
(defcustom bibtex-entry-kill-ring-max 20
195
  "Max length of `bibtex-entry-kill-ring' before discarding oldest elements."
196 197 198
  :group 'bibtex
  :type 'integer)

Richard M. Stallman's avatar
Richard M. Stallman committed
199
(defcustom bibtex-parse-keys-timeout 60
200
  "Time interval in seconds for parsing BibTeX buffers during idle time.
Stefan Monnier's avatar
Stefan Monnier committed
201
Parsing initializes `bibtex-reference-keys' and `bibtex-strings'."
Richard M. Stallman's avatar
Richard M. Stallman committed
202 203
  :group 'bibtex
  :type 'integer)
204

205
(defcustom bibtex-parse-keys-fast t
206
  "If non-nil, use fast but simplified algorithm for parsing BibTeX keys.
207 208 209 210
If parsing fails, try to set this variable to nil."
  :group 'bibtex
  :type 'boolean)

211
(defvar bibtex-entry-field-alist
Stefan Monnier's avatar
Stefan Monnier committed
212
  '(("Article"
Stefan Monnier's avatar
Stefan Monnier committed
213
     ((("author" "Author1 [and Author2 ...] [and others]")
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230
       ("title" "Title of the article (BibTeX converts it to lowercase)")
       ("journal" "Name of the journal (use string, remove braces)")
       ("year" "Year of publication"))
      (("volume" "Volume of the journal")
       ("number" "Number of the journal (only allowed if entry contains volume)")
       ("pages" "Pages in the journal")
       ("month" "Month of the publication as a string (remove braces)")
       ("note" "Remarks to be put at the end of the \\bibitem")))
     ((("author" "Author1 [and Author2 ...] [and others]")
       ("title" "Title of the article (BibTeX converts it to lowercase)"))
      (("pages" "Pages in the journal")
       ("journal" "Name of the journal (use string, remove braces)")
       ("year" "Year of publication")
       ("volume" "Volume of the journal")
       ("number" "Number of the journal")
       ("month" "Month of the publication as a string (remove braces)")
       ("note" "Remarks to be put at the end of the \\bibitem"))))
Stefan Monnier's avatar
Stefan Monnier committed
231
    ("Book"
Stefan Monnier's avatar
Stefan Monnier committed
232 233
     ((("author" "Author1 [and Author2 ...] [and others]" nil t)
       ("editor" "Editor1 [and Editor2 ...] [and others]" nil t)
234 235 236 237 238 239 240 241 242 243
       ("title" "Title of the book")
       ("publisher" "Publishing company")
       ("year" "Year of publication"))
      (("volume" "Volume of the book in the series")
       ("number" "Number of the book in a small series (overwritten by volume)")
       ("series" "Series in which the book appeared")
       ("address" "Address of the publisher")
       ("edition" "Edition of the book as a capitalized English word")
       ("month" "Month of the publication as a string (remove braces)")
       ("note" "Remarks to be put at the end of the \\bibitem")))
Stefan Monnier's avatar
Stefan Monnier committed
244 245
     ((("author" "Author1 [and Author2 ...] [and others]" nil t)
       ("editor" "Editor1 [and Editor2 ...] [and others]" nil t)
246 247 248 249 250 251 252 253 254 255
       ("title" "Title of the book"))
      (("publisher" "Publishing company")
       ("year" "Year of publication")
       ("volume" "Volume of the book in the series")
       ("number" "Number of the book in a small series (overwritten by volume)")
       ("series" "Series in which the book appeared")
       ("address" "Address of the publisher")
       ("edition" "Edition of the book as a capitalized English word")
       ("month" "Month of the publication as a string (remove braces)")
       ("note" "Remarks to be put at the end of the \\bibitem"))))
Stefan Monnier's avatar
Stefan Monnier committed
256 257
    ("Booklet"
     ((("title" "Title of the booklet (BibTeX converts it to lowercase)"))
258 259 260 261 262 263
      (("author" "Author1 [and Author2 ...] [and others]")
       ("howpublished" "The way in which the booklet was published")
       ("address" "Address of the publisher")
       ("month" "Month of the publication as a string (remove braces)")
       ("year" "Year of publication")
       ("note" "Remarks to be put at the end of the \\bibitem"))))
Stefan Monnier's avatar
Stefan Monnier committed
264
    ("InBook"
Stefan Monnier's avatar
Stefan Monnier committed
265 266
     ((("author" "Author1 [and Author2 ...] [and others]" nil t)
       ("editor" "Editor1 [and Editor2 ...] [and others]" nil t)
267 268 269 270 271 272 273 274 275 276 277 278 279
       ("title" "Title of the book")
       ("chapter" "Chapter in the book")
       ("publisher" "Publishing company")
       ("year" "Year of publication"))
      (("volume" "Volume of the book in the series")
       ("number" "Number of the book in a small series (overwritten by volume)")
       ("series" "Series in which the book appeared")
       ("type" "Word to use instead of \"chapter\"")
       ("address" "Address of the publisher")
       ("edition" "Edition of the book as a capitalized English word")
       ("month" "Month of the publication as a string (remove braces)")
       ("pages" "Pages in the book")
       ("note" "Remarks to be put at the end of the \\bibitem")))
Stefan Monnier's avatar
Stefan Monnier committed
280 281
     ((("author" "Author1 [and Author2 ...] [and others]" nil t)
       ("editor" "Editor1 [and Editor2 ...] [and others]" nil t)
282 283 284 285 286 287 288 289 290 291 292 293 294
       ("title" "Title of the book")
       ("chapter" "Chapter in the book"))
      (("pages" "Pages in the book")
       ("publisher" "Publishing company")
       ("year" "Year of publication")
       ("volume" "Volume of the book in the series")
       ("number" "Number of the book in a small series (overwritten by volume)")
       ("series" "Series in which the book appeared")
       ("type" "Word to use instead of \"chapter\"")
       ("address" "Address of the publisher")
       ("edition" "Edition of the book as a capitalized English word")
       ("month" "Month of the publication as a string (remove braces)")
       ("note" "Remarks to be put at the end of the \\bibitem"))))
Stefan Monnier's avatar
Stefan Monnier committed
295 296
    ("InCollection"
     ((("author" "Author1 [and Author2 ...] [and others]")
297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327
       ("title" "Title of the article in book (BibTeX converts it to lowercase)")
       ("booktitle" "Name of the book")
       ("publisher" "Publishing company")
       ("year" "Year of publication"))
      (("editor" "Editor1 [and Editor2 ...] [and others]")
       ("volume" "Volume of the book in the series")
       ("number" "Number of the book in a small series (overwritten by volume)")
       ("series" "Series in which the book appeared")
       ("type" "Word to use instead of \"chapter\"")
       ("chapter" "Chapter in the book")
       ("pages" "Pages in the book")
       ("address" "Address of the publisher")
       ("edition" "Edition of the book as a capitalized English word")
       ("month" "Month of the publication as a string (remove braces)")
       ("note" "Remarks to be put at the end of the \\bibitem")))
     ((("author" "Author1 [and Author2 ...] [and others]")
       ("title" "Title of the article in book (BibTeX converts it to lowercase)")
       ("booktitle" "Name of the book"))
      (("pages" "Pages in the book")
       ("publisher" "Publishing company")
       ("year" "Year of publication")
       ("editor" "Editor1 [and Editor2 ...] [and others]")
       ("volume" "Volume of the book in the series")
       ("number" "Number of the book in a small series (overwritten by volume)")
       ("series" "Series in which the book appeared")
       ("type" "Word to use instead of \"chapter\"")
       ("chapter" "Chapter in the book")
       ("address" "Address of the publisher")
       ("edition" "Edition of the book as a capitalized English word")
       ("month" "Month of the publication as a string (remove braces)")
       ("note" "Remarks to be put at the end of the \\bibitem"))))
Stefan Monnier's avatar
Stefan Monnier committed
328 329
    ("InProceedings"
     ((("author" "Author1 [and Author2 ...] [and others]")
330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356
       ("title" "Title of the article in proceedings (BibTeX converts it to lowercase)")
       ("booktitle" "Name of the conference proceedings")
       ("year" "Year of publication"))
      (("editor" "Editor1 [and Editor2 ...] [and others]")
       ("volume" "Volume of the conference proceedings in the series")
       ("number" "Number of the conference proceedings in a small series (overwritten by volume)")
       ("series" "Series in which the conference proceedings appeared")
       ("pages" "Pages in the conference proceedings")
       ("address" "Location of the Proceedings")
       ("month" "Month of the publication as a string (remove braces)")
       ("organization" "Sponsoring organization of the conference")
       ("publisher" "Publishing company, its location")
       ("note" "Remarks to be put at the end of the \\bibitem")))
     ((("author" "Author1 [and Author2 ...] [and others]")
       ("title" "Title of the article in proceedings (BibTeX converts it to lowercase)"))
      (("booktitle" "Name of the conference proceedings")
       ("pages" "Pages in the conference proceedings")
       ("year" "Year of publication")
       ("editor" "Editor1 [and Editor2 ...] [and others]")
       ("volume" "Volume of the conference proceedings in the series")
       ("number" "Number of the conference proceedings in a small series (overwritten by volume)")
       ("series" "Series in which the conference proceedings appeared")
       ("address" "Location of the Proceedings")
       ("month" "Month of the publication as a string (remove braces)")
       ("organization" "Sponsoring organization of the conference")
       ("publisher" "Publishing company, its location")
       ("note" "Remarks to be put at the end of the \\bibitem"))))
Stefan Monnier's avatar
Stefan Monnier committed
357 358
    ("Manual"
     ((("title" "Title of the manual"))
359 360 361 362 363 364 365
      (("author" "Author1 [and Author2 ...] [and others]")
       ("organization" "Publishing organization of the manual")
       ("address" "Address of the organization")
       ("edition" "Edition of the manual as a capitalized English word")
       ("month" "Month of the publication as a string (remove braces)")
       ("year" "Year of publication")
       ("note" "Remarks to be put at the end of the \\bibitem"))))
Stefan Monnier's avatar
Stefan Monnier committed
366 367
    ("MastersThesis"
     ((("author" "Author1 [and Author2 ...] [and others]")
368 369 370 371 372 373 374
       ("title" "Title of the master\'s thesis (BibTeX converts it to lowercase)")
       ("school" "School where the master\'s thesis was written")
       ("year" "Year of publication"))
      (("type" "Type of the master\'s thesis (if other than \"Master\'s thesis\")")
       ("address" "Address of the school (if not part of field \"school\") or country")
       ("month" "Month of the publication as a string (remove braces)")
       ("note" "Remarks to be put at the end of the \\bibitem"))))
Stefan Monnier's avatar
Stefan Monnier committed
375 376
    ("Misc"
     (()
377 378 379 380 381 382
      (("author" "Author1 [and Author2 ...] [and others]")
       ("title" "Title of the work (BibTeX converts it to lowercase)")
       ("howpublished" "The way in which the work was published")
       ("month" "Month of the publication as a string (remove braces)")
       ("year" "Year of publication")
       ("note" "Remarks to be put at the end of the \\bibitem"))))
Stefan Monnier's avatar
Stefan Monnier committed
383 384
    ("PhdThesis"
     ((("author" "Author1 [and Author2 ...] [and others]")
385 386 387 388 389 390 391
       ("title" "Title of the PhD. thesis")
       ("school" "School where the PhD. thesis was written")
       ("year" "Year of publication"))
      (("type" "Type of the PhD. thesis")
       ("address" "Address of the school (if not part of field \"school\") or country")
       ("month" "Month of the publication as a string (remove braces)")
       ("note" "Remarks to be put at the end of the \\bibitem"))))
Stefan Monnier's avatar
Stefan Monnier committed
392 393
    ("Proceedings"
     ((("title" "Title of the conference proceedings")
394 395 396 397 398 399 400 401 402 403 404
       ("year" "Year of publication"))
      (("booktitle" "Title of the proceedings for cross references")
       ("editor" "Editor1 [and Editor2 ...] [and others]")
       ("volume" "Volume of the conference proceedings in the series")
       ("number" "Number of the conference proceedings in a small series (overwritten by volume)")
       ("series" "Series in which the conference proceedings appeared")
       ("address" "Location of the Proceedings")
       ("month" "Month of the publication as a string (remove braces)")
       ("organization" "Sponsoring organization of the conference")
       ("publisher" "Publishing company, its location")
       ("note" "Remarks to be put at the end of the \\bibitem"))))
Stefan Monnier's avatar
Stefan Monnier committed
405 406
    ("TechReport"
     ((("author" "Author1 [and Author2 ...] [and others]")
407 408 409 410 411 412 413 414
       ("title" "Title of the technical report (BibTeX converts it to lowercase)")
       ("institution" "Sponsoring institution of the report")
       ("year" "Year of publication"))
      (("type" "Type of the report (if other than \"technical report\")")
       ("number" "Number of the technical report")
       ("address" "Address of the institution (if not part of field \"institution\") or country")
       ("month" "Month of the publication as a string (remove braces)")
       ("note" "Remarks to be put at the end of the \\bibitem"))))
Stefan Monnier's avatar
Stefan Monnier committed
415 416
    ("Unpublished"
     ((("author" "Author1 [and Author2 ...] [and others]")
417 418 419
       ("title" "Title of the unpublished work (BibTeX converts it to lowercase)")
       ("note" "Remarks to be put at the end of the \\bibitem"))
      (("month" "Month of the publication as a string (remove braces)")
Stefan Monnier's avatar
Stefan Monnier committed
420 421 422 423 424 425 426 427 428 429
       ("year" "Year of publication")))))

  "List of BibTeX entry types and their associated fields.
List elements are triples
\(ENTRY-NAME (REQUIRED OPTIONAL) (CROSSREF-REQUIRED CROSSREF-OPTIONAL)).
ENTRY-NAME is the name of a BibTeX entry.  The remaining pairs contain
the required and optional fields of the BibTeX entry.
The second pair is used if a crossref field is present
and the first pair is used if a crossref field is absent.
If the second pair is nil, the first pair is always used.
430
REQUIRED, OPTIONAL, CROSSREF-REQUIRED and CROSSREF-OPTIONAL are lists.
431
Each element of these lists is a list of the form
432
\(FIELD-NAME COMMENT-STRING INIT ALTERNATIVE-FLAG).
433
COMMENT-STRING, INIT, and ALTERNATIVE-FLAG are optional.
Stefan Monnier's avatar
Stefan Monnier committed
434 435
FIELD-NAME is the name of the field, COMMENT-STRING is the comment that
appears in the echo area, INIT is either the initial content of the
436 437
field or a function, which is called to determine the initial content
of the field, and ALTERNATIVE-FLAG (either nil or t) marks if the
Richard M. Stallman's avatar
Richard M. Stallman committed
438
field is an alternative.  ALTERNATIVE-FLAG may be t only in the
439 440
REQUIRED or CROSSREF-REQUIRED lists.")

Stefan Monnier's avatar
Stefan Monnier committed
441 442 443 444
(defcustom bibtex-comment-start "@Comment"
  "String starting a BibTeX comment."
  :group 'bibtex
  :type 'string)
445

Richard M. Stallman's avatar
Richard M. Stallman committed
446
(defcustom bibtex-add-entry-hook nil
Stefan Monnier's avatar
Stefan Monnier committed
447
  "List of functions to call when BibTeX entry has been inserted."
Richard M. Stallman's avatar
Richard M. Stallman committed
448
  :group 'bibtex
449
  :type 'hook)
450

Richard M. Stallman's avatar
Richard M. Stallman committed
451
(defcustom bibtex-predefined-month-strings
Stefan Monnier's avatar
Stefan Monnier committed
452 453 454 455 456 457 458 459 460 461 462 463 464
  '(("jan" . "January")
    ("feb" . "February")
    ("mar" . "March")
    ("apr" . "April")
    ("may" . "May")
    ("jun" . "June")
    ("jul" . "July")
    ("aug" . "August")
    ("sep" . "September")
    ("oct" . "October")
    ("nov" . "November")
    ("dec" . "December"))
  "Alist of month string definitions used in the BibTeX style files.
465
Each element is a pair of strings (ABBREVIATION . EXPANSION)."
Richard M. Stallman's avatar
Richard M. Stallman committed
466
  :group 'bibtex
Stefan Monnier's avatar
Stefan Monnier committed
467 468
  :type '(repeat (cons (string :tag "Month abbreviation")
                       (string :tag "Month expansion"))))
469

Richard M. Stallman's avatar
Richard M. Stallman committed
470
(defcustom bibtex-predefined-strings
471 472
  (append
   bibtex-predefined-month-strings
Stefan Monnier's avatar
Stefan Monnier committed
473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493
   '(("acmcs"    . "ACM Computing Surveys")
     ("acta"     . "Acta Informatica")
     ("cacm"     . "Communications of the ACM")
     ("ibmjrd"   . "IBM Journal of Research and Development")
     ("ibmsj"    . "IBM Systems Journal")
     ("ieeese"   . "IEEE Transactions on Software Engineering")
     ("ieeetc"   . "IEEE Transactions on Computers")
     ("ieeetcad" . "IEEE Transactions on Computer-Aided Design of Integrated Circuits")
     ("ipl"      . "Information Processing Letters")
     ("jacm"     . "Journal of the ACM")
     ("jcss"     . "Journal of Computer and System Sciences")
     ("scp"      . "Science of Computer Programming")
     ("sicomp"   . "SIAM Journal on Computing")
     ("tcs"      . "Theoretical Computer Science")
     ("tocs"     . "ACM Transactions on Computer Systems")
     ("tods"     . "ACM Transactions on Database Systems")
     ("tog"      . "ACM Transactions on Graphics")
     ("toms"     . "ACM Transactions on Mathematical Software")
     ("toois"    . "ACM Transactions on Office Information Systems")
     ("toplas"   . "ACM Transactions on Programming Languages and Systems")))
  "Alist of string definitions used in the BibTeX style files.
494
Each element is a pair of strings (ABBREVIATION . EXPANSION)."
Richard M. Stallman's avatar
Richard M. Stallman committed
495
  :group 'bibtex
Stefan Monnier's avatar
Stefan Monnier committed
496 497
  :type '(repeat (cons (string :tag "String")
                       (string :tag "String expansion"))))
498

Richard M. Stallman's avatar
Richard M. Stallman committed
499
(defcustom bibtex-string-files nil
500
  "List of BibTeX files containing string definitions.
Stefan Monnier's avatar
Stefan Monnier committed
501 502
List elements can be absolute file names or file names relative
to the directories specified in `bibtex-string-file-path'."
Richard M. Stallman's avatar
Richard M. Stallman committed
503 504
  :group 'bibtex
  :type '(repeat file))
505 506

(defvar bibtex-string-file-path (getenv "BIBINPUTS")
507
  "*Colon separated list of paths to search for `bibtex-string-files'.")
508

Stefan Monnier's avatar
Stefan Monnier committed
509
(defcustom bibtex-files nil
Stefan Monnier's avatar
Stefan Monnier committed
510
  "List of BibTeX files that are searched for entry keys.
Stefan Monnier's avatar
Stefan Monnier committed
511 512 513 514 515 516 517 518 519 520
List elements can be absolute file names or file names relative to the
directories specified in `bibtex-file-path'.  If an element is a directory,
check all BibTeX files in this directory.  If an element is the symbol
`bibtex-file-path', check all BibTeX files in `bibtex-file-path'."
  :group 'bibtex
  :type '(repeat file))

(defvar bibtex-file-path (getenv "BIBINPUTS")
  "*Colon separated list of paths to search for `bibtex-files'.")

Richard M. Stallman's avatar
Richard M. Stallman committed
521
(defcustom bibtex-help-message t
522
  "If non-nil print help messages in the echo area on entering a new field."
Richard M. Stallman's avatar
Richard M. Stallman committed
523 524
  :group 'bibtex
  :type 'boolean)
525

Richard M. Stallman's avatar
Richard M. Stallman committed
526
(defcustom bibtex-autokey-prefix-string ""
Stefan Monnier's avatar
Stefan Monnier committed
527
  "String prefix for automatically generated reference keys.
528
See `bibtex-generate-autokey' for details."
Richard M. Stallman's avatar
Richard M. Stallman committed
529 530
  :group 'bibtex-autokey
  :type 'string)
531

Richard M. Stallman's avatar
Richard M. Stallman committed
532
(defcustom bibtex-autokey-names 1
533
  "Number of names to use for the automatically generated reference key.
Richard M. Stallman's avatar
Richard M. Stallman committed
534
Possibly more names are used according to `bibtex-autokey-names-stretch'.
535 536
If this variable is nil, all names are used.
See `bibtex-generate-autokey' for details."
Richard M. Stallman's avatar
Richard M. Stallman committed
537
  :group 'bibtex-autokey
538
  :type '(choice (const :tag "All" infty)
Stefan Monnier's avatar
Stefan Monnier committed
539
                 integer))
540

Richard M. Stallman's avatar
Richard M. Stallman committed
541
(defcustom bibtex-autokey-names-stretch 0
Stefan Monnier's avatar
Stefan Monnier committed
542
  "Number of names that can additionally be used for reference keys.
543
These names are used only, if all names are used then.
544
See `bibtex-generate-autokey' for details."
Richard M. Stallman's avatar
Richard M. Stallman committed
545 546
  :group 'bibtex-autokey
  :type 'integer)
547

Richard M. Stallman's avatar
Richard M. Stallman committed
548
(defcustom bibtex-autokey-additional-names ""
Stefan Monnier's avatar
Stefan Monnier committed
549
  "String to append to the generated key if not all names could be used.
550
See `bibtex-generate-autokey' for details."
Richard M. Stallman's avatar
Richard M. Stallman committed
551 552
  :group 'bibtex-autokey
  :type 'string)
553 554

(defvar bibtex-autokey-transcriptions
Stefan Monnier's avatar
Stefan Monnier committed
555 556 557 558 559 560 561 562 563 564 565 566 567 568
  '(;; language specific characters
    ("\\\\aa" . "a")                      ; \aa           -> a
    ("\\\\AA" . "A")                      ; \AA           -> A
    ("\\\"a\\|\\\\\\\"a\\|\\\\ae" . "ae") ; "a,\"a,\ae    -> ae
    ("\\\"A\\|\\\\\\\"A\\|\\\\AE" . "Ae") ; "A,\"A,\AE    -> Ae
    ("\\\\i" . "i")                       ; \i            -> i
    ("\\\\j" . "j")                       ; \j            -> j
    ("\\\\l" . "l")                       ; \l            -> l
    ("\\\\L" . "L")                       ; \L            -> L
    ("\\\"o\\|\\\\\\\"o\\|\\\\o\\|\\\\oe" . "oe") ; "o,\"o,\o,\oe -> oe
    ("\\\"O\\|\\\\\\\"O\\|\\\\O\\|\\\\OE" . "Oe") ; "O,\"O,\O,\OE -> Oe
    ("\\\"s\\|\\\\\\\"s\\|\\\\3" . "ss")  ; "s,\"s,\3     -> ss
    ("\\\"u\\|\\\\\\\"u" . "ue")          ; "u,\"u        -> ue
    ("\\\"U\\|\\\\\\\"U" . "Ue")          ; "U,\"U        -> Ue
569
    ;; accents
Stefan Monnier's avatar
Stefan Monnier committed
570
    ("\\\\`\\|\\\\'\\|\\\\\\^\\|\\\\~\\|\\\\=\\|\\\\\\.\\|\\\\u\\|\\\\v\\|\\\\H\\|\\\\t\\|\\\\c\\|\\\\d\\|\\\\b" . "")
571 572
    ;; braces, quotes, concatenation.
    ("[`'\"{}#]" . "")
Stefan Monnier's avatar
Stefan Monnier committed
573
    ;; spaces
Stefan Monnier's avatar
Stefan Monnier committed
574
    ("\\\\?[ \t\n]+\\|~" . " "))
575
  "Alist of (OLD-REGEXP . NEW-STRING) pairs.
Richard M. Stallman's avatar
Richard M. Stallman committed
576 577 578
Used by the default values of `bibtex-autokey-name-change-strings' and
`bibtex-autokey-titleword-change-strings'.  Defaults to translating some
language specific characters to their ASCII transcriptions, and
579 580
removing any character accents.")

Richard M. Stallman's avatar
Richard M. Stallman committed
581
(defcustom bibtex-autokey-name-change-strings
582
  bibtex-autokey-transcriptions
583
  "Alist of (OLD-REGEXP . NEW-STRING) pairs.
Stefan Monnier's avatar
Stefan Monnier committed
584
Any part of a name matching OLD-REGEXP is replaced by NEW-STRING.
Richard M. Stallman's avatar
Richard M. Stallman committed
585
Case is significant in OLD-REGEXP.  All regexps are tried in the
Stefan Monnier's avatar
Stefan Monnier committed
586
order in which they appear in the list.
587
See `bibtex-generate-autokey' for details."
Richard M. Stallman's avatar
Richard M. Stallman committed
588
  :group 'bibtex-autokey
Stefan Monnier's avatar
Stefan Monnier committed
589 590
  :type '(repeat (cons (regexp :tag "Old")
                       (string :tag "New"))))
591

592
(defcustom bibtex-autokey-name-case-convert 'downcase
593
  "Function called for each name to perform case conversion.
594
See `bibtex-generate-autokey' for details."
595 596
  :group 'bibtex-autokey
  :type '(choice (const :tag "Preserve case" identity)
Stefan Monnier's avatar
Stefan Monnier committed
597 598 599 600
                 (const :tag "Downcase" downcase)
                 (const :tag "Capitalize" capitalize)
                 (const :tag "Upcase" upcase)
                 (function :tag "Conversion function")))
601

Richard M. Stallman's avatar
Richard M. Stallman committed
602
(defcustom bibtex-autokey-name-length 'infty
603
  "Number of characters from name to incorporate into key.
604
If this is set to anything but a number, all characters are used.
605
See `bibtex-generate-autokey' for details."
Richard M. Stallman's avatar
Richard M. Stallman committed
606 607
  :group 'bibtex-autokey
  :type '(choice (const :tag "All" infty)
Stefan Monnier's avatar
Stefan Monnier committed
608
                 integer))
609

Richard M. Stallman's avatar
Richard M. Stallman committed
610
(defcustom bibtex-autokey-name-separator ""
611
  "String that comes between any two names in the key.
612
See `bibtex-generate-autokey' for details."
Richard M. Stallman's avatar
Richard M. Stallman committed
613 614
  :group 'bibtex-autokey
  :type 'string)
615

Richard M. Stallman's avatar
Richard M. Stallman committed
616
(defcustom bibtex-autokey-year-length 2
617
  "Number of rightmost digits from the year field to incorporate into key.
618
See `bibtex-generate-autokey' for details."
Richard M. Stallman's avatar
Richard M. Stallman committed
619 620
  :group 'bibtex-autokey
  :type 'integer)
621

Stefan Monnier's avatar
Stefan Monnier committed
622
(defcustom bibtex-autokey-use-crossref t
623
  "If non-nil use fields from crossreferenced entry if necessary.
Stefan Monnier's avatar
Stefan Monnier committed
624 625
If this variable is non-nil and some field has no entry, but a
valid crossref entry, the field from the crossreferenced entry is used.
626
See `bibtex-generate-autokey' for details."
Richard M. Stallman's avatar
Richard M. Stallman committed
627 628
  :group 'bibtex-autokey
  :type 'boolean)
629

Richard M. Stallman's avatar
Richard M. Stallman committed
630
(defcustom bibtex-autokey-titlewords 5
631
  "Number of title words to use for the automatically generated reference key.
632
If this is set to anything but a number, all title words are used.
633
Possibly more words from the title are used according to
Richard M. Stallman's avatar
Richard M. Stallman committed
634
`bibtex-autokey-titlewords-stretch'.
635
See `bibtex-generate-autokey' for details."
Richard M. Stallman's avatar
Richard M. Stallman committed
636 637
  :group 'bibtex-autokey
  :type '(choice (const :tag "All" infty)
Stefan Monnier's avatar
Stefan Monnier committed
638
                 integer))
639

Stefan Monnier's avatar
Stefan Monnier committed
640 641 642
(defcustom bibtex-autokey-title-terminators "[.!?:;]\\|--"
  "Regexp defining the termination of the main part of the title.
Case of the regexps is ignored.  See `bibtex-generate-autokey' for details."
Richard M. Stallman's avatar
Richard M. Stallman committed
643
  :group 'bibtex-autokey
Stefan Monnier's avatar
Stefan Monnier committed
644
  :type 'regexp)
645

Richard M. Stallman's avatar
Richard M. Stallman committed
646
(defcustom bibtex-autokey-titlewords-stretch 2
647
  "Number of words that can additionally be used from the title.
648
These words are used only, if a sentence from the title can be ended then.
649
See `bibtex-generate-autokey' for details."
Richard M. Stallman's avatar
Richard M. Stallman committed
650 651
  :group 'bibtex-autokey
  :type 'integer)
652

653 654
(defcustom bibtex-autokey-titleword-ignore
  '("A" "An" "On" "The" "Eine?" "Der" "Die" "Das"
655
    "[^A-Z].*" ".*[^A-Z0-9].*")
656
  "Determines words from the title that are not to be used in the key.
657
Each item of the list is a regexp.  If a word of the title matches a
658
regexp from that list, it is not included in the title part of the key.
659
See `bibtex-generate-autokey' for details."
Richard M. Stallman's avatar
Richard M. Stallman committed
660 661
  :group 'bibtex-autokey
  :type '(repeat regexp))
662

663
(defcustom bibtex-autokey-titleword-case-convert 'downcase
664
  "Function called for each titleword to perform case conversion.
665
See `bibtex-generate-autokey' for details."
666 667
  :group 'bibtex-autokey
  :type '(choice (const :tag "Preserve case" identity)
Stefan Monnier's avatar
Stefan Monnier committed
668 669 670 671
                 (const :tag "Downcase" downcase)
                 (const :tag "Capitalize" capitalize)
                 (const :tag "Upcase" upcase)
                 (function :tag "Conversion function")))
672

Richard M. Stallman's avatar
Richard M. Stallman committed
673
(defcustom bibtex-autokey-titleword-abbrevs nil
674
  "Determines exceptions to the usual abbreviation mechanism.
675
An alist of (OLD-REGEXP . NEW-STRING) pairs.  Case is ignored
Richard M. Stallman's avatar
Richard M. Stallman committed
676
in matching against OLD-REGEXP, and the first matching pair is used.
677
See `bibtex-generate-autokey' for details."
Stefan Monnier's avatar
Stefan Monnier committed
678 679 680
  :group 'bibtex-autokey
  :type '(repeat (cons (regexp :tag "Old")
                       (string :tag "New"))))
681

Richard M. Stallman's avatar
Richard M. Stallman committed
682
(defcustom bibtex-autokey-titleword-change-strings
683
  bibtex-autokey-transcriptions
684
  "Alist of (OLD-REGEXP . NEW-STRING) pairs.
Richard M. Stallman's avatar
Richard M. Stallman committed
685 686
Any part of title word matching a OLD-REGEXP is replaced by NEW-STRING.
Case is significant in OLD-REGEXP.  All regexps are tried in the
Stefan Monnier's avatar
Stefan Monnier committed
687
order in which they appear in the list.
688
See `bibtex-generate-autokey' for details."
Richard M. Stallman's avatar
Richard M. Stallman committed
689
  :group 'bibtex-autokey
Stefan Monnier's avatar
Stefan Monnier committed
690 691
  :type '(repeat (cons (regexp :tag "Old")
                       (string :tag "New"))))
692

Richard M. Stallman's avatar
Richard M. Stallman committed
693
(defcustom bibtex-autokey-titleword-length 5
694
  "Number of characters from title words to incorporate into key.
695
If this is set to anything but a number, all characters are used.
696
See `bibtex-generate-autokey' for details."
Richard M. Stallman's avatar
Richard M. Stallman committed
697 698
  :group 'bibtex-autokey
  :type '(choice (const :tag "All" infty)
Stefan Monnier's avatar
Stefan Monnier committed
699
                 integer))
700

Richard M. Stallman's avatar
Richard M. Stallman committed
701
(defcustom bibtex-autokey-titleword-separator "_"
702
  "String to be put between the title words.
703
See `bibtex-generate-autokey' for details."
Richard M. Stallman's avatar
Richard M. Stallman committed
704 705
  :group 'bibtex-autokey
  :type 'string)
706

Richard M. Stallman's avatar
Richard M. Stallman committed
707
(defcustom bibtex-autokey-name-year-separator ""
708
  "String to be put between name part and year part of key.
709
See `bibtex-generate-autokey' for details."
Richard M. Stallman's avatar
Richard M. Stallman committed
710 711
  :group 'bibtex-autokey
  :type 'string)
712

Richard M. Stallman's avatar
Richard M. Stallman committed
713
(defcustom bibtex-autokey-year-title-separator ":_"
714
  "String to be put between name part and year part of key.
715
See `bibtex-generate-autokey' for details."
Richard M. Stallman's avatar
Richard M. Stallman committed
716 717
  :group 'bibtex-autokey
  :type 'string)
718

Richard M. Stallman's avatar
Richard M. Stallman committed
719
(defcustom bibtex-autokey-edit-before-use t
720
  "If non-nil, user is allowed to edit the generated key before it is used."
Richard M. Stallman's avatar
Richard M. Stallman committed
721 722
  :group 'bibtex-autokey
  :type 'boolean)
723

724
(defcustom bibtex-autokey-before-presentation-function nil
Stefan Monnier's avatar
Stefan Monnier committed
725 726 727
  "If non-nil, function to call before generated key is presented.
The function must take one argument (the automatically generated key),
and must return a string (the key to use)."
Richard M. Stallman's avatar
Richard M. Stallman committed
728
  :group 'bibtex-autokey
729
  :type '(choice (const nil) function))
730

Richard M. Stallman's avatar
Richard M. Stallman committed
731
(defcustom bibtex-entry-offset 0
732
  "Offset for BibTeX entries.
733
Added to the value of all other variables which determine columns."
Richard M. Stallman's avatar
Richard M. Stallman committed
734 735
  :group 'bibtex
  :type 'integer)
736

Richard M. Stallman's avatar
Richard M. Stallman committed
737
(defcustom bibtex-field-indentation 2
738
  "Starting column for the name part in BibTeX fields."
Richard M. Stallman's avatar
Richard M. Stallman committed
739 740
  :group 'bibtex
  :type 'integer)
741

Richard M. Stallman's avatar
Richard M. Stallman committed
742
(defcustom bibtex-text-indentation
Stefan Monnier's avatar
Stefan Monnier committed
743 744
  (+ bibtex-field-indentation
     (length "organization = "))
745
  "Starting column for the text part in BibTeX fields.
Richard M. Stallman's avatar
Richard M. Stallman committed
746 747 748
Should be equal to the space needed for the longest name part."
  :group 'bibtex
  :type 'integer)
749

Richard M. Stallman's avatar
Richard M. Stallman committed
750
(defcustom bibtex-contline-indentation
751
  (+ bibtex-text-indentation 1)
752
  "Starting column for continuation lines of BibTeX fields."
Richard M. Stallman's avatar
Richard M. Stallman committed
753 754
  :group 'bibtex
  :type 'integer)
755

Richard M. Stallman's avatar
Richard M. Stallman committed
756
(defcustom bibtex-align-at-equal-sign nil
757
  "If non-nil, align fields at equal sign instead of field text.
Stefan Monnier's avatar
Stefan Monnier committed
758 759
If non-nil, the column for the equal sign is the value of
`bibtex-text-indentation', minus 2."
Richard M. Stallman's avatar
Richard M. Stallman committed
760 761 762 763
  :group 'bibtex
  :type 'boolean)

(defcustom bibtex-comma-after-last-field nil
764
  "If non-nil, a comma is put at end of last field in the entry template."
Richard M. Stallman's avatar
Richard M. Stallman committed
765 766
  :group 'bibtex
  :type 'boolean)
767

768 769
(defcustom bibtex-autoadd-commas t
  "If non-nil automatically add missing commas at end of BibTeX fields."
Stefan Monnier's avatar
Stefan Monnier committed
770
  :group 'bibtex
771 772 773 774
  :type 'boolean)

(defcustom bibtex-autofill-types '("Proceedings")
  "Automatically fill fields if possible for those BibTeX entry types."
Stefan Monnier's avatar
Stefan Monnier committed
775
  :group 'bibtex
776 777
  :type '(repeat string))

Stefan Monnier's avatar
Stefan Monnier committed
778 779 780
(defcustom bibtex-summary-function 'bibtex-summary
  "Function to call for generating a one-line summary of a BibTeX entry.
It takes one argument, the key of the entry.
Stefan Monnier's avatar
Stefan Monnier committed
781
Used by `bibtex-complete-crossref-cleanup' and `bibtex-copy-summary-as-kill'."
Stefan Monnier's avatar
Stefan Monnier committed
782 783 784 785
  :group 'bibtex
  :type '(choice (const :tag "Default" bibtex-summary)
                 (function :tag "Personalized function")))

786
(defcustom bibtex-generate-url-list
787 788 789
  '((("url" . ".*:.*"))
    ;; Example of a complex setup.
    (("journal" . "\\<\\(PR[ABCDEL]?\\|RMP\\)\\>")
Stefan Monnier's avatar
Stefan Monnier committed
790
     "http://link.aps.org/abstract/"
791 792 793 794 795
     ("journal" ".*" downcase)
     "/v"
     ("volume" ".*" 0)
     "/p"
     ("pages" "\\`\\([0-9]+\\)" 1)))
796 797 798
  "List of schemes for generating the URL of a BibTeX entry.
These schemes are used by `bibtex-url'.

799
Each scheme is of the form ((FIELD . REGEXP) STEP...).
800 801

FIELD is a field name as returned by `bibtex-parse-entry'.
Stefan Monnier's avatar
Stefan Monnier committed
802
REGEXP is matched against the text of FIELD.  If the match succeeds, then
803 804
this scheme is used.  If no STEPs are specified the matched text is used
as the URL, otherwise the URL is built by concatenating the STEPs.
805 806 807 808 809 810 811 812

A STEP can be a string or a list (FIELD REGEXP REPLACE) in which case
the text of FIELD is matched against REGEXP, and is replaced with REPLACE.
REPLACE can be a string, or a number (which selects the corresponding submatch)
or a function called with the field's text as argument and with the
`match-data' properly set.

Case is always ignored.  Always remove the field delimiters."
813 814
  :group 'bibtex
  :type '(repeat
815
          (list :tag "Scheme"
816 817
                (cons :tag "Matcher" :extra-offset 4
                      (string :tag "BibTeX field")
818
		      (regexp :tag "Regexp"))
819 820 821 822
                (repeat :tag "Steps to generate URL" :inline t
                        (choice
                         (string :tag "Literal text")
                         (list (string :tag "BibTeX field")
823 824 825 826
			       (regexp :tag "Regexp")
                               (choice (string :tag "Replacement")
				       (integer :tag "Sub-match")
				       (function :tag "Filter"))))))))
Stefan Monnier's avatar
Stefan Monnier committed
827

828 829
;; bibtex-font-lock-keywords is a user option as well, but since the
;; patterns used to define this variable are defined in a later
830
;; section of this file, it is defined later.
831

832

833
;; Syntax Table, Keybindings and BibTeX Entry List
834 835
(defvar bibtex-mode-syntax-table
  (let ((st (make-syntax-table)))
836
    (modify-syntax-entry ?\" "\"" st)
837 838
    (modify-syntax-entry ?$ "$$  " st)
    (modify-syntax-entry ?% "<   " st)
839