aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2004-12-05 16:07:39 +0000
committerStefan Monnier2004-12-05 16:07:39 +0000
commitd10e87a203579f74df86fcf839148993603c7346 (patch)
treee84cef6744d0296ab4389124e8215be1b5e0abb6
parent44240c376d5f7972a91090e4a4d64d7fefb4270f (diff)
downloademacs-d10e87a203579f74df86fcf839148993603c7346.tar.gz
emacs-d10e87a203579f74df86fcf839148993603c7346.zip
(bibtex-font-lock-url-regexp):
Use delete-dups when calculating the initial value. (bibtex-autokey-get-title): Use <=. (bibtex-goto-line): New function. (bibtex-reposition-window): Use line numbers instead of point positions. Use window-body-height. (bibtex-find-crossref): Use bibtex-reposition-window. (bibtex-find-entry): Use bibtex-reposition-window. Always return position of entry if key is found or nil if not found.
-rw-r--r--lisp/ChangeLog12
-rw-r--r--lisp/textmodes/bibtex.el188
2 files changed, 117 insertions, 83 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 098342c9bcb..6afd04befda 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,15 @@
12004-12-05 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
2
3 * textmodes/bibtex.el (bibtex-font-lock-url-regexp):
4 Use delete-dups when calculating the initial value.
5 (bibtex-autokey-get-title): Use <=.
6 (bibtex-goto-line): New function.
7 (bibtex-reposition-window): Use line numbers instead of point
8 positions. Use window-body-height.
9 (bibtex-find-crossref): Use bibtex-reposition-window.
10 (bibtex-find-entry): Use bibtex-reposition-window. Always return
11 position of entry if key is found or nil if not found.
12
12004-12-05 Luc Teirlinck <teirllm@auburn.edu> 132004-12-05 Luc Teirlinck <teirllm@auburn.edu>
2 14
3 * cus-edit.el (custom-file): Escape double-quotes in docstring. 15 * cus-edit.el (custom-file): Escape double-quotes in docstring.
diff --git a/lisp/textmodes/bibtex.el b/lisp/textmodes/bibtex.el
index af6fb195c84..c5209456f83 100644
--- a/lisp/textmodes/bibtex.el
+++ b/lisp/textmodes/bibtex.el
@@ -80,9 +80,9 @@
80 :type '(repeat string)) 80 :type '(repeat string))
81 81
82(defcustom bibtex-include-OPTkey t 82(defcustom bibtex-include-OPTkey t
83 "If non-nil, all entries will have an OPTkey field. 83 "If non-nil, all newly created entries get an OPTkey field.
84If this is a string, it will be used as the initial field text. 84If this is a string, use it as the initial field text.
85If this is a function, it will be called to generate the initial field text." 85If this is a function, call it to generate the initial field text."
86 :group 'bibtex 86 :group 'bibtex
87 :type '(choice (const :tag "None" nil) 87 :type '(choice (const :tag "None" nil)
88 (string :tag "Initial text") 88 (string :tag "Initial text")
@@ -113,11 +113,9 @@ required-fields Signal an error if a required field is missing.
113numerical-fields Delete delimiters around numeral fields. 113numerical-fields Delete delimiters around numeral fields.
114page-dashes Change double dashes in page field to single dash 114page-dashes Change double dashes in page field to single dash
115 (for scribe compatibility). 115 (for scribe compatibility).
116inherit-booktitle If entry contains a crossref field and booktitle 116inherit-booktitle If entry contains a crossref field and the booktitle
117 field is empty, it is set to the contents of the 117 field is empty, set the booktitle field to the content
118 title field of the crossreferenced entry. 118 of the title field of the crossreferenced entry.
119 Caution: this will work only if buffer is
120 correctly sorted.
121realign Realign entries, so that field texts and perhaps equal 119realign Realign entries, so that field texts and perhaps equal
122 signs (depending on the value of 120 signs (depending on the value of
123 `bibtex-align-at-equal-sign') begin in the same column. 121 `bibtex-align-at-equal-sign') begin in the same column.
@@ -151,7 +149,7 @@ narrowed to just the entry."
151 :type 'hook) 149 :type 'hook)
152 150
153(defcustom bibtex-maintain-sorted-entries nil 151(defcustom bibtex-maintain-sorted-entries nil
154 "*If non-nil, BibTeX mode maintains all entries in sorted order. 152 "If non-nil, BibTeX mode maintains all entries in sorted order.
155Allowed non-nil values are: 153Allowed non-nil values are:
156plain All entries are sorted alphabetically. 154plain All entries are sorted alphabetically.
157crossref All entries are sorted alphabetically unless an entry has a 155crossref All entries are sorted alphabetically unless an entry has a
@@ -171,7 +169,7 @@ See also `bibtex-sort-ignore-string-entries'."
171 '(("String") 169 '(("String")
172 (catch-all) 170 (catch-all)
173 ("Book" "Proceedings")) 171 ("Book" "Proceedings"))
174 "*List of classes of BibTeX entry names, used for sorting entries. 172 "List of classes of BibTeX entry names, used for sorting entries.
175If value of `bibtex-maintain-sorted-entries' is `entry-class' 173If value of `bibtex-maintain-sorted-entries' is `entry-class'
176entries are ordered according to the classes they belong to. Each 174entries are ordered according to the classes they belong to. Each
177class contains a list of entry names. An entry `catch-all' applies 175class contains a list of entry names. An entry `catch-all' applies
@@ -182,30 +180,30 @@ to all entries not explicitely mentioned."
182 (repeat :tag "Entry name" string)))) 180 (repeat :tag "Entry name" string))))
183 181
184(defcustom bibtex-sort-ignore-string-entries t 182(defcustom bibtex-sort-ignore-string-entries t
185 "*If non-nil, BibTeX @String entries are not sort-significant. 183 "If non-nil, BibTeX @String entries are not sort-significant.
186That means they are ignored when determining ordering of the buffer 184That means they are ignored when determining ordering of the buffer
187\(e.g., sorting, locating alphabetical position for new entries, etc.)." 185\(e.g., sorting, locating alphabetical position for new entries, etc.)."
188 :group 'bibtex 186 :group 'bibtex
189 :type 'boolean) 187 :type 'boolean)
190 188
191(defcustom bibtex-field-kill-ring-max 20 189(defcustom bibtex-field-kill-ring-max 20
192 "*Max length of `bibtex-field-kill-ring' before discarding oldest elements." 190 "Max length of `bibtex-field-kill-ring' before discarding oldest elements."
193 :group 'bibtex 191 :group 'bibtex
194 :type 'integer) 192 :type 'integer)
195 193
196(defcustom bibtex-entry-kill-ring-max 20 194(defcustom bibtex-entry-kill-ring-max 20
197 "*Max length of `bibtex-entry-kill-ring' before discarding oldest elements." 195 "Max length of `bibtex-entry-kill-ring' before discarding oldest elements."
198 :group 'bibtex 196 :group 'bibtex
199 :type 'integer) 197 :type 'integer)
200 198
201(defcustom bibtex-parse-keys-timeout 60 199(defcustom bibtex-parse-keys-timeout 60
202 "*Time interval in seconds for parsing BibTeX buffers during idle time. 200 "Time interval in seconds for parsing BibTeX buffers during idle time.
203Parsing initializes `bibtex-reference-keys' and `bibtex-strings'." 201Parsing initializes `bibtex-reference-keys' and `bibtex-strings'."
204 :group 'bibtex 202 :group 'bibtex
205 :type 'integer) 203 :type 'integer)
206 204
207(defcustom bibtex-parse-keys-fast t 205(defcustom bibtex-parse-keys-fast t
208 "*If non-nil, use fast but simplified algorithm for parsing BibTeX keys. 206 "If non-nil, use fast but simplified algorithm for parsing BibTeX keys.
209If parsing fails, try to set this variable to nil." 207If parsing fails, try to set this variable to nil."
210 :group 'bibtex 208 :group 'bibtex
211 :type 'boolean) 209 :type 'boolean)
@@ -499,7 +497,7 @@ Each element is a pair of strings (ABBREVIATION . EXPANSION)."
499 (string :tag "String expansion")))) 497 (string :tag "String expansion"))))
500 498
501(defcustom bibtex-string-files nil 499(defcustom bibtex-string-files nil
502 "*List of BibTeX files containing string definitions. 500 "List of BibTeX files containing string definitions.
503List elements can be absolute file names or file names relative 501List elements can be absolute file names or file names relative
504to the directories specified in `bibtex-string-file-path'." 502to the directories specified in `bibtex-string-file-path'."
505 :group 'bibtex 503 :group 'bibtex
@@ -521,7 +519,7 @@ check all BibTeX files in this directory. If an element is the symbol
521 "*Colon separated list of paths to search for `bibtex-files'.") 519 "*Colon separated list of paths to search for `bibtex-files'.")
522 520
523(defcustom bibtex-help-message t 521(defcustom bibtex-help-message t
524 "*If non-nil print help messages in the echo area on entering a new field." 522 "If non-nil print help messages in the echo area on entering a new field."
525 :group 'bibtex 523 :group 'bibtex
526 :type 'boolean) 524 :type 'boolean)
527 525
@@ -532,7 +530,7 @@ See `bibtex-generate-autokey' for details."
532 :type 'string) 530 :type 'string)
533 531
534(defcustom bibtex-autokey-names 1 532(defcustom bibtex-autokey-names 1
535 "*Number of names to use for the automatically generated reference key. 533 "Number of names to use for the automatically generated reference key.
536Possibly more names are used according to `bibtex-autokey-names-stretch'. 534Possibly more names are used according to `bibtex-autokey-names-stretch'.
537If this variable is nil, all names are used. 535If this variable is nil, all names are used.
538See `bibtex-generate-autokey' for details." 536See `bibtex-generate-autokey' for details."
@@ -592,7 +590,7 @@ See `bibtex-generate-autokey' for details."
592 (string :tag "New")))) 590 (string :tag "New"))))
593 591
594(defcustom bibtex-autokey-name-case-convert 'downcase 592(defcustom bibtex-autokey-name-case-convert 'downcase
595 "*Function called for each name to perform case conversion. 593 "Function called for each name to perform case conversion.
596See `bibtex-generate-autokey' for details." 594See `bibtex-generate-autokey' for details."
597 :group 'bibtex-autokey 595 :group 'bibtex-autokey
598 :type '(choice (const :tag "Preserve case" identity) 596 :type '(choice (const :tag "Preserve case" identity)
@@ -602,7 +600,7 @@ See `bibtex-generate-autokey' for details."
602 (function :tag "Conversion function"))) 600 (function :tag "Conversion function")))
603 601
604(defcustom bibtex-autokey-name-length 'infty 602(defcustom bibtex-autokey-name-length 'infty
605 "*Number of characters from name to incorporate into key. 603 "Number of characters from name to incorporate into key.
606If this is set to anything but a number, all characters are used. 604If this is set to anything but a number, all characters are used.
607See `bibtex-generate-autokey' for details." 605See `bibtex-generate-autokey' for details."
608 :group 'bibtex-autokey 606 :group 'bibtex-autokey
@@ -610,19 +608,19 @@ See `bibtex-generate-autokey' for details."
610 integer)) 608 integer))
611 609
612(defcustom bibtex-autokey-name-separator "" 610(defcustom bibtex-autokey-name-separator ""
613 "*String that comes between any two names in the key. 611 "String that comes between any two names in the key.
614See `bibtex-generate-autokey' for details." 612See `bibtex-generate-autokey' for details."
615 :group 'bibtex-autokey 613 :group 'bibtex-autokey
616 :type 'string) 614 :type 'string)
617 615
618(defcustom bibtex-autokey-year-length 2 616(defcustom bibtex-autokey-year-length 2
619 "*Number of rightmost digits from the year field to incorporate into key. 617 "Number of rightmost digits from the year field to incorporate into key.
620See `bibtex-generate-autokey' for details." 618See `bibtex-generate-autokey' for details."
621 :group 'bibtex-autokey 619 :group 'bibtex-autokey
622 :type 'integer) 620 :type 'integer)
623 621
624(defcustom bibtex-autokey-use-crossref t 622(defcustom bibtex-autokey-use-crossref t
625 "*If non-nil use fields from crossreferenced entry if necessary. 623 "If non-nil use fields from crossreferenced entry if necessary.
626If this variable is non-nil and some field has no entry, but a 624If this variable is non-nil and some field has no entry, but a
627valid crossref entry, the field from the crossreferenced entry is used. 625valid crossref entry, the field from the crossreferenced entry is used.
628See `bibtex-generate-autokey' for details." 626See `bibtex-generate-autokey' for details."
@@ -630,7 +628,7 @@ See `bibtex-generate-autokey' for details."
630 :type 'boolean) 628 :type 'boolean)
631 629
632(defcustom bibtex-autokey-titlewords 5 630(defcustom bibtex-autokey-titlewords 5
633 "*Number of title words to use for the automatically generated reference key. 631 "Number of title words to use for the automatically generated reference key.
634If this is set to anything but a number, all title words are used. 632If this is set to anything but a number, all title words are used.
635Possibly more words from the title are used according to 633Possibly more words from the title are used according to
636`bibtex-autokey-titlewords-stretch'. 634`bibtex-autokey-titlewords-stretch'.
@@ -646,7 +644,7 @@ Case of the regexps is ignored. See `bibtex-generate-autokey' for details."
646 :type 'regexp) 644 :type 'regexp)
647 645
648(defcustom bibtex-autokey-titlewords-stretch 2 646(defcustom bibtex-autokey-titlewords-stretch 2
649 "*Number of words that can additionally be used from the title. 647 "Number of words that can additionally be used from the title.
650These words are used only, if a sentence from the title can be ended then. 648These words are used only, if a sentence from the title can be ended then.
651See `bibtex-generate-autokey' for details." 649See `bibtex-generate-autokey' for details."
652 :group 'bibtex-autokey 650 :group 'bibtex-autokey
@@ -655,7 +653,7 @@ See `bibtex-generate-autokey' for details."
655(defcustom bibtex-autokey-titleword-ignore 653(defcustom bibtex-autokey-titleword-ignore
656 '("A" "An" "On" "The" "Eine?" "Der" "Die" "Das" 654 '("A" "An" "On" "The" "Eine?" "Der" "Die" "Das"
657 "[^A-Z].*" ".*[^A-Z0-9].*") 655 "[^A-Z].*" ".*[^A-Z0-9].*")
658 "*Determines words from the title that are not to be used in the key. 656 "Determines words from the title that are not to be used in the key.
659Each item of the list is a regexp. If a word of the title matchs a 657Each item of the list is a regexp. If a word of the title matchs a
660regexp from that list, it is not included in the title part of the key. 658regexp from that list, it is not included in the title part of the key.
661See `bibtex-generate-autokey' for details." 659See `bibtex-generate-autokey' for details."
@@ -663,7 +661,7 @@ See `bibtex-generate-autokey' for details."
663 :type '(repeat regexp)) 661 :type '(repeat regexp))
664 662
665(defcustom bibtex-autokey-titleword-case-convert 'downcase 663(defcustom bibtex-autokey-titleword-case-convert 'downcase
666 "*Function called for each titleword to perform case conversion. 664 "Function called for each titleword to perform case conversion.
667See `bibtex-generate-autokey' for details." 665See `bibtex-generate-autokey' for details."
668 :group 'bibtex-autokey 666 :group 'bibtex-autokey
669 :type '(choice (const :tag "Preserve case" identity) 667 :type '(choice (const :tag "Preserve case" identity)
@@ -673,7 +671,7 @@ See `bibtex-generate-autokey' for details."
673 (function :tag "Conversion function"))) 671 (function :tag "Conversion function")))
674 672
675(defcustom bibtex-autokey-titleword-abbrevs nil 673(defcustom bibtex-autokey-titleword-abbrevs nil
676 "*Determines exceptions to the usual abbreviation mechanism. 674 "Determines exceptions to the usual abbreviation mechanism.
677An alist of (OLD-REGEXP . NEW-STRING) pairs. Case is ignored 675An alist of (OLD-REGEXP . NEW-STRING) pairs. Case is ignored
678in matching against OLD-REGEXP, and the first matching pair is used. 676in matching against OLD-REGEXP, and the first matching pair is used.
679See `bibtex-generate-autokey' for details." 677See `bibtex-generate-autokey' for details."
@@ -693,7 +691,7 @@ See `bibtex-generate-autokey' for details."
693 (string :tag "New")))) 691 (string :tag "New"))))
694 692
695(defcustom bibtex-autokey-titleword-length 5 693(defcustom bibtex-autokey-titleword-length 5
696 "*Number of characters from title words to incorporate into key. 694 "Number of characters from title words to incorporate into key.
697If this is set to anything but a number, all characters are used. 695If this is set to anything but a number, all characters are used.
698See `bibtex-generate-autokey' for details." 696See `bibtex-generate-autokey' for details."
699 :group 'bibtex-autokey 697 :group 'bibtex-autokey
@@ -701,25 +699,25 @@ See `bibtex-generate-autokey' for details."
701 integer)) 699 integer))
702 700
703(defcustom bibtex-autokey-titleword-separator "_" 701(defcustom bibtex-autokey-titleword-separator "_"
704 "*String to be put between the title words. 702 "String to be put between the title words.
705See `bibtex-generate-autokey' for details." 703See `bibtex-generate-autokey' for details."
706 :group 'bibtex-autokey 704 :group 'bibtex-autokey
707 :type 'string) 705 :type 'string)
708 706
709(defcustom bibtex-autokey-name-year-separator "" 707(defcustom bibtex-autokey-name-year-separator ""
710 "*String to be put between name part and year part of key. 708 "String to be put between name part and year part of key.
711See `bibtex-generate-autokey' for details." 709See `bibtex-generate-autokey' for details."
712 :group 'bibtex-autokey 710 :group 'bibtex-autokey
713 :type 'string) 711 :type 'string)
714 712
715(defcustom bibtex-autokey-year-title-separator ":_" 713(defcustom bibtex-autokey-year-title-separator ":_"
716 "*String to be put between name part and year part of key. 714 "String to be put between name part and year part of key.
717See `bibtex-generate-autokey' for details." 715See `bibtex-generate-autokey' for details."
718 :group 'bibtex-autokey 716 :group 'bibtex-autokey
719 :type 'string) 717 :type 'string)
720 718
721(defcustom bibtex-autokey-edit-before-use t 719(defcustom bibtex-autokey-edit-before-use t
722 "*If non-nil, user is allowed to edit the generated key before it is used." 720 "If non-nil, user is allowed to edit the generated key before it is used."
723 :group 'bibtex-autokey 721 :group 'bibtex-autokey
724 :type 'boolean) 722 :type 'boolean)
725 723
@@ -731,39 +729,39 @@ and must return a string (the key to use)."
731 :type '(choice (const nil) function)) 729 :type '(choice (const nil) function))
732 730
733(defcustom bibtex-entry-offset 0 731(defcustom bibtex-entry-offset 0
734 "*Offset for BibTeX entries. 732 "Offset for BibTeX entries.
735Added to the value of all other variables which determine colums." 733Added to the value of all other variables which determine colums."
736 :group 'bibtex 734 :group 'bibtex
737 :type 'integer) 735 :type 'integer)
738 736
739(defcustom bibtex-field-indentation 2 737(defcustom bibtex-field-indentation 2
740 "*Starting column for the name part in BibTeX fields." 738 "Starting column for the name part in BibTeX fields."
741 :group 'bibtex 739 :group 'bibtex
742 :type 'integer) 740 :type 'integer)
743 741
744(defcustom bibtex-text-indentation 742(defcustom bibtex-text-indentation
745 (+ bibtex-field-indentation 743 (+ bibtex-field-indentation
746 (length "organization = ")) 744 (length "organization = "))
747 "*Starting column for the text part in BibTeX fields. 745 "Starting column for the text part in BibTeX fields.
748Should be equal to the space needed for the longest name part." 746Should be equal to the space needed for the longest name part."
749 :group 'bibtex 747 :group 'bibtex
750 :type 'integer) 748 :type 'integer)
751 749
752(defcustom bibtex-contline-indentation 750(defcustom bibtex-contline-indentation
753 (+ bibtex-text-indentation 1) 751 (+ bibtex-text-indentation 1)
754 "*Starting column for continuation lines of BibTeX fields." 752 "Starting column for continuation lines of BibTeX fields."
755 :group 'bibtex 753 :group 'bibtex
756 :type 'integer) 754 :type 'integer)
757 755
758(defcustom bibtex-align-at-equal-sign nil 756(defcustom bibtex-align-at-equal-sign nil
759 "*If non-nil, align fields at equal sign instead of field text. 757 "If non-nil, align fields at equal sign instead of field text.
760If non-nil, the column for the equal sign is the value of 758If non-nil, the column for the equal sign is the value of
761`bibtex-text-indentation', minus 2." 759`bibtex-text-indentation', minus 2."
762 :group 'bibtex 760 :group 'bibtex
763 :type 'boolean) 761 :type 'boolean)
764 762
765(defcustom bibtex-comma-after-last-field nil 763(defcustom bibtex-comma-after-last-field nil
766 "*If non-nil, a comma is put at end of last field in the entry template." 764 "If non-nil, a comma is put at end of last field in the entry template."
767 :group 'bibtex 765 :group 'bibtex
768 :type 'boolean) 766 :type 'boolean)
769 767
@@ -802,8 +800,8 @@ Each scheme is of the form ((FIELD . REGEXP) STEP...).
802 800
803FIELD is a field name as returned by `bibtex-parse-entry'. 801FIELD is a field name as returned by `bibtex-parse-entry'.
804REGEXP is matched against the text of FIELD. If the match succeeds, then 802REGEXP is matched against the text of FIELD. If the match succeeds, then
805this scheme will be used. If no STEPS are specified the matched text is used 803this scheme is used. If no STEPs are specified the matched text is used
806as the URL, otherwise the URL is built by concatenating the STEPS. 804as the URL, otherwise the URL is built by concatenating the STEPs.
807 805
808A STEP can be a string or a list (FIELD REGEXP REPLACE) in which case 806A STEP can be a string or a list (FIELD REGEXP REPLACE) in which case
809the text of FIELD is matched against REGEXP, and is replaced with REPLACE. 807the text of FIELD is matched against REGEXP, and is replaced with REPLACE.
@@ -913,7 +911,9 @@ Case is always ignored. Always remove the field delimiters."
913 ["End of Field" bibtex-find-text t] 911 ["End of Field" bibtex-find-text t]
914 ["Next Field" bibtex-next-field t] 912 ["Next Field" bibtex-next-field t]
915 ["Beginning of Entry" bibtex-beginning-of-entry t] 913 ["Beginning of Entry" bibtex-beginning-of-entry t]
916 ["End of Entry" bibtex-end-of-entry t]) 914 ["End of Entry" bibtex-end-of-entry t]
915 "--"
916 ["Make Entry Visible" bibtex-reposition-window t])
917 ("Moving in BibTeX Buffers" 917 ("Moving in BibTeX Buffers"
918 ["Find Entry" bibtex-find-entry t] 918 ["Find Entry" bibtex-find-entry t]
919 ["Find Crossref Entry" bibtex-find-crossref t]) 919 ["Find Crossref Entry" bibtex-find-crossref t])
@@ -954,7 +954,6 @@ Case is always ignored. Always remove the field delimiters."
954 ["Ispell Entry Abstract" bibtex-ispell-abstract t] 954 ["Ispell Entry Abstract" bibtex-ispell-abstract t]
955 "--" 955 "--"
956 ["Narrow to Entry" bibtex-narrow-to-entry t] 956 ["Narrow to Entry" bibtex-narrow-to-entry t]
957 ["Make Entry Visible" bibtex-reposition-window t]
958 ["Mark Entry" bibtex-mark-entry t] 957 ["Mark Entry" bibtex-mark-entry t]
959 "--" 958 "--"
960 ["View Cite Locations (RefTeX)" reftex-view-crossref-from-bibtex 959 ["View Cite Locations (RefTeX)" reftex-view-crossref-from-bibtex
@@ -1142,7 +1141,8 @@ The CDRs of the elements are t for header keys and nil for crossref keys.")
1142 1141
1143(defvar bibtex-font-lock-url-regexp 1142(defvar bibtex-font-lock-url-regexp
1144 ;; Assume that field names begin at the beginning of a line. 1143 ;; Assume that field names begin at the beginning of a line.
1145 (concat "^[ \t]*" (regexp-opt (mapcar 'caar bibtex-generate-url-list) t) 1144 (concat "^[ \t]*"
1145 (regexp-opt (delete-dups (mapcar 'caar bibtex-generate-url-list)) t)
1146 "[ \t]*=[ \t]*") 1146 "[ \t]*=[ \t]*")
1147 "Regexp for `bibtex-font-lock-url'.") 1147 "Regexp for `bibtex-font-lock-url'.")
1148 1148
@@ -1175,13 +1175,6 @@ ARG is ignored."
1175 '(bibtex-mode "@\\S(*\\s(" "\\s)" nil bibtex-hs-forward-sexp nil)) 1175 '(bibtex-mode "@\\S(*\\s(" "\\s)" nil bibtex-hs-forward-sexp nil))
1176 1176
1177 1177
1178(defun bibtex-remove-delimiters-string (str)
1179 "Remove delimiters of string STR."
1180 (if (and (memq (aref str 0) '(?\{ ?\"))
1181 (memq (aref str (1- (length str))) '(?\} ?\")))
1182 (substring str 1 -1)
1183 str))
1184
1185(defun bibtex-parse-association (parse-lhs parse-rhs) 1178(defun bibtex-parse-association (parse-lhs parse-rhs)
1186 "Parse a string of the format <left-hand-side = right-hand-side>. 1179 "Parse a string of the format <left-hand-side = right-hand-side>.
1187The functions PARSE-LHS and PARSE-RHS are used to parse the corresponding 1180The functions PARSE-LHS and PARSE-RHS are used to parse the corresponding
@@ -1498,6 +1491,13 @@ delimiters if present."
1498 1491
1499;; Helper Functions 1492;; Helper Functions
1500 1493
1494(defun bibtex-remove-delimiters-string (str)
1495 "Remove delimiters of string STR."
1496 (if (and (memq (aref str 0) '(?\{ ?\"))
1497 (memq (aref str (1- (length str))) '(?\} ?\")))
1498 (substring str 1 -1)
1499 str))
1500
1501(defsubst bibtex-string= (str1 str2) 1501(defsubst bibtex-string= (str1 str2)
1502 "Return t if STR1 and STR2 are equal, ignoring case." 1502 "Return t if STR1 and STR2 are equal, ignoring case."
1503 (eq t (compare-strings str1 0 nil str2 0 nil t))) 1503 (eq t (compare-strings str1 0 nil str2 0 nil t)))
@@ -1546,7 +1546,7 @@ entry is found, nil otherwise."
1546 "Call FUN for each BibTeX entry in buffer (possibly narrowed). 1546 "Call FUN for each BibTeX entry in buffer (possibly narrowed).
1547FUN is called with three arguments, the key of the entry and the buffer 1547FUN is called with three arguments, the key of the entry and the buffer
1548positions (marker) of beginning and end of entry. Point is inside the entry. 1548positions (marker) of beginning and end of entry. Point is inside the entry.
1549If `bibtex-sort-ignore-string-entries' is non-nil, FUN will not be called for 1549If `bibtex-sort-ignore-string-entries' is non-nil, FUN is not called for
1550@String entries." 1550@String entries."
1551 (let ((case-fold-search t)) 1551 (let ((case-fold-search t))
1552 (save-excursion 1552 (save-excursion
@@ -2148,7 +2148,7 @@ Return the result as a string"
2148 lst) 2148 lst)
2149 (setq counter (1+ counter)) 2149 (setq counter (1+ counter))
2150 (if (or (not (numberp bibtex-autokey-titlewords)) 2150 (if (or (not (numberp bibtex-autokey-titlewords))
2151 (< counter bibtex-autokey-titlewords)) 2151 (<= counter bibtex-autokey-titlewords))
2152 (push word titlewords) 2152 (push word titlewords)
2153 (push word titlewords-extra)))) 2153 (push word titlewords-extra))))
2154 ;; Obey bibtex-autokey-titlewords-stretch: 2154 ;; Obey bibtex-autokey-titlewords-stretch:
@@ -2725,11 +2725,10 @@ to field. After having filled in all desired fields in the entry, clean the
2725new entry with the command \\[bibtex-clean-entry]. 2725new entry with the command \\[bibtex-clean-entry].
2726 2726
2727Some features of BibTeX mode are available only by setting the variable 2727Some features of BibTeX mode are available only by setting the variable
2728`bibtex-maintain-sorted-entries' to non-nil. However, then BibTeX mode will 2728`bibtex-maintain-sorted-entries' to non-nil. However, then BibTeX mode
2729work only with buffers containing valid (syntactical correct) entries 2729works only with buffers containing valid (syntactical correct) and sorted
2730and with entries being sorted. This is usually the case, if you have 2730entries. This is usually the case, if you have created a buffer completely
2731created a buffer completely with BibTeX mode and finished every new 2731with BibTeX mode and finished every new entry with \\[bibtex-clean-entry].
2732entry with \\[bibtex-clean-entry].
2733 2732
2734For third party BibTeX files, call the function `bibtex-convert-alien' 2733For third party BibTeX files, call the function `bibtex-convert-alien'
2735to fully take advantage of all features of BibTeX mode. 2734to fully take advantage of all features of BibTeX mode.
@@ -2737,7 +2736,7 @@ to fully take advantage of all features of BibTeX mode.
2737 2736
2738Special information: 2737Special information:
2739 2738
2740A command such as \\[bibtex-Book] will outline the fields for a BibTeX book entry. 2739A command such as \\[bibtex-Book] outlines the fields for a BibTeX book entry.
2741 2740
2742The names of optional fields start with the string OPT, and are thus ignored 2741The names of optional fields start with the string OPT, and are thus ignored
2743by BibTeX. The names of alternative fields from which only one is required 2742by BibTeX. The names of alternative fields from which only one is required
@@ -3083,14 +3082,35 @@ Return the new location of point."
3083 (error "Syntactically incorrect BibTeX entry starts here"))) 3082 (error "Syntactically incorrect BibTeX entry starts here")))
3084 (point)) 3083 (point))
3085 3084
3086(defun bibtex-reposition-window (&optional arg) 3085(defun bibtex-goto-line (arg)
3086 "Goto line ARG, counting from beginning of (narrowed) buffer."
3087 ;; code adapted from `goto-line'
3088 (goto-char (point-min))
3089 (if (eq selective-display t)
3090 (re-search-forward "[\n\C-m]" nil 'end (1- arg))
3091 (forward-line (1- arg))))
3092
3093(defun bibtex-reposition-window ()
3087 "Make the current BibTeX entry visible. 3094 "Make the current BibTeX entry visible.
3088Optional argument ARG is exactly as in `recenter'." 3095If entry is smaller than `window-body-height', entry is centered in window.
3089 (interactive "P") 3096Otherwise display the beginning of entry."
3090 (save-excursion 3097 (interactive)
3091 (goto-char 3098 (let ((pnt (point))
3092 (/ (+ (bibtex-beginning-of-entry) (bibtex-end-of-entry)) 2)) 3099 (beg (line-number-at-pos (bibtex-beginning-of-entry)))
3093 (recenter arg))) 3100 (end (line-number-at-pos (bibtex-end-of-entry))))
3101 (if (> (window-body-height) (- end beg))
3102 ;; entry fits in current window
3103 (progn
3104 (bibtex-goto-line (/ (+ 1 beg end) 2))
3105 (recenter)
3106 (goto-char pnt))
3107 ;; entry too large for current window
3108 (bibtex-goto-line beg)
3109 (recenter 0)
3110 (if (> (1+ (- (line-number-at-pos pnt) beg))
3111 (window-body-height))
3112 (bibtex-goto-line beg)
3113 (goto-char pnt)))))
3094 3114
3095(defun bibtex-mark-entry () 3115(defun bibtex-mark-entry ()
3096 "Put mark at beginning, point at end of current BibTeX entry." 3116 "Put mark at beginning, point at end of current BibTeX entry."
@@ -3100,9 +3120,9 @@ Optional argument ARG is exactly as in `recenter'."
3100 3120
3101(defun bibtex-count-entries (&optional count-string-entries) 3121(defun bibtex-count-entries (&optional count-string-entries)
3102 "Count number of entries in current buffer or region. 3122 "Count number of entries in current buffer or region.
3103With prefix argument COUNT-STRING-ENTRIES it counts all entries, 3123With prefix argument COUNT-STRING-ENTRIES count all entries,
3104otherwise it counts all except Strings. 3124otherwise count all entries except @String entries.
3105If mark is active it counts entries in region, if not in whole buffer." 3125If mark is active count entries in region, if not in whole buffer."
3106 (interactive "P") 3126 (interactive "P")
3107 (let ((number 0) 3127 (let ((number 0)
3108 (bibtex-sort-ignore-string-entries 3128 (bibtex-sort-ignore-string-entries
@@ -3119,13 +3139,13 @@ If mark is active it counts entries in region, if not in whole buffer."
3119 number))) 3139 number)))
3120 3140
3121(defun bibtex-ispell-entry () 3141(defun bibtex-ispell-entry ()
3122 "Spell whole BibTeX entry." 3142 "Check BibTeX entry for spelling errors."
3123 (interactive) 3143 (interactive)
3124 (ispell-region (save-excursion (bibtex-beginning-of-entry)) 3144 (ispell-region (save-excursion (bibtex-beginning-of-entry))
3125 (save-excursion (bibtex-end-of-entry)))) 3145 (save-excursion (bibtex-end-of-entry))))
3126 3146
3127(defun bibtex-ispell-abstract () 3147(defun bibtex-ispell-abstract ()
3128 "Spell abstract of BibTeX entry." 3148 "Check abstract of BibTeX entry for spelling errors."
3129 (interactive) 3149 (interactive)
3130 (let ((bounds (save-excursion 3150 (let ((bounds (save-excursion
3131 (bibtex-beginning-of-entry) 3151 (bibtex-beginning-of-entry)
@@ -3198,7 +3218,7 @@ If its value is nil use plain sorting."
3198The predicate for sorting is defined via `bibtex-maintain-sorted-entries'. 3218The predicate for sorting is defined via `bibtex-maintain-sorted-entries'.
3199If its value is nil use plain sorting. Text outside of BibTeX entries is not 3219If its value is nil use plain sorting. Text outside of BibTeX entries is not
3200affected. If `bibtex-sort-ignore-string-entries' is non-nil, @String entries 3220affected. If `bibtex-sort-ignore-string-entries' is non-nil, @String entries
3201will be ignored." 3221are ignored."
3202 (interactive) 3222 (interactive)
3203 (save-restriction 3223 (save-restriction
3204 (narrow-to-region (bibtex-beginning-of-first-entry) 3224 (narrow-to-region (bibtex-beginning-of-first-entry)
@@ -3246,8 +3266,8 @@ entry and SPLIT is t."
3246 (if eqb (select-window (split-window)) 3266 (if eqb (select-window (split-window))
3247 (pop-to-buffer buffer)) 3267 (pop-to-buffer buffer))
3248 (goto-char pos) 3268 (goto-char pos)
3269 (bibtex-reposition-window)
3249 (beginning-of-line) 3270 (beginning-of-line)
3250 (set-window-start (selected-window) (point))
3251 (if (and eqb (> pnt pos)) 3271 (if (and eqb (> pnt pos))
3252 (error "The referencing entry must preceed the crossrefed entry!"))) 3272 (error "The referencing entry must preceed the crossrefed entry!")))
3253 ;; `bibtex-find-crossref' is called noninteractively during 3273 ;; `bibtex-find-crossref' is called noninteractively during
@@ -3281,9 +3301,10 @@ Otherwise, use `set-buffer'. DISPLAY is t when called interactively."
3281 (cond ((and found display) 3301 (cond ((and found display)
3282 (let ((same-window-buffer-names 3302 (let ((same-window-buffer-names
3283 (cons (buffer-name buffer) same-window-buffer-names))) 3303 (cons (buffer-name buffer) same-window-buffer-names)))
3284 (pop-to-buffer buffer))) 3304 (pop-to-buffer buffer)
3305 (bibtex-reposition-window)))
3285 (found (set-buffer buffer)) 3306 (found (set-buffer buffer))
3286 (t (message "Key `%s' not found" key))) 3307 (display (message "Key `%s' not found" key)))
3287 found) 3308 found)
3288 3309
3289 (let* (case-fold-search 3310 (let* (case-fold-search
@@ -3297,17 +3318,18 @@ Otherwise, use `set-buffer'. DISPLAY is t when called interactively."
3297 nil t) 3318 nil t)
3298 (match-beginning 0))))) 3319 (match-beginning 0)))))
3299 (cond (pnt 3320 (cond (pnt
3300 (goto-char pnt)) 3321 (goto-char pnt)
3301 ((interactive-p) 3322 (if display (bibtex-reposition-window)))
3302 (message "Key `%s' not found" key)))))) 3323 (display (message "Key `%s' not found" key)))
3324 pnt)))
3303 3325
3304(defun bibtex-prepare-new-entry (index) 3326(defun bibtex-prepare-new-entry (index)
3305 "Prepare a new BibTeX entry with index INDEX. 3327 "Prepare a new BibTeX entry with index INDEX.
3306INDEX is a list (KEY CROSSREF-KEY ENTRY-NAME). 3328INDEX is a list (KEY CROSSREF-KEY ENTRY-NAME).
3307Move point where the entry KEY should be placed. 3329Move point where the entry KEY should be placed.
3308If `bibtex-maintain-sorted-entries' is non-nil, perform a binary 3330If `bibtex-maintain-sorted-entries' is non-nil, perform a binary
3309search to look for place for KEY. This will fail if buffer is not in 3331search to look for place for KEY. This requires that buffer is sorted,
3310sorted order, see \\[bibtex-validate].) 3332see \\[bibtex-validate].)
3311Return t if preparation was successful or nil if entry KEY already exists." 3333Return t if preparation was successful or nil if entry KEY already exists."
3312 (let ((key (nth 0 index)) 3334 (let ((key (nth 0 index))
3313 key-exist) 3335 key-exist)
@@ -3787,7 +3809,7 @@ intermixed with \\[bibtex-pop-previous] (bibtex-pop-previous)."
3787Check that no required fields are empty and formats entry dependent 3809Check that no required fields are empty and formats entry dependent
3788on the value of `bibtex-entry-format'. 3810on the value of `bibtex-entry-format'.
3789If the reference key of the entry is empty or a prefix argument is given, 3811If the reference key of the entry is empty or a prefix argument is given,
3790calculate a new reference key. (Note: this will only work if fields in entry 3812calculate a new reference key. (Note: this works only if fields in entry
3791begin on separate lines prior to calling `bibtex-clean-entry' or if 3813begin on separate lines prior to calling `bibtex-clean-entry' or if
3792'realign is contained in `bibtex-entry-format'.) 3814'realign is contained in `bibtex-entry-format'.)
3793Don't call `bibtex-clean-entry' on @Preamble entries. 3815Don't call `bibtex-clean-entry' on @Preamble entries.
@@ -4034,9 +4056,9 @@ If mark is active reformat entries in region, if not in whole buffer."
4034 (goto-char pnt))) 4056 (goto-char pnt)))
4035 4057
4036(defun bibtex-convert-alien (&optional read-options) 4058(defun bibtex-convert-alien (&optional read-options)
4037 "Convert an alien BibTeX buffer to be fully usable by BibTeX mode. 4059 "Make an alien BibTeX buffer fully usable by BibTeX mode.
4038If a file does not conform with all standards used by BibTeX mode, 4060If a file does not conform with all standards used by BibTeX mode,
4039some of the high-level features of BibTeX mode will not be available. 4061some of the high-level features of BibTeX mode are not available.
4040This function tries to convert current buffer to conform with these standards. 4062This function tries to convert current buffer to conform with these standards.
4041With prefix argument READ-OPTIONS non-nil, read options for reformatting 4063With prefix argument READ-OPTIONS non-nil, read options for reformatting
4042entries from minibuffer." 4064entries from minibuffer."