aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoland Winkler2021-01-01 16:35:15 -0600
committerRoland Winkler2021-01-01 16:35:15 -0600
commitaac17c9dca21462df57367123301b7c940f9243a (patch)
tree76d6e27318d799f13525151d12d07e1e8b698120
parentaa2739bf1b9a045d94220b607c03b21dbbb7959d (diff)
downloademacs-aac17c9dca21462df57367123301b7c940f9243a.tar.gz
emacs-aac17c9dca21462df57367123301b7c940f9243a.zip
bibtex-mode: Handle biblatex field aliases (bug#44976)
* lisp/textmodes/bibtex.el (bibtex-biblatex-entry-alist): Define field aliases. (bibtex-vec-incr): Remove. (bibtex-format-entry, bibtex-validate): Check for field aliases. (bibtex--skip-field-aliases): New function. (bibtex-field-list): Use it.
-rw-r--r--lisp/textmodes/bibtex.el451
1 files changed, 296 insertions, 155 deletions
diff --git a/lisp/textmodes/bibtex.el b/lisp/textmodes/bibtex.el
index f64629d0ea0..d238b6037e7 100644
--- a/lisp/textmodes/bibtex.el
+++ b/lisp/textmodes/bibtex.el
@@ -477,280 +477,376 @@ COMMENT is the comment string that appears in the echo area.
477If COMMENT is nil use `bibtex-BibTeX-field-alist' if possible. 477If COMMENT is nil use `bibtex-BibTeX-field-alist' if possible.
478INIT is either the initial content of the field or a function, 478INIT is either the initial content of the field or a function,
479which is called to determine the initial content of the field. 479which is called to determine the initial content of the field.
480ALTERNATIVE if non-nil is an integer that numbers sets of 480ALTERNATIVE if non-nil is an integer N that numbers sets of
481alternatives, starting from zero." 481alternatives. A negative integer -N indicates an alias for the
482field +N. Such aliases are ignored by `bibtex-entry' in the template
483for a new entry."
482 :group 'bibtex 484 :group 'bibtex
483 :version "26.1" ; add Conference 485 :version "28.1" ; extend alternatives
484 :type 'bibtex-entry-alist 486 :type 'bibtex-entry-alist
485 :risky t) 487 :risky t)
486 488
487(defcustom bibtex-biblatex-entry-alist 489(defcustom bibtex-biblatex-entry-alist
488 ;; Compare in biblatex documentation: 490 ;; Compare in biblatex documentation:
489 ;; Sec. 2.1.1 Regular types (required and optional fields) 491 ;; Sec. 2.1.1 Regular types (required and optional fields)
492 ;; Sec. 2.2.5 Field Aliases
490 ;; Appendix A Default Crossref setup 493 ;; Appendix A Default Crossref setup
491 '(("Article" "Article in Journal" 494 '(("Article" "Article in Journal"
492 (("author") ("title") ("journaltitle") 495 (("author") ("title")
493 ("year" nil nil 0) ("date" nil nil 0)) 496 ("journaltitle" nil nil 3) ("journal" nil nil -3)
497 ("date" nil nil 1) ("year" nil nil -1))
494 nil 498 nil
495 (("translator") ("annotator") ("commentator") ("subtitle") ("titleaddon") 499 (("translator") ("annotator") ("commentator") ("subtitle") ("titleaddon")
496 ("editor") ("editora") ("editorb") ("editorc") ("journalsubtitle") 500 ("editor") ("editora") ("editorb") ("editorc") ("journalsubtitle")
497 ("journaltitleaddon") ("issuetitle") ("issuesubtitle") ("issuetitleaddon") 501 ("journaltitleaddon") ("issuetitle") ("issuesubtitle") ("issuetitleaddon")
498 ("language") ("origlanguage") ("series") ("volume") ("number") ("eid") 502 ("language") ("origlanguage") ("series") ("volume") ("number") ("eid")
499 ("issue") ("month") ("pages") ("version") ("note") ("issn") 503 ("issue") ("month") ("pages") ("version") ("note") ("issn")
500 ("addendum") ("pubstate") ("doi") ("eprint") ("eprintclass") 504 ("addendum") ("pubstate") ("doi")
501 ("eprinttype") ("url") ("urldate"))) 505 ("eprint") ("eprintclass" nil nil 4) ("primaryclass" nil nil -4)
506 ("eprinttype" nil nil 5) ("archiveprefix" nil nil -5)
507 ("url") ("urldate")))
502 ("Book" "Single-Volume Book" 508 ("Book" "Single-Volume Book"
503 (("author") ("title") ("year" nil nil 0) ("date" nil nil 0)) 509 (("author") ("title")
510 ("date" nil nil 1) ("year" nil nil -1))
504 nil 511 nil
505 (("editor") ("editora") ("editorb") ("editorc") 512 (("editor") ("editora") ("editorb") ("editorc")
506 ("translator") ("annotator") ("commentator") 513 ("translator") ("annotator") ("commentator")
507 ("introduction") ("foreword") ("afterword") ("subtitle") ("titleaddon") 514 ("introduction") ("foreword") ("afterword") ("subtitle") ("titleaddon")
508 ("maintitle") ("mainsubtitle") ("maintitleaddon") 515 ("maintitle") ("mainsubtitle") ("maintitleaddon")
509 ("language") ("origlanguage") ("volume") ("part") ("edition") ("volumes") 516 ("language") ("origlanguage") ("volume") ("part") ("edition") ("volumes")
510 ("series") ("number") ("note") ("publisher") ("location") ("isbn") ("eid") 517 ("series") ("number") ("note") ("publisher")
518 ("location" nil nil 2) ("address" nil nil -2) ("isbn") ("eid")
511 ("chapter") ("pages") ("pagetotal") ("addendum") ("pubstate") ("doi") 519 ("chapter") ("pages") ("pagetotal") ("addendum") ("pubstate") ("doi")
512 ("eprint") ("eprintclass") ("eprinttype") ("url") ("urldate"))) 520 ("eprint") ("eprintclass" nil nil 4) ("primaryclass" nil nil -4)
521 ("eprinttype" nil nil 5) ("archiveprefix" nil nil -5)
522 ("url") ("urldate")))
513 ("MVBook" "Multi-Volume Book" 523 ("MVBook" "Multi-Volume Book"
514 (("author") ("title") ("year" nil nil 0) ("date" nil nil 0)) 524 (("author") ("title")
525 ("date" nil nil 1) ("year" nil nil -1))
515 nil 526 nil
516 (("editor") ("editora") ("editorb") ("editorc") 527 (("editor") ("editora") ("editorb") ("editorc")
517 ("translator") ("annotator") ("commentator") 528 ("translator") ("annotator") ("commentator")
518 ("introduction") ("foreword") ("afterword") ("subtitle") 529 ("introduction") ("foreword") ("afterword") ("subtitle")
519 ("titleaddon") ("language") ("origlanguage") ("edition") ("volumes") 530 ("titleaddon") ("language") ("origlanguage") ("edition") ("volumes")
520 ("series") ("number") ("note") ("publisher") 531 ("series") ("number") ("note") ("publisher")
521 ("location") ("isbn") ("pagetotal") ("addendum") ("pubstate") ("doi") 532 ("location" nil nil 2) ("address" nil nil -2)
522 ("eprint") ("eprintclass") ("eprinttype") ("url") ("urldate"))) 533 ("isbn") ("pagetotal") ("addendum") ("pubstate") ("doi")
534 ("eprint") ("eprintclass" nil nil 4) ("primaryclass" nil nil -4)
535 ("eprinttype" nil nil 5) ("archiveprefix" nil nil -5)
536 ("url") ("urldate")))
523 ("InBook" "Chapter or Pages in a Book" 537 ("InBook" "Chapter or Pages in a Book"
524 (("title") ("year" nil nil 0) ("date" nil nil 0)) 538 (("title") ("date" nil nil 1) ("year" nil nil -1))
525 (("author") ("booktitle")) 539 (("author") ("booktitle"))
526 (("bookauthor") ("editor") ("editora") ("editorb") ("editorc") 540 (("bookauthor") ("editor") ("editora") ("editorb") ("editorc")
527 ("translator") ("annotator") ("commentator") ("introduction") ("foreword") 541 ("translator") ("annotator") ("commentator") ("introduction") ("foreword")
528 ("afterword") ("subtitle") ("titleaddon") ("maintitle") ("mainsubtitle") 542 ("afterword") ("subtitle") ("titleaddon") ("maintitle") ("mainsubtitle")
529 ("maintitleaddon") ("booksubtitle") ("booktitleaddon") 543 ("maintitleaddon") ("booksubtitle") ("booktitleaddon")
530 ("language") ("origlanguage") ("volume") ("part") ("edition") ("volumes") 544 ("language") ("origlanguage") ("volume") ("part") ("edition") ("volumes")
531 ("series") ("number") ("note") ("publisher") ("location") ("isbn") ("eid") 545 ("series") ("number") ("note") ("publisher")
532 ("chapter") ("pages") ("addendum") ("pubstate") 546 ("location" nil nil 2) ("address" nil nil -2) ("isbn") ("eid")
533 ("doi") ("eprint") ("eprintclass") ("eprinttype") ("url") ("urldate"))) 547 ("chapter") ("pages") ("addendum") ("pubstate") ("doi")
548 ("eprint") ("eprintclass" nil nil 4) ("primaryclass" nil nil -4)
549 ("eprinttype" nil nil 5) ("archiveprefix" nil nil -5)
550 ("url") ("urldate")))
534 ("BookInBook" "Book in Collection" ; same as @inbook 551 ("BookInBook" "Book in Collection" ; same as @inbook
535 (("title") ("year" nil nil 0) ("date" nil nil 0)) 552 (("title") ("date" nil nil 1) ("year" nil nil -1))
536 (("author") ("booktitle")) 553 (("author") ("booktitle"))
537 (("bookauthor") ("editor") ("editora") ("editorb") ("editorc") 554 (("bookauthor") ("editor") ("editora") ("editorb") ("editorc")
538 ("translator") ("annotator") ("commentator") ("introduction") ("foreword") 555 ("translator") ("annotator") ("commentator") ("introduction") ("foreword")
539 ("afterword") ("subtitle") ("titleaddon") ("maintitle") ("mainsubtitle") 556 ("afterword") ("subtitle") ("titleaddon") ("maintitle") ("mainsubtitle")
540 ("maintitleaddon") ("booksubtitle") ("booktitleaddon") 557 ("maintitleaddon") ("booksubtitle") ("booktitleaddon")
541 ("language") ("origlanguage") ("volume") ("part") ("edition") ("volumes") 558 ("language") ("origlanguage") ("volume") ("part") ("edition") ("volumes")
542 ("series") ("number") ("note") ("publisher") ("location") ("isbn") ("eid") 559 ("series") ("number") ("note") ("publisher")
543 ("chapter") ("pages") ("addendum") ("pubstate") 560 ("location" nil nil 2) ("address" nil nil -2) ("isbn") ("eid")
544 ("doi") ("eprint") ("eprintclass") ("eprinttype") ("url") ("urldate"))) 561 ("chapter") ("pages") ("addendum") ("pubstate") ("doi")
562 ("eprint") ("eprintclass" nil nil 4) ("primaryclass" nil nil -4)
563 ("eprinttype" nil nil 5) ("archiveprefix" nil nil -5)
564 ("url") ("urldate")))
545 ("SuppBook" "Supplemental Material in a Book" ; same as @inbook 565 ("SuppBook" "Supplemental Material in a Book" ; same as @inbook
546 (("title") ("year" nil nil 0) ("date" nil nil 0)) 566 (("title") ("date" nil nil 1) ("year" nil nil -1))
547 (("author") ("booktitle")) 567 (("author") ("booktitle"))
548 (("bookauthor") ("editor") ("editora") ("editorb") ("editorc") 568 (("bookauthor") ("editor") ("editora") ("editorb") ("editorc")
549 ("translator") ("annotator") ("commentator") ("introduction") ("foreword") 569 ("translator") ("annotator") ("commentator") ("introduction") ("foreword")
550 ("afterword") ("subtitle") ("titleaddon") ("maintitle") ("mainsubtitle") 570 ("afterword") ("subtitle") ("titleaddon") ("maintitle") ("mainsubtitle")
551 ("maintitleaddon") ("booksubtitle") ("booktitleaddon") 571 ("maintitleaddon") ("booksubtitle") ("booktitleaddon")
552 ("language") ("origlanguage") ("volume") ("part") ("edition") ("volumes") 572 ("language") ("origlanguage") ("volume") ("part") ("edition") ("volumes")
553 ("series") ("number") ("note") ("publisher") ("location") ("isbn") ("eid") 573 ("series") ("number") ("note") ("publisher")
554 ("chapter") ("pages") ("addendum") ("pubstate") 574 ("location" nil nil 2) ("address" nil nil -2) ("isbn") ("eid")
555 ("doi") ("eprint") ("eprintclass") ("eprinttype") ("url") ("urldate"))) 575 ("chapter") ("pages") ("addendum") ("pubstate") ("doi")
576 ("eprint")("eprintclass" nil nil 4) ("primaryclass" nil nil -4)
577 ("eprinttype" nil nil 5) ("archiveprefix" nil nil -5)
578 ("url") ("urldate")))
556 ("Booklet" "Booklet (Bound, but no Publisher)" 579 ("Booklet" "Booklet (Bound, but no Publisher)"
557 (("author" nil nil 0) ("editor" nil nil 0) ("title") 580 (("author" nil nil 0) ("editor" nil nil 0) ("title")
558 ("year" nil nil 1) ("date" nil nil 1)) 581 ("date" nil nil 1) ("year" nil nil -1))
559 nil 582 nil
560 (("subtitle") ("titleaddon") ("language") ("howpublished") ("type") 583 (("subtitle") ("titleaddon") ("language") ("howpublished") ("type")
561 ("note") ("location") ("eid") ("chapter") ("pages") ("pagetotal") 584 ("note") ("location" nil nil 2) ("address" nil nil -2)
562 ("addendum") ("pubstate") ("doi") ("eprint") ("eprintclass") 585 ("eid") ("chapter") ("pages") ("pagetotal")
563 ("eprinttype") ("url") ("urldate"))) 586 ("addendum") ("pubstate") ("doi")
587 ("eprint") ("eprintclass" nil nil 4) ("primaryclass" nil nil -4)
588 ("eprinttype" nil nil 5) ("archiveprefix" nil nil -5)
589 ("url") ("urldate")))
564 ("Collection" "Single-Volume Collection" 590 ("Collection" "Single-Volume Collection"
565 (("editor") ("title") ("year" nil nil 0) ("date" nil nil 0)) 591 (("editor") ("title")
592 ("date" nil nil 1) ("year" nil nil -1))
566 nil 593 nil
567 (("editora") ("editorb") ("editorc") ("translator") ("annotator") 594 (("editora") ("editorb") ("editorc") ("translator") ("annotator")
568 ("commentator") ("introduction") ("foreword") ("afterword") 595 ("commentator") ("introduction") ("foreword") ("afterword")
569 ("subtitle") ("titleaddon") ("maintitle") ("mainsubtitle") 596 ("subtitle") ("titleaddon") ("maintitle") ("mainsubtitle")
570 ("maintitleaddon") ("language") ("origlanguage") ("volume") 597 ("maintitleaddon") ("language") ("origlanguage") ("volume")
571 ("part") ("edition") ("volumes") ("series") ("number") ("note") 598 ("part") ("edition") ("volumes") ("series") ("number") ("note")
572 ("publisher") ("location") ("isbn") ("eid") ("chapter") ("pages") 599 ("publisher") ("location" nil nil 2) ("address" nil nil -2)
573 ("pagetotal") ("addendum") ("pubstate") ("doi") ("eprint") ("eprintclass") 600 ("isbn") ("eid") ("chapter") ("pages")
574 ("eprinttype") ("url") ("urldate"))) 601 ("pagetotal") ("addendum") ("pubstate") ("doi")
602 ("eprint") ("eprintclass" nil nil 4) ("primaryclass" nil nil -4)
603 ("eprinttype" nil nil 5) ("archiveprefix" nil nil -5)
604 ("url") ("urldate")))
575 ("MVCollection" "Multi-Volume Collection" 605 ("MVCollection" "Multi-Volume Collection"
576 (("editor") ("title") ("year" nil nil 0) ("date" nil nil 0)) 606 (("editor") ("title")
607 ("date" nil nil 1) ("year" nil nil -1))
577 nil 608 nil
578 (("editora") ("editorb") ("editorc") ("translator") ("annotator") 609 (("editora") ("editorb") ("editorc") ("translator") ("annotator")
579 ("commentator") ("introduction") ("foreword") ("afterword") 610 ("commentator") ("introduction") ("foreword") ("afterword")
580 ("subtitle") ("titleaddon") ("language") ("origlanguage") ("edition") 611 ("subtitle") ("titleaddon") ("language") ("origlanguage") ("edition")
581 ("volumes") ("series") ("number") ("note") ("publisher") 612 ("volumes") ("series") ("number") ("note") ("publisher")
582 ("location") ("isbn") ("pagetotal") ("addendum") ("pubstate") ("doi") 613 ("location" nil nil 2) ("address" nil nil -2)
583 ("eprint") ("eprintclass") ("eprinttype") ("url") ("urldate"))) 614 ("isbn") ("pagetotal") ("addendum") ("pubstate") ("doi")
615 ("eprint") ("eprintclass" nil nil 4) ("primaryclass" nil nil -4)
616 ("eprinttype" nil nil 5) ("archiveprefix" nil nil -5)
617 ("url") ("urldate")))
584 ("InCollection" "Article in a Collection" 618 ("InCollection" "Article in a Collection"
585 (("author") ("title") ("year" nil nil 0) ("date" nil nil 0)) 619 (("author") ("title")
620 ("date" nil nil 1) ("year" nil nil -1))
586 (("booktitle")) 621 (("booktitle"))
587 (("editor") ("editora") ("editorb") ("editorc") ("translator") 622 (("editor") ("editora") ("editorb") ("editorc") ("translator")
588 ("annotator") ("commentator") ("introduction") ("foreword") ("afterword") 623 ("annotator") ("commentator") ("introduction") ("foreword") ("afterword")
589 ("subtitle") ("titleaddon") ("maintitle") ("mainsubtitle") 624 ("subtitle") ("titleaddon") ("maintitle") ("mainsubtitle")
590 ("maintitleaddon") ("booksubtitle") ("booktitleaddon") 625 ("maintitleaddon") ("booksubtitle") ("booktitleaddon")
591 ("language") ("origlanguage") ("volume") ("part") ("edition") 626 ("language") ("origlanguage") ("volume") ("part") ("edition")
592 ("volumes") ("series") ("number") ("note") ("publisher") ("location") 627 ("volumes") ("series") ("number") ("note") ("publisher")
628 ("location" nil nil 2) ("address" nil nil -2)
593 ("isbn") ("eid") ("chapter") ("pages") ("addendum") ("pubstate") ("doi") 629 ("isbn") ("eid") ("chapter") ("pages") ("addendum") ("pubstate") ("doi")
594 ("eprint") ("eprintclass") ("eprinttype") ("url") ("urldate"))) 630 ("eprint") ("eprintclass" nil nil 4) ("primaryclass" nil nil -4)
631 ("eprinttype" nil nil 5) ("archiveprefix" nil nil -5)
632 ("url") ("urldate")))
595 ("SuppCollection" "Supplemental Material in a Collection" ; same as @incollection 633 ("SuppCollection" "Supplemental Material in a Collection" ; same as @incollection
596 (("author") ("title") ("year" nil nil 0) ("date" nil nil 0)) 634 (("author") ("title")
635 ("date" nil nil 1) ("year" nil nil -1))
597 (("booktitle")) 636 (("booktitle"))
598 (("editor") ("editora") ("editorb") ("editorc") ("translator") 637 (("editor") ("editora") ("editorb") ("editorc") ("translator")
599 ("annotator") ("commentator") ("introduction") ("foreword") ("afterword") 638 ("annotator") ("commentator") ("introduction") ("foreword") ("afterword")
600 ("subtitle") ("titleaddon") ("maintitle") ("mainsubtitle") 639 ("subtitle") ("titleaddon") ("maintitle") ("mainsubtitle")
601 ("maintitleaddon") ("booksubtitle") ("booktitleaddon") 640 ("maintitleaddon") ("booksubtitle") ("booktitleaddon")
602 ("language") ("origlanguage") ("volume") ("part") ("edition") 641 ("language") ("origlanguage") ("volume") ("part") ("edition")
603 ("volumes") ("series") ("number") ("note") ("publisher") ("location") 642 ("volumes") ("series") ("number") ("note") ("publisher")
643 ("location" nil nil 2) ("address" nil nil -2)
604 ("isbn") ("eid") ("chapter") ("pages") ("addendum") ("pubstate") ("doi") 644 ("isbn") ("eid") ("chapter") ("pages") ("addendum") ("pubstate") ("doi")
605 ("eprint") ("eprintclass") ("eprinttype") ("url") ("urldate"))) 645 ("eprint") ("eprintclass" nil nil 4) ("primaryclass" nil nil -4)
646 ("eprinttype" nil nil 5) ("archiveprefix" nil nil -5)
647 ("url") ("urldate")))
606 ("Dataset" "Data Set" 648 ("Dataset" "Data Set"
607 (("author" nil nil 0) ("editor" nil nil 0) ("title") 649 (("author" nil nil 0) ("editor" nil nil 0) ("title")
608 ("year" nil nil 1) ("date" nil nil 1)) 650 ("date" nil nil 1) ("year" nil nil -1))
609 nil 651 nil
610 (("subtitle") ("titleaddon") ("language") ("edition") ("type") ("series") 652 (("subtitle") ("titleaddon") ("language") ("edition") ("type") ("series")
611 ("number") ("version") ("note") ("organization") ("publisher") 653 ("number") ("version") ("note") ("organization") ("publisher")
612 ("location") ("addendum") ("pubstate") ("doi") ("eprint") ("eprintclass") 654 ("location" nil nil 2) ("address" nil nil -2)
613 ("eprinttype") ("url") ("urldate"))) 655 ("addendum") ("pubstate") ("doi")
656 ("eprint") ("eprintclass" nil nil 4) ("primaryclass" nil nil -4)
657 ("eprinttype" nil nil 5) ("archiveprefix" nil nil -5)
658 ("url") ("urldate")))
614 ("Manual" "Technical Manual" 659 ("Manual" "Technical Manual"
615 (("author" nil nil 0) ("editor" nil nil 0) ("title") 660 (("author" nil nil 0) ("editor" nil nil 0) ("title")
616 ("year" nil nil 1) ("date" nil nil 1)) 661 ("date" nil nil 1) ("year" nil nil -1))
617 nil 662 nil
618 (("subtitle") ("titleaddon") ("language") ("edition") 663 (("subtitle") ("titleaddon") ("language") ("edition")
619 ("type") ("series") ("number") ("version") ("note") 664 ("type") ("series") ("number") ("version") ("note")
620 ("organization") ("publisher") ("location") ("isbn") ("eid") ("chapter") 665 ("organization") ("publisher")
621 ("pages") ("pagetotal") ("addendum") ("pubstate") 666 ("location" nil nil 2) ("address" nil nil -2)
622 ("doi") ("eprint") ("eprintclass") ("eprinttype") ("url") ("urldate"))) 667 ("isbn") ("eid") ("chapter")
668 ("pages") ("pagetotal") ("addendum") ("pubstate") ("doi")
669 ("eprint") ("eprintclass" nil nil 4) ("primaryclass" nil nil -4)
670 ("eprinttype" nil nil 5) ("archiveprefix" nil nil -5)
671 ("url") ("urldate")))
623 ("Misc" "Miscellaneous" 672 ("Misc" "Miscellaneous"
624 (("author" nil nil 0) ("editor" nil nil 0) ("title") 673 (("author" nil nil 0) ("editor" nil nil 0) ("title")
625 ("year" nil nil 1) ("date" nil nil 1)) 674 ("date" nil nil 1) ("year" nil nil -1))
626 nil 675 nil
627 (("subtitle") ("titleaddon") ("language") ("howpublished") ("type") 676 (("subtitle") ("titleaddon") ("language") ("howpublished") ("type")
628 ("version") ("note") ("organization") ("location") 677 ("version") ("note") ("organization")
629 ("month") ("addendum") ("pubstate") 678 ("location" nil nil 2) ("address" nil nil -2)
630 ("doi") ("eprint") ("eprintclass") ("eprinttype") ("url") ("urldate"))) 679 ("month") ("addendum") ("pubstate") ("doi")
680 ("eprint") ("eprintclass" nil nil 4) ("primaryclass" nil nil -4)
681 ("eprinttype" nil nil 5) ("archiveprefix" nil nil -5)
682 ("url") ("urldate")))
631 ("Online" "Online Resource" 683 ("Online" "Online Resource"
632 (("author" nil nil 0) ("editor" nil nil 0) ("title") 684 (("author" nil nil 0) ("editor" nil nil 0) ("title")
633 ("year" nil nil 1) ("date" nil nil 1) 685 ("date" nil nil 1) ("year" nil nil -1)
634 ("doi" nil nil 2) ("eprint" nil nil 2) ("url" nil nil 2)) 686 ("doi" nil nil 2) ("eprint" nil nil 2) ("url" nil nil 2))
635 nil 687 nil
636 (("subtitle") ("titleaddon") ("language") ("version") ("note") 688 (("subtitle") ("titleaddon") ("language") ("version") ("note")
637 ("organization") ("month") ("addendum") 689 ("organization") ("month") ("addendum")
638 ("pubstate") ("eprintclass") ("eprinttype") ("urldate"))) 690 ("pubstate") ("eprintclass" nil nil 4) ("primaryclass" nil nil -4)
691 ("eprinttype" nil nil 5) ("archiveprefix" nil nil -5) ("urldate")))
639 ("Patent" "Patent" 692 ("Patent" "Patent"
640 (("author") ("title") ("number") ("year" nil nil 0) ("date" nil nil 0)) 693 (("author") ("title") ("number")
694 ("date" nil nil 1) ("year" nil nil -1))
641 nil 695 nil
642 (("holder") ("subtitle") ("titleaddon") ("type") ("version") ("location") 696 (("holder") ("subtitle") ("titleaddon") ("type") ("version")
643 ("note") ("month") ("addendum") ("pubstate") 697 ("location" nil nil 2) ("address" nil nil -2)
644 ("doi") ("eprint") ("eprintclass") ("eprinttype") ("url") ("urldate"))) 698 ("note") ("month") ("addendum") ("pubstate") ("doi")
699 ("eprint") ("eprintclass" nil nil 4) ("primaryclass" nil nil -4)
700 ("eprinttype" nil nil 5) ("archiveprefix" nil nil -5)
701 ("url") ("urldate")))
645 ("Periodical" "Complete Issue of a Periodical" 702 ("Periodical" "Complete Issue of a Periodical"
646 (("editor") ("title") ("year" nil nil 0) ("date" nil nil 0)) 703 (("editor") ("title")
704 ("date" nil nil 1) ("year" nil nil -1))
647 nil 705 nil
648 (("editora") ("editorb") ("editorc") ("subtitle") ("titleaddon") 706 (("editora") ("editorb") ("editorc") ("subtitle") ("titleaddon")
649 ("issuetitle") ("issuesubtitle") ("issuetitleaddon") ("language") 707 ("issuetitle") ("issuesubtitle") ("issuetitleaddon") ("language")
650 ("series") ("volume") ("number") ("issue") 708 ("series") ("volume") ("number") ("issue")
651 ("month") ("note") ("issn") ("addendum") ("pubstate") 709 ("month") ("note") ("issn") ("addendum") ("pubstate") ("doi")
652 ("doi") ("eprint") ("eprintclass") ("eprinttype") ("url") ("urldate"))) 710 ("eprint") ("eprintclass" nil nil 4) ("primaryclass" nil nil -4)
711 ("eprinttype" nil nil 5) ("archiveprefix" nil nil -5)
712 ("url") ("urldate")))
653 ("SuppPeriodical" "Supplemental Material in a Periodical" ; same as @article 713 ("SuppPeriodical" "Supplemental Material in a Periodical" ; same as @article
654 (("author") ("title") ("journaltitle") 714 (("author") ("title")
655 ("year" nil nil 0) ("date" nil nil 0)) 715 ("journaltitle" nil nil 3) ("journal" nil nil -3)
716 ("date" nil nil 1) ("year" nil nil -1))
656 nil 717 nil
657 (("translator") ("annotator") ("commentator") ("subtitle") ("titleaddon") 718 (("translator") ("annotator") ("commentator") ("subtitle") ("titleaddon")
658 ("editor") ("editora") ("editorb") ("editorc") ("journalsubtitle") 719 ("editor") ("editora") ("editorb") ("editorc") ("journalsubtitle")
659 ("journaltitleaddon") ("issuetitle") ("issuesubtitle") ("issuetitleaddon") 720 ("journaltitleaddon") ("issuetitle") ("issuesubtitle") ("issuetitleaddon")
660 ("language") ("origlanguage") ("series") ("volume") ("number") ("eid") 721 ("language") ("origlanguage") ("series") ("volume") ("number") ("eid")
661 ("issue") ("month") ("pages") ("version") ("note") ("issn") 722 ("issue") ("month") ("pages") ("version") ("note") ("issn")
662 ("addendum") ("pubstate") ("doi") ("eprint") ("eprintclass") 723 ("addendum") ("pubstate") ("doi")
663 ("eprinttype") ("url") ("urldate"))) 724 ("eprint") ("eprintclass" nil nil 4) ("primaryclass" nil nil -4)
725 ("eprinttype" nil nil 5) ("archiveprefix" nil nil -5)
726 ("url") ("urldate")))
664 ("Proceedings" "Single-Volume Conference Proceedings" 727 ("Proceedings" "Single-Volume Conference Proceedings"
665 (("title") ("year" nil nil 0) ("date" nil nil 0)) 728 (("title") ("date" nil nil 1) ("year" nil nil -1))
666 nil 729 nil
667 (("editor") ("subtitle") ("titleaddon") ("maintitle") ("mainsubtitle") 730 (("editor") ("subtitle") ("titleaddon") ("maintitle") ("mainsubtitle")
668 ("maintitleaddon") ("eventtitle") ("eventtitleaddon") ("eventdate") 731 ("maintitleaddon") ("eventtitle") ("eventtitleaddon") ("eventdate")
669 ("venue") ("language") ("volume") ("part") ("volumes") ("series") 732 ("venue") ("language") ("volume") ("part") ("volumes") ("series")
670 ("number") ("note") ("organization") ("publisher") ("location") ("month") 733 ("number") ("note") ("organization") ("publisher")
734 ("location" nil nil 2) ("address" nil nil -2) ("month")
671 ("isbn") ("eid") ("chapter") ("pages") ("pagetotal") ("addendum") 735 ("isbn") ("eid") ("chapter") ("pages") ("pagetotal") ("addendum")
672 ("pubstate") ("doi") ("eprint") ("eprintclass") ("eprinttype") ("url") 736 ("pubstate") ("doi")
673 ("urldate"))) 737 ("eprint") ("eprintclass" nil nil 4) ("primaryclass" nil nil -4)
738 ("eprinttype" nil nil 5) ("archiveprefix" nil nil -5)
739 ("url") ("urldate")))
674 ("MVProceedings" "Multi-Volume Conference Proceedings" 740 ("MVProceedings" "Multi-Volume Conference Proceedings"
675 (("title") ("year" nil nil 0) ("date" nil nil 0)) 741 (("title") ("date" nil nil 1) ("year" nil nil -1))
676 nil 742 nil
677 (("editor") ("subtitle") ("titleaddon") ("eventtitle") ("eventtitleaddon") 743 (("editor") ("subtitle") ("titleaddon") ("eventtitle") ("eventtitleaddon")
678 ("eventdate") ("venue") ("language") ("volumes") ("series") ("number") 744 ("eventdate") ("venue") ("language") ("volumes") ("series") ("number")
679 ("note") ("organization") ("publisher") ("location") ("month") 745 ("note") ("organization") ("publisher")
680 ("isbn") ("pagetotal") ("addendum") ("pubstate") 746 ("location" nil nil 2) ("address" nil nil -2) ("month")
681 ("doi") ("eprint") ("eprintclass") ("eprinttype") ("url") ("urldate"))) 747 ("isbn") ("pagetotal") ("addendum") ("pubstate") ("doi")
748 ("eprint") ("eprintclass" nil nil 4) ("primaryclass" nil nil -4)
749 ("eprinttype" nil nil 5) ("archiveprefix" nil nil -5)
750 ("url") ("urldate")))
682 ("InProceedings" "Article in Conference Proceedings" 751 ("InProceedings" "Article in Conference Proceedings"
683 (("author") ("title") ("year" nil nil 0) ("date" nil nil 0)) 752 (("author") ("title")
753 ("date" nil nil 1) ("year" nil nil -1))
684 (("booktitle")) 754 (("booktitle"))
685 (("editor") ("subtitle") ("titleaddon") ("maintitle") ("mainsubtitle") 755 (("editor") ("subtitle") ("titleaddon") ("maintitle") ("mainsubtitle")
686 ("maintitleaddon") ("booksubtitle") ("booktitleaddon") 756 ("maintitleaddon") ("booksubtitle") ("booktitleaddon")
687 ("eventtitle") ("eventtitleaddon") ("eventdate") ("venue") ("language") 757 ("eventtitle") ("eventtitleaddon") ("eventdate") ("venue") ("language")
688 ("volume") ("part") ("volumes") ("series") ("number") ("note") 758 ("volume") ("part") ("volumes") ("series") ("number") ("note")
689 ("organization") ("publisher") ("location") ("month") ("isbn") ("eid") 759 ("organization") ("publisher")
690 ("chapter") ("pages") ("addendum") ("pubstate") 760 ("location" nil nil 2) ("address" nil nil -2) ("month") ("isbn") ("eid")
691 ("doi") ("eprint") ("eprintclass") ("eprinttype") ("url") ("urldate"))) 761 ("chapter") ("pages") ("addendum") ("pubstate") ("doi")
762 ("eprint") ("eprintclass" nil nil 4) ("primaryclass" nil nil -4)
763 ("eprinttype" nil nil 5) ("archiveprefix" nil nil -5)
764 ("url") ("urldate")))
692 ("Reference" "Single-Volume Work of Reference" ; same as @collection 765 ("Reference" "Single-Volume Work of Reference" ; same as @collection
693 (("editor") ("title") ("year" nil nil 0) ("date" nil nil 0)) 766 (("editor") ("title") ("date" nil nil 1) ("year" nil nil -1))
694 nil 767 nil
695 (("editora") ("editorb") ("editorc") ("translator") ("annotator") 768 (("editora") ("editorb") ("editorc") ("translator") ("annotator")
696 ("commentator") ("introduction") ("foreword") ("afterword") 769 ("commentator") ("introduction") ("foreword") ("afterword")
697 ("subtitle") ("titleaddon") ("maintitle") ("mainsubtitle") 770 ("subtitle") ("titleaddon") ("maintitle") ("mainsubtitle")
698 ("maintitleaddon") ("language") ("origlanguage") ("volume") 771 ("maintitleaddon") ("language") ("origlanguage") ("volume")
699 ("part") ("edition") ("volumes") ("series") ("number") ("note") 772 ("part") ("edition") ("volumes") ("series") ("number") ("note")
700 ("publisher") ("location") ("isbn") ("eid") ("chapter") ("pages") 773 ("publisher") ("location" nil nil 2) ("address" nil nil -2)
701 ("pagetotal") ("addendum") ("pubstate") ("doi") ("eprint") ("eprintclass") 774 ("isbn") ("eid") ("chapter") ("pages")
702 ("eprinttype") ("url") ("urldate"))) 775 ("pagetotal") ("addendum") ("pubstate") ("doi")
776 ("eprint") ("eprintclass" nil nil 4) ("primaryclass" nil nil -4)
777 ("eprinttype" nil nil 5) ("archiveprefix" nil nil -5)
778 ("url") ("urldate")))
703 ("MVReference" "Multi-Volume Work of Reference" ; same as @mvcollection 779 ("MVReference" "Multi-Volume Work of Reference" ; same as @mvcollection
704 (("editor") ("title") ("year" nil nil 0) ("date" nil nil 0)) 780 (("editor") ("title") ("date" nil nil 1) ("year" nil nil -1))
705 nil 781 nil
706 (("editora") ("editorb") ("editorc") ("translator") ("annotator") 782 (("editora") ("editorb") ("editorc") ("translator") ("annotator")
707 ("commentator") ("introduction") ("foreword") ("afterword") 783 ("commentator") ("introduction") ("foreword") ("afterword")
708 ("subtitle") ("titleaddon") ("language") ("origlanguage") ("edition") 784 ("subtitle") ("titleaddon") ("language") ("origlanguage") ("edition")
709 ("volumes") ("series") ("number") ("note") ("publisher") 785 ("volumes") ("series") ("number") ("note") ("publisher")
710 ("location") ("isbn") ("pagetotal") ("addendum") ("pubstate") ("doi") 786 ("location" nil nil 2) ("address" nil nil -2)
711 ("eprint") ("eprintclass") ("eprinttype") ("url") ("urldate"))) 787 ("isbn") ("pagetotal") ("addendum") ("pubstate") ("doi")
788 ("eprint") ("eprintclass" nil nil 4) ("primaryclass" nil nil -4)
789 ("eprinttype" nil nil 5) ("archiveprefix" nil nil -5)
790 ("url") ("urldate")))
712 ("InReference" "Article in a Work of Reference" ; same as @incollection 791 ("InReference" "Article in a Work of Reference" ; same as @incollection
713 (("author") ("title") ("year" nil nil 0) ("date" nil nil 0)) 792 (("author") ("title") ("date" nil nil 1) ("year" nil nil -1))
714 (("booktitle")) 793 (("booktitle"))
715 (("editor") ("editora") ("editorb") ("editorc") ("translator") 794 (("editor") ("editora") ("editorb") ("editorc") ("translator")
716 ("annotator") ("commentator") ("introduction") ("foreword") ("afterword") 795 ("annotator") ("commentator") ("introduction") ("foreword") ("afterword")
717 ("subtitle") ("titleaddon") ("maintitle") ("mainsubtitle") 796 ("subtitle") ("titleaddon") ("maintitle") ("mainsubtitle")
718 ("maintitleaddon") ("booksubtitle") ("booktitleaddon") 797 ("maintitleaddon") ("booksubtitle") ("booktitleaddon")
719 ("language") ("origlanguage") ("volume") ("part") ("edition") 798 ("language") ("origlanguage") ("volume") ("part") ("edition")
720 ("volumes") ("series") ("number") ("note") ("publisher") ("location") 799 ("volumes") ("series") ("number") ("note") ("publisher")
800 ("location" nil nil 2) ("address" nil nil -2)
721 ("isbn") ("eid") ("chapter") ("pages") ("addendum") ("pubstate") ("doi") 801 ("isbn") ("eid") ("chapter") ("pages") ("addendum") ("pubstate") ("doi")
722 ("eprint") ("eprintclass") ("eprinttype") ("url") ("urldate"))) 802 ("eprint") ("eprintclass" nil nil 4) ("primaryclass" nil nil -4)
803 ("eprinttype" nil nil 5) ("archiveprefix" nil nil -5)
804 ("url") ("urldate")))
723 ("Report" "Technical or Research Report" 805 ("Report" "Technical or Research Report"
724 (("author") ("title") ("type") ("institution") 806 (("author") ("title") ("type")
725 ("year" nil nil 0) ("date" nil nil 0)) 807 ("institution" nil nil 6) ("school" nil nil -6)
808 ("date" nil nil 1) ("year" nil nil -1))
726 nil 809 nil
727 (("subtitle") ("titleaddon") ("language") ("number") ("version") ("note") 810 (("subtitle") ("titleaddon") ("language") ("number") ("version") ("note")
728 ("location") ("month") ("isrn") ("eid") ("chapter") ("pages") 811 ("location" nil nil 2) ("address" nil nil -2)
729 ("pagetotal") ("addendum") ("pubstate") 812 ("month") ("isrn") ("eid") ("chapter") ("pages")
730 ("doi") ("eprint") ("eprintclass") ("eprinttype") ("url") ("urldate"))) 813 ("pagetotal") ("addendum") ("pubstate") ("doi")
814 ("eprint") ("eprintclass" nil nil 4) ("primaryclass" nil nil -4)
815 ("eprinttype" nil nil 5) ("archiveprefix" nil nil -5)
816 ("url") ("urldate")))
731 ("Software" "Computer Software" ; Same as @misc. 817 ("Software" "Computer Software" ; Same as @misc.
732 (("author" nil nil 0) ("editor" nil nil 0) ("title") 818 (("author" nil nil 0) ("editor" nil nil 0) ("title")
733 ("year" nil nil 1) ("date" nil nil 1)) 819 ("date" nil nil 1) ("year" nil nil -1))
734 nil 820 nil
735 (("subtitle") ("titleaddon") ("language") ("howpublished") ("type") 821 (("subtitle") ("titleaddon") ("language") ("howpublished") ("type")
736 ("version") ("note") ("organization") ("location") 822 ("version") ("note") ("organization")
737 ("month") ("addendum") ("pubstate") 823 ("location" nil nil 2) ("address" nil nil -2)
738 ("doi") ("eprint") ("eprintclass") ("eprinttype") ("url") ("urldate"))) 824 ("month") ("addendum") ("pubstate") ("doi")
825 ("eprint") ("eprintclass" nil nil 4) ("primaryclass" nil nil -4)
826 ("eprinttype" nil nil 5) ("archiveprefix" nil nil -5)
827 ("url") ("urldate")))
739 ("Thesis" "PhD or Master's Thesis" 828 ("Thesis" "PhD or Master's Thesis"
740 (("author") ("title") ("type") ("institution") 829 (("author") ("title") ("type")
741 ("year" nil nil 0) ("date" nil nil 0)) 830 ("institution" nil nil 6) ("school" nil nil -6)
831 ("date" nil nil 1) ("year" nil nil -1))
742 nil 832 nil
743 (("subtitle") ("titleaddon") ("language") ("note") ("location") 833 (("subtitle") ("titleaddon") ("language") ("note")
834 ("location" nil nil 2) ("address" nil nil -2)
744 ("month") ("isbn") ("eid") ("chapter") ("pages") ("pagetotal") 835 ("month") ("isbn") ("eid") ("chapter") ("pages") ("pagetotal")
745 ("addendum") ("pubstate") 836 ("addendum") ("pubstate") ("doi")
746 ("doi") ("eprint") ("eprintclass") ("eprinttype") ("url") ("urldate"))) 837 ("eprint") ("eprintclass" nil nil 4) ("primaryclass" nil nil -4)
838 ("eprinttype" nil nil 5) ("archiveprefix" nil nil -5)
839 ("url") ("urldate")))
747 ("Unpublished" "Unpublished" 840 ("Unpublished" "Unpublished"
748 (("author") ("title") ("year" nil nil 0) ("date" nil nil 0)) 841 (("author") ("title") ("date" nil nil 1) ("year" nil nil -1))
749 nil 842 nil
750 (("subtitle") ("titleaddon") ("type") ("eventtitle") ("eventtitleaddon") 843 (("subtitle") ("titleaddon") ("type") ("eventtitle") ("eventtitleaddon")
751 ("eventdate") ("venue") ("language") ("howpublished") ("note") 844 ("eventdate") ("venue") ("language") ("howpublished") ("note")
752 ("location") ("isbn") ("month") ("addendum") ("pubstate") ("doi") 845 ("location" nil nil 2) ("address" nil nil -2)
753 ("eprint") ("eprintclass") ("eprinttype") ("url") ("urldate")))) 846 ("isbn") ("month") ("addendum") ("pubstate") ("doi")
847 ("eprint") ("eprintclass" nil nil 4) ("primaryclass" nil nil -4)
848 ("eprinttype" nil nil 5) ("archiveprefix" nil nil -5)
849 ("url") ("urldate"))))
754 "Alist of biblatex entry types and their associated fields. 850 "Alist of biblatex entry types and their associated fields.
755It has the same format as `bibtex-BibTeX-entry-alist'." 851It has the same format as `bibtex-BibTeX-entry-alist'."
756 :group 'bibtex 852 :group 'bibtex
@@ -2328,10 +2424,6 @@ Optional arg COMMA is as in `bibtex-enclosing-field'."
2328 "Add NEWELT to the list stored in VEC at index IDX." 2424 "Add NEWELT to the list stored in VEC at index IDX."
2329 (aset vec idx (cons newelt (aref vec idx)))) 2425 (aset vec idx (cons newelt (aref vec idx))))
2330 2426
2331(defsubst bibtex-vec-incr (vec idx)
2332 "Increment by 1 the counter which is stored in VEC at index IDX."
2333 (aset vec idx (1+ (aref vec idx))))
2334
2335(defun bibtex-format-entry () 2427(defun bibtex-format-entry ()
2336 "Helper function for `bibtex-clean-entry'. 2428 "Helper function for `bibtex-clean-entry'.
2337Formats current entry according to variable `bibtex-entry-format'." 2429Formats current entry according to variable `bibtex-entry-format'."
@@ -2352,7 +2444,8 @@ Formats current entry according to variable `bibtex-entry-format'."
2352 strings sort-fields) 2444 strings sort-fields)
2353 bibtex-entry-format)) 2445 bibtex-entry-format))
2354 (left-delim-re (regexp-quote (bibtex-field-left-delimiter))) 2446 (left-delim-re (regexp-quote (bibtex-field-left-delimiter)))
2355 bounds crossref-key req-field-list default-field-list field-list 2447 bounds crossref-key req-field-list opt-field-list
2448 default-field-list field-list
2356 num-alt alt-fields idx error-field-name) 2449 num-alt alt-fields idx error-field-name)
2357 (unwind-protect 2450 (unwind-protect
2358 ;; formatting (undone if error occurs) 2451 ;; formatting (undone if error occurs)
@@ -2399,16 +2492,22 @@ Formats current entry according to variable `bibtex-entry-format'."
2399 2492
2400 ;; list of required fields appropriate for an entry with 2493 ;; list of required fields appropriate for an entry with
2401 ;; or without crossref key. 2494 ;; or without crossref key.
2402 (setq req-field-list (if crossref-key (nth 2 entry-list) 2495 (setq req-field-list (append (nth 2 entry-list)
2403 (append (nth 2 entry-list) (nth 3 entry-list))) 2496 (unless crossref-key
2497 (nth 3 entry-list)))
2498 opt-field-list (append (if crossref-key
2499 (nth 3 entry-list))
2500 (nth 4 entry-list)
2501 bibtex-user-optional-fields)
2404 ;; default list of fields that may appear in this entry 2502 ;; default list of fields that may appear in this entry
2405 default-field-list (append (nth 2 entry-list) (nth 3 entry-list) 2503 default-field-list (append req-field-list opt-field-list)
2406 (nth 4 entry-list) 2504 ;; number of ALT fields we may find
2407 bibtex-user-optional-fields) 2505 num-alt (let ((n 0))
2408 ;; number of ALT fields we expect to find 2506 (mapc (lambda (x)
2409 num-alt (length (delq nil (delete-dups 2507 (if (nth 3 x)
2410 (mapcar (lambda (x) (nth 3 x)) 2508 (setq n (max n (abs (nth 3 x))))))
2411 req-field-list)))) 2509 default-field-list)
2510 (1+ n))
2412 ;; ALT fields of respective groups 2511 ;; ALT fields of respective groups
2413 alt-fields (make-vector num-alt nil)) 2512 alt-fields (make-vector num-alt nil))
2414 2513
@@ -2447,8 +2546,9 @@ Formats current entry according to variable `bibtex-entry-format'."
2447 (if opt-alt (setq field-name (substring field-name 3))) 2546 (if opt-alt (setq field-name (substring field-name 3)))
2448 2547
2449 ;; keep track of alternatives 2548 ;; keep track of alternatives
2450 (if (setq idx (nth 3 (assoc-string field-name req-field-list t))) 2549 (if (and (not empty-field)
2451 (bibtex-vec-push alt-fields idx field-name)) 2550 (setq idx (nth 3 (assoc-string field-name default-field-list t))))
2551 (bibtex-vec-push alt-fields (abs idx) field-name))
2452 2552
2453 (if (memq 'opts-or-alts format) 2553 (if (memq 'opts-or-alts format)
2454 ;; delete empty optional and alternative fields 2554 ;; delete empty optional and alternative fields
@@ -2597,34 +2697,34 @@ Formats current entry according to variable `bibtex-entry-format'."
2597 2697
2598 ;; check whether all required fields are present 2698 ;; check whether all required fields are present
2599 (when (memq 'required-fields format) 2699 (when (memq 'required-fields format)
2600 (let ((alt-expect (make-vector num-alt nil)) 2700 (let ((alt-expect (make-vector num-alt nil)))
2601 (alt-found (make-vector num-alt 0)))
2602 (dolist (fname req-field-list) 2701 (dolist (fname req-field-list)
2603 (cond ((setq idx (nth 3 fname)) 2702 (cond ((nth 3 fname)
2604 ;; t if field has alternative flag 2703 ;; t if required field has alternative flag
2605 (bibtex-vec-push alt-expect idx (car fname)) 2704 (setq idx (abs (nth 3 fname)))
2606 (if (member-ignore-case (car fname) field-list) 2705 (bibtex-vec-push alt-expect idx (car fname)))
2607 (bibtex-vec-incr alt-found idx)))
2608 ((not (member-ignore-case (car fname) field-list)) 2706 ((not (member-ignore-case (car fname) field-list))
2609 ;; If we use the crossref field, a required field 2707 (setq error-field-name (car fname))
2610 ;; can have the OPT prefix. So if it was empty,
2611 ;; we have deleted by now. Nonetheless we can
2612 ;; move point on this empty field.
2613 (setq error-field-name (car fname))
2614 (user-error "Mandatory field `%s' is missing" 2708 (user-error "Mandatory field `%s' is missing"
2615 (car fname))))) 2709 (car fname)))))
2616 (dotimes (idx num-alt) 2710 (dotimes (idx num-alt)
2617 (cond ((= 0 (aref alt-found idx)) 2711 (cond ((and (aref alt-expect idx)
2712 (not (aref alt-fields idx)))
2618 (setq error-field-name 2713 (setq error-field-name
2619 (car (last (aref alt-fields idx)))) 2714 (car (last (aref alt-fields idx))))
2620 (user-error "Alternative mandatory field `%s' is missing" 2715 (user-error "Alternative mandatory fields `%s' are missing"
2621 (aref alt-expect idx))) 2716 (mapconcat 'identity
2622 ((< 1 (aref alt-found idx)) 2717 (reverse
2718 (aref alt-expect idx))
2719 ", ")))
2720 ((nth 1 (aref alt-fields idx))
2623 (setq error-field-name 2721 (setq error-field-name
2624 (car (last (aref alt-fields idx)))) 2722 (car (last (aref alt-fields idx))))
2625 (user-error "Alternative fields `%s' are defined %s times" 2723 (user-error "Fields `%s' are alternatives"
2626 (aref alt-expect idx) 2724 (mapconcat 'identity
2627 (length (aref alt-fields idx)))))))) 2725 (reverse
2726 (aref alt-fields idx))
2727 ", ")))))))
2628 2728
2629 ;; update comma after last field 2729 ;; update comma after last field
2630 (if (memq 'last-comma format) 2730 (if (memq 'last-comma format)
@@ -3653,8 +3753,7 @@ and `bibtex-user-optional-fields'."
3653 (setq required (append (nth 2 e-list) (nth 3 e-list)) 3753 (setq required (append (nth 2 e-list) (nth 3 e-list))
3654 optional (nth 4 e-list))) 3754 optional (nth 4 e-list)))
3655 (if bibtex-include-OPTkey 3755 (if bibtex-include-OPTkey
3656 (push (list "key" 3756 (push (list "key" "Used as label with certain BibTeX styles"
3657 "Crossref key"
3658 (if (or (stringp bibtex-include-OPTkey) 3757 (if (or (stringp bibtex-include-OPTkey)
3659 (functionp bibtex-include-OPTkey)) 3758 (functionp bibtex-include-OPTkey))
3660 bibtex-include-OPTkey)) 3759 bibtex-include-OPTkey))
@@ -3663,7 +3762,41 @@ and `bibtex-user-optional-fields'."
3663 (push '("crossref" "Reference key of the cross-referenced entry") 3762 (push '("crossref" "Reference key of the cross-referenced entry")
3664 optional)) 3763 optional))
3665 (setq optional (append optional bibtex-user-optional-fields)) 3764 (setq optional (append optional bibtex-user-optional-fields))
3666 (cons required optional))) 3765 (cons (bibtex--skip-field-aliases required)
3766 (bibtex--skip-field-aliases optional))))
3767
3768(defun bibtex--skip-field-aliases (list)
3769 "Skip fields in LIST that are aliases, return the shortened list.
3770Aliases are fields for which the element ALTERNATIVE is a negative number,
3771see `bibtex-BibTeX-entry-alist'. The shortened field list is used
3772for the templates of `bibtex-entry', whereas entry validation performed by
3773`bibtex-format-entry' uses the full list of fields for an entry."
3774 ;; FIXME: `bibtex-entry' and `bibtex-format-entry' handle aliases
3775 ;; under the hood in a manner that is largely invisible to users.
3776 ;; If instead one wanted to display the aliases as alternatives
3777 ;; in the usual way, field names may get both the ALT and the OPT prefix.
3778 ;; That gets rather clumsy. Also, the code currently assumes that
3779 ;; field names have either the ALT or the OPT prefix, but not both.
3780 ;; Are there scenarios when it would be useful to display both?
3781 (let (alt-list new-list)
3782 (dolist (elt list) ; identify alternatives
3783 (if (and (nth 3 elt)
3784 (<= 0 (nth 3 elt)))
3785 (push (nth 3 elt) alt-list)))
3786 (setq alt-list (sort alt-list '<))
3787 ;; Skip aliases. If ELT is marked as "proper alternative", but all
3788 ;; alternatives for field ELT are aliases, we do not label ELT
3789 ;; as an alternative either.
3790 (dolist (elt list)
3791 (let ((alt (nth 3 elt)))
3792 (if alt
3793 (if (<= 0 alt)
3794 (push (if (eq alt (cadr (memq alt alt-list)))
3795 elt ; ELT has proper alternatives
3796 (butlast elt)) ; alternatives of ELT are alias
3797 new-list))
3798 (push elt new-list))))
3799 (reverse new-list)))
3667 3800
3668(defun bibtex-entry (entry-type) 3801(defun bibtex-entry (entry-type)
3669 "Insert a template for a BibTeX entry of type ENTRY-TYPE. 3802 "Insert a template for a BibTeX entry of type ENTRY-TYPE.
@@ -4399,12 +4532,19 @@ Return t if test was successful, nil otherwise."
4399 (entry-list (assoc-string (bibtex-type-in-head) 4532 (entry-list (assoc-string (bibtex-type-in-head)
4400 bibtex-entry-alist t)) 4533 bibtex-entry-alist t))
4401 (crossref (bibtex-search-forward-field "crossref" end)) 4534 (crossref (bibtex-search-forward-field "crossref" end))
4402 (req (if crossref (copy-sequence (nth 2 entry-list)) 4535 (req (append (nth 2 entry-list)
4403 (append (nth 2 entry-list) 4536 (unless crossref
4404 (copy-sequence (nth 3 entry-list))))) 4537 (copy-sequence (nth 3 entry-list)))))
4405 (num-alt (length (delq nil (delete-dups 4538 (opt (append (if crossref (nth 3 entry-list))
4406 (mapcar (lambda (x) (nth 3 x)) 4539 (nth 4 entry-list)
4407 req))))) 4540 bibtex-user-optional-fields))
4541 (default (append req opt))
4542 (num-alt (let ((n 0))
4543 (mapc (lambda (x)
4544 (if (nth 3 x)
4545 (setq n (max n (abs (nth 3 x))))))
4546 default)
4547 (1+ n)))
4408 (alt-fields (make-vector num-alt nil)) 4548 (alt-fields (make-vector num-alt nil))
4409 bounds field idx) 4549 bounds field idx)
4410 (while (setq bounds (bibtex-parse-field)) 4550 (while (setq bounds (bibtex-parse-field))
@@ -4419,7 +4559,7 @@ Return t if test was successful, nil otherwise."
4419 (push (cons (bibtex-current-line) 4559 (push (cons (bibtex-current-line)
4420 "Questionable month field") 4560 "Questionable month field")
4421 error-list)) 4561 error-list))
4422 (setq field (assoc-string field-name req t) 4562 (setq field (assoc-string field-name default t)
4423 req (delete field req)) 4563 req (delete field req))
4424 (if (setq idx (nth 3 field)) 4564 (if (setq idx (nth 3 field))
4425 (if (aref alt-fields idx) 4565 (if (aref alt-fields idx)
@@ -4438,12 +4578,13 @@ Return t if test was successful, nil otherwise."
4438 (car field))) 4578 (car field)))
4439 error-list))) 4579 error-list)))
4440 (dotimes (idx num-alt) 4580 (dotimes (idx num-alt)
4441 (unless (aref alt-fields idx) 4581 (if (and (aref alt-expect idx)
4442 (push (cons beg-line 4582 (not (aref alt-fields idx)))
4443 (format-message 4583 (push (cons beg-line
4444 "Alternative fields `%s' missing" 4584 (format-message
4445 (aref alt-expect idx))) 4585 "Alternative fields `%s' missing"
4446 error-list)))))))) 4586 (aref alt-expect idx)))
4587 error-list))))))))
4447 (bibtex-progress-message 'done))))) 4588 (bibtex-progress-message 'done)))))
4448 4589
4449 (if error-list 4590 (if error-list