bibtex.el 242 KB
Newer Older
1
;;; bibtex.el --- BibTeX mode for GNU Emacs -*- lexical-binding: t -*-
Eric S. Raymond's avatar
Eric S. Raymond committed
2

Paul Eggert's avatar
Paul Eggert committed
3
;; Copyright (C) 1992, 1994-1999, 2001-2018 Free Software Foundation,
4
;; 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
;;      Bengt Martensson <bengt@mathematik.uni-Bremen.de>
8
;;      Marc Shapiro <marc.shapiro@acm.org>
Stefan Monnier's avatar
Stefan Monnier committed
9 10 11
;;      Mike Newton <newton@gumby.cs.caltech.edu>
;;      Aaron Larson <alarson@src.honeywell.com>
;;      Dirk Herrmann <D.Herrmann@tu-bs.de>
12
;; Maintainer: Roland Winkler <winkler@gnu.org>
13
;; Keywords: BibTeX, LaTeX, TeX
Eric S. Raymond's avatar
Eric S. Raymond committed
14

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

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

;; 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
28
;; along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.
Jim Blandy's avatar
Jim Blandy committed
29

30
;;; Commentary:
Erik Naggum's avatar
Erik Naggum committed
31

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

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

38 39
;;  Todo:
;;  Distribute texinfo file.
40

41
;;; Code:
Erik Naggum's avatar
Erik Naggum committed
42

Stefan Monnier's avatar
Stefan Monnier committed
43 44
(require 'button)

45

46
;; User Options:
Eric S. Raymond's avatar
Eric S. Raymond committed
47

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

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

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

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

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

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

Richard M. Stallman's avatar
Richard M. Stallman committed
80
(defcustom bibtex-include-OPTkey t
81 82 83
  "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
84 85
  :group 'bibtex
  :type '(choice (const :tag "None" nil)
Stefan Monnier's avatar
Stefan Monnier committed
86
                 (string :tag "Initial text")
87
                 (function :tag "Initialize Function")
88
                 (const :tag "Default" t)))
89
(put 'bibtex-include-OPTkey 'risky-local-variable t)
Richard M. Stallman's avatar
Richard M. Stallman committed
90 91

(defcustom bibtex-user-optional-fields
92
  '(("annote" "Personal annotation (ignored)"))
Stefan Monnier's avatar
Stefan Monnier committed
93
  "List of optional fields the user wants to have always present.
94 95
Entries should be of the same form as the OPTIONAL list
in `bibtex-BibTeX-entry-alist' (which see)."
Richard M. Stallman's avatar
Richard M. Stallman committed
96
  :group 'bibtex
Stefan Monnier's avatar
Stefan Monnier committed
97 98
  :type '(repeat (group (string :tag "Field")
                        (string :tag "Comment")
99 100
                        (option (choice :tag "Init"
                                        (const nil) string function)))))
101
(put 'bibtex-user-optional-fields 'risky-local-variable t)
Stefan Monnier's avatar
Stefan Monnier committed
102 103 104

(defcustom bibtex-entry-format
  '(opts-or-alts required-fields numerical-fields)
Stefan Monnier's avatar
Stefan Monnier committed
105
  "Type of formatting performed by `bibtex-clean-entry'.
106
It may be t, nil, or a list of symbols out of the following:
Richard M. Stallman's avatar
Richard M. Stallman committed
107 108
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
109
required-fields     Signal an error if a required field is missing.
Richard M. Stallman's avatar
Richard M. Stallman committed
110 111 112
numerical-fields    Delete delimiters around numeral fields.
page-dashes         Change double dashes in page field to single dash
                      (for scribe compatibility).
113
whitespace          Delete whitespace at the beginning and end of fields.
114 115 116
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
117
realign             Realign entries, so that field texts and perhaps equal
118
                      signs (depending on the value of
119
                      `bibtex-align-at-equal-sign') begin in the same column.
120
                      Also fill fields.
Richard M. Stallman's avatar
Richard M. Stallman committed
121 122 123 124
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'.
125
unify-case          Change case of entry types and field names.
126 127 128 129
braces              Enclose parts of field entries by braces according to
                      `bibtex-field-braces-alist'.
strings             Replace parts of field entries by string constants
                      according to `bibtex-field-strings-alist'.
130
sort-fields         Sort fields to match the field order in
131
                    `bibtex-BibTeX-entry-alist'.
Richard M. Stallman's avatar
Richard M. Stallman committed
132 133 134

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
135 136
  :group 'bibtex
  :type '(choice (const :tag "None" nil)
Stefan Monnier's avatar
Stefan Monnier committed
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)
143
                      (const whitespace)
Stefan Monnier's avatar
Stefan Monnier committed
144 145 146 147
                      (const inherit-booktitle)
                      (const realign)
                      (const last-comma)
                      (const delimiters)
148 149
                      (const unify-case)
                      (const braces)
150 151
                      (const strings)
                      (const sort-fields))))
152 153 154 155 156 157 158 159
(put 'bibtex-entry-format 'safe-local-variable
     (lambda (x)
       (or (eq x t)
           (let ((OK t))
             (while (consp x)
               (unless (memq (pop x)
                             '(opts-or-alts required-fields numerical-fields
                               page-dashes whitespace inherit-booktitle realign
160 161
                               last-comma delimiters unify-case braces strings
                               sort-fields))
162 163 164
                 (setq OK nil)))
             (unless (null x) (setq OK nil))
             OK))))
165 166 167 168 169

(defcustom bibtex-field-braces-alist nil
 "Alist of field regexps that \\[bibtex-clean-entry] encloses by braces.
Each element has the form (FIELDS REGEXP), where FIELDS is a list
of BibTeX field names and REGEXP is a regexp.
170
Space characters in REGEXP will be replaced by \"[ \\t\\n]+\"."
171 172 173 174 175 176 177 178 179 180
  :group 'bibtex
  :type '(repeat (list (repeat (string :tag "field name"))
                       (choice (regexp :tag "regexp")
                               (sexp :tag "sexp")))))

(defcustom bibtex-field-strings-alist nil
 "Alist of regexps that \\[bibtex-clean-entry] replaces by string constants.
Each element has the form (FIELDS REGEXP TO-STR), where FIELDS is a list
of BibTeX field names.  In FIELDS search for REGEXP, which are replaced
by the BibTeX string constant TO-STR.
181
Space characters in REGEXP will be replaced by \"[ \\t\\n]+\"."
182 183 184 185
  :group 'bibtex
  :type '(repeat (list (repeat (string :tag "field name"))
                       (regexp :tag "From regexp")
                       (regexp :tag "To string constant"))))
186

Richard M. Stallman's avatar
Richard M. Stallman committed
187
(defcustom bibtex-clean-entry-hook nil
Stefan Monnier's avatar
Stefan Monnier committed
188
  "List of functions to call when entry has been cleaned.
Richard M. Stallman's avatar
Richard M. Stallman committed
189
Functions are called with point inside the cleaned entry, and the buffer
Richard M. Stallman's avatar
Richard M. Stallman committed
190 191
narrowed to just the entry."
  :group 'bibtex
192
  :type 'hook)
193

Richard M. Stallman's avatar
Richard M. Stallman committed
194
(defcustom bibtex-maintain-sorted-entries nil
195
  "If non-nil, BibTeX mode maintains all entries in sorted order.
196
Allowed non-nil values are:
197
plain or t   All entries are sorted alphabetically.
Stefan Monnier's avatar
Stefan Monnier committed
198
crossref     All entries are sorted alphabetically unless an entry has a
199
             crossref field.  These crossrefed entries are placed in
Stefan Monnier's avatar
Stefan Monnier committed
200 201
             alphabetical order immediately preceding the main entry.
entry-class  The entries are divided into classes according to their
202
             entry type, see `bibtex-sort-entry-class'.  Within each class
Stefan Monnier's avatar
Stefan Monnier committed
203 204 205 206 207 208
             the entries are sorted alphabetically.
See also `bibtex-sort-ignore-string-entries'."
  :group 'bibtex
  :type '(choice (const nil)
                 (const plain)
                 (const crossref)
209 210 211
                 (const entry-class)
                 (const t)))
(put 'bibtex-maintain-sorted-entries 'safe-local-variable
212
     (lambda (a) (memq a '(nil t plain crossref entry-class))))
Stefan Monnier's avatar
Stefan Monnier committed
213

Stefan Monnier's avatar
Stefan Monnier committed
214
(defcustom bibtex-sort-entry-class
Stefan Monnier's avatar
Stefan Monnier committed
215
  '(("String")
216 217
    (catch-all)
    ("Book" "Proceedings"))
218
  "List of classes of BibTeX entry types, used for sorting entries.
219
If value of `bibtex-maintain-sorted-entries' is `entry-class'
220
entries are ordered according to the classes they belong to.  Each
221
class contains a list of entry types.  An entry `catch-all' applies
222
to all entries not explicitly mentioned."
Juanma Barranquero's avatar
Juanma Barranquero committed
223
  :group 'bibtex
Stefan Monnier's avatar
Stefan Monnier committed
224 225
  :type '(repeat (choice :tag "Class"
                         (const :tag "catch-all" (catch-all))
226
                         (repeat :tag "Entry type" string))))
227 228 229 230 231 232 233 234 235 236 237
(put 'bibtex-sort-entry-class 'safe-local-variable
     (lambda (x) (let ((OK t))
              (while (consp x)
                (let ((y (pop x)))
                  (while (consp y)
                    (let ((z (pop y)))
                      (unless (or (stringp z) (eq z 'catch-all))
                        (setq OK nil))))
                  (unless (null y) (setq OK nil))))
              (unless (null x) (setq OK nil))
              OK)))
Stefan Monnier's avatar
Stefan Monnier committed
238

239
(defcustom bibtex-sort-ignore-string-entries t
240
  "If non-nil, BibTeX @String entries are not sort-significant.
Stefan Monnier's avatar
Stefan Monnier committed
241 242
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
243 244
  :group 'bibtex
  :type 'boolean)
245

Richard M. Stallman's avatar
Richard M. Stallman committed
246
(defcustom bibtex-field-kill-ring-max 20
247
  "Max length of `bibtex-field-kill-ring' before discarding oldest elements."
Richard M. Stallman's avatar
Richard M. Stallman committed
248 249
  :group 'bibtex
  :type 'integer)
250

251
(defcustom bibtex-entry-kill-ring-max 20
252
  "Max length of `bibtex-entry-kill-ring' before discarding oldest elements."
253 254 255
  :group 'bibtex
  :type 'integer)

Richard M. Stallman's avatar
Richard M. Stallman committed
256
(defcustom bibtex-parse-keys-timeout 60
257
  "Time interval in seconds for parsing BibTeX buffers during idle time.
Stefan Monnier's avatar
Stefan Monnier committed
258
Parsing initializes `bibtex-reference-keys' and `bibtex-strings'."
Richard M. Stallman's avatar
Richard M. Stallman committed
259 260
  :group 'bibtex
  :type 'integer)
261

262
(defcustom bibtex-parse-keys-fast t
263
  "If non-nil, use fast but simplified algorithm for parsing BibTeX keys.
264 265 266 267
If parsing fails, try to set this variable to nil."
  :group 'bibtex
  :type 'boolean)

268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319
(define-widget 'bibtex-entry-alist 'lazy
  "Format of `bibtex-BibTeX-entry-alist' and friends."
  :type '(repeat (group (string :tag "Entry type")
                        (string :tag "Documentation")
                        (repeat :tag "Required fields"
                                (group (string :tag "Field")
                                       (option (choice :tag "Comment" :value nil
                                                       (const nil) string))
                                       (option (choice :tag "Init" :value nil
                                                       (const nil) string function))
                                       (option (choice :tag "Alternative" :value nil
                                                       (const nil) integer))))
                        (repeat :tag "Crossref fields"
                                (group (string :tag "Field")
                                       (option (choice :tag "Comment" :value nil
                                                       (const nil) string))
                                       (option (choice :tag "Init" :value nil
                                                       (const nil) string function))
                                       (option (choice :tag "Alternative" :value nil
                                                       (const nil) integer))))
                        (repeat :tag "Optional fields"
                                (group (string :tag "Field")
                                       (option (choice :tag "Comment" :value nil
                                                       (const nil) string))
                                       (option (choice :tag "Init" :value nil
                                                       (const nil) string function)))))))

(define-obsolete-variable-alias 'bibtex-entry-field-alist
  'bibtex-BibTeX-entry-alist "24.1")
(defcustom bibtex-BibTeX-entry-alist
  '(("Article" "Article in Journal"
     (("author")
      ("title" "Title of the article (BibTeX converts it to lowercase)"))
     (("journal") ("year"))
     (("volume" "Volume of the journal")
      ("number" "Number of the journal (only allowed if entry contains volume)")
      ("pages" "Pages in the journal")
      ("month") ("note")))
    ("InProceedings" "Article in Conference Proceedings"
     (("author")
      ("title" "Title of the article in proceedings (BibTeX converts it to lowercase)"))
     (("booktitle" "Name of the conference proceedings")
      ("year"))
     (("editor")
      ("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")
      ("month") ("address")
      ("organization" "Sponsoring organization of the conference")
      ("publisher" "Publishing company, its location")
      ("note")))
320 321 322 323 324 325 326 327 328 329 330 331 332 333
    ("Conference" "Article in Conference Proceedings" ; same as InProceedings
     (("author")
      ("title" "Title of the article in proceedings (BibTeX converts it to lowercase)"))
     (("booktitle" "Name of the conference proceedings")
      ("year"))
     (("editor")
      ("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")
      ("month") ("address")
      ("organization" "Sponsoring organization of the conference")
      ("publisher" "Publishing company, its location")
      ("note")))
334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448
    ("InCollection" "Article in a Collection"
     (("author")
      ("title" "Title of the article in book (BibTeX converts it to lowercase)")
      ("booktitle" "Name of the book"))
     (("publisher") ("year"))
     (("editor")
      ("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")
      ("edition" "Edition of the book as a capitalized English word")
      ("month") ("address") ("note")))
    ("InBook" "Chapter or Pages in a Book"
     (("author" nil nil 0)
      ("editor" nil nil 0)
      ("title" "Title of the book")
      ("chapter" "Chapter in the book"))
     (("publisher") ("year"))
     (("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")
      ("edition" "Edition of the book as a capitalized English word")
      ("month")
      ("pages" "Pages in the book")
      ("note")))
    ("Proceedings" "Conference Proceedings"
     (("title" "Title of the conference proceedings")
      ("year"))
     nil
     (("booktitle" "Title of the proceedings for cross references")
      ("editor")
      ("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")
      ("month")
      ("organization" "Sponsoring organization of the conference")
      ("publisher" "Publishing company, its location")
      ("note")))
    ("Book" "Book"
     (("author" nil nil 0)
      ("editor" nil nil 0)
      ("title" "Title of the book"))
     (("publisher") ("year"))
     (("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")
      ("edition" "Edition of the book as a capitalized English word")
      ("month") ("note")))
    ("Booklet" "Booklet (Bound, but no Publisher)"
     (("title" "Title of the booklet (BibTeX converts it to lowercase)"))
     nil
     (("author")
      ("howpublished" "The way in which the booklet was published")
      ("address") ("month") ("year") ("note")))
    ("PhdThesis" "PhD. Thesis"
     (("author")
      ("title" "Title of the PhD. thesis")
      ("school" "School where the PhD. thesis was written")
      ("year"))
     nil
     (("type" "Type of the PhD. thesis")
      ("address" "Address of the school (if not part of field \"school\") or country")
      ("month") ("note")))
    ("MastersThesis" "Master's Thesis"
     (("author")
      ("title" "Title of the master's thesis (BibTeX converts it to lowercase)")
      ("school" "School where the master's thesis was written")
      ("year"))
     nil
     (("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") ("note")))
    ("TechReport" "Technical Report"
     (("author")
      ("title" "Title of the technical report (BibTeX converts it to lowercase)")
      ("institution" "Sponsoring institution of the report")
      ("year"))
     nil
     (("type" "Type of the report (if other than \"technical report\")")
      ("number" "Number of the technical report")
      ("address") ("month") ("note")))
    ("Manual" "Technical Manual"
     (("title" "Title of the manual"))
     nil
     (("author")
      ("organization" "Publishing organization of the manual")
      ("address")
      ("edition" "Edition of the manual as a capitalized English word")
      ("month") ("year") ("note")))
    ("Unpublished" "Unpublished"
     (("author")
      ("title" "Title of the unpublished work (BibTeX converts it to lowercase)")
      ("note"))
     nil
     (("month") ("year")))
    ("Misc" "Miscellaneous" nil nil
     (("author")
      ("title" "Title of the work (BibTeX converts it to lowercase)")
      ("howpublished" "The way in which the work was published")
      ("month") ("year") ("note"))))
  "Alist of BibTeX entry types and their associated fields.
Elements are lists (ENTRY-TYPE DOC REQUIRED CROSSREF OPTIONAL).
ENTRY-TYPE is the type of a BibTeX entry.
DOC is a brief doc string used for menus. If nil ENTRY-TYPE is used.
REQUIRED is a list of required fields.
CROSSREF is a list of fields that are optional if a crossref field
is present; but these fields are required otherwise.
OPTIONAL is a list of optional fields.

449
Each element of these lists is a list of the form
450
  (FIELD COMMENT INIT ALTERNATIVE).
451 452 453 454 455 456 457 458 459 460
COMMENT, INIT, and ALTERNATIVE are optional.

FIELD is the name of the field.
COMMENT is the comment string that appears in the echo area.
If COMMENT is nil use `bibtex-BibTeX-field-alist' if possible.
INIT is either the initial content of the field or a function,
which is called to determine the initial content of the field.
ALTERNATIVE if non-nil is an integer that numbers sets of
alternatives, starting from zero."
  :group 'BibTeX
461
  :version "26.1"                       ; add Conference
462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484
  :type 'bibtex-entry-alist)
(put 'bibtex-BibTeX-entry-alist 'risky-local-variable t)

(defcustom bibtex-biblatex-entry-alist
  ;; Compare in biblatex documentation:
  ;; Sec. 2.1.1  Regular types (required and optional fields)
  ;; Appendix A  Default Crossref setup
  '(("Article" "Article in Journal"
     (("author") ("title") ("journaltitle")
      ("year" nil nil 0) ("date" nil nil 0))
     nil
     (("translator") ("annotator") ("commentator") ("subtitle") ("titleaddon")
      ("editor") ("editora") ("editorb") ("editorc")
      ("journalsubtitle") ("issuetitle") ("issuesubtitle")
      ("language") ("origlanguage") ("series") ("volume") ("number") ("eid")
      ("issue") ("month") ("pages") ("version") ("note") ("issn")
      ("addendum") ("pubstate") ("doi") ("eprint") ("eprintclass")
      ("eprinttype") ("url") ("urldate")))
    ("Book" "Single-Volume Book"
     (("author") ("title") ("year" nil nil 0) ("date" nil nil 0))
     nil
     (("editor") ("editora") ("editorb") ("editorc")
      ("translator") ("annotator") ("commentator")
485
      ("introduction") ("foreword") ("afterword") ("subtitle") ("titleaddon")
486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562
      ("maintitle") ("mainsubtitle") ("maintitleaddon")
      ("language") ("origlanguage") ("volume") ("part") ("edition") ("volumes")
      ("series") ("number") ("note") ("publisher") ("location") ("isbn")
      ("chapter") ("pages") ("pagetotal") ("addendum") ("pubstate") ("doi")
      ("eprint") ("eprintclass") ("eprinttype") ("url") ("urldate")))
    ("MVBook" "Multi-Volume Book"
     (("author") ("title") ("year" nil nil 0) ("date" nil nil 0))
     nil
     (("editor") ("editora") ("editorb") ("editorc")
      ("translator") ("annotator") ("commentator")
      ("introduction") ("foreword") ("afterword") ("subtitle")
      ("titleaddon") ("language") ("origlanguage") ("edition") ("volumes")
      ("series") ("number") ("note") ("publisher")
      ("location") ("isbn") ("pagetotal") ("addendum") ("pubstate") ("doi")
      ("eprint") ("eprintclass") ("eprinttype") ("url") ("urldate")))
    ("InBook" "Chapter or Pages in a Book"
     (("title") ("year" nil nil 0) ("date" nil nil 0))
     (("author") ("booktitle"))
     (("bookauthor") ("editor") ("editora") ("editorb") ("editorc")
      ("translator") ("annotator") ("commentator") ("introduction") ("foreword")
      ("afterword") ("subtitle") ("titleaddon") ("maintitle") ("mainsubtitle")
      ("maintitleaddon") ("booksubtitle") ("booktitleaddon")
      ("language") ("origlanguage") ("volume") ("part") ("edition") ("volumes")
      ("series") ("number") ("note") ("publisher") ("location") ("isbn")
      ("chapter") ("pages") ("addendum") ("pubstate")
      ("doi") ("eprint") ("eprintclass") ("eprinttype") ("url") ("urldate")))
    ("BookInBook" "Book in Collection" ; same as @inbook
     (("title") ("year" nil nil 0) ("date" nil nil 0))
     (("author") ("booktitle"))
     (("bookauthor") ("editor") ("editora") ("editorb") ("editorc")
      ("translator") ("annotator") ("commentator") ("introduction") ("foreword")
      ("afterword") ("subtitle") ("titleaddon") ("maintitle") ("mainsubtitle")
      ("maintitleaddon") ("booksubtitle") ("booktitleaddon")
      ("language") ("origlanguage") ("volume") ("part") ("edition") ("volumes")
      ("series") ("number") ("note") ("publisher") ("location") ("isbn")
      ("chapter") ("pages") ("addendum") ("pubstate")
      ("doi") ("eprint") ("eprintclass") ("eprinttype") ("url") ("urldate")))
    ("SuppBook" "Supplemental Material in a Book" ; same as @inbook
     (("title") ("year" nil nil 0) ("date" nil nil 0))
     (("author") ("booktitle"))
     (("bookauthor") ("editor") ("editora") ("editorb") ("editorc")
      ("translator") ("annotator") ("commentator") ("introduction") ("foreword")
      ("afterword") ("subtitle") ("titleaddon") ("maintitle") ("mainsubtitle")
      ("maintitleaddon") ("booksubtitle") ("booktitleaddon")
      ("language") ("origlanguage") ("volume") ("part") ("edition") ("volumes")
      ("series") ("number") ("note") ("publisher") ("location") ("isbn")
      ("chapter") ("pages") ("addendum") ("pubstate")
      ("doi") ("eprint") ("eprintclass") ("eprinttype") ("url") ("urldate")))
    ("Booklet" "Booklet (Bound, but no Publisher)"
     (("author" nil nil 0) ("editor" nil nil 0) ("title")
      ("year" nil nil 1) ("date" nil nil 1))
     nil
     (("subtitle") ("titleaddon") ("language") ("howpublished") ("type")
      ("note") ("location") ("chapter") ("pages") ("pagetotal") ("addendum")
      ("pubstate") ("doi") ("eprint") ("eprintclass") ("eprinttype")
      ("url") ("urldate")))
    ("Collection" "Single-Volume Collection"
     (("editor") ("title") ("year" nil nil 0) ("date" nil nil 0))
     nil
     (("editora") ("editorb") ("editorc") ("translator") ("annotator")
      ("commentator") ("introduction") ("foreword") ("afterword")
      ("subtitle") ("titleaddon") ("maintitle") ("mainsubtitle")
      ("maintitleaddon") ("language") ("origlanguage") ("volume")
      ("part") ("edition") ("volumes") ("series") ("number") ("note")
      ("publisher") ("location") ("isbn") ("chapter") ("pages") ("pagetotal")
      ("addendum") ("pubstate") ("doi") ("eprint") ("eprintclass")
      ("eprinttype") ("url") ("urldate")))
    ("MVCollection" "Multi-Volume Collection"
     (("editor") ("title") ("year" nil nil 0) ("date" nil nil 0))
     nil
     (("editora") ("editorb") ("editorc") ("translator") ("annotator")
      ("commentator") ("introduction") ("foreword") ("afterword")
      ("subtitle") ("titleaddon") ("language") ("origlanguage") ("edition")
      ("volumes") ("series") ("number") ("note") ("publisher")
      ("location") ("isbn") ("pagetotal") ("addendum") ("pubstate") ("doi")
      ("eprint") ("eprintclass") ("eprinttype") ("url") ("urldate")))
    ("InCollection" "Article in a Collection"
563
     (("author") ("title") ("year" nil nil 0) ("date" nil nil 0))
564
     (("booktitle"))
565
     (("editor") ("editora") ("editorb") ("editorc") ("translator") ("annotator")
566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632
      ("commentator") ("introduction") ("foreword") ("afterword")
      ("subtitle") ("titleaddon") ("maintitle") ("mainsubtitle")
      ("maintitleaddon") ("booksubtitle") ("booktitleaddon")
      ("language") ("origlanguage") ("volume") ("part") ("edition")
      ("volumes") ("series") ("number") ("note") ("publisher") ("location")
      ("isbn") ("chapter") ("pages") ("addendum") ("pubstate") ("doi")
      ("eprint") ("eprintclass") ("eprinttype") ("url") ("urldate")))
    ("SuppCollection" "Supplemental Material in a Collection" ; same as @incollection
     (("author") ("editor") ("title") ("year" nil nil 0) ("date" nil nil 0))
     (("booktitle"))
     (("editora") ("editorb") ("editorc") ("translator") ("annotator")
      ("commentator") ("introduction") ("foreword") ("afterword")
      ("subtitle") ("titleaddon") ("maintitle") ("mainsubtitle")
      ("maintitleaddon") ("booksubtitle") ("booktitleaddon")
      ("language") ("origlanguage") ("volume") ("part") ("edition")
      ("volumes") ("series") ("number") ("note") ("publisher") ("location")
      ("isbn") ("chapter") ("pages") ("addendum") ("pubstate") ("doi")
      ("eprint") ("eprintclass") ("eprinttype") ("url") ("urldate")))
    ("Manual" "Technical Manual"
     (("author" nil nil 0) ("editor" nil nil 0) ("title")
      ("year" nil nil 1) ("date" nil nil 1))
     nil
     (("subtitle") ("titleaddon") ("language") ("edition")
      ("type") ("series") ("number") ("version") ("note")
      ("organization") ("publisher") ("location") ("isbn") ("chapter")
      ("pages") ("pagetotal") ("addendum") ("pubstate")
      ("doi") ("eprint") ("eprintclass") ("eprinttype") ("url") ("urldate")))
    ("Misc" "Miscellaneous"
     (("author" nil nil 0) ("editor" nil nil 0) ("title")
      ("year" nil nil 1) ("date" nil nil 1))
     nil
     (("subtitle") ("titleaddon") ("language") ("howpublished") ("type")
      ("version") ("note") ("organization") ("location")
      ("date") ("month") ("year") ("addendum") ("pubstate")
      ("doi") ("eprint") ("eprintclass") ("eprinttype") ("url") ("urldate")))
    ("Online" "Online Resource"
     (("author" nil nil 0) ("editor" nil nil 0) ("title")
      ("year" nil nil 1) ("date" nil nil 1) ("url"))
     nil
     (("subtitle") ("titleaddon") ("language") ("version") ("note")
      ("organization") ("date") ("month") ("year") ("addendum")
      ("pubstate") ("urldate")))
    ("Patent" "Patent"
     (("author") ("title") ("number") ("year" nil nil 0) ("date" nil nil 0))
     nil
     (("holder") ("subtitle") ("titleaddon") ("type") ("version") ("location")
      ("note") ("date") ("month") ("year") ("addendum") ("pubstate")
      ("doi") ("eprint") ("eprintclass") ("eprinttype") ("url") ("urldate")))
    ("Periodical" "Complete Issue of a Periodical"
     (("editor") ("title") ("year" nil nil 0) ("date" nil nil 0))
     nil
     (("editora") ("editorb") ("editorc") ("subtitle") ("issuetitle")
      ("issuesubtitle") ("language") ("series") ("volume") ("number") ("issue")
      ("date") ("month") ("year") ("note") ("issn") ("addendum") ("pubstate")
      ("doi") ("eprint") ("eprintclass") ("eprinttype") ("url") ("urldate")))
    ("SuppPeriodical" "Supplemental Material in a Periodical" ; same as @article
     (("author") ("title") ("journaltitle")
      ("year" nil nil 0) ("date" nil nil 0))
     nil
     (("translator") ("annotator") ("commentator") ("subtitle") ("titleaddon")
      ("editor") ("editora") ("editorb") ("editorc")
      ("journalsubtitle") ("issuetitle") ("issuesubtitle")
      ("language") ("origlanguage") ("series") ("volume") ("number") ("eid")
      ("issue") ("month") ("pages") ("version") ("note") ("issn")
      ("addendum") ("pubstate") ("doi") ("eprint") ("eprintclass")
      ("eprinttype") ("url") ("urldate")))
    ("Proceedings" "Single-Volume Conference Proceedings"
633
     (("title") ("year" nil nil 0) ("date" nil nil 0))
634 635 636
     nil
     (("subtitle") ("titleaddon") ("maintitle") ("mainsubtitle")
      ("maintitleaddon") ("eventtitle") ("eventdate") ("venue") ("language")
637
      ("editor")
638 639 640 641 642 643 644 645 646 647 648 649 650
      ("volume") ("part") ("volumes") ("series") ("number") ("note")
      ("organization") ("publisher") ("location") ("month")
      ("isbn") ("chapter") ("pages") ("pagetotal") ("addendum") ("pubstate")
      ("doi") ("eprint") ("eprintclass") ("eprinttype") ("url") ("urldate")))
    ("MVProceedings" "Multi-Volume Conference Proceedings"
     (("editor") ("title") ("year" nil nil 0) ("date" nil nil 0))
     nil
     (("subtitle") ("titleaddon") ("eventtitle") ("eventdate") ("venue")
      ("language") ("volumes") ("series") ("number") ("note")
      ("organization") ("publisher") ("location") ("month")
      ("isbn") ("pagetotal") ("addendum") ("pubstate")
      ("doi") ("eprint") ("eprintclass") ("eprinttype") ("url") ("urldate")))
    ("InProceedings" "Article in Conference Proceedings"
651
     (("author") ("title") ("year" nil nil 0) ("date" nil nil 0))
652
     (("booktitle"))
653
     (("editor") ("subtitle") ("titleaddon") ("maintitle") ("mainsubtitle")
654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714
      ("maintitleaddon") ("booksubtitle") ("booktitleaddon")
      ("eventtitle") ("eventdate") ("venue") ("language")
      ("volume") ("part") ("volumes") ("series") ("number") ("note")
      ("organization") ("publisher") ("location") ("month") ("isbn")
      ("chapter") ("pages") ("addendum") ("pubstate")
      ("doi") ("eprint") ("eprintclass") ("eprinttype") ("url") ("urldate")))
    ("Reference" "Single-Volume Work of Reference" ; same as @collection
     (("editor") ("title") ("year" nil nil 0) ("date" nil nil 0))
     nil
     (("editora") ("editorb") ("editorc") ("translator") ("annotator")
      ("commentator") ("introduction") ("foreword") ("afterword")
      ("subtitle") ("titleaddon") ("maintitle") ("mainsubtitle")
      ("maintitleaddon") ("language") ("origlanguage") ("volume")
      ("part") ("edition") ("volumes") ("series") ("number") ("note")
      ("publisher") ("location") ("isbn") ("chapter") ("pages") ("pagetotal")
      ("addendum") ("pubstate") ("doi") ("eprint") ("eprintclass")
      ("eprinttype") ("url") ("urldate")))
    ("MVReference" "Multi-Volume Work of Reference" ; same as @mvcollection
     (("editor") ("title") ("year" nil nil 0) ("date" nil nil 0))
     nil
     (("editora") ("editorb") ("editorc") ("translator") ("annotator")
      ("commentator") ("introduction") ("foreword") ("afterword")
      ("subtitle") ("titleaddon") ("language") ("origlanguage") ("edition")
      ("volumes") ("series") ("number") ("note") ("publisher")
      ("location") ("isbn") ("pagetotal") ("addendum") ("pubstate") ("doi")
      ("eprint") ("eprintclass") ("eprinttype") ("url") ("urldate")))
    ("InReference" "Article in a Work of Reference" ; same as @incollection
     (("author") ("editor") ("title") ("year" nil nil 0) ("date" nil nil 0))
     (("booktitle"))
     (("editora") ("editorb") ("editorc") ("translator") ("annotator")
      ("commentator") ("introduction") ("foreword") ("afterword")
      ("subtitle") ("titleaddon") ("maintitle") ("mainsubtitle")
      ("maintitleaddon") ("booksubtitle") ("booktitleaddon")
      ("language") ("origlanguage") ("volume") ("part") ("edition")
      ("volumes") ("series") ("number") ("note") ("publisher") ("location")
      ("isbn") ("chapter") ("pages") ("addendum") ("pubstate") ("doi")
      ("eprint") ("eprintclass") ("eprinttype") ("url") ("urldate")))
    ("Report" "Technical or Research Report"
     (("author") ("title") ("type") ("institution")
      ("year" nil nil 0) ("date" nil nil 0))
     nil
     (("subtitle") ("titleaddon") ("language") ("number") ("version") ("note")
      ("location") ("month") ("isrn") ("chapter") ("pages") ("pagetotal")
      ("addendum") ("pubstate")
      ("doi") ("eprint") ("eprintclass") ("eprinttype") ("url") ("urldate")))
    ("Thesis" "PhD. or Master's Thesis"
     (("author") ("title") ("type") ("institution")
      ("year" nil nil 0) ("date" nil nil 0))
     nil
     (("subtitle") ("titleaddon") ("language") ("note") ("location")
      ("month") ("isbn") ("chapter") ("pages") ("pagetotal")
      ("addendum") ("pubstate")
      ("doi") ("eprint") ("eprintclass") ("eprinttype") ("url") ("urldate")))
    ("Unpublished" "Unpublished"
     (("author") ("title") ("year" nil nil 0) ("date" nil nil 0))
     nil
     (("subtitle") ("titleaddon") ("language") ("howpublished")
      ("note") ("location") ("isbn") ("date") ("month") ("year")
      ("addendum") ("pubstate") ("url") ("urldate"))))
  "Alist of biblatex entry types and their associated fields.
It has the same format as `bibtex-BibTeX-entry-alist'."
715
  :group 'bibtex
716
  :version "24.1"
717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737
  :type 'bibtex-entry-alist)
(put 'bibtex-biblatex-entry-alist 'risky-local-variable t)

(define-widget 'bibtex-field-alist 'lazy
  "Format of `bibtex-BibTeX-entry-alist' and friends."
  :type '(repeat (group (string :tag "Field type")
                        (string :tag "Comment"))))

(defcustom bibtex-BibTeX-field-alist
  '(("author" "Author1 [and Author2 ...] [and others]")
    ("editor" "Editor1 [and Editor2 ...] [and others]")
    ("journal" "Name of the journal (use string, remove braces)")
    ("year" "Year of publication")
    ("month" "Month of the publication as a string (remove braces)")
    ("note" "Remarks to be put at the end of the \\bibitem")
    ("publisher" "Publishing company")
    ("address" "Address of the publisher"))
    "Alist of BibTeX fields.
Each element is a list (FIELD COMMENT).  COMMENT is used as a default
if `bibtex-BibTeX-entry-alist' does not define a comment for FIELD."
  :group 'bibtex
738
  :version "24.1"
739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835
  :type 'bibtex-field-alist)

(defcustom bibtex-biblatex-field-alist
  ;; See 2.2.2 Data Fields
  '(("abstract" "Abstract of the work")
    ("addendum" "Miscellaneous bibliographic data")
    ("afterword" "Author(s) of an afterword to the work")
    ("annotation" "Annotation")
    ("annotator" "Author(s) of annotations to the work")
    ("author" "Author(s) of the title")
    ("bookauthor" "Author(s) of the booktitle.")
    ("bookpagination" "Pagination scheme of the enclosing work")
    ("booksubtitle" "Subtitle related to the booktitle")
    ("booktitle" "Title of the book")
    ("booktitleaddon" "Annex to the booktitle")
    ("chapter" "Chapter, section, or any other unit of a work")
    ("commentator" "Author(s) of a commentary to the work")
    ("date" "Publication date")
    ("doi" "Digital Object Identifier")
    ("edition" "Edition of a printed publication")
    ("editor" "Editor(s) of the title, booktitle, or maintitle")
    ("editora" "Secondary editor")
    ("editorb" "Secondary editor")
    ("editorc" "Secondary editor")
    ("editortype" "Type of editorial role performed by the editor")
    ("editoratype" "Type of editorial role performed by editora")
    ("editorbtype" "Type of editorial role performed by editorb")
    ("editorctype" "Type of editorial role performed by editorc")
    ("eid" "Electronic identifier of an article")
    ("eprint" "Electronic identifier of an online publication")
    ("eprintclass" "Additional information related to the eprinttype")
    ("eprinttype" "Type of eprint identifier")
    ("eventdate" "Date of a conference or some other event")
    ("eventtitle" "Title of a conference or some other event")
    ("file" "Local link to an electronic version of the work")
    ("foreword" "Author(s) of a foreword to the work")
    ("holder" "Holder(s) of a patent")
    ("howpublished" "Publication notice for unusual publications")
    ("indextitle" "Title to use for indexing instead of the regular title")
    ("institution" "Name of a university or some other institution")
    ("introduction" "Author(s) of an introduction to the work")
    ("isan" "International Standard Audiovisual Number of an audiovisual work")
    ("isbn" "International Standard Book Number of a book.")
    ("ismn" "International Standard Music Number for printed music")
    ("isrn" "International Standard Technical Report Number")
    ("issn" "International Standard Serial Number of a periodical.")
    ("issue" "Issue of a journal")
    ("issuesubtitle" "Subtitle of a specific issue of a journal or other periodical.")
    ("issuetitle" "Title of a specific issue of a journal or other periodical.")
    ("iswc" "International Standard Work Code of a musical work")
    ("journalsubtitle" "Subtitle of a journal, a newspaper, or some other periodical.")
    ("journaltitle" "Name of a journal, a newspaper, or some other periodical.")
    ("label" "Substitute for the regular label to be used by the citation style")
    ("language" "Language(s) of the work")
    ("library" "Library name and a call number")
    ("location" "Place(s) of publication")
    ("mainsubtitle" "Subtitle related to the maintitle")
    ("maintitle" "Main title of a multi-volume book, such as Collected Works")
    ("maintitleaddon" "Annex to the maintitle")
    ("month" "Publication month")
    ("nameaddon" "Addon to be printed immediately after the author name")
    ("note" "Miscellaneous bibliographic data")
    ("number" "Number of a journal or the volume/number of a book in a series")
    ("organization" "Organization(s) that published a work")
    ("origdate" "Publication date of the original edition")
    ("origlanguage" "Original publication language of a translated edition")
    ("origlocation" "Location of the original edition")
    ("origpublisher" "Publisher of the original edition")
    ("origtitle" "Title of the original work")
    ("pages" "Page number(s) or page range(s)")
    ("pagetotal" "Total number of pages of the work.")
    ("pagination" "Pagination of the work")
    ("part" "Number of a partial volume")
    ("publisher" "Name(s) of the publisher(s)")
    ("pubstate" "Publication state of the work, e. g.,'in press'")
    ("reprinttitle" "Title of a reprint of the work")
    ("series" "Name of a publication series")
    ("shortauthor" "Author(s) of the work, given in an abbreviated form")
    ("shorteditor" "Editor(s) of the work, given in an abbreviated form")
    ("shortjournal" "Short version or an acronym of the journal title")
    ("shortseries" "Short version or an acronym of the series field")
    ("shorttitle" "Title in an abridged form")
    ("subtitle" "Subtitle of the work")
    ("title" "Title of the work")
    ("titleaddon" "Annex to the title")
    ("translator" "Translator(s) of the work")
    ("type" "Type of a manual, patent, report, or thesis")
    ("url" " URL of an online publication.")
    ("urldate" "Access date of the address specified in the url field")
    ("venue" "Location of a conference, a symposium, or some other event")
    ("version" "Revision number of a piece of software, a manual, etc.")
    ("volume" "Volume of a multi-volume book or a periodical")
    ("volumes" "Total number of volumes of a multi-volume work")
    ("year" "Year of publication"))
    "Alist of biblatex fields.
It has the same format as `bibtex-BibTeX-entry-alist'."
  :group 'bibtex
836
  :version "24.1"
837 838 839 840 841 842 843 844
  :type 'bibtex-field-alist)

(defcustom bibtex-dialect-list '(BibTeX biblatex)
  "List of BibTeX dialects known to BibTeX mode.
For each DIALECT (a symbol) a variable bibtex-DIALECT-entry-alist defines
the allowed entries and bibtex-DIALECT-field-alist defines known field types.
Predefined dialects include BibTeX and biblatex."
  :group 'bibtex
845
  :version "24.1"
846 847 848 849
  :type '(repeat (symbol :tag "Dialect")))

(defcustom bibtex-dialect 'BibTeX
  "Current BibTeX dialect.  For allowed values see `bibtex-dialect-list'.
850
To interactively change the dialect use the command `bibtex-set-dialect'."
851
  :group 'bibtex
852
  :version "24.1"
853 854 855 856 857 858 859 860
  :set '(lambda (symbol value)
          (set-default symbol value)
          ;; `bibtex-set-dialect' is undefined during loading (no problem)
          (if (fboundp 'bibtex-set-dialect)
              (bibtex-set-dialect value)))
  :type '(choice (const BibTeX)
                 (const biblatex)
                 (symbol :tag "Custom")))
861
(put 'bibtex-dialect 'safe-local-variable 'symbolp)
862 863 864 865 866

(defcustom bibtex-no-opt-remove-re "\\`option"
  "If a field name matches this regexp, the prefix OPT is not removed.
If nil prefix OPT is always removed"
  :group 'bibtex
867
  :version "24.1"
868
  :type '(choice (regexp) (const nil)))
869

Stefan Monnier's avatar
Stefan Monnier committed
870 871 872 873
(defcustom bibtex-comment-start "@Comment"
  "String starting a BibTeX comment."
  :group 'bibtex
  :type 'string)
874

Richard M. Stallman's avatar
Richard M. Stallman committed
875
(defcustom bibtex-add-entry-hook nil
Stefan Monnier's avatar
Stefan Monnier committed
876
  "List of functions to call when BibTeX entry has been inserted."
Richard M. Stallman's avatar
Richard M. Stallman committed
877
  :group 'bibtex
878
  :type 'hook)
879

Richard M. Stallman's avatar
Richard M. Stallman committed
880
(defcustom bibtex-predefined-month-strings
Stefan Monnier's avatar
Stefan Monnier committed
881 882 883 884 885 886 887 888 889 890 891 892 893
  '(("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.
894
Each element is a pair of strings (ABBREVIATION . EXPANSION)."
Richard M. Stallman's avatar
Richard M. Stallman committed
895
  :group 'bibtex
Stefan Monnier's avatar
Stefan Monnier committed
896 897
  :type '(repeat (cons (string :tag "Month abbreviation")
                       (string :tag "Month expansion"))))
898

Richard M. Stallman's avatar
Richard M. Stallman committed
899
(defcustom bibtex-predefined-strings
900 901
  (append
   bibtex-predefined-month-strings
Stefan Monnier's avatar
Stefan Monnier committed
902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922
   '(("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.
923
Each element is a pair of strings (ABBREVIATION . EXPANSION)."
Richard M. Stallman's avatar
Richard M. Stallman committed
924
  :group 'bibtex
Stefan Monnier's avatar
Stefan Monnier committed
925 926
  :type '(repeat (cons (string :tag "String")
                       (string :tag "String expansion"))))
927

Richard M. Stallman's avatar
Richard M. Stallman committed
928
(defcustom bibtex-string-files nil
929
  "List of BibTeX files containing string definitions.
Stefan Monnier's avatar
Stefan Monnier committed
930 931
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
932 933
  :group 'bibtex
  :type '(repeat file))
934

935 936 937 938
(defcustom bibtex-string-file-path (getenv "BIBINPUTS")
  "Colon-separated list of paths to search for `bibtex-string-files'."
  :group 'bibtex
  :type 'string)
939

Stefan Monnier's avatar
Stefan Monnier committed
940
(defcustom bibtex-files nil
Stefan Monnier's avatar
Stefan Monnier committed
941
  "List of BibTeX files that are searched for entry keys.
Stefan Monnier's avatar
Stefan Monnier committed
942 943 944
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
945 946
`bibtex-file-path', check all BibTeX files in `bibtex-file-path'.
See also `bibtex-search-entry-globally'."
Stefan Monnier's avatar
Stefan Monnier committed
947
  :group 'bibtex
948 949
  :type '(repeat (choice (const :tag "bibtex-file-path" bibtex-file-path)
                         directory file)))
Stefan Monnier's avatar
Stefan Monnier committed
950

951 952 953 954
(defcustom bibtex-file-path (getenv "BIBINPUTS")
  "Colon separated list of paths to search for `bibtex-files'."
  :group 'bibtex
  :type 'string)
Stefan Monnier's avatar
Stefan Monnier committed
955

956 957 958 959
(defcustom bibtex-search-entry-globally nil
  "If non-nil, interactive calls of `bibtex-search-entry' search globally.
A global search includes all files in `bibtex-files'."
  :group 'bibtex
960
  :version "24.1"
961 962
  :type 'boolean)

Richard M. Stallman's avatar
Richard M. Stallman committed
963
(defcustom bibtex-help-message t
964
  "If non-nil print help messages in the echo area on entering a new field."
Richard M. Stallman's avatar
Richard M. Stallman committed
965 966
  :group 'bibtex
  :type 'boolean)
967

Richard M. Stallman's avatar
Richard M. Stallman committed
968
(defcustom bibtex-autokey-prefix-string ""
Stefan Monnier's avatar
Stefan Monnier committed
969
  "String prefix for automatically generated reference keys.
970
See `bibtex-generate-autokey' for details."
Richard M. Stallman's avatar
Richard M. Stallman committed
971 972
  :group 'bibtex-autokey
  :type 'string)
973

Richard M. Stallman's avatar
Richard M. Stallman committed
974
(defcustom bibtex-autokey-names 1
975
  "Number of names to use for the automatically generated reference key.
Richard M. Stallman's avatar
Richard M. Stallman committed
976
Possibly more names are used according to `bibtex-autokey-names-stretch'.
977 978
If this variable is nil, all names are used.
See `bibtex-generate-autokey' for details."
Richard M. Stallman's avatar
Richard M. Stallman committed
979
  :group 'bibtex-autokey
980
  :type '(choice (const :tag "All" infty)
Stefan Monnier's avatar
Stefan Monnier committed
981
                 integer))
982

Richard M. Stallman's avatar
Richard M. Stallman committed
983
(defcustom bibtex-autokey-names-stretch 0
Stefan Monnier's avatar
Stefan Monnier committed
984
  "Number of names that can additionally be used for reference keys.
985
These names are used only, if all names are used then.
986
See `bibtex-generate-autokey' for details."
Richard M. Stallman's avatar
Richard M. Stallman committed
987 988
  :group 'bibtex-autokey
  :type 'integer)
989

Richard M. Stallman's avatar
Richard M. Stallman committed
990
(defcustom bibtex-autokey-additional-names ""
Stefan Monnier's avatar
Stefan Monnier committed
991
  "String to append to the generated key if not all names could be used.
992
See `bibtex-generate-autokey' for details."
Richard M. Stallman's avatar
Richard M. Stallman committed
993 994
  :group 'bibtex-autokey
  :type 'string)
995

Stefan Monnier's avatar
Stefan Monnier committed
996 997 998 999 1000 1001
(defcustom bibtex-autokey-expand-strings nil
  "If non-nil, expand strings when extracting the content of a BibTeX field.
See `bibtex-generate-autokey' for details."
  :group 'bibtex-autokey
  :type 'boolean)

1002
(defvar bibtex-autokey-transcriptions
Stefan Monnier's avatar
Stefan Monnier committed
1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016
  '(;; 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
1017
    ;; accents
Stefan Monnier's avatar
Stefan Monnier committed
1018
    ("\\\\`\\|\\\\'\\|\\\\\\^\\|\\\\~\\|\\\\=\\|\\\\\\.\\|\\\\u\\|\\\\v\\|\\\\H\\|\\\\t\\|\\\\c\\|\\\\d\\|\\\\b" . "")
1019 1020
    ;; braces, quotes, concatenation.
    ("[`'\"{}#]" . "")
1021
    ("\\\\-" . "")                        ; \-            ->
Stefan Monnier's avatar
Stefan Monnier committed
1022
    ;; spaces
Stefan Monnier's avatar
Stefan Monnier committed
1023
    ("\\\\?[ \t\n]+\\|~" . " "))
1024
  "Alist of (OLD-REGEXP . NEW-STRING) pairs.
Richard M. Stallman's avatar
Richard M. Stallman committed
1025 1026 1027
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
1028 1029
removing any character accents.")

Richard M. Stallman's avatar
Richard M. Stallman committed
1030
(defcustom bibtex-autokey-name-change-strings
1031
  bibtex-autokey-transcriptions
1032
  "Alist of (OLD-REGEXP . NEW-STRING) pairs.
Stefan Monnier's avatar
Stefan Monnier committed
1033
Any part of a name matching OLD-REGEXP is replaced by NEW-STRING.
Richard M. Stallman's avatar
Richard M. Stallman committed
1034
Case is significant in OLD-REGEXP.  All regexps are tried in the
Stefan Monnier's avatar
Stefan Monnier committed
1035
order in which they appear in the list.
1036
See `bibtex-generate-autokey' for details."
Richard M. Stallman's avatar
Richard M. Stallman committed
1037
  :group 'bibtex-autokey
Stefan Monnier's avatar
Stefan Monnier committed
1038 1039
  :type '(repeat (cons (regexp :tag "Old")
                       (string :tag "New"))))
1040

1041
(defcustom bibtex-autokey-name-case-convert-function 'downcase
1042
  "Function called for each name to perform case conversion.
1043
See `bibtex-generate-autokey' for details."
1044 1045
  :group 'bibtex-autokey
  :type '(choice (const :tag "Preserve case" identity)
Stefan Monnier's avatar
Stefan Monnier committed
1046 1047 1048 1049
                 (const :tag "Downcase" downcase)
                 (const :tag "Capitalize" capitalize)
                 (const :tag "Upcase" upcase)
                 (function :tag "Conversion function")))
1050 1051
(put 'bibtex-autokey-name-case-convert-function 'safe-local-variable
     (lambda (x) (memq x '(upcase downcase capitalize identity))))
1052 1053
(defvaralias 'bibtex-autokey-name-case-convert
  'bibtex-autokey-name-case-convert-function)
1054

Richard M. Stallman's avatar
Richard M. Stallman committed
1055
(defcustom bibtex-autokey-name-length 'infty
1056
  "Number of characters from name to incorporate into key.
1057
If this is set to anything but a number, all characters are used.
1058
See `bibtex-generate-autokey' for details."
Richard M. Stallman's avatar
Richard M. Stallman committed