aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--etc/NEWS5
-rw-r--r--lisp/ChangeLog26
-rw-r--r--lisp/textmodes/bibtex.el1257
3 files changed, 837 insertions, 451 deletions
diff --git a/etc/NEWS b/etc/NEWS
index 5da6e06d0d0..87ac6e22921 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -475,6 +475,11 @@ Just set shell-dir-cookie-re to an appropriate regexp.
475 475
476** BibTeX mode 476** BibTeX mode
477 477
478*** BibTeX mode now supports biblatex.
479Use the variable bibtex-dialect to select support for different BibTeX dialects.
480bibtex-entry-field-alist is now an obsolete alias for
481bibtex-BibTeX-entry-alist.
482
478*** New command `bibtex-search-entries' bound to C-c C-a. 483*** New command `bibtex-search-entries' bound to C-c C-a.
479 484
480*** New `bibtex-entry-format' option `sort-fields', disabled by default. 485*** New `bibtex-entry-format' option `sort-fields', disabled by default.
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 1a6c66e2bdf..05fbbfa89fc 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,29 @@
12011-07-05 Roland Winkler <winkler@gnu.org>
2
3 * textmodes/bibtex.el: Add support for biblatex.
4 (bibtex-BibTeX-entry-alist, bibtex-biblatex-entry-alist)
5 (bibtex-BibTeX-field-alist, bibtex-biblatex-field-alist)
6 (bibtex-dialect-list, bibtex-dialect, bibtex-no-opt-remove-re)
7 (bibtex-entry-alist, bibtex-field-alist): New variables.
8 (bibtex-entry-field-alist): Obsolete alias for
9 bibtex-BibTeX-entry-alist.
10 (bibtex-entry-alist, bibtex-field-alist): New widgets.
11 (bibtex-set-dialect): New command.
12 (bibtex-entry-type, bibtex-entry-head)
13 (bibtex-entry-maybe-empty-head, bibtex-any-valid-entry-type): Bind
14 via bibtex-set-dialect.
15 (bibtex-Article, bibtex-Book, bibtex-Booklet, bibtex-InBook)
16 (bibtex-InCollection, bibtex-InProceedings, bibtex-Manual)
17 (bibtex-MastersThesis, bibtex-Misc, bibtex-PhdThesis)
18 (bibtex-Proceedings, bibtex-TechReport, bibtex-Unpublished):
19 Define via bibtex-set-dialect.
20 (bibtex-name-in-field, bibtex-remove-OPT-or-ALT): Obey
21 bibtex-no-opt-remove-re.
22 (bibtex-vec-push, bibtex-vec-incr): New functions.
23 (bibtex-format-entry, bibtex-field-list)
24 (bibtex-print-help-message, bibtex-validate)
25 (bibtex-search-entries): Use new format of bibtex-entry-alist.
26
12011-07-05 Stefan Monnier <monnier@iro.umontreal.ca> 272011-07-05 Stefan Monnier <monnier@iro.umontreal.ca>
2 28
3 * progmodes/compile.el (compilation-goto-locus): 29 * progmodes/compile.el (compilation-goto-locus):
diff --git a/lisp/textmodes/bibtex.el b/lisp/textmodes/bibtex.el
index 107a0728bae..930d3200234 100644
--- a/lisp/textmodes/bibtex.el
+++ b/lisp/textmodes/bibtex.el
@@ -90,8 +90,8 @@ If this is a function, call it to generate the initial field text."
90(defcustom bibtex-user-optional-fields 90(defcustom bibtex-user-optional-fields
91 '(("annote" "Personal annotation (ignored)")) 91 '(("annote" "Personal annotation (ignored)"))
92 "List of optional fields the user wants to have always present. 92 "List of optional fields the user wants to have always present.
93Entries should be of the same form as the OPTIONAL and 93Entries should be of the same form as the OPTIONAL list
94CROSSREF-OPTIONAL lists in `bibtex-entry-field-alist' (which see)." 94in `bibtex-BibTeX-entry-alist' (which see)."
95 :group 'bibtex 95 :group 'bibtex
96 :type '(repeat (group (string :tag "Field") 96 :type '(repeat (group (string :tag "Field")
97 (string :tag "Comment") 97 (string :tag "Comment")
@@ -127,7 +127,7 @@ braces Enclose parts of field entries by braces according to
127strings Replace parts of field entries by string constants 127strings Replace parts of field entries by string constants
128 according to `bibtex-field-strings-alist'. 128 according to `bibtex-field-strings-alist'.
129sort-fields Sort fields to match the field order in 129sort-fields Sort fields to match the field order in
130 `bibtex-entry-field-alist'. 130 `bibtex-BibTeX-entry-alist'.
131 131
132The value t means do all of the above formatting actions. 132The value t means do all of the above formatting actions.
133The value nil means do no formatting at all." 133The value nil means do no formatting at all."
@@ -264,265 +264,584 @@ If parsing fails, try to set this variable to nil."
264 :group 'bibtex 264 :group 'bibtex
265 :type 'boolean) 265 :type 'boolean)
266 266
267(defcustom bibtex-entry-field-alist 267(define-widget 'bibtex-entry-alist 'lazy
268 '(("Article" 268 "Format of `bibtex-BibTeX-entry-alist' and friends."
269 ((("author" "Author1 [and Author2 ...] [and others]") 269 :type '(repeat (group (string :tag "Entry type")
270 ("title" "Title of the article (BibTeX converts it to lowercase)") 270 (string :tag "Documentation")
271 ("journal" "Name of the journal (use string, remove braces)") 271 (repeat :tag "Required fields"
272 ("year" "Year of publication")) 272 (group (string :tag "Field")
273 (("volume" "Volume of the journal") 273 (option (choice :tag "Comment" :value nil
274 ("number" "Number of the journal (only allowed if entry contains volume)") 274 (const nil) string))
275 ("pages" "Pages in the journal") 275 (option (choice :tag "Init" :value nil
276 ("month" "Month of the publication as a string (remove braces)") 276 (const nil) string function))
277 ("note" "Remarks to be put at the end of the \\bibitem"))) 277 (option (choice :tag "Alternative" :value nil
278 ((("author" "Author1 [and Author2 ...] [and others]") 278 (const nil) integer))))
279 ("title" "Title of the article (BibTeX converts it to lowercase)")) 279 (repeat :tag "Crossref fields"
280 (("pages" "Pages in the journal") 280 (group (string :tag "Field")
281 ("journal" "Name of the journal (use string, remove braces)") 281 (option (choice :tag "Comment" :value nil
282 ("year" "Year of publication") 282 (const nil) string))
283 ("volume" "Volume of the journal") 283 (option (choice :tag "Init" :value nil
284 ("number" "Number of the journal") 284 (const nil) string function))
285 ("month" "Month of the publication as a string (remove braces)") 285 (option (choice :tag "Alternative" :value nil
286 ("note" "Remarks to be put at the end of the \\bibitem")))) 286 (const nil) integer))))
287 ("Book" 287 (repeat :tag "Optional fields"
288 ((("author" "Author1 [and Author2 ...] [and others]" nil t) 288 (group (string :tag "Field")
289 ("editor" "Editor1 [and Editor2 ...] [and others]" nil t) 289 (option (choice :tag "Comment" :value nil
290 ("title" "Title of the book") 290 (const nil) string))
291 ("publisher" "Publishing company") 291 (option (choice :tag "Init" :value nil
292 ("year" "Year of publication")) 292 (const nil) string function)))))))
293 (("volume" "Volume of the book in the series") 293
294 ("number" "Number of the book in a small series (overwritten by volume)") 294(define-obsolete-variable-alias 'bibtex-entry-field-alist
295 ("series" "Series in which the book appeared") 295 'bibtex-BibTeX-entry-alist "24.1")
296 ("address" "Address of the publisher") 296(defcustom bibtex-BibTeX-entry-alist
297 ("edition" "Edition of the book as a capitalized English word") 297 '(("Article" "Article in Journal"
298 ("month" "Month of the publication as a string (remove braces)") 298 (("author")
299 ("note" "Remarks to be put at the end of the \\bibitem"))) 299 ("title" "Title of the article (BibTeX converts it to lowercase)"))
300 ((("author" "Author1 [and Author2 ...] [and others]" nil t) 300 (("journal") ("year"))
301 ("editor" "Editor1 [and Editor2 ...] [and others]" nil t) 301 (("volume" "Volume of the journal")
302 ("title" "Title of the book")) 302 ("number" "Number of the journal (only allowed if entry contains volume)")
303 (("publisher" "Publishing company") 303 ("pages" "Pages in the journal")
304 ("year" "Year of publication") 304 ("month") ("note")))
305 ("volume" "Volume of the book in the series") 305 ("InProceedings" "Article in Conference Proceedings"
306 ("number" "Number of the book in a small series (overwritten by volume)") 306 (("author")
307 ("series" "Series in which the book appeared") 307 ("title" "Title of the article in proceedings (BibTeX converts it to lowercase)"))
308 ("address" "Address of the publisher") 308 (("booktitle" "Name of the conference proceedings")
309 ("edition" "Edition of the book as a capitalized English word") 309 ("year"))
310 ("month" "Month of the publication as a string (remove braces)") 310 (("editor")
311 ("note" "Remarks to be put at the end of the \\bibitem")))) 311 ("volume" "Volume of the conference proceedings in the series")
312 ("Booklet" 312 ("number" "Number of the conference proceedings in a small series (overwritten by volume)")
313 ((("title" "Title of the booklet (BibTeX converts it to lowercase)")) 313 ("series" "Series in which the conference proceedings appeared")
314 (("author" "Author1 [and Author2 ...] [and others]") 314 ("pages" "Pages in the conference proceedings")
315 ("howpublished" "The way in which the booklet was published") 315 ("month") ("address")
316 ("address" "Address of the publisher") 316 ("organization" "Sponsoring organization of the conference")
317 ("month" "Month of the publication as a string (remove braces)") 317 ("publisher" "Publishing company, its location")
318 ("year" "Year of publication") 318 ("note")))
319 ("note" "Remarks to be put at the end of the \\bibitem")))) 319 ("InCollection" "Article in a Collection"
320 ("InBook" 320 (("author")
321 ((("author" "Author1 [and Author2 ...] [and others]" nil t) 321 ("title" "Title of the article in book (BibTeX converts it to lowercase)")
322 ("editor" "Editor1 [and Editor2 ...] [and others]" nil t) 322 ("booktitle" "Name of the book"))
323 ("title" "Title of the book") 323 (("publisher") ("year"))
324 ("chapter" "Chapter in the book") 324 (("editor")
325 ("publisher" "Publishing company") 325 ("volume" "Volume of the book in the series")
326 ("year" "Year of publication")) 326 ("number" "Number of the book in a small series (overwritten by volume)")
327 (("volume" "Volume of the book in the series") 327 ("series" "Series in which the book appeared")
328 ("number" "Number of the book in a small series (overwritten by volume)") 328 ("type" "Word to use instead of \"chapter\"")
329 ("series" "Series in which the book appeared") 329 ("chapter" "Chapter in the book")
330 ("type" "Word to use instead of \"chapter\"") 330 ("pages" "Pages in the book")
331 ("address" "Address of the publisher") 331 ("edition" "Edition of the book as a capitalized English word")
332 ("edition" "Edition of the book as a capitalized English word") 332 ("month") ("address") ("note")))
333 ("month" "Month of the publication as a string (remove braces)") 333 ("InBook" "Chapter or Pages in a Book"
334 ("pages" "Pages in the book") 334 (("author" nil nil 0)
335 ("note" "Remarks to be put at the end of the \\bibitem"))) 335 ("editor" nil nil 0)
336 ((("author" "Author1 [and Author2 ...] [and others]" nil t) 336 ("title" "Title of the book")
337 ("editor" "Editor1 [and Editor2 ...] [and others]" nil t) 337 ("chapter" "Chapter in the book"))
338 ("title" "Title of the book") 338 (("publisher") ("year"))
339 ("chapter" "Chapter in the book")) 339 (("volume" "Volume of the book in the series")
340 (("pages" "Pages in the book") 340 ("number" "Number of the book in a small series (overwritten by volume)")
341 ("publisher" "Publishing company") 341 ("series" "Series in which the book appeared")
342 ("year" "Year of publication") 342 ("type" "Word to use instead of \"chapter\"")
343 ("volume" "Volume of the book in the series") 343 ("address")
344 ("number" "Number of the book in a small series (overwritten by volume)") 344 ("edition" "Edition of the book as a capitalized English word")
345 ("series" "Series in which the book appeared") 345 ("month")
346 ("type" "Word to use instead of \"chapter\"") 346 ("pages" "Pages in the book")
347 ("address" "Address of the publisher") 347 ("note")))
348 ("edition" "Edition of the book as a capitalized English word") 348 ("Proceedings" "Conference Proceedings"
349 ("month" "Month of the publication as a string (remove braces)") 349 (("title" "Title of the conference proceedings")
350 ("note" "Remarks to be put at the end of the \\bibitem")))) 350 ("year"))
351 ("InCollection" 351 nil
352 ((("author" "Author1 [and Author2 ...] [and others]") 352 (("booktitle" "Title of the proceedings for cross references")
353 ("title" "Title of the article in book (BibTeX converts it to lowercase)") 353 ("editor")
354 ("booktitle" "Name of the book") 354 ("volume" "Volume of the conference proceedings in the series")
355 ("publisher" "Publishing company") 355 ("number" "Number of the conference proceedings in a small series (overwritten by volume)")
356 ("year" "Year of publication")) 356 ("series" "Series in which the conference proceedings appeared")
357 (("editor" "Editor1 [and Editor2 ...] [and others]") 357 ("address")
358 ("volume" "Volume of the book in the series") 358 ("month")
359 ("number" "Number of the book in a small series (overwritten by volume)") 359 ("organization" "Sponsoring organization of the conference")
360 ("series" "Series in which the book appeared") 360 ("publisher" "Publishing company, its location")
361 ("type" "Word to use instead of \"chapter\"") 361 ("note")))
362 ("chapter" "Chapter in the book") 362 ("Book" "Book"
363 ("pages" "Pages in the book") 363 (("author" nil nil 0)
364 ("address" "Address of the publisher") 364 ("editor" nil nil 0)
365 ("edition" "Edition of the book as a capitalized English word") 365 ("title" "Title of the book"))
366 ("month" "Month of the publication as a string (remove braces)") 366 (("publisher") ("year"))
367 ("note" "Remarks to be put at the end of the \\bibitem"))) 367 (("volume" "Volume of the book in the series")
368 ((("author" "Author1 [and Author2 ...] [and others]") 368 ("number" "Number of the book in a small series (overwritten by volume)")
369 ("title" "Title of the article in book (BibTeX converts it to lowercase)") 369 ("series" "Series in which the book appeared")
370 ("booktitle" "Name of the book")) 370 ("address")
371 (("pages" "Pages in the book") 371 ("edition" "Edition of the book as a capitalized English word")
372 ("publisher" "Publishing company") 372 ("month") ("note")))
373 ("year" "Year of publication") 373 ("Booklet" "Booklet (Bound, but no Publisher)"
374 ("editor" "Editor1 [and Editor2 ...] [and others]") 374 (("title" "Title of the booklet (BibTeX converts it to lowercase)"))
375 ("volume" "Volume of the book in the series") 375 nil
376 ("number" "Number of the book in a small series (overwritten by volume)") 376 (("author")
377 ("series" "Series in which the book appeared") 377 ("howpublished" "The way in which the booklet was published")
378 ("type" "Word to use instead of \"chapter\"") 378 ("address") ("month") ("year") ("note")))
379 ("chapter" "Chapter in the book") 379 ("PhdThesis" "PhD. Thesis"
380 ("address" "Address of the publisher") 380 (("author")
381 ("edition" "Edition of the book as a capitalized English word") 381 ("title" "Title of the PhD. thesis")
382 ("month" "Month of the publication as a string (remove braces)") 382 ("school" "School where the PhD. thesis was written")
383 ("note" "Remarks to be put at the end of the \\bibitem")))) 383 ("year"))
384 ("InProceedings" 384 nil
385 ((("author" "Author1 [and Author2 ...] [and others]") 385 (("type" "Type of the PhD. thesis")
386 ("title" "Title of the article in proceedings (BibTeX converts it to lowercase)") 386 ("address" "Address of the school (if not part of field \"school\") or country")
387 ("booktitle" "Name of the conference proceedings") 387 ("month") ("note")))
388 ("year" "Year of publication")) 388 ("MastersThesis" "Master's Thesis"
389 (("editor" "Editor1 [and Editor2 ...] [and others]") 389 (("author")
390 ("volume" "Volume of the conference proceedings in the series") 390 ("title" "Title of the master's thesis (BibTeX converts it to lowercase)")
391 ("number" "Number of the conference proceedings in a small series (overwritten by volume)") 391 ("school" "School where the master's thesis was written")
392 ("series" "Series in which the conference proceedings appeared") 392 ("year"))
393 ("pages" "Pages in the conference proceedings") 393 nil
394 ("address" "Location of the Proceedings") 394 (("type" "Type of the master's thesis (if other than \"Master's thesis\")")
395 ("month" "Month of the publication as a string (remove braces)") 395 ("address" "Address of the school (if not part of field \"school\") or country")
396 ("organization" "Sponsoring organization of the conference") 396 ("month") ("note")))
397 ("publisher" "Publishing company, its location") 397 ("TechReport" "Technical Report"
398 ("note" "Remarks to be put at the end of the \\bibitem"))) 398 (("author")
399 ((("author" "Author1 [and Author2 ...] [and others]") 399 ("title" "Title of the technical report (BibTeX converts it to lowercase)")
400 ("title" "Title of the article in proceedings (BibTeX converts it to lowercase)")) 400 ("institution" "Sponsoring institution of the report")
401 (("booktitle" "Name of the conference proceedings") 401 ("year"))
402 ("pages" "Pages in the conference proceedings") 402 nil
403 ("year" "Year of publication") 403 (("type" "Type of the report (if other than \"technical report\")")
404 ("editor" "Editor1 [and Editor2 ...] [and others]") 404 ("number" "Number of the technical report")
405 ("volume" "Volume of the conference proceedings in the series") 405 ("address") ("month") ("note")))
406 ("number" "Number of the conference proceedings in a small series (overwritten by volume)") 406 ("Manual" "Technical Manual"
407 ("series" "Series in which the conference proceedings appeared") 407 (("title" "Title of the manual"))
408 ("address" "Location of the Proceedings") 408 nil
409 ("month" "Month of the publication as a string (remove braces)") 409 (("author")
410 ("organization" "Sponsoring organization of the conference") 410 ("organization" "Publishing organization of the manual")
411 ("publisher" "Publishing company, its location") 411 ("address")
412 ("note" "Remarks to be put at the end of the \\bibitem")))) 412 ("edition" "Edition of the manual as a capitalized English word")
413 ("Manual" 413 ("month") ("year") ("note")))
414 ((("title" "Title of the manual")) 414 ("Unpublished" "Unpublished"
415 (("author" "Author1 [and Author2 ...] [and others]") 415 (("author")
416 ("organization" "Publishing organization of the manual") 416 ("title" "Title of the unpublished work (BibTeX converts it to lowercase)")
417 ("address" "Address of the organization") 417 ("note"))
418 ("edition" "Edition of the manual as a capitalized English word") 418 nil
419 ("month" "Month of the publication as a string (remove braces)") 419 (("month") ("year")))
420 ("year" "Year of publication") 420 ("Misc" "Miscellaneous" nil nil
421 ("note" "Remarks to be put at the end of the \\bibitem")))) 421 (("author")
422 ("MastersThesis" 422 ("title" "Title of the work (BibTeX converts it to lowercase)")
423 ((("author" "Author1 [and Author2 ...] [and others]") 423 ("howpublished" "The way in which the work was published")
424 ("title" "Title of the master\'s thesis (BibTeX converts it to lowercase)") 424 ("month") ("year") ("note"))))
425 ("school" "School where the master\'s thesis was written") 425 "Alist of BibTeX entry types and their associated fields.
426 ("year" "Year of publication")) 426Elements are lists (ENTRY-TYPE DOC REQUIRED CROSSREF OPTIONAL).
427 (("type" "Type of the master\'s thesis (if other than \"Master\'s thesis\")") 427ENTRY-TYPE is the type of a BibTeX entry.
428 ("address" "Address of the school (if not part of field \"school\") or country") 428DOC is a brief doc string used for menus. If nil ENTRY-TYPE is used.
429 ("month" "Month of the publication as a string (remove braces)") 429REQUIRED is a list of required fields.
430 ("note" "Remarks to be put at the end of the \\bibitem")))) 430CROSSREF is a list of fields that are optional if a crossref field
431 ("Misc" 431is present; but these fields are required otherwise.
432 (() 432OPTIONAL is a list of optional fields.
433 (("author" "Author1 [and Author2 ...] [and others]") 433
434 ("title" "Title of the work (BibTeX converts it to lowercase)")
435 ("howpublished" "The way in which the work was published")
436 ("month" "Month of the publication as a string (remove braces)")
437 ("year" "Year of publication")
438 ("note" "Remarks to be put at the end of the \\bibitem"))))
439 ("PhdThesis"
440 ((("author" "Author1 [and Author2 ...] [and others]")
441 ("title" "Title of the PhD. thesis")
442 ("school" "School where the PhD. thesis was written")
443 ("year" "Year of publication"))
444 (("type" "Type of the PhD. thesis")
445 ("address" "Address of the school (if not part of field \"school\") or country")
446 ("month" "Month of the publication as a string (remove braces)")
447 ("note" "Remarks to be put at the end of the \\bibitem"))))
448 ("Proceedings"
449 ((("title" "Title of the conference proceedings")
450 ("year" "Year of publication"))
451 (("booktitle" "Title of the proceedings for cross references")
452 ("editor" "Editor1 [and Editor2 ...] [and others]")
453 ("volume" "Volume of the conference proceedings in the series")
454 ("number" "Number of the conference proceedings in a small series (overwritten by volume)")
455 ("series" "Series in which the conference proceedings appeared")
456 ("address" "Location of the Proceedings")
457 ("month" "Month of the publication as a string (remove braces)")
458 ("organization" "Sponsoring organization of the conference")
459 ("publisher" "Publishing company, its location")
460 ("note" "Remarks to be put at the end of the \\bibitem"))))
461 ("TechReport"
462 ((("author" "Author1 [and Author2 ...] [and others]")
463 ("title" "Title of the technical report (BibTeX converts it to lowercase)")
464 ("institution" "Sponsoring institution of the report")
465 ("year" "Year of publication"))
466 (("type" "Type of the report (if other than \"technical report\")")
467 ("number" "Number of the technical report")
468 ("address" "Address of the institution (if not part of field \"institution\") or country")
469 ("month" "Month of the publication as a string (remove braces)")
470 ("note" "Remarks to be put at the end of the \\bibitem"))))
471 ("Unpublished"
472 ((("author" "Author1 [and Author2 ...] [and others]")
473 ("title" "Title of the unpublished work (BibTeX converts it to lowercase)")
474 ("note" "Remarks to be put at the end of the \\bibitem"))
475 (("month" "Month of the publication as a string (remove braces)")
476 ("year" "Year of publication")))))
477
478 "List of BibTeX entry types and their associated fields.
479List elements are triples
480\(ENTRY-TYPE (REQUIRED OPTIONAL) (CROSSREF-REQUIRED CROSSREF-OPTIONAL)).
481ENTRY-TYPE is the type of a BibTeX entry. The remaining pairs contain
482the required and optional fields of the BibTeX entry.
483The second pair is used if a crossref field is present
484and the first pair is used if a crossref field is absent.
485If the second pair is nil, the first pair is always used.
486REQUIRED, OPTIONAL, CROSSREF-REQUIRED and CROSSREF-OPTIONAL are lists.
487Each element of these lists is a list of the form 434Each element of these lists is a list of the form
488\(FIELD-NAME COMMENT-STRING INIT ALTERNATIVE-FLAG). 435 \(FIELD COMMENT INIT ALTERNATIVE).
489COMMENT-STRING, INIT, and ALTERNATIVE-FLAG are optional. 436COMMENT, INIT, and ALTERNATIVE are optional.
490FIELD-NAME is the name of the field, COMMENT-STRING is the comment that 437
491appears in the echo area, INIT is either the initial content of the 438FIELD is the name of the field.
492field or a function, which is called to determine the initial content 439COMMENT is the comment string that appears in the echo area.
493of the field, and ALTERNATIVE-FLAG (either nil or t) marks if the 440If COMMENT is nil use `bibtex-BibTeX-field-alist' if possible.
494field is an alternative. ALTERNATIVE-FLAG may be t only in the 441INIT is either the initial content of the field or a function,
495REQUIRED or CROSSREF-REQUIRED lists." 442which is called to determine the initial content of the field.
443ALTERNATIVE if non-nil is an integer that numbers sets of
444alternatives, starting from zero."
445 :group 'BibTeX
446 :type 'bibtex-entry-alist)
447(put 'bibtex-BibTeX-entry-alist 'risky-local-variable t)
448
449(defcustom bibtex-biblatex-entry-alist
450 ;; Compare in biblatex documentation:
451 ;; Sec. 2.1.1 Regular types (required and optional fields)
452 ;; Appendix A Default Crossref setup
453 '(("Article" "Article in Journal"
454 (("author") ("title") ("journaltitle")
455 ("year" nil nil 0) ("date" nil nil 0))
456 nil
457 (("translator") ("annotator") ("commentator") ("subtitle") ("titleaddon")
458 ("editor") ("editora") ("editorb") ("editorc")
459 ("journalsubtitle") ("issuetitle") ("issuesubtitle")
460 ("language") ("origlanguage") ("series") ("volume") ("number") ("eid")
461 ("issue") ("month") ("pages") ("version") ("note") ("issn")
462 ("addendum") ("pubstate") ("doi") ("eprint") ("eprintclass")
463 ("eprinttype") ("url") ("urldate")))
464 ("Book" "Single-Volume Book"
465 (("author") ("title") ("year" nil nil 0) ("date" nil nil 0))
466 nil
467 (("editor") ("editora") ("editorb") ("editorc")
468 ("translator") ("annotator") ("commentator")
469 ("introduction") ("foreword") ("afterword") ("titleaddon")
470 ("maintitle") ("mainsubtitle") ("maintitleaddon")
471 ("language") ("origlanguage") ("volume") ("part") ("edition") ("volumes")
472 ("series") ("number") ("note") ("publisher") ("location") ("isbn")
473 ("chapter") ("pages") ("pagetotal") ("addendum") ("pubstate") ("doi")
474 ("eprint") ("eprintclass") ("eprinttype") ("url") ("urldate")))
475 ("MVBook" "Multi-Volume Book"
476 (("author") ("title") ("year" nil nil 0) ("date" nil nil 0))
477 nil
478 (("editor") ("editora") ("editorb") ("editorc")
479 ("translator") ("annotator") ("commentator")
480 ("introduction") ("foreword") ("afterword") ("subtitle")
481 ("titleaddon") ("language") ("origlanguage") ("edition") ("volumes")
482 ("series") ("number") ("note") ("publisher")
483 ("location") ("isbn") ("pagetotal") ("addendum") ("pubstate") ("doi")
484 ("eprint") ("eprintclass") ("eprinttype") ("url") ("urldate")))
485 ("InBook" "Chapter or Pages in a Book"
486 (("title") ("year" nil nil 0) ("date" nil nil 0))
487 (("author") ("booktitle"))
488 (("bookauthor") ("editor") ("editora") ("editorb") ("editorc")
489 ("translator") ("annotator") ("commentator") ("introduction") ("foreword")
490 ("afterword") ("subtitle") ("titleaddon") ("maintitle") ("mainsubtitle")
491 ("maintitleaddon") ("booksubtitle") ("booktitleaddon")
492 ("language") ("origlanguage") ("volume") ("part") ("edition") ("volumes")
493 ("series") ("number") ("note") ("publisher") ("location") ("isbn")
494 ("chapter") ("pages") ("addendum") ("pubstate")
495 ("doi") ("eprint") ("eprintclass") ("eprinttype") ("url") ("urldate")))
496 ("BookInBook" "Book in Collection" ; same as @inbook
497 (("title") ("year" nil nil 0) ("date" nil nil 0))
498 (("author") ("booktitle"))
499 (("bookauthor") ("editor") ("editora") ("editorb") ("editorc")
500 ("translator") ("annotator") ("commentator") ("introduction") ("foreword")
501 ("afterword") ("subtitle") ("titleaddon") ("maintitle") ("mainsubtitle")
502 ("maintitleaddon") ("booksubtitle") ("booktitleaddon")
503 ("language") ("origlanguage") ("volume") ("part") ("edition") ("volumes")
504 ("series") ("number") ("note") ("publisher") ("location") ("isbn")
505 ("chapter") ("pages") ("addendum") ("pubstate")
506 ("doi") ("eprint") ("eprintclass") ("eprinttype") ("url") ("urldate")))
507 ("SuppBook" "Supplemental Material in a Book" ; same as @inbook
508 (("title") ("year" nil nil 0) ("date" nil nil 0))
509 (("author") ("booktitle"))
510 (("bookauthor") ("editor") ("editora") ("editorb") ("editorc")
511 ("translator") ("annotator") ("commentator") ("introduction") ("foreword")
512 ("afterword") ("subtitle") ("titleaddon") ("maintitle") ("mainsubtitle")
513 ("maintitleaddon") ("booksubtitle") ("booktitleaddon")
514 ("language") ("origlanguage") ("volume") ("part") ("edition") ("volumes")
515 ("series") ("number") ("note") ("publisher") ("location") ("isbn")
516 ("chapter") ("pages") ("addendum") ("pubstate")
517 ("doi") ("eprint") ("eprintclass") ("eprinttype") ("url") ("urldate")))
518 ("Booklet" "Booklet (Bound, but no Publisher)"
519 (("author" nil nil 0) ("editor" nil nil 0) ("title")
520 ("year" nil nil 1) ("date" nil nil 1))
521 nil
522 (("subtitle") ("titleaddon") ("language") ("howpublished") ("type")
523 ("note") ("location") ("chapter") ("pages") ("pagetotal") ("addendum")
524 ("pubstate") ("doi") ("eprint") ("eprintclass") ("eprinttype")
525 ("url") ("urldate")))
526 ("Collection" "Single-Volume Collection"
527 (("editor") ("title") ("year" nil nil 0) ("date" nil nil 0))
528 nil
529 (("editora") ("editorb") ("editorc") ("translator") ("annotator")
530 ("commentator") ("introduction") ("foreword") ("afterword")
531 ("subtitle") ("titleaddon") ("maintitle") ("mainsubtitle")
532 ("maintitleaddon") ("language") ("origlanguage") ("volume")
533 ("part") ("edition") ("volumes") ("series") ("number") ("note")
534 ("publisher") ("location") ("isbn") ("chapter") ("pages") ("pagetotal")
535 ("addendum") ("pubstate") ("doi") ("eprint") ("eprintclass")
536 ("eprinttype") ("url") ("urldate")))
537 ("MVCollection" "Multi-Volume Collection"
538 (("editor") ("title") ("year" nil nil 0) ("date" nil nil 0))
539 nil
540 (("editora") ("editorb") ("editorc") ("translator") ("annotator")
541 ("commentator") ("introduction") ("foreword") ("afterword")
542 ("subtitle") ("titleaddon") ("language") ("origlanguage") ("edition")
543 ("volumes") ("series") ("number") ("note") ("publisher")
544 ("location") ("isbn") ("pagetotal") ("addendum") ("pubstate") ("doi")
545 ("eprint") ("eprintclass") ("eprinttype") ("url") ("urldate")))
546 ("InCollection" "Article in a Collection"
547 (("author") ("editor") ("title") ("year" nil nil 0) ("date" nil nil 0))
548 (("booktitle"))
549 (("editora") ("editorb") ("editorc") ("translator") ("annotator")
550 ("commentator") ("introduction") ("foreword") ("afterword")
551 ("subtitle") ("titleaddon") ("maintitle") ("mainsubtitle")
552 ("maintitleaddon") ("booksubtitle") ("booktitleaddon")
553 ("language") ("origlanguage") ("volume") ("part") ("edition")
554 ("volumes") ("series") ("number") ("note") ("publisher") ("location")
555 ("isbn") ("chapter") ("pages") ("addendum") ("pubstate") ("doi")
556 ("eprint") ("eprintclass") ("eprinttype") ("url") ("urldate")))
557 ("SuppCollection" "Supplemental Material in a Collection" ; same as @incollection
558 (("author") ("editor") ("title") ("year" nil nil 0) ("date" nil nil 0))
559 (("booktitle"))
560 (("editora") ("editorb") ("editorc") ("translator") ("annotator")
561 ("commentator") ("introduction") ("foreword") ("afterword")
562 ("subtitle") ("titleaddon") ("maintitle") ("mainsubtitle")
563 ("maintitleaddon") ("booksubtitle") ("booktitleaddon")
564 ("language") ("origlanguage") ("volume") ("part") ("edition")
565 ("volumes") ("series") ("number") ("note") ("publisher") ("location")
566 ("isbn") ("chapter") ("pages") ("addendum") ("pubstate") ("doi")
567 ("eprint") ("eprintclass") ("eprinttype") ("url") ("urldate")))
568 ("Manual" "Technical Manual"
569 (("author" nil nil 0) ("editor" nil nil 0) ("title")
570 ("year" nil nil 1) ("date" nil nil 1))
571 nil
572 (("subtitle") ("titleaddon") ("language") ("edition")
573 ("type") ("series") ("number") ("version") ("note")
574 ("organization") ("publisher") ("location") ("isbn") ("chapter")
575 ("pages") ("pagetotal") ("addendum") ("pubstate")
576 ("doi") ("eprint") ("eprintclass") ("eprinttype") ("url") ("urldate")))
577 ("Misc" "Miscellaneous"
578 (("author" nil nil 0) ("editor" nil nil 0) ("title")
579 ("year" nil nil 1) ("date" nil nil 1))
580 nil
581 (("subtitle") ("titleaddon") ("language") ("howpublished") ("type")
582 ("version") ("note") ("organization") ("location")
583 ("date") ("month") ("year") ("addendum") ("pubstate")
584 ("doi") ("eprint") ("eprintclass") ("eprinttype") ("url") ("urldate")))
585 ("Online" "Online Resource"
586 (("author" nil nil 0) ("editor" nil nil 0) ("title")
587 ("year" nil nil 1) ("date" nil nil 1) ("url"))
588 nil
589 (("subtitle") ("titleaddon") ("language") ("version") ("note")
590 ("organization") ("date") ("month") ("year") ("addendum")
591 ("pubstate") ("urldate")))
592 ("Patent" "Patent"
593 (("author") ("title") ("number") ("year" nil nil 0) ("date" nil nil 0))
594 nil
595 (("holder") ("subtitle") ("titleaddon") ("type") ("version") ("location")
596 ("note") ("date") ("month") ("year") ("addendum") ("pubstate")
597 ("doi") ("eprint") ("eprintclass") ("eprinttype") ("url") ("urldate")))
598 ("Periodical" "Complete Issue of a Periodical"
599 (("editor") ("title") ("year" nil nil 0) ("date" nil nil 0))
600 nil
601 (("editora") ("editorb") ("editorc") ("subtitle") ("issuetitle")
602 ("issuesubtitle") ("language") ("series") ("volume") ("number") ("issue")
603 ("date") ("month") ("year") ("note") ("issn") ("addendum") ("pubstate")
604 ("doi") ("eprint") ("eprintclass") ("eprinttype") ("url") ("urldate")))
605 ("SuppPeriodical" "Supplemental Material in a Periodical" ; same as @article
606 (("author") ("title") ("journaltitle")
607 ("year" nil nil 0) ("date" nil nil 0))
608 nil
609 (("translator") ("annotator") ("commentator") ("subtitle") ("titleaddon")
610 ("editor") ("editora") ("editorb") ("editorc")
611 ("journalsubtitle") ("issuetitle") ("issuesubtitle")
612 ("language") ("origlanguage") ("series") ("volume") ("number") ("eid")
613 ("issue") ("month") ("pages") ("version") ("note") ("issn")
614 ("addendum") ("pubstate") ("doi") ("eprint") ("eprintclass")
615 ("eprinttype") ("url") ("urldate")))
616 ("Proceedings" "Single-Volume Conference Proceedings"
617 (("editor") ("title") ("year" nil nil 0) ("date" nil nil 0))
618 nil
619 (("subtitle") ("titleaddon") ("maintitle") ("mainsubtitle")
620 ("maintitleaddon") ("eventtitle") ("eventdate") ("venue") ("language")
621 ("volume") ("part") ("volumes") ("series") ("number") ("note")
622 ("organization") ("publisher") ("location") ("month")
623 ("isbn") ("chapter") ("pages") ("pagetotal") ("addendum") ("pubstate")
624 ("doi") ("eprint") ("eprintclass") ("eprinttype") ("url") ("urldate")))
625 ("MVProceedings" "Multi-Volume Conference Proceedings"
626 (("editor") ("title") ("year" nil nil 0) ("date" nil nil 0))
627 nil
628 (("subtitle") ("titleaddon") ("eventtitle") ("eventdate") ("venue")
629 ("language") ("volumes") ("series") ("number") ("note")
630 ("organization") ("publisher") ("location") ("month")
631 ("isbn") ("pagetotal") ("addendum") ("pubstate")
632 ("doi") ("eprint") ("eprintclass") ("eprinttype") ("url") ("urldate")))
633 ("InProceedings" "Article in Conference Proceedings"
634 (("author") ("editor") ("title") ("year" nil nil 0) ("date" nil nil 0))
635 (("booktitle"))
636 (("subtitle") ("titleaddon") ("maintitle") ("mainsubtitle")
637 ("maintitleaddon") ("booksubtitle") ("booktitleaddon")
638 ("eventtitle") ("eventdate") ("venue") ("language")
639 ("volume") ("part") ("volumes") ("series") ("number") ("note")
640 ("organization") ("publisher") ("location") ("month") ("isbn")
641 ("chapter") ("pages") ("addendum") ("pubstate")
642 ("doi") ("eprint") ("eprintclass") ("eprinttype") ("url") ("urldate")))
643 ("Reference" "Single-Volume Work of Reference" ; same as @collection
644 (("editor") ("title") ("year" nil nil 0) ("date" nil nil 0))
645 nil
646 (("editora") ("editorb") ("editorc") ("translator") ("annotator")
647 ("commentator") ("introduction") ("foreword") ("afterword")
648 ("subtitle") ("titleaddon") ("maintitle") ("mainsubtitle")
649 ("maintitleaddon") ("language") ("origlanguage") ("volume")
650 ("part") ("edition") ("volumes") ("series") ("number") ("note")
651 ("publisher") ("location") ("isbn") ("chapter") ("pages") ("pagetotal")
652 ("addendum") ("pubstate") ("doi") ("eprint") ("eprintclass")
653 ("eprinttype") ("url") ("urldate")))
654 ("MVReference" "Multi-Volume Work of Reference" ; same as @mvcollection
655 (("editor") ("title") ("year" nil nil 0) ("date" nil nil 0))
656 nil
657 (("editora") ("editorb") ("editorc") ("translator") ("annotator")
658 ("commentator") ("introduction") ("foreword") ("afterword")
659 ("subtitle") ("titleaddon") ("language") ("origlanguage") ("edition")
660 ("volumes") ("series") ("number") ("note") ("publisher")
661 ("location") ("isbn") ("pagetotal") ("addendum") ("pubstate") ("doi")
662 ("eprint") ("eprintclass") ("eprinttype") ("url") ("urldate")))
663 ("InReference" "Article in a Work of Reference" ; same as @incollection
664 (("author") ("editor") ("title") ("year" nil nil 0) ("date" nil nil 0))
665 (("booktitle"))
666 (("editora") ("editorb") ("editorc") ("translator") ("annotator")
667 ("commentator") ("introduction") ("foreword") ("afterword")
668 ("subtitle") ("titleaddon") ("maintitle") ("mainsubtitle")
669 ("maintitleaddon") ("booksubtitle") ("booktitleaddon")
670 ("language") ("origlanguage") ("volume") ("part") ("edition")
671 ("volumes") ("series") ("number") ("note") ("publisher") ("location")
672 ("isbn") ("chapter") ("pages") ("addendum") ("pubstate") ("doi")
673 ("eprint") ("eprintclass") ("eprinttype") ("url") ("urldate")))
674 ("Report" "Technical or Research Report"
675 (("author") ("title") ("type") ("institution")
676 ("year" nil nil 0) ("date" nil nil 0))
677 nil
678 (("subtitle") ("titleaddon") ("language") ("number") ("version") ("note")
679 ("location") ("month") ("isrn") ("chapter") ("pages") ("pagetotal")
680 ("addendum") ("pubstate")
681 ("doi") ("eprint") ("eprintclass") ("eprinttype") ("url") ("urldate")))
682 ("Thesis" "PhD. or Master's Thesis"
683 (("author") ("title") ("type") ("institution")
684 ("year" nil nil 0) ("date" nil nil 0))
685 nil
686 (("subtitle") ("titleaddon") ("language") ("note") ("location")
687 ("month") ("isbn") ("chapter") ("pages") ("pagetotal")
688 ("addendum") ("pubstate")
689 ("doi") ("eprint") ("eprintclass") ("eprinttype") ("url") ("urldate")))
690 ("Unpublished" "Unpublished"
691 (("author") ("title") ("year" nil nil 0) ("date" nil nil 0))
692 nil
693 (("subtitle") ("titleaddon") ("language") ("howpublished")
694 ("note") ("location") ("isbn") ("date") ("month") ("year")
695 ("addendum") ("pubstate") ("url") ("urldate"))))
696 "Alist of biblatex entry types and their associated fields.
697It has the same format as `bibtex-BibTeX-entry-alist'."
496 :group 'bibtex 698 :group 'bibtex
497 :type '(repeat (group (string :tag "Entry type") 699 :type 'bibtex-entry-alist)
498 (group (repeat :tag "Required fields" 700(put 'bibtex-biblatex-entry-alist 'risky-local-variable t)
499 (group (string :tag "Field") 701
500 (string :tag "Comment") 702(define-widget 'bibtex-field-alist 'lazy
501 (option (choice :tag "Init" :value nil 703 "Format of `bibtex-BibTeX-entry-alist' and friends."
502 (const nil) string function)) 704 :type '(repeat (group (string :tag "Field type")
503 (option (choice :tag "Alternative" 705 (string :tag "Comment"))))
504 (const :tag "No" nil) 706
505 (const :tag "Yes" t))))) 707(defcustom bibtex-BibTeX-field-alist
506 (repeat :tag "Optional fields" 708 '(("author" "Author1 [and Author2 ...] [and others]")
507 (group (string :tag "Field") 709 ("editor" "Editor1 [and Editor2 ...] [and others]")
508 (string :tag "Comment") 710 ("journal" "Name of the journal (use string, remove braces)")
509 (option (choice :tag "Init" :value nil 711 ("year" "Year of publication")
510 (const nil) string function))))) 712 ("month" "Month of the publication as a string (remove braces)")
511 (option :extra-offset -4 713 ("note" "Remarks to be put at the end of the \\bibitem")
512 (group (repeat :tag "Crossref: required fields" 714 ("publisher" "Publishing company")
513 (group (string :tag "Field") 715 ("address" "Address of the publisher"))
514 (string :tag "Comment") 716 "Alist of BibTeX fields.
515 (option (choice :tag "Init" :value nil 717Each element is a list (FIELD COMMENT). COMMENT is used as a default
516 (const nil) string function)) 718if `bibtex-BibTeX-entry-alist' does not define a comment for FIELD."
517 (option (choice :tag "Alternative" 719 :group 'bibtex
518 (const :tag "No" nil) 720 :type 'bibtex-field-alist)
519 (const :tag "Yes" t))))) 721
520 (repeat :tag "Crossref: optional fields" 722(defcustom bibtex-biblatex-field-alist
521 (group (string :tag "Field") 723 ;; See 2.2.2 Data Fields
522 (string :tag "Comment") 724 '(("abstract" "Abstract of the work")
523 (option (choice :tag "Init" :value nil 725 ("addendum" "Miscellaneous bibliographic data")
524 (const nil) string function))))))))) 726 ("afterword" "Author(s) of an afterword to the work")
525(put 'bibtex-entry-field-alist 'risky-local-variable t) 727 ("annotation" "Annotation")
728 ("annotator" "Author(s) of annotations to the work")
729 ("author" "Author(s) of the title")
730 ("bookauthor" "Author(s) of the booktitle.")
731 ("bookpagination" "Pagination scheme of the enclosing work")
732 ("booksubtitle" "Subtitle related to the booktitle")
733 ("booktitle" "Title of the book")
734 ("booktitleaddon" "Annex to the booktitle")
735 ("chapter" "Chapter, section, or any other unit of a work")
736 ("commentator" "Author(s) of a commentary to the work")
737 ("date" "Publication date")
738 ("doi" "Digital Object Identifier")
739 ("edition" "Edition of a printed publication")
740 ("editor" "Editor(s) of the title, booktitle, or maintitle")
741 ("editora" "Secondary editor")
742 ("editorb" "Secondary editor")
743 ("editorc" "Secondary editor")
744 ("editortype" "Type of editorial role performed by the editor")
745 ("editoratype" "Type of editorial role performed by editora")
746 ("editorbtype" "Type of editorial role performed by editorb")
747 ("editorctype" "Type of editorial role performed by editorc")
748 ("eid" "Electronic identifier of an article")
749 ("eprint" "Electronic identifier of an online publication")
750 ("eprintclass" "Additional information related to the eprinttype")
751 ("eprinttype" "Type of eprint identifier")
752 ("eventdate" "Date of a conference or some other event")
753 ("eventtitle" "Title of a conference or some other event")
754 ("file" "Local link to an electronic version of the work")
755 ("foreword" "Author(s) of a foreword to the work")
756 ("holder" "Holder(s) of a patent")
757 ("howpublished" "Publication notice for unusual publications")
758 ("indextitle" "Title to use for indexing instead of the regular title")
759 ("institution" "Name of a university or some other institution")
760 ("introduction" "Author(s) of an introduction to the work")
761 ("isan" "International Standard Audiovisual Number of an audiovisual work")
762 ("isbn" "International Standard Book Number of a book.")
763 ("ismn" "International Standard Music Number for printed music")
764 ("isrn" "International Standard Technical Report Number")
765 ("issn" "International Standard Serial Number of a periodical.")
766 ("issue" "Issue of a journal")
767 ("issuesubtitle" "Subtitle of a specific issue of a journal or other periodical.")
768 ("issuetitle" "Title of a specific issue of a journal or other periodical.")
769 ("iswc" "International Standard Work Code of a musical work")
770 ("journalsubtitle" "Subtitle of a journal, a newspaper, or some other periodical.")
771 ("journaltitle" "Name of a journal, a newspaper, or some other periodical.")
772 ("label" "Substitute for the regular label to be used by the citation style")
773 ("language" "Language(s) of the work")
774 ("library" "Library name and a call number")
775 ("location" "Place(s) of publication")
776 ("mainsubtitle" "Subtitle related to the maintitle")
777 ("maintitle" "Main title of a multi-volume book, such as Collected Works")
778 ("maintitleaddon" "Annex to the maintitle")
779 ("month" "Publication month")
780 ("nameaddon" "Addon to be printed immediately after the author name")
781 ("note" "Miscellaneous bibliographic data")
782 ("number" "Number of a journal or the volume/number of a book in a series")
783 ("organization" "Organization(s) that published a work")
784 ("origdate" "Publication date of the original edition")
785 ("origlanguage" "Original publication language of a translated edition")
786 ("origlocation" "Location of the original edition")
787 ("origpublisher" "Publisher of the original edition")
788 ("origtitle" "Title of the original work")
789 ("pages" "Page number(s) or page range(s)")
790 ("pagetotal" "Total number of pages of the work.")
791 ("pagination" "Pagination of the work")
792 ("part" "Number of a partial volume")
793 ("publisher" "Name(s) of the publisher(s)")
794 ("pubstate" "Publication state of the work, e. g.,'in press'")
795 ("reprinttitle" "Title of a reprint of the work")
796 ("series" "Name of a publication series")
797 ("shortauthor" "Author(s) of the work, given in an abbreviated form")
798 ("shorteditor" "Editor(s) of the work, given in an abbreviated form")
799 ("shortjournal" "Short version or an acronym of the journal title")
800 ("shortseries" "Short version or an acronym of the series field")
801 ("shorttitle" "Title in an abridged form")
802 ("subtitle" "Subtitle of the work")
803 ("title" "Title of the work")
804 ("titleaddon" "Annex to the title")
805 ("translator" "Translator(s) of the work")
806 ("type" "Type of a manual, patent, report, or thesis")
807 ("url" " URL of an online publication.")
808 ("urldate" "Access date of the address specified in the url field")
809 ("venue" "Location of a conference, a symposium, or some other event")
810 ("version" "Revision number of a piece of software, a manual, etc.")
811 ("volume" "Volume of a multi-volume book or a periodical")
812 ("volumes" "Total number of volumes of a multi-volume work")
813 ("year" "Year of publication"))
814 "Alist of biblatex fields.
815It has the same format as `bibtex-BibTeX-entry-alist'."
816 :group 'bibtex
817 :type 'bibtex-field-alist)
818
819(defcustom bibtex-dialect-list '(BibTeX biblatex)
820 "List of BibTeX dialects known to BibTeX mode.
821For each DIALECT (a symbol) a variable bibtex-DIALECT-entry-alist defines
822the allowed entries and bibtex-DIALECT-field-alist defines known field types.
823Predefined dialects include BibTeX and biblatex."
824 :group 'bibtex
825 :type '(repeat (symbol :tag "Dialect")))
826
827(defcustom bibtex-dialect 'BibTeX
828 "Current BibTeX dialect. For allowed values see `bibtex-dialect-list'.
829During a session change it via `bibtex-set-dialect'."
830 :group 'bibtex
831 :set '(lambda (symbol value)
832 (set-default symbol value)
833 ;; `bibtex-set-dialect' is undefined during loading (no problem)
834 (if (fboundp 'bibtex-set-dialect)
835 (bibtex-set-dialect value)))
836 :type '(choice (const BibTeX)
837 (const biblatex)
838 (symbol :tag "Custom")))
839
840(defcustom bibtex-no-opt-remove-re "\\`option"
841 "If a field name matches this regexp, the prefix OPT is not removed.
842If nil prefix OPT is always removed"
843 :group 'bibtex
844 :type '(choice (regexp) (const nil)))
526 845
527(defcustom bibtex-comment-start "@Comment" 846(defcustom bibtex-comment-start "@Comment"
528 "String starting a BibTeX comment." 847 "String starting a BibTeX comment."
@@ -1120,29 +1439,15 @@ Set this variable before loading BibTeX mode."
1120 ["(Re)Initialize BibTeX Buffers" bibtex-initialize t] 1439 ["(Re)Initialize BibTeX Buffers" bibtex-initialize t]
1121 ["Validate Entries" bibtex-validate-globally t]))) 1440 ["Validate Entries" bibtex-validate-globally t])))
1122 1441
1123(easy-menu-define
1124 bibtex-entry-menu bibtex-mode-map "Entry-Types Menu in BibTeX mode"
1125 (list "Entry-Types"
1126 ["Article in Journal" bibtex-Article t]
1127 ["Article in Conference Proceedings" bibtex-InProceedings t]
1128 ["Article in a Collection" bibtex-InCollection t]
1129 ["Chapter or Pages in a Book" bibtex-InBook t]
1130 ["Conference Proceedings" bibtex-Proceedings t]
1131 ["Book" bibtex-Book t]
1132 ["Booklet (Bound, but no Publisher/Institution)" bibtex-Booklet t]
1133 ["PhD. Thesis" bibtex-PhdThesis t]
1134 ["Master's Thesis" bibtex-MastersThesis t]
1135 ["Technical Report" bibtex-TechReport t]
1136 ["Technical Manual" bibtex-Manual t]
1137 ["Unpublished" bibtex-Unpublished t]
1138 ["Miscellaneous" bibtex-Misc t]
1139 "--"
1140 ["String" bibtex-String t]
1141 ["Preamble" bibtex-Preamble t]))
1142
1143 1442
1144;; Internal Variables 1443;; Internal Variables
1145 1444
1445(defvar bibtex-entry-alist bibtex-BibTeX-entry-alist
1446 "Alist of currently active entry types.")
1447
1448(defvar bibtex-field-alist bibtex-BibTeX-field-alist
1449 "Alist of currently active field types.")
1450
1146(defvar bibtex-field-braces-opt nil 1451(defvar bibtex-field-braces-opt nil
1147 "Optimized value of `bibtex-field-braces-alist'. 1452 "Optimized value of `bibtex-field-braces-alist'.
1148Created by `bibtex-field-re-init'. 1453Created by `bibtex-field-re-init'.
@@ -1237,33 +1542,26 @@ The CDRs of the elements are t for header keys and nil for crossref keys.")
1237(defconst bibtex-field-const "[][[:alnum:].:;?!`'/*@+=|<>&_^$-]+" 1542(defconst bibtex-field-const "[][[:alnum:].:;?!`'/*@+=|<>&_^$-]+"
1238 "Regexp matching a BibTeX field constant.") 1543 "Regexp matching a BibTeX field constant.")
1239 1544
1240(defvar bibtex-entry-type 1545(defvar bibtex-entry-type nil
1241 (concat "@[ \t]*\\(?:" 1546 "Regexp matching the type of a BibTeX entry.
1242 (regexp-opt (mapcar 'car bibtex-entry-field-alist)) "\\)") 1547Initialized by `bibtex-set-dialect'.")
1243 "Regexp matching the type of a BibTeX entry.")
1244 1548
1245(defvar bibtex-entry-head 1549(defvar bibtex-entry-head nil
1246 (concat "^[ \t]*\\(" 1550 "Regexp matching the header line of a BibTeX entry (including key).
1247 bibtex-entry-type 1551Initialized by `bibtex-set-dialect'.")
1248 "\\)[ \t]*[({][ \t\n]*\\("
1249 bibtex-reference-key
1250 "\\)")
1251 "Regexp matching the header line of a BibTeX entry (including key).")
1252 1552
1253(defvar bibtex-entry-maybe-empty-head 1553(defvar bibtex-entry-maybe-empty-head nil
1254 (concat bibtex-entry-head "?") 1554 "Regexp matching the header line of a BibTeX entry (possibly without key).
1255 "Regexp matching the header line of a BibTeX entry (possibly without key).") 1555Initialized by `bibtex-set-dialect'.")
1256 1556
1257(defconst bibtex-any-entry-maybe-empty-head 1557(defconst bibtex-any-entry-maybe-empty-head
1258 (concat "^[ \t]*\\(@[ \t]*" bibtex-field-name "\\)[ \t]*[({][ \t\n]*\\(" 1558 (concat "^[ \t]*\\(@[ \t]*" bibtex-field-name "\\)[ \t]*[({][ \t\n]*\\("
1259 bibtex-reference-key "\\)?") 1559 bibtex-reference-key "\\)?")
1260 "Regexp matching the header line of any BibTeX entry (possibly without key).") 1560 "Regexp matching the header line of any BibTeX entry (possibly without key).")
1261 1561
1262(defvar bibtex-any-valid-entry-type 1562(defvar bibtex-any-valid-entry-type nil
1263 (concat "^[ \t]*@[ \t]*\\(?:" 1563 "Regexp matching any valid BibTeX entry (including String and Preamble).
1264 (regexp-opt (append '("String" "Preamble") 1564Initialized by `bibtex-set-dialect'.")
1265 (mapcar 'car bibtex-entry-field-alist))) "\\)")
1266 "Regexp matching any valid BibTeX entry (including String and Preamble).")
1267 1565
1268(defconst bibtex-type-in-head 1 1566(defconst bibtex-type-in-head 1
1269 "Regexp subexpression number of the type part in `bibtex-entry-head'.") 1567 "Regexp subexpression number of the type part in `bibtex-entry-head'.")
@@ -1520,7 +1818,9 @@ If optional arg REMOVE-OPT-ALT is non-nil remove \"OPT\" and \"ALT\"."
1520 (bibtex-start-of-name-in-field bounds) 1818 (bibtex-start-of-name-in-field bounds)
1521 (bibtex-end-of-name-in-field bounds)))) 1819 (bibtex-end-of-name-in-field bounds))))
1522 (if (and remove-opt-alt 1820 (if (and remove-opt-alt
1523 (string-match "\\`\\(OPT\\|ALT\\)" name)) 1821 (string-match "\\`\\(OPT\\|ALT\\)" name)
1822 (not (and bibtex-no-opt-remove-re
1823 (string-match bibtex-no-opt-remove-re name))))
1524 (substring name 3) 1824 (substring name 3)
1525 name))) 1825 name)))
1526 1826
@@ -1686,7 +1986,7 @@ Point must be at beginning of preamble. Do not move point."
1686(defun bibtex-valid-entry (&optional empty-key) 1986(defun bibtex-valid-entry (&optional empty-key)
1687 "Parse a valid BibTeX entry (maybe without key if EMPTY-KEY is t). 1987 "Parse a valid BibTeX entry (maybe without key if EMPTY-KEY is t).
1688A valid entry is a syntactical correct one with type contained in 1988A valid entry is a syntactical correct one with type contained in
1689`bibtex-entry-field-alist'. Ignore @String and @Preamble entries. 1989`bibtex-BibTeX-entry-alist'. Ignore @String and @Preamble entries.
1690Return a cons pair with buffer positions of beginning and end of entry 1990Return a cons pair with buffer positions of beginning and end of entry
1691if a valid entry is found, nil otherwise. Do not move point. 1991if a valid entry is found, nil otherwise. Do not move point.
1692After a call to this function `match-data' corresponds to the header 1992After a call to this function `match-data' corresponds to the header
@@ -1717,7 +2017,7 @@ of the entry, see regexp `bibtex-entry-head'."
1717Do not move if we are already at beginning of a valid BibTeX entry. 2017Do not move if we are already at beginning of a valid BibTeX entry.
1718With optional argument BACKWARD non-nil, move backward to 2018With optional argument BACKWARD non-nil, move backward to
1719beginning of previous valid one. A valid entry is a syntactical correct one 2019beginning of previous valid one. A valid entry is a syntactical correct one
1720with type contained in `bibtex-entry-field-alist' or, if 2020with type contained in `bibtex-BibTeX-entry-alist' or, if
1721`bibtex-sort-ignore-string-entries' is nil, a syntactical correct string 2021`bibtex-sort-ignore-string-entries' is nil, a syntactical correct string
1722entry. Return buffer position of beginning and end of entry if a valid 2022entry. Return buffer position of beginning and end of entry if a valid
1723entry is found, nil otherwise." 2023entry is found, nil otherwise."
@@ -1911,6 +2211,14 @@ Optional arg COMMA is as in `bibtex-enclosing-field'."
1911 (let ((key (bibtex-key-in-head))) 2211 (let ((key (bibtex-key-in-head)))
1912 (if key (push (cons key t) bibtex-reference-keys)))))))) 2212 (if key (push (cons key t) bibtex-reference-keys))))))))
1913 2213
2214(defsubst bibtex-vec-push (vec idx newelt)
2215 "Add NEWELT to the list stored in VEC at index IDX."
2216 (aset vec idx (cons newelt (aref vec idx))))
2217
2218(defsubst bibtex-vec-incr (vec idx)
2219 "Add NEWELT to the list stored in VEC at index IDX."
2220 (aset vec idx (1+ (aref vec idx))))
2221
1914(defun bibtex-format-entry () 2222(defun bibtex-format-entry ()
1915 "Helper function for `bibtex-clean-entry'. 2223 "Helper function for `bibtex-clean-entry'.
1916Formats current entry according to variable `bibtex-entry-format'." 2224Formats current entry according to variable `bibtex-entry-format'."
@@ -1932,7 +2240,7 @@ Formats current entry according to variable `bibtex-entry-format'."
1932 bibtex-entry-format)) 2240 bibtex-entry-format))
1933 (left-delim-re (regexp-quote (bibtex-field-left-delimiter))) 2241 (left-delim-re (regexp-quote (bibtex-field-left-delimiter)))
1934 bounds crossref-key req-field-list default-field-list field-list 2242 bounds crossref-key req-field-list default-field-list field-list
1935 alt-fields error-field-name) 2243 num-alt alt-fields idx error-field-name)
1936 (unwind-protect 2244 (unwind-protect
1937 ;; formatting (undone if error occurs) 2245 ;; formatting (undone if error occurs)
1938 (atomic-change-group 2246 (atomic-change-group
@@ -1954,7 +2262,7 @@ Formats current entry according to variable `bibtex-entry-format'."
1954 (end-type (match-end 0)) 2262 (end-type (match-end 0))
1955 (entry-list (assoc-string (buffer-substring-no-properties 2263 (entry-list (assoc-string (buffer-substring-no-properties
1956 beg-type end-type) 2264 beg-type end-type)
1957 bibtex-entry-field-alist t))) 2265 bibtex-entry-alist t)))
1958 2266
1959 ;; unify case of entry type 2267 ;; unify case of entry type
1960 (when (memq 'unify-case format) 2268 (when (memq 'unify-case format)
@@ -1978,13 +2286,18 @@ Formats current entry according to variable `bibtex-entry-format'."
1978 2286
1979 ;; list of required fields appropriate for an entry with 2287 ;; list of required fields appropriate for an entry with
1980 ;; or without crossref key. 2288 ;; or without crossref key.
1981 (setq req-field-list (if (and crossref-key (nth 2 entry-list)) 2289 (setq req-field-list (if crossref-key (nth 2 entry-list)
1982 (car (nth 2 entry-list)) 2290 (append (nth 2 entry-list) (nth 3 entry-list)))
1983 (car (nth 1 entry-list)))
1984 ;; default list of fields that may appear in this entry 2291 ;; default list of fields that may appear in this entry
1985 default-field-list (append (nth 0 (nth 1 entry-list)) 2292 default-field-list (append (nth 2 entry-list) (nth 3 entry-list)
1986 (nth 1 (nth 1 entry-list)) 2293 (nth 4 entry-list)
1987 bibtex-user-optional-fields)) 2294 bibtex-user-optional-fields)
2295 ;; number of ALT fields we expect to find
2296 num-alt (length (delq nil (delete-dups
2297 (mapcar (lambda (x) (nth 3 x))
2298 req-field-list))))
2299 ;; ALT fields of respective groups
2300 alt-fields (make-vector num-alt nil))
1988 2301
1989 (when (memq 'sort-fields format) 2302 (when (memq 'sort-fields format)
1990 (goto-char (point-min)) 2303 (goto-char (point-min))
@@ -1995,10 +2308,10 @@ Formats current entry according to variable `bibtex-entry-format'."
1995 (dolist (field default-field-list) 2308 (dolist (field default-field-list)
1996 (when (setq elt (assoc-string (car field) fields-alist t)) 2309 (when (setq elt (assoc-string (car field) fields-alist t))
1997 (setq fields-alist (delete elt fields-alist)) 2310 (setq fields-alist (delete elt fields-alist))
1998 (bibtex-make-field (list (car elt) "" (cdr elt)) nil nil t))) 2311 (bibtex-make-field (list (car elt) nil (cdr elt)) nil nil t)))
1999 (dolist (field fields-alist) 2312 (dolist (field fields-alist)
2000 (unless (member (car field) '("=key=" "=type=")) 2313 (unless (member (car field) '("=key=" "=type="))
2001 (bibtex-make-field (list (car field) "" (cdr field)) nil nil t)))))) 2314 (bibtex-make-field (list (car field) nil (cdr field)) nil nil t))))))
2002 2315
2003 ;; process all fields 2316 ;; process all fields
2004 (bibtex-beginning-first-field (point-min)) 2317 (bibtex-beginning-first-field (point-min))
@@ -2009,17 +2322,18 @@ Formats current entry according to variable `bibtex-entry-format'."
2009 (end-name (copy-marker (bibtex-end-of-name-in-field bounds))) 2322 (end-name (copy-marker (bibtex-end-of-name-in-field bounds)))
2010 (beg-text (copy-marker (bibtex-start-of-text-in-field bounds))) 2323 (beg-text (copy-marker (bibtex-start-of-text-in-field bounds)))
2011 (end-text (copy-marker (bibtex-end-of-text-in-field bounds) t)) 2324 (end-text (copy-marker (bibtex-end-of-text-in-field bounds) t))
2012 (opt-alt (string-match "OPT\\|ALT"
2013 (buffer-substring-no-properties
2014 beg-name (+ beg-name 3))))
2015 (field-name (buffer-substring-no-properties
2016 (if opt-alt (+ beg-name 3) beg-name) end-name))
2017 (empty-field (equal "" (bibtex-text-in-field-bounds bounds t))) 2325 (empty-field (equal "" (bibtex-text-in-field-bounds bounds t)))
2326 (field-name (buffer-substring-no-properties beg-name end-name))
2327 (opt-alt (and (string-match "\\`\\(OPT\\|ALT\\)" field-name)
2328 (not (and bibtex-no-opt-remove-re
2329 (string-match bibtex-no-opt-remove-re
2330 field-name)))))
2018 deleted) 2331 deleted)
2332 (if opt-alt (setq field-name (substring field-name 3)))
2019 2333
2020 ;; keep track of alternatives 2334 ;; keep track of alternatives
2021 (if (nth 3 (assoc-string field-name req-field-list t)) 2335 (if (setq idx (nth 3 (assoc-string field-name req-field-list t)))
2022 (push field-name alt-fields)) 2336 (bibtex-vec-push alt-fields idx field-name))
2023 2337
2024 (if (memq 'opts-or-alts format) 2338 (if (memq 'opts-or-alts format)
2025 ;; delete empty optional and alternative fields 2339 ;; delete empty optional and alternative fields
@@ -2170,12 +2484,14 @@ Formats current entry according to variable `bibtex-entry-format'."
2170 2484
2171 ;; check whether all required fields are present 2485 ;; check whether all required fields are present
2172 (if (memq 'required-fields format) 2486 (if (memq 'required-fields format)
2173 (let ((found 0) alt-list) 2487 (let ((alt-expect (make-vector num-alt nil))
2488 (alt-found (make-vector num-alt 0)))
2174 (dolist (fname req-field-list) 2489 (dolist (fname req-field-list)
2175 (cond ((nth 3 fname) ; t if field has alternative flag 2490 (cond ((setq idx (nth 3 fname))
2176 (push (car fname) alt-list) 2491 ;; t if field has alternative flag
2492 (bibtex-vec-push alt-expect idx (car fname))
2177 (if (member-ignore-case (car fname) field-list) 2493 (if (member-ignore-case (car fname) field-list)
2178 (setq found (1+ found)))) 2494 (bibtex-vec-incr alt-found idx)))
2179 ((not (member-ignore-case (car fname) field-list)) 2495 ((not (member-ignore-case (car fname) field-list))
2180 ;; If we use the crossref field, a required field 2496 ;; If we use the crossref field, a required field
2181 ;; can have the OPT prefix. So if it was empty, 2497 ;; can have the OPT prefix. So if it was empty,
@@ -2183,17 +2499,16 @@ Formats current entry according to variable `bibtex-entry-format'."
2183 ;; move point on this empty field. 2499 ;; move point on this empty field.
2184 (setq error-field-name (car fname)) 2500 (setq error-field-name (car fname))
2185 (error "Mandatory field `%s' is missing" (car fname))))) 2501 (error "Mandatory field `%s' is missing" (car fname)))))
2186 (if alt-list 2502 (dotimes (idx num-alt)
2187 (cond ((= found 0) 2503 (cond ((= 0 (aref alt-found idx))
2188 (if alt-fields 2504 (setq error-field-name (car (last (aref alt-fields idx))))
2189 (setq error-field-name (car (last alt-fields)))) 2505 (error "Alternative mandatory field `%s' is missing"
2190 (error "Alternative mandatory field `%s' is missing" 2506 (aref alt-expect idx)))
2191 alt-list)) 2507 ((< 1 (aref alt-found idx))
2192 ((> found 1) 2508 (setq error-field-name (car (last (aref alt-fields idx))))
2193 (if alt-fields 2509 (error "Alternative fields `%s' are defined %s times"
2194 (setq error-field-name (car (last alt-fields)))) 2510 (aref alt-expect idx)
2195 (error "Alternative fields `%s' are defined %s times" 2511 (length (aref alt-fields idx))))))))
2196 alt-list found))))))
2197 2512
2198 ;; update comma after last field 2513 ;; update comma after last field
2199 (if (memq 'last-comma format) 2514 (if (memq 'last-comma format)
@@ -2547,7 +2862,7 @@ for parsing BibTeX keys. If parsing fails, try to set this variable to nil."
2547 (push (list key) crossref-keys)))) 2862 (push (list key) crossref-keys))))
2548 ;; only keys of known entries 2863 ;; only keys of known entries
2549 ((assoc-string (bibtex-type-in-head) 2864 ((assoc-string (bibtex-type-in-head)
2550 bibtex-entry-field-alist t) 2865 bibtex-entry-alist t)
2551 ;; This is an entry. 2866 ;; This is an entry.
2552 (let ((key (bibtex-key-in-head))) 2867 (let ((key (bibtex-key-in-head)))
2553 (unless (assoc key ref-keys) 2868 (unless (assoc key ref-keys)
@@ -3056,25 +3371,122 @@ if that value is non-nil.
3056 bibtex-font-lock-syntactic-keywords)) 3371 bibtex-font-lock-syntactic-keywords))
3057 (setq imenu-generic-expression 3372 (setq imenu-generic-expression
3058 (list (list nil bibtex-entry-head bibtex-key-in-head)) 3373 (list (list nil bibtex-entry-head bibtex-key-in-head))
3059 imenu-case-fold-search t)) 3374 imenu-case-fold-search t)
3375 (bibtex-set-dialect bibtex-dialect))
3376
3377(defun bibtex-set-dialect (dialect)
3378 "Select BibTeX mode DIALECT.
3379This sets the variable `bibtex-dialect' which holds the currently active
3380dialect. Dialects are listed in `bibtex-dialect-list'."
3381 (interactive (list (intern (completing-read "Dialect: "
3382 (mapcar 'list bibtex-dialect-list)
3383 nil t))))
3384 (unless (eq dialect (get 'bibtex-dialect 'dialect))
3385 (put 'bibtex-dialect 'dialect dialect)
3386 (setq bibtex-dialect dialect)
3387
3388 ;; Bind variables
3389 (setq bibtex-entry-alist
3390 (let ((var (intern (format "bibtex-%s-entry-alist" dialect)))
3391 entry-alist)
3392 (if (boundp var)
3393 (setq entry-alist (symbol-value var))
3394 (error "BibTeX dialect `%s' undefined" dialect))
3395 (if (not (consp (nth 1 (car entry-alist))))
3396 ;; new format
3397 entry-alist
3398 ;; Convert old format
3399 (unless (get var 'entry-list-format)
3400 (put var 'entry-list-format "pre-24")
3401 (message "Old format of `%s' (pre GNU Emacs 24).
3402Please convert to the new format."
3403 (if (eq (indirect-variable 'bibtex-entry-field-alist) var)
3404 'bibtex-entry-field-alist var))
3405 (sit-for 3))
3406 (let (lst)
3407 (dolist (entry entry-alist)
3408 (let ((fl (nth 1 entry)) req xref opt)
3409 (dolist (field (copy-tree (car fl)))
3410 (if (nth 3 field) (setcar (nthcdr 3 field) 0))
3411 (if (or (not (nth 2 entry))
3412 (assoc-string (car field) (car (nth 2 entry)) t))
3413 (push field req)
3414 (push field xref)))
3415 (dolist (field (nth 1 fl))
3416 (push field opt))
3417 (push (list (car entry) nil (nreverse req)
3418 (nreverse xref) (nreverse opt))
3419 lst)))
3420 (nreverse lst))))
3421 bibtex-field-alist
3422 (let ((var (intern (format "bibtex-%s-field-alist" dialect))))
3423 (if (boundp var)
3424 (symbol-value var)
3425 (error "Field types for BibTeX dialect `%s' undefined" dialect)))
3426 bibtex-entry-type
3427 (concat "@[ \t]*\\(?:"
3428 (regexp-opt (mapcar 'car bibtex-entry-alist)) "\\)")
3429 bibtex-entry-head (concat "^[ \t]*\\("
3430 bibtex-entry-type
3431 "\\)[ \t]*[({][ \t\n]*\\("
3432 bibtex-reference-key
3433 "\\)")
3434 bibtex-entry-maybe-empty-head (concat bibtex-entry-head "?")
3435 bibtex-any-valid-entry-type
3436 (concat "^[ \t]*@[ \t]*\\(?:"
3437 (regexp-opt (append '("String" "Preamble")
3438 (mapcar 'car bibtex-entry-alist))) "\\)"))
3439 ;; Define entry commands
3440 (dolist (elt bibtex-entry-alist)
3441 (let* ((entry (car elt))
3442 (fname (intern (concat "bibtex-" entry))))
3443 (unless (fboundp fname)
3444 (eval (list 'defun fname nil
3445 (format "Insert a new BibTeX @%s entry; see also `bibtex-entry'."
3446 entry)
3447 '(interactive "*")
3448 `(bibtex-entry ,entry))))))
3449 ;; Define menu
3450 ;; We use the same keymap for all BibTeX buffers. So all these buffers
3451 ;; have the same BibTeX dialect. To define entry types buffer-locally,
3452 ;; it would be necessary to give each BibTeX buffer a new keymap that
3453 ;; becomes a child of `bibtex-mode-map'. Useful??
3454 (easy-menu-define
3455 nil bibtex-mode-map "Entry-Types Menu in BibTeX mode"
3456 (apply 'list "Entry-Types"
3457 (append
3458 (mapcar (lambda (entry)
3459 (vector (or (nth 1 entry) (car entry))
3460 (intern (format "bibtex-%s" (car entry))) t))
3461 bibtex-entry-alist)
3462 `("---"
3463 ["String" bibtex-String t]
3464 ["Preamble" bibtex-Preamble t]
3465 "---"
3466 ,(append '("BibTeX dialect")
3467 (mapcar (lambda (dialect)
3468 (vector (symbol-name dialect)
3469 `(lambda () (interactive)
3470 (bibtex-set-dialect ',dialect))
3471 t))
3472 bibtex-dialect-list))))))))
3060 3473
3061(defun bibtex-field-list (entry-type) 3474(defun bibtex-field-list (entry-type)
3062 "Return list of allowed fields for entry ENTRY-TYPE. 3475 "Return list of allowed fields for entry ENTRY-TYPE.
3063More specifically, the return value is a cons pair (REQUIRED . OPTIONAL), 3476More specifically, the return value is a cons pair (REQUIRED . OPTIONAL),
3064where REQUIRED and OPTIONAL are lists of the required and optional field 3477where REQUIRED and OPTIONAL are lists of the required and optional field
3065names for ENTRY-TYPE according to `bibtex-entry-field-alist', 3478names for ENTRY-TYPE according to `bibtex-BibTeX-entry-alist' and friends,
3066`bibtex-include-OPTkey', `bibtex-include-OPTcrossref', 3479`bibtex-include-OPTkey', `bibtex-include-OPTcrossref',
3067and `bibtex-user-optional-fields'." 3480and `bibtex-user-optional-fields'."
3068 (let ((e (assoc-string entry-type bibtex-entry-field-alist t)) 3481 (let ((e-list (assoc-string entry-type bibtex-entry-alist t))
3069 required optional) 3482 required optional)
3070 (unless e 3483 (unless e-list
3071 (error "Fields for BibTeX entry type %s not defined" entry-type)) 3484 (error "Fields for BibTeX entry type %s not defined" entry-type))
3072 (if (and (member-ignore-case entry-type bibtex-include-OPTcrossref) 3485 (if (member-ignore-case entry-type bibtex-include-OPTcrossref)
3073 (nth 2 e)) 3486 (setq required (nth 2 e-list)
3074 (setq required (nth 0 (nth 2 e)) 3487 optional (append (nth 3 e-list) (nth 4 e-list)))
3075 optional (nth 1 (nth 2 e))) 3488 (setq required (append (nth 2 e-list) (nth 3 e-list))
3076 (setq required (nth 0 (nth 1 e)) 3489 optional (nth 4 e-list)))
3077 optional (nth 1 (nth 1 e))))
3078 (if bibtex-include-OPTkey 3490 (if bibtex-include-OPTkey
3079 (push (list "key" 3491 (push (list "key"
3080 "Used for reference key creation if author and editor fields are missing" 3492 "Used for reference key creation if author and editor fields are missing"
@@ -3094,7 +3506,7 @@ After insertion call the value of `bibtex-add-entry-hook' if that value
3094is non-nil." 3506is non-nil."
3095 (interactive 3507 (interactive
3096 (let ((completion-ignore-case t)) 3508 (let ((completion-ignore-case t))
3097 (list (completing-read "Entry Type: " bibtex-entry-field-alist 3509 (list (completing-read "Entry Type: " bibtex-entry-alist
3098 nil t nil 'bibtex-entry-type-history)))) 3510 nil t nil 'bibtex-entry-type-history))))
3099 (let ((key (if bibtex-maintain-sorted-entries 3511 (let ((key (if bibtex-maintain-sorted-entries
3100 (bibtex-read-key (format "%s key: " entry-type)))) 3512 (bibtex-read-key (format "%s key: " entry-type))))
@@ -3127,7 +3539,7 @@ When called interactively with a prefix arg, query for a value of ENTRY-TYPE."
3127 (interactive 3539 (interactive
3128 (list (if current-prefix-arg 3540 (list (if current-prefix-arg
3129 (let ((completion-ignore-case t)) 3541 (let ((completion-ignore-case t))
3130 (completing-read "New entry type: " bibtex-entry-field-alist 3542 (completing-read "New entry type: " bibtex-entry-alist
3131 nil t nil 'bibtex-entry-type-history))))) 3543 nil t nil 'bibtex-entry-type-history)))))
3132 (save-excursion 3544 (save-excursion
3133 (bibtex-beginning-of-entry) 3545 (bibtex-beginning-of-entry)
@@ -3264,14 +3676,16 @@ interactive calls."
3264 (field-list (bibtex-field-list type)) 3676 (field-list (bibtex-field-list type))
3265 (comment (assoc-string field (append (car field-list) 3677 (comment (assoc-string field (append (car field-list)
3266 (cdr field-list)) t))) 3678 (cdr field-list)) t)))
3267 (if comment (message "%s" (nth 1 comment)) 3679 (message "%s" (cond ((nth 1 comment) (nth 1 comment))
3268 (message "No comment available"))))) 3680 ((setq comment (assoc-string field bibtex-field-alist t))
3681 (nth 1 comment))
3682 (t "No comment available"))))))
3269 3683
3270(defun bibtex-make-field (field &optional move interactive nodelim) 3684(defun bibtex-make-field (field &optional move interactive nodelim)
3271 "Make a field named FIELD in current BibTeX entry. 3685 "Make a field named FIELD in current BibTeX entry.
3272FIELD is either a string or a list of the form 3686FIELD is either a string or a list of the form
3273\(FIELD-NAME COMMENT-STRING INIT ALTERNATIVE-FLAG) as in 3687\(FIELD-NAME COMMENT-STRING INIT ALTERNATIVE-FLAG) as in
3274`bibtex-entry-field-alist'. 3688`bibtex-BibTeX-entry-alist' and friends.
3275If MOVE is non-nil, move point past the present field before making 3689If MOVE is non-nil, move point past the present field before making
3276the new field. If INTERACTIVE is non-nil, move point to the end of 3690the new field. If INTERACTIVE is non-nil, move point to the end of
3277the new field. Otherwise move point past the new field. 3691the new field. Otherwise move point past the new field.
@@ -3296,6 +3710,8 @@ INIT is surrounded by field delimiters, unless NODELIM is non-nil."
3296 (forward-char))) 3710 (forward-char)))
3297 (insert ",\n") 3711 (insert ",\n")
3298 (indent-to-column (+ bibtex-entry-offset bibtex-field-indentation)) 3712 (indent-to-column (+ bibtex-entry-offset bibtex-field-indentation))
3713 ;; If there are multiple sets of alternatives, we could use
3714 ;; the numeric value of (nth 3 field) to number these sets. Useful??
3299 (if (nth 3 field) (insert "ALT")) 3715 (if (nth 3 field) (insert "ALT"))
3300 (insert (car field) " ") 3716 (insert (car field) " ")
3301 (if bibtex-align-at-equal-sign 3717 (if bibtex-align-at-equal-sign
@@ -3794,14 +4210,22 @@ Return t if test was successful, nil otherwise."
3794 "Checking required fields and month fields") 4210 "Checking required fields and month fields")
3795 (let ((bibtex-sort-ignore-string-entries t)) 4211 (let ((bibtex-sort-ignore-string-entries t))
3796 (bibtex-map-entries 4212 (bibtex-map-entries
3797 (lambda (_key beg _end) 4213 (lambda (_key beg end)
3798 (bibtex-progress-message) 4214 (bibtex-progress-message)
3799 (let* ((entry-list (assoc-string (bibtex-type-in-head) 4215 (bibtex-beginning-first-field beg)
3800 bibtex-entry-field-alist t)) 4216 (let* ((beg-line (save-excursion (goto-char beg)
3801 (req (copy-sequence (elt (elt entry-list 1) 0))) 4217 (bibtex-current-line)))
3802 (creq (copy-sequence (elt (elt entry-list 2) 0))) 4218 (entry-list (assoc-string (bibtex-type-in-head)
3803 crossref-there bounds alt-there field) 4219 bibtex-entry-alist t))
3804 (bibtex-beginning-first-field beg) 4220 (crossref (bibtex-search-forward-field "crossref" end))
4221 (req (if crossref (copy-sequence (nth 2 entry-list))
4222 (append (nth 2 entry-list)
4223 (copy-sequence (nth 3 entry-list)))))
4224 (num-alt (length (delq nil (delete-dups
4225 (mapcar (lambda (x) (nth 3 x))
4226 req)))))
4227 (alt-fields (make-vector num-alt nil))
4228 bounds field idx)
3805 (while (setq bounds (bibtex-parse-field)) 4229 (while (setq bounds (bibtex-parse-field))
3806 (let ((field-name (bibtex-name-in-field bounds))) 4230 (let ((field-name (bibtex-name-in-field bounds)))
3807 (if (and (bibtex-string= field-name "month") 4231 (if (and (bibtex-string= field-name "month")
@@ -3815,36 +4239,28 @@ Return t if test was successful, nil otherwise."
3815 "Questionable month field") 4239 "Questionable month field")
3816 error-list)) 4240 error-list))
3817 (setq field (assoc-string field-name req t) 4241 (setq field (assoc-string field-name req t)
3818 req (delete field req) 4242 req (delete field req))
3819 creq (delete (assoc-string field-name creq t) creq)) 4243 (if (setq idx (nth 3 field))
3820 (if (nth 3 field) 4244 (if (aref alt-fields idx)
3821 (if alt-there
3822 (push (cons (bibtex-current-line) 4245 (push (cons (bibtex-current-line)
3823 "More than one non-empty alternative") 4246 "More than one non-empty alternative")
3824 error-list) 4247 error-list)
3825 (setq alt-there t))) 4248 (aset alt-fields idx t))))
3826 (if (bibtex-string= field-name "crossref")
3827 (setq crossref-there t)))
3828 (goto-char (bibtex-end-of-field bounds))) 4249 (goto-char (bibtex-end-of-field bounds)))
3829 (if crossref-there (setq req creq)) 4250 (let ((alt-expect (make-vector num-alt nil)))
3830 (let (alt) 4251 (dolist (field req) ; absent required fields
3831 (dolist (field req) 4252 (if (setq idx (nth 3 field))
3832 (if (nth 3 field) 4253 (bibtex-vec-push alt-expect idx (car field))
3833 (push (car field) alt) 4254 (push (cons beg-line
3834 (push (cons (save-excursion (goto-char beg)
3835 (bibtex-current-line))
3836 (format "Required field `%s' missing" 4255 (format "Required field `%s' missing"
3837 (car field))) 4256 (car field)))
3838 error-list))) 4257 error-list)))
3839 ;; The following fails if there are more than two 4258 (dotimes (idx num-alt)
3840 ;; alternatives in a BibTeX entry, which isn't 4259 (unless (aref alt-fields idx)
3841 ;; the case momentarily. 4260 (push (cons beg-line
3842 (if (cdr alt) 4261 (format "Alternative fields `%s' missing"
3843 (push (cons (save-excursion (goto-char beg) 4262 (aref alt-expect idx)))
3844 (bibtex-current-line)) 4263 error-list))))))))
3845 (format "Alternative fields `%s'/`%s' missing"
3846 (car alt) (cadr alt)))
3847 error-list)))))))
3848 (bibtex-progress-message 'done))))) 4264 (bibtex-progress-message 'done)))))
3849 4265
3850 (if error-list 4266 (if error-list
@@ -3890,7 +4306,7 @@ Return t if test was successful, nil otherwise."
3890 (setq entry-type (bibtex-type-in-head) 4306 (setq entry-type (bibtex-type-in-head)
3891 key (bibtex-key-in-head)) 4307 key (bibtex-key-in-head))
3892 (if (or (and strings (bibtex-string= entry-type "string")) 4308 (if (or (and strings (bibtex-string= entry-type "string"))
3893 (assoc-string entry-type bibtex-entry-field-alist t)) 4309 (assoc-string entry-type bibtex-entry-alist t))
3894 (if (member key key-list) 4310 (if (member key key-list)
3895 (push (format "%s:%d: Duplicate key `%s'\n" 4311 (push (format "%s:%d: Duplicate key `%s'\n"
3896 (buffer-file-name) 4312 (buffer-file-name)
@@ -4057,7 +4473,13 @@ is as in `bibtex-enclosing-field'. It is t for interactive calls."
4057 (bounds (bibtex-enclosing-field comma))) 4473 (bounds (bibtex-enclosing-field comma)))
4058 (save-excursion 4474 (save-excursion
4059 (goto-char (bibtex-start-of-name-in-field bounds)) 4475 (goto-char (bibtex-start-of-name-in-field bounds))
4060 (when (looking-at "OPT\\|ALT") 4476 (when (and (looking-at "OPT\\|ALT")
4477 (not (and bibtex-no-opt-remove-re
4478 (string-match
4479 bibtex-no-opt-remove-re
4480 (buffer-substring-no-properties
4481 (bibtex-start-of-name-in-field bounds)
4482 (bibtex-end-of-name-in-field bounds))))))
4061 (delete-region (match-beginning 0) (match-end 0)) 4483 (delete-region (match-beginning 0) (match-end 0))
4062 ;; make field non-OPT 4484 ;; make field non-OPT
4063 (search-forward "=") 4485 (search-forward "=")
@@ -4600,71 +5022,6 @@ entries from minibuffer."
4600 (when (eq status 'finished) 5022 (when (eq status 'finished)
4601 (save-excursion (bibtex-remove-delimiters))))))))) 5023 (save-excursion (bibtex-remove-delimiters)))))))))
4602 5024
4603(defun bibtex-Article ()
4604 "Insert a new BibTeX @Article entry; see also `bibtex-entry'."
4605 (interactive "*")
4606 (bibtex-entry "Article"))
4607
4608(defun bibtex-Book ()
4609 "Insert a new BibTeX @Book entry; see also `bibtex-entry'."
4610 (interactive "*")
4611 (bibtex-entry "Book"))
4612
4613(defun bibtex-Booklet ()
4614 "Insert a new BibTeX @Booklet entry; see also `bibtex-entry'."
4615 (interactive "*")
4616 (bibtex-entry "Booklet"))
4617
4618(defun bibtex-InBook ()
4619 "Insert a new BibTeX @InBook entry; see also `bibtex-entry'."
4620 (interactive "*")
4621 (bibtex-entry "InBook"))
4622
4623(defun bibtex-InCollection ()
4624 "Insert a new BibTeX @InCollection entry; see also `bibtex-entry'."
4625 (interactive "*")
4626 (bibtex-entry "InCollection"))
4627
4628(defun bibtex-InProceedings ()
4629 "Insert a new BibTeX @InProceedings entry; see also `bibtex-entry'."
4630 (interactive "*")
4631 (bibtex-entry "InProceedings"))
4632
4633(defun bibtex-Manual ()
4634 "Insert a new BibTeX @Manual entry; see also `bibtex-entry'."
4635 (interactive "*")
4636 (bibtex-entry "Manual"))
4637
4638(defun bibtex-MastersThesis ()
4639 "Insert a new BibTeX @MastersThesis entry; see also `bibtex-entry'."
4640 (interactive "*")
4641 (bibtex-entry "MastersThesis"))
4642
4643(defun bibtex-Misc ()
4644 "Insert a new BibTeX @Misc entry; see also `bibtex-entry'."
4645 (interactive "*")
4646 (bibtex-entry "Misc"))
4647
4648(defun bibtex-PhdThesis ()
4649 "Insert a new BibTeX @PhdThesis entry; see also `bibtex-entry'."
4650 (interactive "*")
4651 (bibtex-entry "PhdThesis"))
4652
4653(defun bibtex-Proceedings ()
4654 "Insert a new BibTeX @Proceedings entry; see also `bibtex-entry'."
4655 (interactive "*")
4656 (bibtex-entry "Proceedings"))
4657
4658(defun bibtex-TechReport ()
4659 "Insert a new BibTeX @TechReport entry; see also `bibtex-entry'."
4660 (interactive "*")
4661 (bibtex-entry "TechReport"))
4662
4663(defun bibtex-Unpublished ()
4664 "Insert a new BibTeX @Unpublished entry; see also `bibtex-entry'."
4665 (interactive "*")
4666 (bibtex-entry "Unpublished"))
4667
4668(defun bibtex-String (&optional key) 5025(defun bibtex-String (&optional key)
4669 "Insert a new BibTeX @String entry with key KEY." 5026 "Insert a new BibTeX @String entry with key KEY."
4670 (interactive (list (bibtex-read-string-key))) 5027 (interactive (list (bibtex-read-string-key)))
@@ -4822,10 +5179,8 @@ where FILE is the BibTeX file of ENTRY."
4822 (delete-dups 5179 (delete-dups
4823 (apply 'append 5180 (apply 'append
4824 bibtex-user-optional-fields 5181 bibtex-user-optional-fields
4825 (mapcar (lambda (x) 5182 (mapcar (lambda (x) (mapcar 'car (apply 'append (cdr x))))
4826 (append (mapcar 'car (nth 0 (nth 1 x))) 5183 bibtex-entry-alist))) nil t)
4827 (mapcar 'car (nth 1 (nth 1 x)))))
4828 bibtex-entry-field-alist))) nil t)
4829 (read-string "Regexp: ") 5184 (read-string "Regexp: ")
4830 (if bibtex-search-entry-globally 5185 (if bibtex-search-entry-globally
4831 (not current-prefix-arg) 5186 (not current-prefix-arg)