diff options
| author | Kai Großjohann | 2003-07-05 12:41:24 +0000 |
|---|---|---|
| committer | Kai Großjohann | 2003-07-05 12:41:24 +0000 |
| commit | d715b065ad4a8bc36bfd36d6971e598ed66fdd86 (patch) | |
| tree | 4d6f89d827eadd17861012cdf73c160db830c30a | |
| parent | 34a4faa04b8ad2d969fabd543b62c6c244a7fa17 (diff) | |
| download | emacs-d715b065ad4a8bc36bfd36d6971e598ed66fdd86.tar.gz emacs-d715b065ad4a8bc36bfd36d6971e598ed66fdd86.zip | |
2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
* textmodes/bibtex.el (bibtex-sort-entry-class): new entry
catch-all.
(bibtex-sort-ignore-string-entries): default value t.
(bibtex-entry-kill-ring-max): Reintroduced as it was removed
erroneously in previous version.
(bibtex-string-files): Docstring reflects new parsing scheme.
(bibtex-autokey-transcriptions): Merge some rewrite entries, fix
docstring, add # as one of the chars to crush
(bibtex-autokey-prefix-string, bibtex-autokey-names)
(bibtex-autokey-names-stretch, bibtex-autokey-additional-names)
(bibtex-autokey-name-change-strings)
(bibtex-autokey-name-case-convert, bibtex-autokey-name-length)
(bibtex-autokey-name-separator, bibtex-autokey-year-length)
(bibtex-autokey-use-crossref, bibtex-autokey-titlewords)
(bibtex-autokey-title-terminators)
(bibtex-autokey-titlewords-stretch)
(bibtex-autokey-titleword-ignore)
(bibtex-autokey-titleword-case-convert)
(bibtex-autokey-titleword-abbrevs)
(bibtex-autokey-titleword-abbrevs)
(bibtex-autokey-titleword-change-strings)
(bibtex-autokey-titleword-length)
(bibtex-autokey-titleword-separator)
(bibtex-autokey-name-year-separator)
(bibtex-autokey-year-title-separator)
(bibtex-autokey-before-presentation-function)
(bibtex-entry-type-history, bibtex-entry-maybe-empty-head): Fix
docstring.
(bibtex-strings, bibtex-reference-keys): Use
lazy-completion-table and make-variable-buffer-local.
(bibtex-sort-entry-class-alist): Use downcase, account for
catch-all.
(bibtex-braced-string-syntax-table)
(bibtex-quoted-string-syntax-table): New variables.
(bibtex-parse-nested-braces): Remove.
(bibtex-parse-field-string): Use syntax table and forward-sexp.
(bibtex-parse-association): Simplify.
(bibtex-parse-field-name): Obey bibtex-autoadd-commas.
(bibtex-parse-field-text): Simplify.
(bibtex-search-forward-field, bibtex-search-backward-field):
argument BOUND can take value t.
(bibtex-start-of-field, bibtex-start-of-name-in-field)
(bibtex-end-of-name-in-field, bibtex-end-of-field)
(bibtex-start-of-text-in-field, bibtex-end-of-text-in-field)
(bibtex-start-of-text-in-string, bibtex-end-of-text-in-string)
(bibtex-end-of-string, bibtex-type-in-head): Use defsubst.
(bibtex-skip-to-valid-entry): Return buffer position of beginning
and ending of entry. Update for changes of bibtex-search-entry.
Simplify.
(bibtex-map-entries): FUN is called with three arguments.
(bibtex-search-entry): Return a cons pair with buffer positions of
beginning and end of entry.
(bibtex-enclosing-field): Simplify.
(bibtex-format-entry): Use booktitle to set a missing title.
(bibtex-autokey-get-names): Fiddle with regexps.
(bibtex-generate-autokey): Use identity.
(bibtex-parse-keys): Use simplified parsing algorithm if
bibtex-parse-keys-fast is non-nil. Simplify. Change order of
arguments. Return alist of keys.
(bibtex-parse-strings): Simplify. Return alist of strings.
(bibtex-complete-string-cleanup): Fix docstring.
(bibtex-read-key): New function.
(bibtex-mode): Fix docstring. Do not parse for keys and
strings when the mode is entered. Set fill-paragraph-function to
bibtex-fill-field. Setup font-lock-mark-block-function the way
font-lock intended.
(bibtex-entry): Use bibtex-read-key. Obey bibtex-autofill-types.
(bibtex-parse-entry, bibtex-autofill-entry): New functions.
(bibtex-print-help-message, bibtex-remove-OPT-or-ALT)
(bibtex-Preamble): Avoid hard coded constants.
(bibtex-make-field): Fix docstring. Simplify.
(bibtex-beginning-of-entry): Always return new position of point.
(bibtex-end-of-entry): Rearrange cond clauses.
(bibtex-count-entries, bibtex-validate, bibtex-reformat): Update
for changes of bibtex-map-entries.
(bibtex-ispell-abstract): Do not move point.
(bibtex-entry-index): Use downcase. Simplify.
(bibtex-lessp): Handle catch-all.
(bibtex-find-crossref): Turned into a command.
(bibtex-find-entry): Simplify. Use bibtex-read-key. Fix regexp.
(bibtex-clean-entry): Use bibtex-read-key. Handle string and
preamble entries.
(bibtex-fill-field-bounds): New function.
(bibtex-fill-field): New command. Bound to
fill-paragraph-function.
(bibtex-fill-entry): Use bibtex-fill-field-bounds
(bibtex-String): Use bibtex-strings. Always obey
bibtex-sort-ignore-string-entries.
| -rw-r--r-- | lisp/ChangeLog | 91 | ||||
| -rw-r--r-- | lisp/textmodes/bibtex.el | 1394 |
2 files changed, 880 insertions, 605 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 9776891068c..40ba6a364c4 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,94 @@ | |||
| 1 | 2003-06-30 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de> | ||
| 2 | |||
| 3 | * textmodes/bibtex.el (bibtex-sort-entry-class): new entry | ||
| 4 | catch-all. | ||
| 5 | (bibtex-sort-ignore-string-entries): default value t. | ||
| 6 | (bibtex-entry-kill-ring-max): Reintroduced as it was removed | ||
| 7 | erroneously in previous version. | ||
| 8 | (bibtex-string-files): Docstring reflects new parsing scheme. | ||
| 9 | (bibtex-autokey-transcriptions): Merge some rewrite entries, fix | ||
| 10 | docstring, add # as one of the chars to crush | ||
| 11 | (bibtex-autokey-prefix-string, bibtex-autokey-names) | ||
| 12 | (bibtex-autokey-names-stretch, bibtex-autokey-additional-names) | ||
| 13 | (bibtex-autokey-name-change-strings) | ||
| 14 | (bibtex-autokey-name-case-convert, bibtex-autokey-name-length) | ||
| 15 | (bibtex-autokey-name-separator, bibtex-autokey-year-length) | ||
| 16 | (bibtex-autokey-use-crossref, bibtex-autokey-titlewords) | ||
| 17 | (bibtex-autokey-title-terminators) | ||
| 18 | (bibtex-autokey-titlewords-stretch) | ||
| 19 | (bibtex-autokey-titleword-ignore) | ||
| 20 | (bibtex-autokey-titleword-case-convert) | ||
| 21 | (bibtex-autokey-titleword-abbrevs) | ||
| 22 | (bibtex-autokey-titleword-abbrevs) | ||
| 23 | (bibtex-autokey-titleword-change-strings) | ||
| 24 | (bibtex-autokey-titleword-length) | ||
| 25 | (bibtex-autokey-titleword-separator) | ||
| 26 | (bibtex-autokey-name-year-separator) | ||
| 27 | (bibtex-autokey-year-title-separator) | ||
| 28 | (bibtex-autokey-before-presentation-function) | ||
| 29 | (bibtex-entry-type-history, bibtex-entry-maybe-empty-head): Fix | ||
| 30 | docstring. | ||
| 31 | (bibtex-strings, bibtex-reference-keys): Use | ||
| 32 | lazy-completion-table and make-variable-buffer-local. | ||
| 33 | (bibtex-sort-entry-class-alist): Use downcase, account for | ||
| 34 | catch-all. | ||
| 35 | (bibtex-braced-string-syntax-table) | ||
| 36 | (bibtex-quoted-string-syntax-table): New variables. | ||
| 37 | (bibtex-parse-nested-braces): Remove. | ||
| 38 | (bibtex-parse-field-string): Use syntax table and forward-sexp. | ||
| 39 | (bibtex-parse-association): Simplify. | ||
| 40 | (bibtex-parse-field-name): Obey bibtex-autoadd-commas. | ||
| 41 | (bibtex-parse-field-text): Simplify. | ||
| 42 | (bibtex-search-forward-field, bibtex-search-backward-field): | ||
| 43 | argument BOUND can take value t. | ||
| 44 | (bibtex-start-of-field, bibtex-start-of-name-in-field) | ||
| 45 | (bibtex-end-of-name-in-field, bibtex-end-of-field) | ||
| 46 | (bibtex-start-of-text-in-field, bibtex-end-of-text-in-field) | ||
| 47 | (bibtex-start-of-text-in-string, bibtex-end-of-text-in-string) | ||
| 48 | (bibtex-end-of-string, bibtex-type-in-head): Use defsubst. | ||
| 49 | (bibtex-skip-to-valid-entry): Return buffer position of beginning | ||
| 50 | and ending of entry. Update for changes of bibtex-search-entry. | ||
| 51 | Simplify. | ||
| 52 | (bibtex-map-entries): FUN is called with three arguments. | ||
| 53 | (bibtex-search-entry): Return a cons pair with buffer positions of | ||
| 54 | beginning and end of entry. | ||
| 55 | (bibtex-enclosing-field): Simplify. | ||
| 56 | (bibtex-format-entry): Use booktitle to set a missing title. | ||
| 57 | (bibtex-autokey-get-names): Fiddle with regexps. | ||
| 58 | (bibtex-generate-autokey): Use identity. | ||
| 59 | (bibtex-parse-keys): Use simplified parsing algorithm if | ||
| 60 | bibtex-parse-keys-fast is non-nil. Simplify. Change order of | ||
| 61 | arguments. Return alist of keys. | ||
| 62 | (bibtex-parse-strings): Simplify. Return alist of strings. | ||
| 63 | (bibtex-complete-string-cleanup): Fix docstring. | ||
| 64 | (bibtex-read-key): New function. | ||
| 65 | (bibtex-mode): Fix docstring. Do not parse for keys and | ||
| 66 | strings when the mode is entered. Set fill-paragraph-function to | ||
| 67 | bibtex-fill-field. Setup font-lock-mark-block-function the way | ||
| 68 | font-lock intended. | ||
| 69 | (bibtex-entry): Use bibtex-read-key. Obey bibtex-autofill-types. | ||
| 70 | (bibtex-parse-entry, bibtex-autofill-entry): New functions. | ||
| 71 | (bibtex-print-help-message, bibtex-remove-OPT-or-ALT) | ||
| 72 | (bibtex-Preamble): Avoid hard coded constants. | ||
| 73 | (bibtex-make-field): Fix docstring. Simplify. | ||
| 74 | (bibtex-beginning-of-entry): Always return new position of point. | ||
| 75 | (bibtex-end-of-entry): Rearrange cond clauses. | ||
| 76 | (bibtex-count-entries, bibtex-validate, bibtex-reformat): Update | ||
| 77 | for changes of bibtex-map-entries. | ||
| 78 | (bibtex-ispell-abstract): Do not move point. | ||
| 79 | (bibtex-entry-index): Use downcase. Simplify. | ||
| 80 | (bibtex-lessp): Handle catch-all. | ||
| 81 | (bibtex-find-crossref): Turned into a command. | ||
| 82 | (bibtex-find-entry): Simplify. Use bibtex-read-key. Fix regexp. | ||
| 83 | (bibtex-clean-entry): Use bibtex-read-key. Handle string and | ||
| 84 | preamble entries. | ||
| 85 | (bibtex-fill-field-bounds): New function. | ||
| 86 | (bibtex-fill-field): New command. Bound to | ||
| 87 | fill-paragraph-function. | ||
| 88 | (bibtex-fill-entry): Use bibtex-fill-field-bounds | ||
| 89 | (bibtex-String): Use bibtex-strings. Always obey | ||
| 90 | bibtex-sort-ignore-string-entries. | ||
| 91 | |||
| 1 | 2003-07-05 John Paul Wallington <jpw@gnu.org> | 92 | 2003-07-05 John Paul Wallington <jpw@gnu.org> |
| 2 | 93 | ||
| 3 | * ibuffer.el (ibuffer-backward-line, ibuffer-forward-line) | 94 | * ibuffer.el (ibuffer-backward-line, ibuffer-forward-line) |
diff --git a/lisp/textmodes/bibtex.el b/lisp/textmodes/bibtex.el index e64f698d051..141d1236417 100644 --- a/lisp/textmodes/bibtex.el +++ b/lisp/textmodes/bibtex.el | |||
| @@ -150,9 +150,7 @@ narrowed to just the entry." | |||
| 150 | 150 | ||
| 151 | (defcustom bibtex-maintain-sorted-entries nil | 151 | (defcustom bibtex-maintain-sorted-entries nil |
| 152 | "*If non-nil, BibTeX mode maintains all BibTeX entries in sorted order. | 152 | "*If non-nil, BibTeX mode maintains all BibTeX entries in sorted order. |
| 153 | If it is nil this will strip off some comfort (e.g., TAB | 153 | Allowed non-nil values are: |
| 154 | completion for reference keys in minibuffer, automatic detection of | ||
| 155 | duplicates) from BibTeX mode. Allowed non-nil values are: | ||
| 156 | plain All entries are sorted alphabetically. | 154 | plain All entries are sorted alphabetically. |
| 157 | crossref All entries are sorted alphabetically unless an entry has a | 155 | crossref All entries are sorted alphabetically unless an entry has a |
| 158 | crossref field. These crossrefed entries are placed in | 156 | crossref field. These crossrefed entries are placed in |
| @@ -169,17 +167,15 @@ See also `bibtex-sort-ignore-string-entries'." | |||
| 169 | 167 | ||
| 170 | (defvar bibtex-sort-entry-class | 168 | (defvar bibtex-sort-entry-class |
| 171 | '(("String") | 169 | '(("String") |
| 172 | ("Article" "InBook" "InCollection" "InProceedings") | 170 | (catch-all) |
| 173 | ("Book" "Proceedings") | 171 | ("Book" "Proceedings")) |
| 174 | ("Booklet" "Manual" "MastersThesis" "PhdThesis" "TechReport" ) | ||
| 175 | ("Misc" "Unpublished")) | ||
| 176 | "*List of classes of BibTeX entry names, used for sorting entries. | 172 | "*List of classes of BibTeX entry names, used for sorting entries. |
| 177 | Each class contains a list of entry names. If value of | 173 | If value of `bibtex-maintain-sorted-entries' is `entry-class' |
| 178 | `bibtex-maintain-sorted-entries' is `entry-class' entries are ordered | 174 | entries are ordered according to the classes they belong to. Each |
| 179 | according to the classes they belong to.") | 175 | class contains a list of entry names. An entry `catch-all' applies |
| 176 | to all entries not explicitely mentioned.") | ||
| 180 | 177 | ||
| 181 | (defcustom bibtex-sort-ignore-string-entries | 178 | (defcustom bibtex-sort-ignore-string-entries t |
| 182 | (not (equal bibtex-maintain-sorted-entries 'entry-class)) | ||
| 183 | "*If non-nil, BibTeX @String entries are not sort-significant. | 179 | "*If non-nil, BibTeX @String entries are not sort-significant. |
| 184 | That means they are ignored when determining ordering of the buffer | 180 | That means they are ignored when determining ordering of the buffer |
| 185 | \(e.g., sorting, locating alphabetical position for new entries, etc.)." | 181 | \(e.g., sorting, locating alphabetical position for new entries, etc.)." |
| @@ -191,6 +187,11 @@ That means they are ignored when determining ordering of the buffer | |||
| 191 | :group 'bibtex | 187 | :group 'bibtex |
| 192 | :type 'integer) | 188 | :type 'integer) |
| 193 | 189 | ||
| 190 | (defcustom bibtex-entry-kill-ring-max 20 | ||
| 191 | "*Max length of `bibtex-entry-kill-ring' before discarding oldest elements." | ||
| 192 | :group 'bibtex | ||
| 193 | :type 'integer) | ||
| 194 | |||
| 194 | (defcustom bibtex-parse-keys-timeout 60 | 195 | (defcustom bibtex-parse-keys-timeout 60 |
| 195 | "*Specify interval for parsing BibTeX buffers. | 196 | "*Specify interval for parsing BibTeX buffers. |
| 196 | All BibTeX buffers in Emacs are parsed if Emacs has been idle | 197 | All BibTeX buffers in Emacs are parsed if Emacs has been idle |
| @@ -199,217 +200,223 @@ after last parsing and which are maintained in sorted order are parsed." | |||
| 199 | :group 'bibtex | 200 | :group 'bibtex |
| 200 | :type 'integer) | 201 | :type 'integer) |
| 201 | 202 | ||
| 203 | (defcustom bibtex-parse-keys-fast t | ||
| 204 | "*If non-nil, use fast but simplified algorithm for parsing BibTeX keys. | ||
| 205 | If parsing fails, try to set this variable to nil." | ||
| 206 | :group 'bibtex | ||
| 207 | :type 'boolean) | ||
| 208 | |||
| 202 | (defvar bibtex-entry-field-alist | 209 | (defvar bibtex-entry-field-alist |
| 203 | '( | 210 | '( |
| 204 | ("Article" | 211 | ("Article" |
| 205 | ((("author" "Author1 [and Author2 ...] [and others]") | 212 | ((("author" "Author1 [and Author2 ...] [and others]") |
| 206 | ("title" "Title of the article (BibTeX converts it to lowercase)") | 213 | ("title" "Title of the article (BibTeX converts it to lowercase)") |
| 207 | ("journal" "Name of the journal (use string, remove braces)") | 214 | ("journal" "Name of the journal (use string, remove braces)") |
| 208 | ("year" "Year of publication")) | 215 | ("year" "Year of publication")) |
| 209 | (("volume" "Volume of the journal") | 216 | (("volume" "Volume of the journal") |
| 210 | ("number" "Number of the journal (only allowed if entry contains volume)") | 217 | ("number" "Number of the journal (only allowed if entry contains volume)") |
| 211 | ("pages" "Pages in the journal") | 218 | ("pages" "Pages in the journal") |
| 212 | ("month" "Month of the publication as a string (remove braces)") | 219 | ("month" "Month of the publication as a string (remove braces)") |
| 213 | ("note" "Remarks to be put at the end of the \\bibitem"))) | 220 | ("note" "Remarks to be put at the end of the \\bibitem"))) |
| 214 | ((("author" "Author1 [and Author2 ...] [and others]") | 221 | ((("author" "Author1 [and Author2 ...] [and others]") |
| 215 | ("title" "Title of the article (BibTeX converts it to lowercase)")) | 222 | ("title" "Title of the article (BibTeX converts it to lowercase)")) |
| 216 | (("pages" "Pages in the journal") | 223 | (("pages" "Pages in the journal") |
| 217 | ("journal" "Name of the journal (use string, remove braces)") | 224 | ("journal" "Name of the journal (use string, remove braces)") |
| 218 | ("year" "Year of publication") | 225 | ("year" "Year of publication") |
| 219 | ("volume" "Volume of the journal") | 226 | ("volume" "Volume of the journal") |
| 220 | ("number" "Number of the journal") | 227 | ("number" "Number of the journal") |
| 221 | ("month" "Month of the publication as a string (remove braces)") | 228 | ("month" "Month of the publication as a string (remove braces)") |
| 222 | ("note" "Remarks to be put at the end of the \\bibitem")))) | 229 | ("note" "Remarks to be put at the end of the \\bibitem")))) |
| 223 | ("Book" | 230 | ("Book" |
| 224 | ((("author" "Author1 [and Author2 ...] [and others]" "" t) | 231 | ((("author" "Author1 [and Author2 ...] [and others]" "" t) |
| 225 | ("editor" "Editor1 [and Editor2 ...] [and others]" "" t) | 232 | ("editor" "Editor1 [and Editor2 ...] [and others]" "" t) |
| 226 | ("title" "Title of the book") | 233 | ("title" "Title of the book") |
| 227 | ("publisher" "Publishing company") | 234 | ("publisher" "Publishing company") |
| 228 | ("year" "Year of publication")) | 235 | ("year" "Year of publication")) |
| 229 | (("volume" "Volume of the book in the series") | 236 | (("volume" "Volume of the book in the series") |
| 230 | ("number" "Number of the book in a small series (overwritten by volume)") | 237 | ("number" "Number of the book in a small series (overwritten by volume)") |
| 231 | ("series" "Series in which the book appeared") | 238 | ("series" "Series in which the book appeared") |
| 232 | ("address" "Address of the publisher") | 239 | ("address" "Address of the publisher") |
| 233 | ("edition" "Edition of the book as a capitalized English word") | 240 | ("edition" "Edition of the book as a capitalized English word") |
| 234 | ("month" "Month of the publication as a string (remove braces)") | 241 | ("month" "Month of the publication as a string (remove braces)") |
| 235 | ("note" "Remarks to be put at the end of the \\bibitem"))) | 242 | ("note" "Remarks to be put at the end of the \\bibitem"))) |
| 236 | ((("author" "Author1 [and Author2 ...] [and others]" "" t) | 243 | ((("author" "Author1 [and Author2 ...] [and others]" "" t) |
| 237 | ("editor" "Editor1 [and Editor2 ...] [and others]" "" t) | 244 | ("editor" "Editor1 [and Editor2 ...] [and others]" "" t) |
| 238 | ("title" "Title of the book")) | 245 | ("title" "Title of the book")) |
| 239 | (("publisher" "Publishing company") | 246 | (("publisher" "Publishing company") |
| 240 | ("year" "Year of publication") | 247 | ("year" "Year of publication") |
| 241 | ("volume" "Volume of the book in the series") | 248 | ("volume" "Volume of the book in the series") |
| 242 | ("number" "Number of the book in a small series (overwritten by volume)") | 249 | ("number" "Number of the book in a small series (overwritten by volume)") |
| 243 | ("series" "Series in which the book appeared") | 250 | ("series" "Series in which the book appeared") |
| 244 | ("address" "Address of the publisher") | 251 | ("address" "Address of the publisher") |
| 245 | ("edition" "Edition of the book as a capitalized English word") | 252 | ("edition" "Edition of the book as a capitalized English word") |
| 246 | ("month" "Month of the publication as a string (remove braces)") | 253 | ("month" "Month of the publication as a string (remove braces)") |
| 247 | ("note" "Remarks to be put at the end of the \\bibitem")))) | 254 | ("note" "Remarks to be put at the end of the \\bibitem")))) |
| 248 | ("Booklet" | 255 | ("Booklet" |
| 249 | ((("title" "Title of the booklet (BibTeX converts it to lowercase)")) | 256 | ((("title" "Title of the booklet (BibTeX converts it to lowercase)")) |
| 250 | (("author" "Author1 [and Author2 ...] [and others]") | 257 | (("author" "Author1 [and Author2 ...] [and others]") |
| 251 | ("howpublished" "The way in which the booklet was published") | 258 | ("howpublished" "The way in which the booklet was published") |
| 252 | ("address" "Address of the publisher") | 259 | ("address" "Address of the publisher") |
| 253 | ("month" "Month of the publication as a string (remove braces)") | 260 | ("month" "Month of the publication as a string (remove braces)") |
| 254 | ("year" "Year of publication") | 261 | ("year" "Year of publication") |
| 255 | ("note" "Remarks to be put at the end of the \\bibitem")))) | 262 | ("note" "Remarks to be put at the end of the \\bibitem")))) |
| 256 | ("InBook" | 263 | ("InBook" |
| 257 | ((("author" "Author1 [and Author2 ...] [and others]" "" t) | 264 | ((("author" "Author1 [and Author2 ...] [and others]" "" t) |
| 258 | ("editor" "Editor1 [and Editor2 ...] [and others]" "" t) | 265 | ("editor" "Editor1 [and Editor2 ...] [and others]" "" t) |
| 259 | ("title" "Title of the book") | 266 | ("title" "Title of the book") |
| 260 | ("chapter" "Chapter in the book") | 267 | ("chapter" "Chapter in the book") |
| 261 | ("publisher" "Publishing company") | 268 | ("publisher" "Publishing company") |
| 262 | ("year" "Year of publication")) | 269 | ("year" "Year of publication")) |
| 263 | (("volume" "Volume of the book in the series") | 270 | (("volume" "Volume of the book in the series") |
| 264 | ("number" "Number of the book in a small series (overwritten by volume)") | 271 | ("number" "Number of the book in a small series (overwritten by volume)") |
| 265 | ("series" "Series in which the book appeared") | 272 | ("series" "Series in which the book appeared") |
| 266 | ("type" "Word to use instead of \"chapter\"") | 273 | ("type" "Word to use instead of \"chapter\"") |
| 267 | ("address" "Address of the publisher") | 274 | ("address" "Address of the publisher") |
| 268 | ("edition" "Edition of the book as a capitalized English word") | 275 | ("edition" "Edition of the book as a capitalized English word") |
| 269 | ("month" "Month of the publication as a string (remove braces)") | 276 | ("month" "Month of the publication as a string (remove braces)") |
| 270 | ("pages" "Pages in the book") | 277 | ("pages" "Pages in the book") |
| 271 | ("note" "Remarks to be put at the end of the \\bibitem"))) | 278 | ("note" "Remarks to be put at the end of the \\bibitem"))) |
| 272 | ((("author" "Author1 [and Author2 ...] [and others]" "" t) | 279 | ((("author" "Author1 [and Author2 ...] [and others]" "" t) |
| 273 | ("editor" "Editor1 [and Editor2 ...] [and others]" "" t) | 280 | ("editor" "Editor1 [and Editor2 ...] [and others]" "" t) |
| 274 | ("title" "Title of the book") | 281 | ("title" "Title of the book") |
| 275 | ("chapter" "Chapter in the book")) | 282 | ("chapter" "Chapter in the book")) |
| 276 | (("pages" "Pages in the book") | 283 | (("pages" "Pages in the book") |
| 277 | ("publisher" "Publishing company") | 284 | ("publisher" "Publishing company") |
| 278 | ("year" "Year of publication") | 285 | ("year" "Year of publication") |
| 279 | ("volume" "Volume of the book in the series") | 286 | ("volume" "Volume of the book in the series") |
| 280 | ("number" "Number of the book in a small series (overwritten by volume)") | 287 | ("number" "Number of the book in a small series (overwritten by volume)") |
| 281 | ("series" "Series in which the book appeared") | 288 | ("series" "Series in which the book appeared") |
| 282 | ("type" "Word to use instead of \"chapter\"") | 289 | ("type" "Word to use instead of \"chapter\"") |
| 283 | ("address" "Address of the publisher") | 290 | ("address" "Address of the publisher") |
| 284 | ("edition" "Edition of the book as a capitalized English word") | 291 | ("edition" "Edition of the book as a capitalized English word") |
| 285 | ("month" "Month of the publication as a string (remove braces)") | 292 | ("month" "Month of the publication as a string (remove braces)") |
| 286 | ("note" "Remarks to be put at the end of the \\bibitem")))) | 293 | ("note" "Remarks to be put at the end of the \\bibitem")))) |
| 287 | ("InCollection" | 294 | ("InCollection" |
| 288 | ((("author" "Author1 [and Author2 ...] [and others]") | 295 | ((("author" "Author1 [and Author2 ...] [and others]") |
| 289 | ("title" "Title of the article in book (BibTeX converts it to lowercase)") | 296 | ("title" "Title of the article in book (BibTeX converts it to lowercase)") |
| 290 | ("booktitle" "Name of the book") | 297 | ("booktitle" "Name of the book") |
| 291 | ("publisher" "Publishing company") | 298 | ("publisher" "Publishing company") |
| 292 | ("year" "Year of publication")) | 299 | ("year" "Year of publication")) |
| 293 | (("editor" "Editor1 [and Editor2 ...] [and others]") | 300 | (("editor" "Editor1 [and Editor2 ...] [and others]") |
| 294 | ("volume" "Volume of the book in the series") | 301 | ("volume" "Volume of the book in the series") |
| 295 | ("number" "Number of the book in a small series (overwritten by volume)") | 302 | ("number" "Number of the book in a small series (overwritten by volume)") |
| 296 | ("series" "Series in which the book appeared") | 303 | ("series" "Series in which the book appeared") |
| 297 | ("type" "Word to use instead of \"chapter\"") | 304 | ("type" "Word to use instead of \"chapter\"") |
| 298 | ("chapter" "Chapter in the book") | 305 | ("chapter" "Chapter in the book") |
| 299 | ("pages" "Pages in the book") | 306 | ("pages" "Pages in the book") |
| 300 | ("address" "Address of the publisher") | 307 | ("address" "Address of the publisher") |
| 301 | ("edition" "Edition of the book as a capitalized English word") | 308 | ("edition" "Edition of the book as a capitalized English word") |
| 302 | ("month" "Month of the publication as a string (remove braces)") | 309 | ("month" "Month of the publication as a string (remove braces)") |
| 303 | ("note" "Remarks to be put at the end of the \\bibitem"))) | 310 | ("note" "Remarks to be put at the end of the \\bibitem"))) |
| 304 | ((("author" "Author1 [and Author2 ...] [and others]") | 311 | ((("author" "Author1 [and Author2 ...] [and others]") |
| 305 | ("title" "Title of the article in book (BibTeX converts it to lowercase)") | 312 | ("title" "Title of the article in book (BibTeX converts it to lowercase)") |
| 306 | ("booktitle" "Name of the book")) | 313 | ("booktitle" "Name of the book")) |
| 307 | (("pages" "Pages in the book") | 314 | (("pages" "Pages in the book") |
| 308 | ("publisher" "Publishing company") | 315 | ("publisher" "Publishing company") |
| 309 | ("year" "Year of publication") | 316 | ("year" "Year of publication") |
| 310 | ("editor" "Editor1 [and Editor2 ...] [and others]") | 317 | ("editor" "Editor1 [and Editor2 ...] [and others]") |
| 311 | ("volume" "Volume of the book in the series") | 318 | ("volume" "Volume of the book in the series") |
| 312 | ("number" "Number of the book in a small series (overwritten by volume)") | 319 | ("number" "Number of the book in a small series (overwritten by volume)") |
| 313 | ("series" "Series in which the book appeared") | 320 | ("series" "Series in which the book appeared") |
| 314 | ("type" "Word to use instead of \"chapter\"") | 321 | ("type" "Word to use instead of \"chapter\"") |
| 315 | ("chapter" "Chapter in the book") | 322 | ("chapter" "Chapter in the book") |
| 316 | ("address" "Address of the publisher") | 323 | ("address" "Address of the publisher") |
| 317 | ("edition" "Edition of the book as a capitalized English word") | 324 | ("edition" "Edition of the book as a capitalized English word") |
| 318 | ("month" "Month of the publication as a string (remove braces)") | 325 | ("month" "Month of the publication as a string (remove braces)") |
| 319 | ("note" "Remarks to be put at the end of the \\bibitem")))) | 326 | ("note" "Remarks to be put at the end of the \\bibitem")))) |
| 320 | ("InProceedings" | 327 | ("InProceedings" |
| 321 | ((("author" "Author1 [and Author2 ...] [and others]") | 328 | ((("author" "Author1 [and Author2 ...] [and others]") |
| 322 | ("title" "Title of the article in proceedings (BibTeX converts it to lowercase)") | 329 | ("title" "Title of the article in proceedings (BibTeX converts it to lowercase)") |
| 323 | ("booktitle" "Name of the conference proceedings") | 330 | ("booktitle" "Name of the conference proceedings") |
| 324 | ("year" "Year of publication")) | 331 | ("year" "Year of publication")) |
| 325 | (("editor" "Editor1 [and Editor2 ...] [and others]") | 332 | (("editor" "Editor1 [and Editor2 ...] [and others]") |
| 326 | ("volume" "Volume of the conference proceedings in the series") | 333 | ("volume" "Volume of the conference proceedings in the series") |
| 327 | ("number" "Number of the conference proceedings in a small series (overwritten by volume)") | 334 | ("number" "Number of the conference proceedings in a small series (overwritten by volume)") |
| 328 | ("series" "Series in which the conference proceedings appeared") | 335 | ("series" "Series in which the conference proceedings appeared") |
| 329 | ("pages" "Pages in the conference proceedings") | 336 | ("pages" "Pages in the conference proceedings") |
| 330 | ("address" "Location of the Proceedings") | 337 | ("address" "Location of the Proceedings") |
| 331 | ("month" "Month of the publication as a string (remove braces)") | 338 | ("month" "Month of the publication as a string (remove braces)") |
| 332 | ("organization" "Sponsoring organization of the conference") | 339 | ("organization" "Sponsoring organization of the conference") |
| 333 | ("publisher" "Publishing company, its location") | 340 | ("publisher" "Publishing company, its location") |
| 334 | ("note" "Remarks to be put at the end of the \\bibitem"))) | 341 | ("note" "Remarks to be put at the end of the \\bibitem"))) |
| 335 | ((("author" "Author1 [and Author2 ...] [and others]") | 342 | ((("author" "Author1 [and Author2 ...] [and others]") |
| 336 | ("title" "Title of the article in proceedings (BibTeX converts it to lowercase)")) | 343 | ("title" "Title of the article in proceedings (BibTeX converts it to lowercase)")) |
| 337 | (("booktitle" "Name of the conference proceedings") | 344 | (("booktitle" "Name of the conference proceedings") |
| 338 | ("pages" "Pages in the conference proceedings") | 345 | ("pages" "Pages in the conference proceedings") |
| 339 | ("year" "Year of publication") | 346 | ("year" "Year of publication") |
| 340 | ("editor" "Editor1 [and Editor2 ...] [and others]") | 347 | ("editor" "Editor1 [and Editor2 ...] [and others]") |
| 341 | ("volume" "Volume of the conference proceedings in the series") | 348 | ("volume" "Volume of the conference proceedings in the series") |
| 342 | ("number" "Number of the conference proceedings in a small series (overwritten by volume)") | 349 | ("number" "Number of the conference proceedings in a small series (overwritten by volume)") |
| 343 | ("series" "Series in which the conference proceedings appeared") | 350 | ("series" "Series in which the conference proceedings appeared") |
| 344 | ("address" "Location of the Proceedings") | 351 | ("address" "Location of the Proceedings") |
| 345 | ("month" "Month of the publication as a string (remove braces)") | 352 | ("month" "Month of the publication as a string (remove braces)") |
| 346 | ("organization" "Sponsoring organization of the conference") | 353 | ("organization" "Sponsoring organization of the conference") |
| 347 | ("publisher" "Publishing company, its location") | 354 | ("publisher" "Publishing company, its location") |
| 348 | ("note" "Remarks to be put at the end of the \\bibitem")))) | 355 | ("note" "Remarks to be put at the end of the \\bibitem")))) |
| 349 | ("Manual" | 356 | ("Manual" |
| 350 | ((("title" "Title of the manual")) | 357 | ((("title" "Title of the manual")) |
| 351 | (("author" "Author1 [and Author2 ...] [and others]") | 358 | (("author" "Author1 [and Author2 ...] [and others]") |
| 352 | ("organization" "Publishing organization of the manual") | 359 | ("organization" "Publishing organization of the manual") |
| 353 | ("address" "Address of the organization") | 360 | ("address" "Address of the organization") |
| 354 | ("edition" "Edition of the manual as a capitalized English word") | 361 | ("edition" "Edition of the manual as a capitalized English word") |
| 355 | ("month" "Month of the publication as a string (remove braces)") | 362 | ("month" "Month of the publication as a string (remove braces)") |
| 356 | ("year" "Year of publication") | 363 | ("year" "Year of publication") |
| 357 | ("note" "Remarks to be put at the end of the \\bibitem")))) | 364 | ("note" "Remarks to be put at the end of the \\bibitem")))) |
| 358 | ("MastersThesis" | 365 | ("MastersThesis" |
| 359 | ((("author" "Author1 [and Author2 ...] [and others]") | 366 | ((("author" "Author1 [and Author2 ...] [and others]") |
| 360 | ("title" "Title of the master\'s thesis (BibTeX converts it to lowercase)") | 367 | ("title" "Title of the master\'s thesis (BibTeX converts it to lowercase)") |
| 361 | ("school" "School where the master\'s thesis was written") | 368 | ("school" "School where the master\'s thesis was written") |
| 362 | ("year" "Year of publication")) | 369 | ("year" "Year of publication")) |
| 363 | (("type" "Type of the master\'s thesis (if other than \"Master\'s thesis\")") | 370 | (("type" "Type of the master\'s thesis (if other than \"Master\'s thesis\")") |
| 364 | ("address" "Address of the school (if not part of field \"school\") or country") | 371 | ("address" "Address of the school (if not part of field \"school\") or country") |
| 365 | ("month" "Month of the publication as a string (remove braces)") | 372 | ("month" "Month of the publication as a string (remove braces)") |
| 366 | ("note" "Remarks to be put at the end of the \\bibitem")))) | 373 | ("note" "Remarks to be put at the end of the \\bibitem")))) |
| 367 | ("Misc" | 374 | ("Misc" |
| 368 | (() | 375 | (() |
| 369 | (("author" "Author1 [and Author2 ...] [and others]") | 376 | (("author" "Author1 [and Author2 ...] [and others]") |
| 370 | ("title" "Title of the work (BibTeX converts it to lowercase)") | 377 | ("title" "Title of the work (BibTeX converts it to lowercase)") |
| 371 | ("howpublished" "The way in which the work was published") | 378 | ("howpublished" "The way in which the work was published") |
| 372 | ("month" "Month of the publication as a string (remove braces)") | 379 | ("month" "Month of the publication as a string (remove braces)") |
| 373 | ("year" "Year of publication") | 380 | ("year" "Year of publication") |
| 374 | ("note" "Remarks to be put at the end of the \\bibitem")))) | 381 | ("note" "Remarks to be put at the end of the \\bibitem")))) |
| 375 | ("PhdThesis" | 382 | ("PhdThesis" |
| 376 | ((("author" "Author1 [and Author2 ...] [and others]") | 383 | ((("author" "Author1 [and Author2 ...] [and others]") |
| 377 | ("title" "Title of the PhD. thesis") | 384 | ("title" "Title of the PhD. thesis") |
| 378 | ("school" "School where the PhD. thesis was written") | 385 | ("school" "School where the PhD. thesis was written") |
| 379 | ("year" "Year of publication")) | 386 | ("year" "Year of publication")) |
| 380 | (("type" "Type of the PhD. thesis") | 387 | (("type" "Type of the PhD. thesis") |
| 381 | ("address" "Address of the school (if not part of field \"school\") or country") | 388 | ("address" "Address of the school (if not part of field \"school\") or country") |
| 382 | ("month" "Month of the publication as a string (remove braces)") | 389 | ("month" "Month of the publication as a string (remove braces)") |
| 383 | ("note" "Remarks to be put at the end of the \\bibitem")))) | 390 | ("note" "Remarks to be put at the end of the \\bibitem")))) |
| 384 | ("Proceedings" | 391 | ("Proceedings" |
| 385 | ((("title" "Title of the conference proceedings") | 392 | ((("title" "Title of the conference proceedings") |
| 386 | ("year" "Year of publication")) | 393 | ("year" "Year of publication")) |
| 387 | (("booktitle" "Title of the proceedings for cross references") | 394 | (("booktitle" "Title of the proceedings for cross references") |
| 388 | ("editor" "Editor1 [and Editor2 ...] [and others]") | 395 | ("editor" "Editor1 [and Editor2 ...] [and others]") |
| 389 | ("volume" "Volume of the conference proceedings in the series") | 396 | ("volume" "Volume of the conference proceedings in the series") |
| 390 | ("number" "Number of the conference proceedings in a small series (overwritten by volume)") | 397 | ("number" "Number of the conference proceedings in a small series (overwritten by volume)") |
| 391 | ("series" "Series in which the conference proceedings appeared") | 398 | ("series" "Series in which the conference proceedings appeared") |
| 392 | ("address" "Location of the Proceedings") | 399 | ("address" "Location of the Proceedings") |
| 393 | ("month" "Month of the publication as a string (remove braces)") | 400 | ("month" "Month of the publication as a string (remove braces)") |
| 394 | ("organization" "Sponsoring organization of the conference") | 401 | ("organization" "Sponsoring organization of the conference") |
| 395 | ("publisher" "Publishing company, its location") | 402 | ("publisher" "Publishing company, its location") |
| 396 | ("note" "Remarks to be put at the end of the \\bibitem")))) | 403 | ("note" "Remarks to be put at the end of the \\bibitem")))) |
| 397 | ("TechReport" | 404 | ("TechReport" |
| 398 | ((("author" "Author1 [and Author2 ...] [and others]") | 405 | ((("author" "Author1 [and Author2 ...] [and others]") |
| 399 | ("title" "Title of the technical report (BibTeX converts it to lowercase)") | 406 | ("title" "Title of the technical report (BibTeX converts it to lowercase)") |
| 400 | ("institution" "Sponsoring institution of the report") | 407 | ("institution" "Sponsoring institution of the report") |
| 401 | ("year" "Year of publication")) | 408 | ("year" "Year of publication")) |
| 402 | (("type" "Type of the report (if other than \"technical report\")") | 409 | (("type" "Type of the report (if other than \"technical report\")") |
| 403 | ("number" "Number of the technical report") | 410 | ("number" "Number of the technical report") |
| 404 | ("address" "Address of the institution (if not part of field \"institution\") or country") | 411 | ("address" "Address of the institution (if not part of field \"institution\") or country") |
| 405 | ("month" "Month of the publication as a string (remove braces)") | 412 | ("month" "Month of the publication as a string (remove braces)") |
| 406 | ("note" "Remarks to be put at the end of the \\bibitem")))) | 413 | ("note" "Remarks to be put at the end of the \\bibitem")))) |
| 407 | ("Unpublished" | 414 | ("Unpublished" |
| 408 | ((("author" "Author1 [and Author2 ...] [and others]") | 415 | ((("author" "Author1 [and Author2 ...] [and others]") |
| 409 | ("title" "Title of the unpublished work (BibTeX converts it to lowercase)") | 416 | ("title" "Title of the unpublished work (BibTeX converts it to lowercase)") |
| 410 | ("note" "Remarks to be put at the end of the \\bibitem")) | 417 | ("note" "Remarks to be put at the end of the \\bibitem")) |
| 411 | (("month" "Month of the publication as a string (remove braces)") | 418 | (("month" "Month of the publication as a string (remove braces)") |
| 412 | ("year" "Year of publication")))) | 419 | ("year" "Year of publication")))) |
| 413 | ) | 420 | ) |
| 414 | 421 | ||
| 415 | "Defines entry types and their associated fields. | 422 | "Defines entry types and their associated fields. |
| @@ -452,7 +459,7 @@ REQUIRED or CROSSREF-REQUIRED lists.") | |||
| 452 | ("nov" . "November") | 459 | ("nov" . "November") |
| 453 | ("dec" . "December")) | 460 | ("dec" . "December")) |
| 454 | "Alist of month string definitions used in the BibTeX style files. | 461 | "Alist of month string definitions used in the BibTeX style files. |
| 455 | Each element is a pair of strings (ABBREVIATION EXPANSION)." | 462 | Each element is a pair of strings (ABBREVIATION . EXPANSION)." |
| 456 | :group 'bibtex | 463 | :group 'bibtex |
| 457 | :type '(repeat (cons (string :tag "Month abbreviation") | 464 | :type '(repeat (cons (string :tag "Month abbreviation") |
| 458 | (string :tag "Month expansion")))) | 465 | (string :tag "Month expansion")))) |
| @@ -481,7 +488,7 @@ Each element is a pair of strings (ABBREVIATION EXPANSION)." | |||
| 481 | ("toois" . "ACM Transactions on Office Information Systems") | 488 | ("toois" . "ACM Transactions on Office Information Systems") |
| 482 | ("toplas" . "ACM Transactions on Programming Languages and Systems"))) | 489 | ("toplas" . "ACM Transactions on Programming Languages and Systems"))) |
| 483 | "Alist of string definitions used in the BibTeX style files. | 490 | "Alist of string definitions used in the BibTeX style files. |
| 484 | Each element is a pair of strings (ABBREVIATION EXPANSION)." | 491 | Each element is a pair of strings (ABBREVIATION . EXPANSION)." |
| 485 | :group 'bibtex | 492 | :group 'bibtex |
| 486 | :type '(repeat (cons (string :tag "String") | 493 | :type '(repeat (cons (string :tag "String") |
| 487 | (string :tag "String expansion")))) | 494 | (string :tag "String expansion")))) |
| @@ -489,9 +496,7 @@ Each element is a pair of strings (ABBREVIATION EXPANSION)." | |||
| 489 | (defcustom bibtex-string-files nil | 496 | (defcustom bibtex-string-files nil |
| 490 | "*List of BibTeX files containing string definitions. | 497 | "*List of BibTeX files containing string definitions. |
| 491 | Those files must be specified using pathnames relative to the | 498 | Those files must be specified using pathnames relative to the |
| 492 | directories specified in `bibtex-string-file-path'. This variable is only | 499 | directories specified in `bibtex-string-file-path'." |
| 493 | evaluated when BibTeX mode is entered (i.e., when loading the BibTeX | ||
| 494 | file)." | ||
| 495 | :group 'bibtex | 500 | :group 'bibtex |
| 496 | :type '(repeat file)) | 501 | :type '(repeat file)) |
| 497 | 502 | ||
| @@ -499,21 +504,21 @@ file)." | |||
| 499 | "*Colon separated list of paths to search for `bibtex-string-files'.") | 504 | "*Colon separated list of paths to search for `bibtex-string-files'.") |
| 500 | 505 | ||
| 501 | (defcustom bibtex-help-message t | 506 | (defcustom bibtex-help-message t |
| 502 | "*If not nil print help messages in the echo area on entering a new field." | 507 | "*If non-nil print help messages in the echo area on entering a new field." |
| 503 | :group 'bibtex | 508 | :group 'bibtex |
| 504 | :type 'boolean) | 509 | :type 'boolean) |
| 505 | 510 | ||
| 506 | (defcustom bibtex-autokey-prefix-string "" | 511 | (defcustom bibtex-autokey-prefix-string "" |
| 507 | "*String to use as a prefix for all generated keys. | 512 | "*String to use as a prefix for all generated keys. |
| 508 | See the documentation of function `bibtex-generate-autokey' for more detail." | 513 | See `bibtex-generate-autokey' for details." |
| 509 | :group 'bibtex-autokey | 514 | :group 'bibtex-autokey |
| 510 | :type 'string) | 515 | :type 'string) |
| 511 | 516 | ||
| 512 | (defcustom bibtex-autokey-names 1 | 517 | (defcustom bibtex-autokey-names 1 |
| 513 | "*Number of names to use for the automatically generated reference key. | 518 | "*Number of names to use for the automatically generated reference key. |
| 514 | If this variable is nil, all names are used. | ||
| 515 | Possibly more names are used according to `bibtex-autokey-names-stretch'. | 519 | Possibly more names are used according to `bibtex-autokey-names-stretch'. |
| 516 | See the documentation of function `bibtex-generate-autokey' for more detail." | 520 | If this variable is nil, all names are used. |
| 521 | See `bibtex-generate-autokey' for details." | ||
| 517 | :group 'bibtex-autokey | 522 | :group 'bibtex-autokey |
| 518 | :type '(choice (const :tag "All" infty) | 523 | :type '(choice (const :tag "All" infty) |
| 519 | integer)) | 524 | integer)) |
| @@ -521,13 +526,13 @@ See the documentation of function `bibtex-generate-autokey' for more detail." | |||
| 521 | (defcustom bibtex-autokey-names-stretch 0 | 526 | (defcustom bibtex-autokey-names-stretch 0 |
| 522 | "*Number of names that can additionally be used. | 527 | "*Number of names that can additionally be used. |
| 523 | These names are used only, if all names are used then. | 528 | These names are used only, if all names are used then. |
| 524 | See the documentation of function `bibtex-generate-autokey' for details." | 529 | See `bibtex-generate-autokey' for details." |
| 525 | :group 'bibtex-autokey | 530 | :group 'bibtex-autokey |
| 526 | :type 'integer) | 531 | :type 'integer) |
| 527 | 532 | ||
| 528 | (defcustom bibtex-autokey-additional-names "" | 533 | (defcustom bibtex-autokey-additional-names "" |
| 529 | "*String to prepend to the generated key if not all names could be used. | 534 | "*String to prepend to the generated key if not all names could be used. |
| 530 | See the documentation of function `bibtex-generate-autokey' for details." | 535 | See `bibtex-generate-autokey' for details." |
| 531 | :group 'bibtex-autokey | 536 | :group 'bibtex-autokey |
| 532 | :type 'string) | 537 | :type 'string) |
| 533 | 538 | ||
| @@ -548,12 +553,11 @@ See the documentation of function `bibtex-generate-autokey' for details." | |||
| 548 | ("\\\"U\\|\\\\\\\"U" . "Ue") ; "U,\"U -> Ue | 553 | ("\\\"U\\|\\\\\\\"U" . "Ue") ; "U,\"U -> Ue |
| 549 | ;; accents | 554 | ;; accents |
| 550 | ("\\\\`\\|\\\\'\\|\\\\\\^\\|\\\\~\\|\\\\=\\|\\\\\\.\\|\\\\u\\|\\\\v\\|\\\\H\\|\\\\t\\|\\\\c\\|\\\\d\\|\\\\b" . "") | 555 | ("\\\\`\\|\\\\'\\|\\\\\\^\\|\\\\~\\|\\\\=\\|\\\\\\.\\|\\\\u\\|\\\\v\\|\\\\H\\|\\\\t\\|\\\\c\\|\\\\d\\|\\\\b" . "") |
| 551 | ("`\\|'\\|\\\"" . "") | 556 | ;; braces, quotes, concatenation. |
| 552 | ;; braces | 557 | ("[`'\"{}#]" . "") |
| 553 | ("{" . "") ("}" . "") | ||
| 554 | ;; spaces | 558 | ;; spaces |
| 555 | ("[ \t\n]+" . " ")) | 559 | ("[ \t\n]+" . " ")) |
| 556 | "Alist of (OLD-REGEXP NEW-STRING) pairs. | 560 | "Alist of (OLD-REGEXP . NEW-STRING) pairs. |
| 557 | Used by the default values of `bibtex-autokey-name-change-strings' and | 561 | Used by the default values of `bibtex-autokey-name-change-strings' and |
| 558 | `bibtex-autokey-titleword-change-strings'. Defaults to translating some | 562 | `bibtex-autokey-titleword-change-strings'. Defaults to translating some |
| 559 | language specific characters to their ASCII transcriptions, and | 563 | language specific characters to their ASCII transcriptions, and |
| @@ -561,18 +565,18 @@ removing any character accents.") | |||
| 561 | 565 | ||
| 562 | (defcustom bibtex-autokey-name-change-strings | 566 | (defcustom bibtex-autokey-name-change-strings |
| 563 | bibtex-autokey-transcriptions | 567 | bibtex-autokey-transcriptions |
| 564 | "Alist of (OLD-REGEXP NEW-STRING) pairs. | 568 | "Alist of (OLD-REGEXP . NEW-STRING) pairs. |
| 565 | Any part of name matching a OLD-REGEXP is replaced by NEW-STRING. | 569 | Any part of name matching a OLD-REGEXP is replaced by NEW-STRING. |
| 566 | Case is significant in OLD-REGEXP. All regexps are tried in the | 570 | Case is significant in OLD-REGEXP. All regexps are tried in the |
| 567 | order in which they appear in the list. | 571 | order in which they appear in the list. |
| 568 | See the documentation of function `bibtex-generate-autokey' for details." | 572 | See `bibtex-generate-autokey' for details." |
| 569 | :group 'bibtex-autokey | 573 | :group 'bibtex-autokey |
| 570 | :type '(repeat (cons (regexp :tag "Old") | 574 | :type '(repeat (cons (regexp :tag "Old") |
| 571 | (string :tag "New")))) | 575 | (string :tag "New")))) |
| 572 | 576 | ||
| 573 | (defcustom bibtex-autokey-name-case-convert 'downcase | 577 | (defcustom bibtex-autokey-name-case-convert 'downcase |
| 574 | "*Function called for each name to perform case conversion. | 578 | "*Function called for each name to perform case conversion. |
| 575 | See the documentation of function `bibtex-generate-autokey' for details." | 579 | See `bibtex-generate-autokey' for details." |
| 576 | :group 'bibtex-autokey | 580 | :group 'bibtex-autokey |
| 577 | :type '(choice (const :tag "Preserve case" identity) | 581 | :type '(choice (const :tag "Preserve case" identity) |
| 578 | (const :tag "Downcase" downcase) | 582 | (const :tag "Downcase" downcase) |
| @@ -583,20 +587,20 @@ See the documentation of function `bibtex-generate-autokey' for details." | |||
| 583 | (defcustom bibtex-autokey-name-length 'infty | 587 | (defcustom bibtex-autokey-name-length 'infty |
| 584 | "*Number of characters from name to incorporate into key. | 588 | "*Number of characters from name to incorporate into key. |
| 585 | If this is set to anything but a number, all characters are used. | 589 | If this is set to anything but a number, all characters are used. |
| 586 | See the documentation of function `bibtex-generate-autokey' for details." | 590 | See `bibtex-generate-autokey' for details." |
| 587 | :group 'bibtex-autokey | 591 | :group 'bibtex-autokey |
| 588 | :type '(choice (const :tag "All" infty) | 592 | :type '(choice (const :tag "All" infty) |
| 589 | integer)) | 593 | integer)) |
| 590 | 594 | ||
| 591 | (defcustom bibtex-autokey-name-separator "" | 595 | (defcustom bibtex-autokey-name-separator "" |
| 592 | "*String that comes between any two names in the key. | 596 | "*String that comes between any two names in the key. |
| 593 | See the documentation of function `bibtex-generate-autokey' for details." | 597 | See `bibtex-generate-autokey' for details." |
| 594 | :group 'bibtex-autokey | 598 | :group 'bibtex-autokey |
| 595 | :type 'string) | 599 | :type 'string) |
| 596 | 600 | ||
| 597 | (defcustom bibtex-autokey-year-length 2 | 601 | (defcustom bibtex-autokey-year-length 2 |
| 598 | "*Number of rightmost digits from the year field to incorporate into key. | 602 | "*Number of rightmost digits from the year field to incorporate into key. |
| 599 | See the documentation of function `bibtex-generate-autokey' for details." | 603 | See `bibtex-generate-autokey' for details." |
| 600 | :group 'bibtex-autokey | 604 | :group 'bibtex-autokey |
| 601 | :type 'integer) | 605 | :type 'integer) |
| 602 | 606 | ||
| @@ -604,7 +608,7 @@ See the documentation of function `bibtex-generate-autokey' for details." | |||
| 604 | "*If non-nil use fields from crossreferenced entry if necessary. | 608 | "*If non-nil use fields from crossreferenced entry if necessary. |
| 605 | If this variable is non-nil and some field has no entry, but a | 609 | If this variable is non-nil and some field has no entry, but a |
| 606 | valid crossref entry, the field from the crossreferenced entry is used. | 610 | valid crossref entry, the field from the crossreferenced entry is used. |
| 607 | See the documentation of function `bibtex-generate-autokey' for details." | 611 | See `bibtex-generate-autokey' for details." |
| 608 | :group 'bibtex-autokey | 612 | :group 'bibtex-autokey |
| 609 | :type 'boolean) | 613 | :type 'boolean) |
| 610 | 614 | ||
| @@ -613,7 +617,7 @@ See the documentation of function `bibtex-generate-autokey' for details." | |||
| 613 | If this is set to anything but a number, all title words are used. | 617 | If this is set to anything but a number, all title words are used. |
| 614 | Possibly more words from the title are used according to | 618 | Possibly more words from the title are used according to |
| 615 | `bibtex-autokey-titlewords-stretch'. | 619 | `bibtex-autokey-titlewords-stretch'. |
| 616 | See the documentation of function `bibtex-generate-autokey' for details." | 620 | See `bibtex-generate-autokey' for details." |
| 617 | :group 'bibtex-autokey | 621 | :group 'bibtex-autokey |
| 618 | :type '(choice (const :tag "All" infty) | 622 | :type '(choice (const :tag "All" infty) |
| 619 | integer)) | 623 | integer)) |
| @@ -622,14 +626,14 @@ See the documentation of function `bibtex-generate-autokey' for details." | |||
| 622 | '("\\." "!" "\\?" ":" ";" "--") | 626 | '("\\." "!" "\\?" ":" ";" "--") |
| 623 | "*Regexp list defining the termination of the main part of the title. | 627 | "*Regexp list defining the termination of the main part of the title. |
| 624 | Case of the regexps is ignored. | 628 | Case of the regexps is ignored. |
| 625 | See the documentation of function `bibtex-generate-autokey' for details." | 629 | See `bibtex-generate-autokey' for details." |
| 626 | :group 'bibtex-autokey | 630 | :group 'bibtex-autokey |
| 627 | :type '(repeat regexp)) | 631 | :type '(repeat regexp)) |
| 628 | 632 | ||
| 629 | (defcustom bibtex-autokey-titlewords-stretch 2 | 633 | (defcustom bibtex-autokey-titlewords-stretch 2 |
| 630 | "*Number of words that can additionally be used from the title. | 634 | "*Number of words that can additionally be used from the title. |
| 631 | These words are used only, if a sentence from the title can be ended then. | 635 | These words are used only, if a sentence from the title can be ended then. |
| 632 | See the documentation of function `bibtex-generate-autokey' for details." | 636 | See `bibtex-generate-autokey' for details." |
| 633 | :group 'bibtex-autokey | 637 | :group 'bibtex-autokey |
| 634 | :type 'integer) | 638 | :type 'integer) |
| 635 | 639 | ||
| @@ -639,13 +643,13 @@ See the documentation of function `bibtex-generate-autokey' for details." | |||
| 639 | "*Determines words from the title that are not to be used in the key. | 643 | "*Determines words from the title that are not to be used in the key. |
| 640 | Each item of the list is a regexp. If a word of the title matchs a | 644 | Each item of the list is a regexp. If a word of the title matchs a |
| 641 | regexp from that list, it is not included in the title part of the key. | 645 | regexp from that list, it is not included in the title part of the key. |
| 642 | See the documentation of function `bibtex-generate-autokey' for details." | 646 | See `bibtex-generate-autokey' for details." |
| 643 | :group 'bibtex-autokey | 647 | :group 'bibtex-autokey |
| 644 | :type '(repeat regexp)) | 648 | :type '(repeat regexp)) |
| 645 | 649 | ||
| 646 | (defcustom bibtex-autokey-titleword-case-convert 'downcase | 650 | (defcustom bibtex-autokey-titleword-case-convert 'downcase |
| 647 | "*Function called for each titleword to perform case conversion. | 651 | "*Function called for each titleword to perform case conversion. |
| 648 | See the documentation of function `bibtex-generate-autokey' for details." | 652 | See `bibtex-generate-autokey' for details." |
| 649 | :group 'bibtex-autokey | 653 | :group 'bibtex-autokey |
| 650 | :type '(choice (const :tag "Preserve case" identity) | 654 | :type '(choice (const :tag "Preserve case" identity) |
| 651 | (const :tag "Downcase" downcase) | 655 | (const :tag "Downcase" downcase) |
| @@ -655,20 +659,20 @@ See the documentation of function `bibtex-generate-autokey' for details." | |||
| 655 | 659 | ||
| 656 | (defcustom bibtex-autokey-titleword-abbrevs nil | 660 | (defcustom bibtex-autokey-titleword-abbrevs nil |
| 657 | "*Determines exceptions to the usual abbreviation mechanism. | 661 | "*Determines exceptions to the usual abbreviation mechanism. |
| 658 | An alist of (OLD-REGEXP NEW-STRING) pairs. Case is ignored | 662 | An alist of (OLD-REGEXP . NEW-STRING) pairs. Case is ignored |
| 659 | in matching against OLD-REGEXP, and the first matching pair is used. | 663 | in matching against OLD-REGEXP, and the first matching pair is used. |
| 660 | See the documentation of function `bibtex-generate-autokey' for details." | 664 | See `bibtex-generate-autokey' for details." |
| 661 | :group 'bibtex-autokey | 665 | :group 'bibtex-autokey |
| 662 | :type '(repeat (cons (regexp :tag "Old") | 666 | :type '(repeat (cons (regexp :tag "Old") |
| 663 | (string :tag "New")))) | 667 | (string :tag "New")))) |
| 664 | 668 | ||
| 665 | (defcustom bibtex-autokey-titleword-change-strings | 669 | (defcustom bibtex-autokey-titleword-change-strings |
| 666 | bibtex-autokey-transcriptions | 670 | bibtex-autokey-transcriptions |
| 667 | "Alist of (OLD-REGEXP NEW-STRING) pairs. | 671 | "Alist of (OLD-REGEXP . NEW-STRING) pairs. |
| 668 | Any part of title word matching a OLD-REGEXP is replaced by NEW-STRING. | 672 | Any part of title word matching a OLD-REGEXP is replaced by NEW-STRING. |
| 669 | Case is significant in OLD-REGEXP. All regexps are tried in the | 673 | Case is significant in OLD-REGEXP. All regexps are tried in the |
| 670 | order in which they appear in the list. | 674 | order in which they appear in the list. |
| 671 | See the documentation of function `bibtex-generate-autokey' for details." | 675 | See `bibtex-generate-autokey' for details." |
| 672 | :group 'bibtex-autokey | 676 | :group 'bibtex-autokey |
| 673 | :type '(repeat (cons (regexp :tag "Old") | 677 | :type '(repeat (cons (regexp :tag "Old") |
| 674 | (string :tag "New")))) | 678 | (string :tag "New")))) |
| @@ -676,26 +680,26 @@ See the documentation of function `bibtex-generate-autokey' for details." | |||
| 676 | (defcustom bibtex-autokey-titleword-length 5 | 680 | (defcustom bibtex-autokey-titleword-length 5 |
| 677 | "*Number of characters from title words to incorporate into key. | 681 | "*Number of characters from title words to incorporate into key. |
| 678 | If this is set to anything but a number, all characters are used. | 682 | If this is set to anything but a number, all characters are used. |
| 679 | See the documentation of function `bibtex-generate-autokey' for details." | 683 | See `bibtex-generate-autokey' for details." |
| 680 | :group 'bibtex-autokey | 684 | :group 'bibtex-autokey |
| 681 | :type '(choice (const :tag "All" infty) | 685 | :type '(choice (const :tag "All" infty) |
| 682 | integer)) | 686 | integer)) |
| 683 | 687 | ||
| 684 | (defcustom bibtex-autokey-titleword-separator "_" | 688 | (defcustom bibtex-autokey-titleword-separator "_" |
| 685 | "*String to be put between the title words. | 689 | "*String to be put between the title words. |
| 686 | See the documentation of function `bibtex-generate-autokey' for details." | 690 | See `bibtex-generate-autokey' for details." |
| 687 | :group 'bibtex-autokey | 691 | :group 'bibtex-autokey |
| 688 | :type 'string) | 692 | :type 'string) |
| 689 | 693 | ||
| 690 | (defcustom bibtex-autokey-name-year-separator "" | 694 | (defcustom bibtex-autokey-name-year-separator "" |
| 691 | "*String to be put between name part and year part of key. | 695 | "*String to be put between name part and year part of key. |
| 692 | See the documentation of function `bibtex-generate-autokey' for details." | 696 | See `bibtex-generate-autokey' for details." |
| 693 | :group 'bibtex-autokey | 697 | :group 'bibtex-autokey |
| 694 | :type 'string) | 698 | :type 'string) |
| 695 | 699 | ||
| 696 | (defcustom bibtex-autokey-year-title-separator ":_" | 700 | (defcustom bibtex-autokey-year-title-separator ":_" |
| 697 | "*String to be put between name part and year part of key. | 701 | "*String to be put between name part and year part of key. |
| 698 | See the documentation of function `bibtex-generate-autokey' for details." | 702 | See `bibtex-generate-autokey' for details." |
| 699 | :group 'bibtex-autokey | 703 | :group 'bibtex-autokey |
| 700 | :type 'string) | 704 | :type 'string) |
| 701 | 705 | ||
| @@ -706,11 +710,9 @@ See the documentation of function `bibtex-generate-autokey' for details." | |||
| 706 | 710 | ||
| 707 | (defcustom bibtex-autokey-before-presentation-function nil | 711 | (defcustom bibtex-autokey-before-presentation-function nil |
| 708 | "*Function to call before the generated key is presented. | 712 | "*Function to call before the generated key is presented. |
| 709 | If non-nil this should be a single function, which is called before | 713 | If non-nil this should be a function which is called before the generated key |
| 710 | the generated key is presented (in entry or, if | 714 | is presented. The function must take one argument (the automatically |
| 711 | `bibtex-autokey-edit-before-use' is t, in minibuffer). This function | 715 | generated key), and must return a string (the key to use)." |
| 712 | must take one argument (the automatically generated key), and must | ||
| 713 | return with a string (the key to use)." | ||
| 714 | :group 'bibtex-autokey | 716 | :group 'bibtex-autokey |
| 715 | :type '(choice (const nil) function)) | 717 | :type '(choice (const nil) function)) |
| 716 | 718 | ||
| @@ -751,6 +753,14 @@ If non-nil, the column for the equal sign is the value of | |||
| 751 | :group 'bibtex | 753 | :group 'bibtex |
| 752 | :type 'boolean) | 754 | :type 'boolean) |
| 753 | 755 | ||
| 756 | (defcustom bibtex-autoadd-commas t | ||
| 757 | "If non-nil automatically add missing commas at end of BibTeX fields." | ||
| 758 | :type 'boolean) | ||
| 759 | |||
| 760 | (defcustom bibtex-autofill-types '("Proceedings") | ||
| 761 | "Automatically fill fields if possible for those BibTeX entry types." | ||
| 762 | :type '(repeat string)) | ||
| 763 | |||
| 754 | (defcustom bibtex-complete-key-cleanup nil | 764 | (defcustom bibtex-complete-key-cleanup nil |
| 755 | "*Function called by `bibtex-complete' after insertion of a key fragment." | 765 | "*Function called by `bibtex-complete' after insertion of a key fragment." |
| 756 | :group 'bibtex-autokey | 766 | :group 'bibtex-autokey |
| @@ -839,6 +849,9 @@ If non-nil, the column for the equal sign is the value of | |||
| 839 | ["Next Field" bibtex-next-field t] | 849 | ["Next Field" bibtex-next-field t] |
| 840 | ["Beginning of Entry" bibtex-beginning-of-entry t] | 850 | ["Beginning of Entry" bibtex-beginning-of-entry t] |
| 841 | ["End of Entry" bibtex-end-of-entry t]) | 851 | ["End of Entry" bibtex-end-of-entry t]) |
| 852 | ("Moving in BibTeX Buffer" | ||
| 853 | ["Find Entry" bibtex-find-entry t] | ||
| 854 | ["Find Crossref Entry" bibtex-find-crossref t]) | ||
| 842 | ("Operating on Current Entry" | 855 | ("Operating on Current Entry" |
| 843 | ["Fill Entry" bibtex-fill-entry t] | 856 | ["Fill Entry" bibtex-fill-entry t] |
| 844 | ["Clean Entry" bibtex-clean-entry t] | 857 | ["Clean Entry" bibtex-clean-entry t] |
| @@ -855,6 +868,7 @@ If non-nil, the column for the equal sign is the value of | |||
| 855 | ["View Cite Locations (RefTeX)" reftex-view-crossref-from-bibtex | 868 | ["View Cite Locations (RefTeX)" reftex-view-crossref-from-bibtex |
| 856 | (fboundp 'reftex-view-crossref-from-bibtex)]) | 869 | (fboundp 'reftex-view-crossref-from-bibtex)]) |
| 857 | ("Operating on Current Field" | 870 | ("Operating on Current Field" |
| 871 | ["Fill Field" fill-paragraph t] | ||
| 858 | ["Remove Delimiters" bibtex-remove-delimiters t] | 872 | ["Remove Delimiters" bibtex-remove-delimiters t] |
| 859 | ["Remove OPT or ALT Prefix" bibtex-remove-OPT-or-ALT t] | 873 | ["Remove OPT or ALT Prefix" bibtex-remove-OPT-or-ALT t] |
| 860 | ["Clear Field" bibtex-empty-field t] | 874 | ["Clear Field" bibtex-empty-field t] |
| @@ -925,14 +939,17 @@ At most `bibtex-entry-kill-ring-max' items are kept here.") | |||
| 925 | (defvar bibtex-last-kill-command nil | 939 | (defvar bibtex-last-kill-command nil |
| 926 | "Type of the last kill command (either 'field or 'entry).") | 940 | "Type of the last kill command (either 'field or 'entry).") |
| 927 | 941 | ||
| 928 | (defvar bibtex-strings nil | 942 | (defvar bibtex-strings |
| 929 | "Candidates for `bibtex-complete' (string completion). | 943 | (lazy-completion-table bibtex-strings |
| 944 | bibtex-parse-strings (bibtex-string-files-init)) | ||
| 945 | "Completion table for BibTeX string keys. | ||
| 930 | Initialized from `bibtex-predefined-strings' and `bibtex-string-files'.") | 946 | Initialized from `bibtex-predefined-strings' and `bibtex-string-files'.") |
| 947 | (make-variable-buffer-local 'bibtex-strings) | ||
| 931 | 948 | ||
| 932 | (defvar bibtex-reference-keys nil | 949 | (defvar bibtex-reference-keys |
| 933 | "Candidates for TAB completion when entering a reference key using | 950 | (lazy-completion-table bibtex-reference-keys bibtex-parse-keys nil nil t) |
| 934 | the minibuffer. Also used for `bibtex-complete' (key completion). | 951 | "Completion table for BibTeX reference keys.") |
| 935 | Initialized in `bibtex-mode' and updated for each new entry.") | 952 | (make-variable-buffer-local 'bibtex-reference-keys) |
| 936 | 953 | ||
| 937 | (defvar bibtex-buffer-last-parsed-tick nil | 954 | (defvar bibtex-buffer-last-parsed-tick nil |
| 938 | "Last value returned by `buffer-modified-tick' when buffer | 955 | "Last value returned by `buffer-modified-tick' when buffer |
| @@ -954,7 +971,7 @@ was parsed for keys the last time.") | |||
| 954 | "History list for reading keys.") | 971 | "History list for reading keys.") |
| 955 | 972 | ||
| 956 | (defvar bibtex-entry-type-history nil | 973 | (defvar bibtex-entry-type-history nil |
| 957 | "Used to store the history list for reading entry types.") | 974 | "History list for reading entry types.") |
| 958 | 975 | ||
| 959 | (defvar bibtex-field-history nil | 976 | (defvar bibtex-field-history nil |
| 960 | "History list for reading field names.") | 977 | "History list for reading field names.") |
| @@ -987,8 +1004,7 @@ was parsed for keys the last time.") | |||
| 987 | 1004 | ||
| 988 | (defconst bibtex-entry-maybe-empty-head | 1005 | (defconst bibtex-entry-maybe-empty-head |
| 989 | (concat bibtex-entry-head "?") | 1006 | (concat bibtex-entry-head "?") |
| 990 | "Regexp matching the header line of a maybe empty BibTeX entry | 1007 | "Regexp matching the header line of a BibTeX entry (possibly without key).") |
| 991 | \(possibly without reference key).") | ||
| 992 | 1008 | ||
| 993 | (defconst bibtex-type-in-head 1 | 1009 | (defconst bibtex-type-in-head 1 |
| 994 | "Regexp subexpression number of the type part in `bibtex-entry-head'.") | 1010 | "Regexp subexpression number of the type part in `bibtex-entry-head'.") |
| @@ -1063,7 +1079,8 @@ function `bibtex-parse-field-name'.") | |||
| 1063 | (dolist (class bibtex-sort-entry-class alist) | 1079 | (dolist (class bibtex-sort-entry-class alist) |
| 1064 | (setq i (1+ i)) | 1080 | (setq i (1+ i)) |
| 1065 | (dolist (entry class) | 1081 | (dolist (entry class) |
| 1066 | (push (cons entry i) alist)))) | 1082 | ;; all entry names should be downcase (for ease of comparison) |
| 1083 | (push (cons (if (stringp entry) (downcase entry) entry) i) alist)))) | ||
| 1067 | "Alist for the classes of the entry types if the value of | 1084 | "Alist for the classes of the entry types if the value of |
| 1068 | `bibtex-maintain-sorted-entries' is `entry-class'.") | 1085 | `bibtex-maintain-sorted-entries' is `entry-class'.") |
| 1069 | 1086 | ||
| @@ -1105,33 +1122,43 @@ function `bibtex-parse-field-name'.") | |||
| 1105 | '(bibtex-mode "@\\S(*\\s(" "\\s)" nil bibtex-hs-forward-sexp nil)) | 1122 | '(bibtex-mode "@\\S(*\\s(" "\\s)" nil bibtex-hs-forward-sexp nil)) |
| 1106 | 1123 | ||
| 1107 | 1124 | ||
| 1108 | ;; Functions to Parse the BibTeX Entries | 1125 | (defconst bibtex-braced-string-syntax-table |
| 1109 | 1126 | (let ((st (make-syntax-table))) | |
| 1110 | (defun bibtex-parse-nested-braces (nesting-level) | 1127 | (modify-syntax-entry ?\{ "(}" st) |
| 1111 | "Starting on an opening brace, find the corresponding closing brace. | 1128 | (modify-syntax-entry ?\} "){" st) |
| 1112 | When the function is called, NESTING-LEVEL has to be set to `0'." | 1129 | (modify-syntax-entry ?\[ "." st) |
| 1113 | (cond ((looking-at "{") | 1130 | (modify-syntax-entry ?\] "." st) |
| 1114 | (search-forward-regexp "{[^{}]*") | 1131 | (modify-syntax-entry ?\( "." st) |
| 1115 | (bibtex-parse-nested-braces (+ nesting-level 1))) | 1132 | (modify-syntax-entry ?\) "." st) |
| 1116 | ((looking-at "}") | 1133 | (modify-syntax-entry ?\\ "." st) |
| 1117 | (forward-char 1) | 1134 | (modify-syntax-entry ?\" "." st) |
| 1118 | (if (= nesting-level 1) | 1135 | st) |
| 1119 | (point) | 1136 | "Syntax-table to parse matched braces.") |
| 1120 | (search-forward-regexp "[^{}]*") | 1137 | |
| 1121 | (bibtex-parse-nested-braces (- nesting-level 1)))) | 1138 | (defconst bibtex-quoted-string-syntax-table |
| 1122 | (t nil))) | 1139 | (let ((st (make-syntax-table))) |
| 1140 | (modify-syntax-entry ?\\ "\\" st) | ||
| 1141 | (modify-syntax-entry ?\" "\"" st) | ||
| 1142 | st) | ||
| 1143 | "Syntax-table to parse matched quotes.") | ||
| 1123 | 1144 | ||
| 1124 | (defun bibtex-parse-field-string () | 1145 | (defun bibtex-parse-field-string () |
| 1125 | "Parse a field string enclosed by braces or quotes. | 1146 | "Parse a field string enclosed by braces or quotes. |
| 1126 | If a syntactically correct string is found, a pair containing the start and | 1147 | If a syntactically correct string is found, a pair containing the start and |
| 1127 | end position of the field string is returned, nil otherwise." | 1148 | end position of the field string is returned, nil otherwise." |
| 1128 | (save-match-data | 1149 | (let ((end-point |
| 1129 | (let ((end-point (or (and (looking-at bibtex-quoted-string-re) | 1150 | (or (and (eq (following-char) ?\") |
| 1130 | (match-end 0)) | 1151 | (save-excursion |
| 1131 | (and (looking-at "{") | 1152 | (with-syntax-table bibtex-quoted-string-syntax-table |
| 1132 | (save-excursion (bibtex-parse-nested-braces 0)))))) | 1153 | (forward-sexp 1)) |
| 1133 | (if end-point | 1154 | (point))) |
| 1134 | (cons (point) end-point))))) | 1155 | (and (eq (following-char) ?\{) |
| 1156 | (save-excursion | ||
| 1157 | (with-syntax-table bibtex-braced-string-syntax-table | ||
| 1158 | (forward-sexp 1)) | ||
| 1159 | (point)))))) | ||
| 1160 | (if end-point | ||
| 1161 | (cons (point) end-point)))) | ||
| 1135 | 1162 | ||
| 1136 | (defun bibtex-parse-association (parse-lhs parse-rhs) | 1163 | (defun bibtex-parse-association (parse-lhs parse-rhs) |
| 1137 | "Parse a string of the format <left-hand-side = right-hand-side>. | 1164 | "Parse a string of the format <left-hand-side = right-hand-side>. |
| @@ -1141,8 +1168,9 @@ successfull. If both functions return non-nil, a pair containing the returned | |||
| 1141 | values of the functions PARSE-LHS and PARSE-RHS is returned." | 1168 | values of the functions PARSE-LHS and PARSE-RHS is returned." |
| 1142 | (save-match-data | 1169 | (save-match-data |
| 1143 | (save-excursion | 1170 | (save-excursion |
| 1144 | (let (left right) | 1171 | (let ((left (funcall parse-lhs)) |
| 1145 | (if (and (setq left (funcall parse-lhs)) | 1172 | right) |
| 1173 | (if (and left | ||
| 1146 | (looking-at "[ \t\n]*=[ \t\n]*") | 1174 | (looking-at "[ \t\n]*=[ \t\n]*") |
| 1147 | (goto-char (match-end 0)) | 1175 | (goto-char (match-end 0)) |
| 1148 | (setq right (funcall parse-rhs))) | 1176 | (setq right (funcall parse-rhs))) |
| @@ -1152,13 +1180,24 @@ values of the functions PARSE-LHS and PARSE-RHS is returned." | |||
| 1152 | "Parse the field name stored in `bibtex-field-name-for-parsing'. | 1180 | "Parse the field name stored in `bibtex-field-name-for-parsing'. |
| 1153 | If the field name is found, return a triple consisting of the position of the | 1181 | If the field name is found, return a triple consisting of the position of the |
| 1154 | very first character of the match, the actual starting position of the name | 1182 | very first character of the match, the actual starting position of the name |
| 1155 | part and end position of the match. Move point to end of field name." | 1183 | part and end position of the match. Move point to end of field name. |
| 1156 | (if (looking-at ",[ \t\n]*") | 1184 | If `bibtex-autoadd-commas' is non-nil add missing comma at end of preceeding |
| 1157 | (let ((start (point))) | 1185 | BibTeX field as necessary." |
| 1158 | (goto-char (match-end 0)) | 1186 | (cond ((looking-at ",[ \t\n]*") |
| 1159 | (when (looking-at bibtex-field-name-for-parsing) | 1187 | (let ((start (point))) |
| 1160 | (goto-char (match-end 0)) | 1188 | (goto-char (match-end 0)) |
| 1161 | (list start (match-beginning 0) (match-end 0)))))) | 1189 | (when (looking-at bibtex-field-name-for-parsing) |
| 1190 | (goto-char (match-end 0)) | ||
| 1191 | (list start (match-beginning 0) (match-end 0))))) | ||
| 1192 | ;; Maybe add a missing comma. | ||
| 1193 | ((and bibtex-autoadd-commas | ||
| 1194 | (looking-at (concat "[ \t\n]*\\(?:" bibtex-field-name-for-parsing | ||
| 1195 | "\\)[ \t\n]*="))) | ||
| 1196 | (skip-chars-backward " \t\n") | ||
| 1197 | (insert ",") | ||
| 1198 | (forward-char -1) | ||
| 1199 | ;; Now try again. | ||
| 1200 | (bibtex-parse-field-name)))) | ||
| 1162 | 1201 | ||
| 1163 | (defun bibtex-parse-field-text () | 1202 | (defun bibtex-parse-field-text () |
| 1164 | "Parse the text part of a BibTeX field. | 1203 | "Parse the text part of a BibTeX field. |
| @@ -1168,8 +1207,7 @@ is found, a pair containing the start and end position of the text is | |||
| 1168 | returned, nil otherwise. Move point to end of field text." | 1207 | returned, nil otherwise. Move point to end of field text." |
| 1169 | (let ((starting-point (point)) | 1208 | (let ((starting-point (point)) |
| 1170 | end-point failure boundaries) | 1209 | end-point failure boundaries) |
| 1171 | (while (and (not end-point) | 1210 | (while (not (or end-point failure)) |
| 1172 | (not failure)) | ||
| 1173 | (cond ((looking-at bibtex-field-const) | 1211 | (cond ((looking-at bibtex-field-const) |
| 1174 | (goto-char (match-end 0))) | 1212 | (goto-char (match-end 0))) |
| 1175 | ((setq boundaries (bibtex-parse-field-string)) | 1213 | ((setq boundaries (bibtex-parse-field-string)) |
| @@ -1194,10 +1232,14 @@ the name and text parts of the field is returned." | |||
| 1194 | "Search forward to find a field of name NAME. | 1232 | "Search forward to find a field of name NAME. |
| 1195 | If a syntactically correct field is found, a pair containing the boundaries of | 1233 | If a syntactically correct field is found, a pair containing the boundaries of |
| 1196 | the name and text parts of the field is returned. The search is limited by | 1234 | the name and text parts of the field is returned. The search is limited by |
| 1197 | optional arg BOUND. Do not move point." | 1235 | optional arg BOUND. If BOUND is t the search is limited by the end of the current |
| 1236 | entry. Do not move point." | ||
| 1198 | (save-match-data | 1237 | (save-match-data |
| 1199 | (save-excursion | 1238 | (save-excursion |
| 1200 | (unless bound (setq bound (point-max))) | 1239 | (unless (integer-or-marker-p bound) |
| 1240 | (setq bound (if bound | ||
| 1241 | (save-excursion (bibtex-end-of-entry)) | ||
| 1242 | (point-max)))) | ||
| 1201 | (let ((case-fold-search t) | 1243 | (let ((case-fold-search t) |
| 1202 | (bibtex-field-name-for-parsing name) | 1244 | (bibtex-field-name-for-parsing name) |
| 1203 | boundaries temp-boundaries) | 1245 | boundaries temp-boundaries) |
| @@ -1217,10 +1259,14 @@ optional arg BOUND. Do not move point." | |||
| 1217 | "Search backward to find a field of name NAME. | 1259 | "Search backward to find a field of name NAME. |
| 1218 | If a syntactically correct field is found, a pair containing the boundaries of | 1260 | If a syntactically correct field is found, a pair containing the boundaries of |
| 1219 | the name and text parts of the field is returned. The search is limited by | 1261 | the name and text parts of the field is returned. The search is limited by |
| 1220 | optional arg BOUND. Do not move point." | 1262 | optional arg BOUND. If BOUND is t the search is limited by the beginning of the |
| 1263 | current entry. Do not move point." | ||
| 1221 | (save-match-data | 1264 | (save-match-data |
| 1222 | (save-excursion | 1265 | (save-excursion |
| 1223 | (unless bound (setq bound (point-min))) | 1266 | (unless (integer-or-marker-p bound) |
| 1267 | (setq bound (if bound | ||
| 1268 | (save-excursion (bibtex-beginning-of-entry)) | ||
| 1269 | (point-min)))) | ||
| 1224 | (let ((case-fold-search t) | 1270 | (let ((case-fold-search t) |
| 1225 | (bibtex-field-name-for-parsing name) | 1271 | (bibtex-field-name-for-parsing name) |
| 1226 | boundaries temp-boundaries) | 1272 | boundaries temp-boundaries) |
| @@ -1233,17 +1279,17 @@ optional arg BOUND. Do not move point." | |||
| 1233 | (setq boundaries temp-boundaries))) | 1279 | (setq boundaries temp-boundaries))) |
| 1234 | boundaries)))) | 1280 | boundaries)))) |
| 1235 | 1281 | ||
| 1236 | (defun bibtex-start-of-field (bounds) | 1282 | (defsubst bibtex-start-of-field (bounds) |
| 1237 | (nth 0 (car bounds))) | 1283 | (nth 0 (car bounds))) |
| 1238 | (defun bibtex-start-of-name-in-field (bounds) | 1284 | (defsubst bibtex-start-of-name-in-field (bounds) |
| 1239 | (nth 1 (car bounds))) | 1285 | (nth 1 (car bounds))) |
| 1240 | (defun bibtex-end-of-name-in-field (bounds) | 1286 | (defsubst bibtex-end-of-name-in-field (bounds) |
| 1241 | (nth 2 (car bounds))) | 1287 | (nth 2 (car bounds))) |
| 1242 | (defun bibtex-end-of-field (bounds) | 1288 | (defsubst bibtex-end-of-field (bounds) |
| 1243 | (cddr bounds)) | 1289 | (cddr bounds)) |
| 1244 | (defun bibtex-start-of-text-in-field (bounds) | 1290 | (defsubst bibtex-start-of-text-in-field (bounds) |
| 1245 | (cadr bounds)) | 1291 | (cadr bounds)) |
| 1246 | (defun bibtex-end-of-text-in-field (bounds) | 1292 | (defsubst bibtex-end-of-text-in-field (bounds) |
| 1247 | (cddr bounds)) | 1293 | (cddr bounds)) |
| 1248 | 1294 | ||
| 1249 | (defun bibtex-name-in-field (bounds) | 1295 | (defun bibtex-name-in-field (bounds) |
| @@ -1267,6 +1313,7 @@ if present." | |||
| 1267 | If optional arg FOLLOW-CROSSREF is non-nil, follow crossref." | 1313 | If optional arg FOLLOW-CROSSREF is non-nil, follow crossref." |
| 1268 | (save-excursion | 1314 | (save-excursion |
| 1269 | (save-restriction | 1315 | (save-restriction |
| 1316 | ;; We want to jump back and forth while searching FIELD | ||
| 1270 | (bibtex-narrow-to-entry) | 1317 | (bibtex-narrow-to-entry) |
| 1271 | (goto-char (point-min)) | 1318 | (goto-char (point-min)) |
| 1272 | (let ((bounds (bibtex-search-forward-field field)) | 1319 | (let ((bounds (bibtex-search-forward-field field)) |
| @@ -1304,13 +1351,13 @@ If the string postfix is found, return a triple consisting of the position of | |||
| 1304 | the actual starting and ending position of the text and the very last | 1351 | the actual starting and ending position of the text and the very last |
| 1305 | character of the string entry. Move point past BibTeX string entry." | 1352 | character of the string entry. Move point past BibTeX string entry." |
| 1306 | (let* ((case-fold-search t) | 1353 | (let* ((case-fold-search t) |
| 1307 | (text-boundaries (bibtex-parse-field-text))) | 1354 | (bounds (bibtex-parse-field-text))) |
| 1308 | (when text-boundaries | 1355 | (when bounds |
| 1309 | (goto-char (cdr text-boundaries)) | 1356 | (goto-char (cdr bounds)) |
| 1310 | (when (looking-at "[ \t\n]*[})]") | 1357 | (when (looking-at "[ \t\n]*[})]") |
| 1311 | (goto-char (match-end 0)) | 1358 | (goto-char (match-end 0)) |
| 1312 | (list (car text-boundaries) | 1359 | (list (car bounds) |
| 1313 | (cdr text-boundaries) | 1360 | (cdr bounds) |
| 1314 | (match-end 0)))))) | 1361 | (match-end 0)))))) |
| 1315 | 1362 | ||
| 1316 | (defun bibtex-parse-string () | 1363 | (defun bibtex-parse-string () |
| @@ -1367,14 +1414,14 @@ delimiters if present." | |||
| 1367 | (substring content (match-beginning 1) (match-end 1)) | 1414 | (substring content (match-beginning 1) (match-end 1)) |
| 1368 | content))) | 1415 | content))) |
| 1369 | 1416 | ||
| 1370 | (defun bibtex-start-of-text-in-string (bounds) | 1417 | (defsubst bibtex-start-of-text-in-string (bounds) |
| 1371 | (nth 0 (cdr bounds))) | 1418 | (nth 0 (cdr bounds))) |
| 1372 | (defun bibtex-end-of-text-in-string (bounds) | 1419 | (defsubst bibtex-end-of-text-in-string (bounds) |
| 1373 | (nth 1 (cdr bounds))) | 1420 | (nth 1 (cdr bounds))) |
| 1374 | (defun bibtex-end-of-string (bounds) | 1421 | (defsubst bibtex-end-of-string (bounds) |
| 1375 | (nth 2 (cdr bounds))) | 1422 | (nth 2 (cdr bounds))) |
| 1376 | 1423 | ||
| 1377 | (defun bibtex-type-in-head () | 1424 | (defsubst bibtex-type-in-head () |
| 1378 | "Extract BibTeX type in head." | 1425 | "Extract BibTeX type in head." |
| 1379 | ;; ignore @ | 1426 | ;; ignore @ |
| 1380 | (buffer-substring-no-properties (1+ (match-beginning bibtex-type-in-head)) | 1427 | (buffer-substring-no-properties (1+ (match-beginning bibtex-type-in-head)) |
| @@ -1424,45 +1471,48 @@ next valid one. With optional argument BACKWARD non-nil, move backward to | |||
| 1424 | beginning of previous valid one. A valid entry is a syntactical correct one | 1471 | beginning of previous valid one. A valid entry is a syntactical correct one |
| 1425 | with type contained in `bibtex-entry-field-alist' or, if | 1472 | with type contained in `bibtex-entry-field-alist' or, if |
| 1426 | `bibtex-sort-ignore-string-entries' is nil, a syntactical correct string | 1473 | `bibtex-sort-ignore-string-entries' is nil, a syntactical correct string |
| 1427 | entry. Return buffer position if a valid entry is found, nil otherwise." | 1474 | entry. Return buffer position of beginning and ending of entry if a valid |
| 1475 | entry is found, nil otherwise." | ||
| 1476 | (interactive "P") | ||
| 1428 | (let ((case-fold-search t) | 1477 | (let ((case-fold-search t) |
| 1429 | found) | 1478 | found) |
| 1430 | (while (and (not found) | 1479 | (while (not (or found (if backward (bobp) (eobp)))) |
| 1431 | (not (if backward (bobp) (eobp)))) | 1480 | (let ((pnt (point)) |
| 1432 | (let ((pnt (point))) | 1481 | bounds) |
| 1433 | (cond ((or (and (looking-at bibtex-valid-entry-re) | 1482 | (cond ((or (and (looking-at bibtex-valid-entry-re) |
| 1434 | (bibtex-search-entry nil nil t) | 1483 | (setq found (bibtex-search-entry nil nil t)) |
| 1435 | (equal (match-beginning 0) pnt)) | 1484 | (equal (match-beginning 0) pnt)) |
| 1436 | (and (not bibtex-sort-ignore-string-entries) | 1485 | (and (not bibtex-sort-ignore-string-entries) |
| 1437 | (bibtex-parse-string))) | 1486 | (setq bounds (bibtex-parse-string)) |
| 1438 | (setq found pnt) | 1487 | (setq found (cons (bibtex-start-of-field bounds) |
| 1488 | (bibtex-end-of-string bounds))))) | ||
| 1439 | (goto-char pnt)) | 1489 | (goto-char pnt)) |
| 1440 | (backward | 1490 | (backward |
| 1441 | (goto-char (1- pnt)) | ||
| 1442 | (if (re-search-backward "^[ \t]*\\(@\\)" nil 'move) | 1491 | (if (re-search-backward "^[ \t]*\\(@\\)" nil 'move) |
| 1443 | (goto-char (match-beginning 1)))) | 1492 | (goto-char (match-beginning 1)))) |
| 1444 | (t (goto-char (1+ pnt)) | 1493 | (t (if (re-search-forward "\n[ \t]*@" nil 'move) |
| 1445 | (if (re-search-forward "^[ \t]*@" nil 'move) | ||
| 1446 | (forward-char -1)))))) | 1494 | (forward-char -1)))))) |
| 1447 | found)) | 1495 | found)) |
| 1448 | 1496 | ||
| 1449 | (defun bibtex-map-entries (fun) | 1497 | (defun bibtex-map-entries (fun) |
| 1450 | "Call FUN for each BibTeX entry starting with the current. | 1498 | "Call FUN for each BibTeX entry starting with the current. |
| 1451 | Do this to the end of the file. FUN is called with one argument, the key | 1499 | Do this to the end of the file. FUN is called with three arguments, the key of |
| 1452 | of the entry, and with point inside the entry. | 1500 | the entry and the buffer positions (marker) of beginning and end of entry. |
| 1453 | If `bibtex-sort-ignore-string-entries' is non-nil, FUN will not be | 1501 | Point is inside the entry. If `bibtex-sort-ignore-string-entries' is non-nil, |
| 1454 | called for @String entries." | 1502 | FUN will not be called for @String entries." |
| 1455 | (let ((case-fold-search t)) | 1503 | (let ((case-fold-search t)) |
| 1456 | (bibtex-beginning-of-entry) | 1504 | (bibtex-beginning-of-entry) |
| 1457 | (while (re-search-forward bibtex-entry-maybe-empty-head nil t) | 1505 | (while (re-search-forward bibtex-entry-head nil t) |
| 1458 | (save-excursion | 1506 | (let ((entry-type (bibtex-type-in-head)) |
| 1459 | (let ((entry-type (downcase (bibtex-type-in-head))) | 1507 | (key (bibtex-key-in-head "")) |
| 1460 | (key (bibtex-key-in-head ""))) | 1508 | (beg (copy-marker (match-beginning 0))) |
| 1509 | (end (copy-marker (save-excursion (bibtex-end-of-entry))))) | ||
| 1510 | (save-excursion | ||
| 1461 | (if (or (and (not bibtex-sort-ignore-string-entries) | 1511 | (if (or (and (not bibtex-sort-ignore-string-entries) |
| 1462 | (string-equal "string" entry-type)) | 1512 | (string-equal "string" (downcase entry-type))) |
| 1463 | (assoc-ignore-case entry-type bibtex-entry-field-alist)) | 1513 | (assoc-ignore-case entry-type bibtex-entry-field-alist)) |
| 1464 | (funcall fun key)))) | 1514 | (funcall fun key beg end))) |
| 1465 | (bibtex-end-of-entry)))) | 1515 | (goto-char end))))) |
| 1466 | 1516 | ||
| 1467 | (defun bibtex-progress-message (&optional flag interval) | 1517 | (defun bibtex-progress-message (&optional flag interval) |
| 1468 | "Echo a message about progress of current buffer. | 1518 | "Echo a message about progress of current buffer. |
| @@ -1513,29 +1563,29 @@ at least INTERVAL percent since last message was echoed." | |||
| 1513 | ")")) | 1563 | ")")) |
| 1514 | 1564 | ||
| 1515 | (defun bibtex-search-entry (empty-head &optional bound noerror backward) | 1565 | (defun bibtex-search-entry (empty-head &optional bound noerror backward) |
| 1516 | "A helper function necessary since the failure stack size limit for | 1566 | "Search for a BibTeX entry (maybe without reference key if EMPTY-HEAD is t). |
| 1517 | regexps was reduced in emacs 19.32. | 1567 | BOUND and NOERROR are exactly as in `re-search-forward'. If BACKWARD |
| 1518 | It searches for a BibTeX entry (maybe without a reference key if | 1568 | is non-nil, search is done in reverse direction. Point is moved past the |
| 1519 | EMPTY-HEAD is t). | 1569 | closing delimiter (at the beginning of entry if BACKWARD is non-nil). |
| 1520 | BOUND and NOERROR are exactly as in `re-search-forward'. If | 1570 | Return a cons pair with buffer positions of beginning and end of entry. |
| 1521 | BACKWARD is non-nil, search is done in reverse direction. After | 1571 | After call to this function MATCH-BEGINNING and MATCH-END functions |
| 1522 | call to this function MATCH-BEGINNING and MATCH-END functions are | 1572 | are defined, but only for the head part of the entry |
| 1523 | defined, but only for the head part of the entry (especially | 1573 | \(especially (match-end 0) just gives the end of the head part)." |
| 1524 | \(match-end 0) just gives the end of the head part)." | ||
| 1525 | (let ((pnt (point)) | 1574 | (let ((pnt (point)) |
| 1526 | (prefix (if empty-head | 1575 | (entry-head-re (if empty-head |
| 1527 | bibtex-entry-maybe-empty-head | 1576 | bibtex-entry-maybe-empty-head |
| 1528 | bibtex-entry-head))) | 1577 | bibtex-entry-head))) |
| 1529 | (if backward | 1578 | (if backward |
| 1530 | (let (found) | 1579 | (let (found) |
| 1531 | (while (and (not found) | 1580 | (while (and (not found) |
| 1532 | (re-search-backward prefix bound noerror)) | 1581 | (re-search-backward entry-head-re bound noerror)) |
| 1533 | (setq found (bibtex-search-entry empty-head pnt t))) | 1582 | (setq found (bibtex-search-entry empty-head pnt t))) |
| 1534 | (if found | 1583 | (if found |
| 1535 | (goto-char (match-beginning 0)) | 1584 | (progn (goto-char (match-beginning 0)) |
| 1585 | found) | ||
| 1536 | (cond ((equal noerror nil) | 1586 | (cond ((equal noerror nil) |
| 1537 | ;; yell | 1587 | ;; yell |
| 1538 | (error "Search of BibTeX entry failed")) | 1588 | (error "Backward search of BibTeX entry failed")) |
| 1539 | ((equal noerror t) | 1589 | ((equal noerror t) |
| 1540 | ;; don't move | 1590 | ;; don't move |
| 1541 | (goto-char pnt))) | 1591 | (goto-char pnt))) |
| @@ -1543,7 +1593,7 @@ defined, but only for the head part of the entry (especially | |||
| 1543 | (let ((limit (or bound (point-max))) | 1593 | (let ((limit (or bound (point-max))) |
| 1544 | found) | 1594 | found) |
| 1545 | (while (and (not found) | 1595 | (while (and (not found) |
| 1546 | (re-search-forward prefix bound noerror)) | 1596 | (re-search-forward entry-head-re bound noerror)) |
| 1547 | (save-match-data | 1597 | (save-match-data |
| 1548 | (let ((entry-closer | 1598 | (let ((entry-closer |
| 1549 | (if (save-excursion | 1599 | (if (save-excursion |
| @@ -1569,7 +1619,7 @@ defined, but only for the head part of the entry (especially | |||
| 1569 | (goto-char (match-end 0)) | 1619 | (goto-char (match-end 0)) |
| 1570 | (setq found t))))) | 1620 | (setq found t))))) |
| 1571 | (if found | 1621 | (if found |
| 1572 | (point) | 1622 | (cons (match-beginning 0) (point)) |
| 1573 | (cond ((not noerror) | 1623 | (cond ((not noerror) |
| 1574 | ;; yell | 1624 | ;; yell |
| 1575 | (error "Search of BibTeX entry failed")) | 1625 | (error "Search of BibTeX entry failed")) |
| @@ -1596,11 +1646,11 @@ defined, but only for the head part of the entry (especially | |||
| 1596 | (message "From: %s" | 1646 | (message "From: %s" |
| 1597 | (buffer-substring (point) flash))))) | 1647 | (buffer-substring (point) flash))))) |
| 1598 | 1648 | ||
| 1599 | (defun bibtex-make-optional-field (e-t) | 1649 | (defun bibtex-make-optional-field (field) |
| 1600 | "Make an optional field named E-T in current BibTeX entry." | 1650 | "Make an optional field named FIELD in current BibTeX entry." |
| 1601 | (if (consp e-t) | 1651 | (if (consp field) |
| 1602 | (bibtex-make-field (cons (concat "OPT" (car e-t)) (cdr e-t))) | 1652 | (bibtex-make-field (cons (concat "OPT" (car field)) (cdr field))) |
| 1603 | (bibtex-make-field (concat "OPT" e-t)))) | 1653 | (bibtex-make-field (concat "OPT" field)))) |
| 1604 | 1654 | ||
| 1605 | (defun bibtex-move-outside-of-entry () | 1655 | (defun bibtex-move-outside-of-entry () |
| 1606 | "Make sure point is outside of a BibTeX entry." | 1656 | "Make sure point is outside of a BibTeX entry." |
| @@ -1647,29 +1697,26 @@ defined, but only for the head part of the entry (especially | |||
| 1647 | Use `match-beginning' and `match-end' to parse the field. If NOERR is non-nil, | 1697 | Use `match-beginning' and `match-end' to parse the field. If NOERR is non-nil, |
| 1648 | no error is signalled. In this case, bounds are returned on success, | 1698 | no error is signalled. In this case, bounds are returned on success, |
| 1649 | nil otherwise." | 1699 | nil otherwise." |
| 1650 | (let* ((case-fold-search t) | 1700 | (let ((bounds (bibtex-search-backward-field bibtex-field-name t))) |
| 1651 | (old-point (point)) | ||
| 1652 | (boe (save-excursion (bibtex-beginning-of-entry))) | ||
| 1653 | (bounds (bibtex-search-backward-field bibtex-field-name boe))) | ||
| 1654 | (if (and bounds | 1701 | (if (and bounds |
| 1655 | (<= (bibtex-start-of-field bounds) old-point) | 1702 | (<= (bibtex-start-of-field bounds) (point)) |
| 1656 | (>= (bibtex-end-of-field bounds) old-point)) | 1703 | (>= (bibtex-end-of-field bounds) (point))) |
| 1657 | bounds | 1704 | bounds |
| 1658 | (unless noerr | 1705 | (unless noerr |
| 1659 | (error "Can't find enclosing BibTeX field"))))) | 1706 | (error "Can't find enclosing BibTeX field"))))) |
| 1660 | 1707 | ||
| 1661 | (defun bibtex-enclosing-entry-maybe-empty-head () | 1708 | (defun bibtex-enclosing-entry-maybe-empty-head () |
| 1662 | "Search for BibTeX entry enclosing point. Point moves to end of entry. | 1709 | "Search for BibTeX entry enclosing point. Move point to end of entry. |
| 1663 | Beginning (but not end) of entry is given by (`match-beginning' 0)." | 1710 | Beginning (but not end) of entry is given by (`match-beginning' 0)." |
| 1664 | (let ((case-fold-search t) | 1711 | (let ((case-fold-search t) |
| 1665 | (old-point (point))) | 1712 | (old-point (point))) |
| 1666 | (unless (re-search-backward bibtex-entry-maybe-empty-head nil t) | 1713 | (unless (re-search-backward bibtex-entry-maybe-empty-head nil t) |
| 1667 | (error "Can't find enclosing BibTeX entry") | 1714 | (goto-char old-point) |
| 1668 | (goto-char old-point)) | 1715 | (error "Can't find beginning of enclosing BibTeX entry")) |
| 1669 | (goto-char (match-beginning bibtex-type-in-head)) | 1716 | (goto-char (match-beginning bibtex-type-in-head)) |
| 1670 | (unless (bibtex-search-entry t nil t) | 1717 | (unless (bibtex-search-entry t nil t) |
| 1671 | (error "Can't find enclosing BibTeX entry") | 1718 | (goto-char old-point) |
| 1672 | (goto-char old-point)))) | 1719 | (error "Can't find end of enclosing BibTeX entry")))) |
| 1673 | 1720 | ||
| 1674 | (defun bibtex-insert-current-kill (n) | 1721 | (defun bibtex-insert-current-kill (n) |
| 1675 | (if (not bibtex-last-kill-command) | 1722 | (if (not bibtex-last-kill-command) |
| @@ -1830,10 +1877,10 @@ Formats current entry according to variable `bibtex-entry-format'." | |||
| 1830 | "\\([\"{][0-9]+\\)[ \t\n]*--?[ \t\n]*\\([0-9]+[\"}]\\)"))) | 1877 | "\\([\"{][0-9]+\\)[ \t\n]*--?[ \t\n]*\\([0-9]+[\"}]\\)"))) |
| 1831 | (replace-match "\\1-\\2")) | 1878 | (replace-match "\\1-\\2")) |
| 1832 | 1879 | ||
| 1833 | ;; use book title of crossrefed entry | 1880 | ;; use book title of crossref'd entry |
| 1834 | (if (and (memq 'inherit-booktitle format) | 1881 | (if (and (memq 'inherit-booktitle format) |
| 1835 | (equal (downcase field-name) "booktitle") | ||
| 1836 | empty-field | 1882 | empty-field |
| 1883 | (equal (downcase field-name) "booktitle") | ||
| 1837 | crossref-key) | 1884 | crossref-key) |
| 1838 | (let ((title (save-restriction | 1885 | (let ((title (save-restriction |
| 1839 | (widen) | 1886 | (widen) |
| @@ -1844,6 +1891,14 @@ Formats current entry according to variable `bibtex-entry-format'." | |||
| 1844 | (goto-char (1+ beg-text)) | 1891 | (goto-char (1+ beg-text)) |
| 1845 | (insert title)))) | 1892 | (insert title)))) |
| 1846 | 1893 | ||
| 1894 | ;; Use booktitle to set a missing title. | ||
| 1895 | (if (and empty-field | ||
| 1896 | (equal (downcase field-name) "title")) | ||
| 1897 | (let ((booktitle (bibtex-text-in-field "booktitle"))) | ||
| 1898 | (when booktitle | ||
| 1899 | (setq empty-field nil) | ||
| 1900 | (goto-char (1+ beg-text)) | ||
| 1901 | (insert booktitle)))) | ||
| 1847 | 1902 | ||
| 1848 | ;; if empty field, complain | 1903 | ;; if empty field, complain |
| 1849 | (if (and empty-field | 1904 | (if (and empty-field |
| @@ -1954,9 +2009,9 @@ and return results as a list." | |||
| 1954 | (let ((case-fold-search t)) | 2009 | (let ((case-fold-search t)) |
| 1955 | (mapcar 'bibtex-autokey-demangle-name | 2010 | (mapcar 'bibtex-autokey-demangle-name |
| 1956 | (split-string (bibtex-autokey-get-field | 2011 | (split-string (bibtex-autokey-get-field |
| 1957 | "\\(author\\)\\|\\(editor\\)" | 2012 | "author\\|editor" |
| 1958 | bibtex-autokey-name-change-strings) | 2013 | bibtex-autokey-name-change-strings) |
| 1959 | "[ ]+and[ ]+")))) | 2014 | "[ \t\n]+and[ \t\n]+")))) |
| 1960 | 2015 | ||
| 1961 | (defun bibtex-autokey-demangle-name (fullname) | 2016 | (defun bibtex-autokey-demangle-name (fullname) |
| 1962 | "Get the last part from a well-formed name and perform abbreviations." | 2017 | "Get the last part from a well-formed name and perform abbreviations." |
| @@ -2120,7 +2175,7 @@ The generation algorithm works as follows: | |||
| 2120 | (setq nnl (append nnl (list (car nl))) | 2175 | (setq nnl (append nnl (list (car nl))) |
| 2121 | nl (cdr nl))) | 2176 | nl (cdr nl))) |
| 2122 | nnl))) | 2177 | nnl))) |
| 2123 | (namepart (concat (mapconcat (lambda (name) name) | 2178 | (namepart (concat (mapconcat 'identity |
| 2124 | namelist | 2179 | namelist |
| 2125 | bibtex-autokey-name-separator) | 2180 | bibtex-autokey-name-separator) |
| 2126 | name-etal)) | 2181 | name-etal)) |
| @@ -2130,7 +2185,7 @@ The generation algorithm works as follows: | |||
| 2130 | (substring yearfield | 2185 | (substring yearfield |
| 2131 | (- (length yearfield) | 2186 | (- (length yearfield) |
| 2132 | bibtex-autokey-year-length)))) | 2187 | bibtex-autokey-year-length)))) |
| 2133 | (titlepart (mapconcat (lambda (name) name) | 2188 | (titlepart (mapconcat 'identity |
| 2134 | (bibtex-autokey-get-title) | 2189 | (bibtex-autokey-get-title) |
| 2135 | bibtex-autokey-titleword-separator)) | 2190 | bibtex-autokey-titleword-separator)) |
| 2136 | (autokey (concat bibtex-autokey-prefix-string | 2191 | (autokey (concat bibtex-autokey-prefix-string |
| @@ -2149,79 +2204,104 @@ The generation algorithm works as follows: | |||
| 2149 | autokey))) | 2204 | autokey))) |
| 2150 | 2205 | ||
| 2151 | 2206 | ||
| 2152 | (defun bibtex-parse-keys (add verbose &optional abortable) | 2207 | (defun bibtex-parse-keys (&optional add abortable verbose) |
| 2153 | "Set `bibtex-reference-keys' to the keys used in the whole buffer. | 2208 | "Set `bibtex-reference-keys' to the keys used in the whole buffer. |
| 2154 | The buffer might possibly be restricted. | 2209 | The buffer might possibly be restricted. |
| 2155 | Find both entry keys and crossref entries. | 2210 | Find both entry keys and crossref entries. |
| 2156 | If ADD is non-nil adds the new keys to `bibtex-reference-keys' instead of | 2211 | If ADD is non-nil add the new keys to `bibtex-reference-keys' instead of |
| 2157 | simply resetting it. If VERBOSE is non-nil gives messages about | 2212 | simply resetting it. If ADD is an alist of keys, also add ADD to |
| 2158 | progress. If ABORTABLE is non-nil abort on user input. | 2213 | `bibtex-reference-keys'. If ABORTABLE is non-nil abort on user |
| 2159 | Return t if parsing was completed, nil if aborted." | 2214 | input. If VERBOSE is non-nil gives messages about progress. |
| 2160 | (let ((reference-keys (if add bibtex-reference-keys))) | 2215 | Return alist of keys if parsing was completed, `aborted' otherwise." |
| 2216 | (let ((reference-keys (if (and add | ||
| 2217 | (listp bibtex-reference-keys)) | ||
| 2218 | bibtex-reference-keys))) | ||
| 2219 | (if (listp add) | ||
| 2220 | (dolist (key add) | ||
| 2221 | (unless (assoc (car key) reference-keys) | ||
| 2222 | (push key reference-keys)))) | ||
| 2161 | (save-excursion | 2223 | (save-excursion |
| 2162 | (save-match-data | 2224 | (save-match-data |
| 2163 | (goto-char (point-min)) | ||
| 2164 | (if verbose | 2225 | (if verbose |
| 2165 | (bibtex-progress-message | 2226 | (bibtex-progress-message |
| 2166 | (concat (buffer-name) ": parsing reference keys"))) | 2227 | (concat (buffer-name) ": parsing reference keys"))) |
| 2167 | (if (catch 'userkey | 2228 | (catch 'userkey |
| 2168 | (while (bibtex-skip-to-valid-entry) | 2229 | (goto-char (point-min)) |
| 2169 | (if (and abortable | 2230 | (if bibtex-parse-keys-fast |
| 2170 | (input-pending-p)) | 2231 | (let ((case-fold-search t) |
| 2171 | (throw 'userkey t)) | 2232 | (re (concat bibtex-entry-head "\\|" |
| 2172 | (if verbose | 2233 | ",[ \t\n]*crossref[ \t\n]*=[ \t\n]*" |
| 2173 | (bibtex-progress-message)) | 2234 | "\\(\"[^\"]*\"\\|{[^}]*}\\)[ \t\n]*[,})]"))) |
| 2174 | (let ((case-fold-search t) | 2235 | (while (re-search-forward re nil t) |
| 2175 | key crossref-key bounds) | 2236 | (if (and abortable (input-pending-p)) |
| 2176 | (cond ((looking-at bibtex-entry-head) | 2237 | ;; user has aborted by typing a key --> return `aborted' |
| 2177 | (setq key (bibtex-key-in-head)) | 2238 | (throw 'userkey 'aborted)) |
| 2178 | (let ((p (point)) | 2239 | (let ((key (cond ((match-end 3) |
| 2179 | (m (bibtex-end-of-entry))) | 2240 | ;; This is a crossref. |
| 2180 | (goto-char p) | 2241 | (buffer-substring-no-properties |
| 2181 | (if (setq bounds (bibtex-search-forward-field "crossref" m)) | 2242 | (1+ (match-beginning 3)) (1- (match-end 3)))) |
| 2182 | (setq crossref-key (bibtex-text-in-field-bounds bounds t))))) | 2243 | ((assoc-ignore-case (bibtex-type-in-head) |
| 2183 | ((setq bounds (bibtex-parse-string)) | 2244 | bibtex-entry-field-alist) |
| 2184 | (setq key (bibtex-reference-key-in-string bounds)))) | 2245 | ;; This is an entry. |
| 2185 | (forward-char) | 2246 | (match-string-no-properties bibtex-key-in-head))))) |
| 2186 | (unless (assoc key reference-keys) | 2247 | (if (and (stringp key) |
| 2187 | (push (list key) reference-keys)) | 2248 | (not (assoc key reference-keys))) |
| 2188 | (if (and crossref-key | 2249 | (push (list key) reference-keys))))) |
| 2189 | (not (assoc crossref-key reference-keys))) | 2250 | |
| 2190 | (push (list crossref-key) reference-keys))))) | 2251 | (let (;; ignore @String entries because they are handled |
| 2191 | ;; user has aborted by typing a key --> return nil | 2252 | ;; separately by bibtex-parse-strings |
| 2192 | nil | 2253 | (bibtex-sort-ignore-string-entries t) |
| 2193 | ;; successful operation --> return t | 2254 | crossref-key bounds) |
| 2194 | (setq bibtex-reference-keys reference-keys) | 2255 | (bibtex-map-entries |
| 2256 | (lambda (key beg end) | ||
| 2257 | (if (and abortable | ||
| 2258 | (input-pending-p)) | ||
| 2259 | ;; user has aborted by typing a key --> return `aborted' | ||
| 2260 | (throw 'userkey 'aborted)) | ||
| 2261 | (if verbose (bibtex-progress-message)) | ||
| 2262 | (unless (assoc key reference-keys) | ||
| 2263 | (push (list key) reference-keys)) | ||
| 2264 | (if (and (setq bounds (bibtex-search-forward-field "crossref" end)) | ||
| 2265 | (setq crossref-key (bibtex-text-in-field-bounds bounds t)) | ||
| 2266 | (not (assoc crossref-key reference-keys))) | ||
| 2267 | (push (list crossref-key) reference-keys)))))) | ||
| 2268 | |||
| 2195 | (if verbose | 2269 | (if verbose |
| 2196 | (bibtex-progress-message 'done)) | 2270 | (bibtex-progress-message 'done)) |
| 2197 | t))))) | 2271 | ;; successful operation --> return `bibtex-reference-keys' |
| 2272 | (setq bibtex-reference-keys reference-keys)))))) | ||
| 2198 | 2273 | ||
| 2199 | (defun bibtex-parse-strings (&optional init abortable) | 2274 | (defun bibtex-parse-strings (&optional add abortable) |
| 2200 | "Set `bibtex-strings' to the string definitions in the whole buffer. | 2275 | "Set `bibtex-strings' to the string definitions in the whole buffer. |
| 2201 | The buffer might possibly be restricted. | 2276 | The buffer might possibly be restricted. |
| 2202 | Optional arg INIT is used to initialize `bibtex-strings'. | 2277 | If ADD is non-nil add the new strings to `bibtex-strings' instead of |
| 2203 | If ABORTABLE is non-nil abort on user input. | 2278 | simply resetting it. If ADD is an alist of strings, also add ADD to |
| 2204 | Return t if parsing was completed, nil if aborted." | 2279 | `bibtex-strings'. If ABORTABLE is non-nil abort on user input. |
| 2280 | Return alist of strings if parsing was completed, `aborted' otherwise." | ||
| 2205 | (save-excursion | 2281 | (save-excursion |
| 2206 | (save-match-data | 2282 | (save-match-data |
| 2207 | (goto-char (point-min)) | 2283 | (goto-char (point-min)) |
| 2208 | (let ((strings init) | 2284 | (let ((strings (if (and add |
| 2285 | (listp bibtex-strings)) | ||
| 2286 | bibtex-strings)) | ||
| 2209 | bounds key) | 2287 | bounds key) |
| 2210 | (if (catch 'userkey | 2288 | (if (listp add) |
| 2211 | (while (setq bounds (bibtex-search-forward-string)) | 2289 | (dolist (string add) |
| 2212 | (if (and abortable | 2290 | (unless (assoc (car string) strings) |
| 2213 | (input-pending-p)) | 2291 | (push string strings)))) |
| 2214 | (throw 'userkey t)) | 2292 | (catch 'userkey |
| 2215 | (setq key (bibtex-reference-key-in-string bounds)) | 2293 | (while (setq bounds (bibtex-search-forward-string)) |
| 2216 | (if (not (assoc-ignore-case key strings)) | 2294 | (if (and abortable |
| 2217 | (push (cons key (bibtex-text-in-string bounds t)) | 2295 | (input-pending-p)) |
| 2218 | strings)) | 2296 | ;; user has aborted by typing a key --> return `aborted' |
| 2219 | (goto-char (bibtex-end-of-text-in-string bounds)))) | 2297 | (throw 'userkey 'aborted)) |
| 2220 | ;; user has aborted by typing a key --> return nil | 2298 | (setq key (bibtex-reference-key-in-string bounds)) |
| 2221 | nil | 2299 | (if (not (assoc-ignore-case key strings)) |
| 2222 | ;; successful operation --> return t | 2300 | (push (cons key (bibtex-text-in-string bounds t)) |
| 2223 | (setq bibtex-strings strings) | 2301 | strings)) |
| 2224 | t))))) | 2302 | (goto-char (bibtex-end-of-text-in-string bounds))) |
| 2303 | ;; successful operation --> return `bibtex-strings' | ||
| 2304 | (setq bibtex-strings strings)))))) | ||
| 2225 | 2305 | ||
| 2226 | (defun bibtex-string-files-init () | 2306 | (defun bibtex-string-files-init () |
| 2227 | "Return initialization for `bibtex-strings'. | 2307 | "Return initialization for `bibtex-strings'. |
| @@ -2251,7 +2331,7 @@ Use `bibtex-predefined-strings' and bib files `bibtex-string-files'." | |||
| 2251 | (goto-char (bibtex-end-of-string bounds)))) | 2331 | (goto-char (bibtex-end-of-string bounds)))) |
| 2252 | (setq found t))) | 2332 | (setq found t))) |
| 2253 | (unless found | 2333 | (unless found |
| 2254 | (error "File %s not in paths defined by bibtex-string-file-path variable" | 2334 | (error "File %s not in paths defined via bibtex-string-file-path" |
| 2255 | filename)))) | 2335 | filename)))) |
| 2256 | (append bibtex-predefined-strings (nreverse compl))))) | 2336 | (append bibtex-predefined-strings (nreverse compl))))) |
| 2257 | 2337 | ||
| @@ -2271,11 +2351,9 @@ with the current) are parsed." | |||
| 2271 | (widen) | 2351 | (widen) |
| 2272 | ;; Output no progress messages in bibtex-parse-keys | 2352 | ;; Output no progress messages in bibtex-parse-keys |
| 2273 | ;; because when in y-or-n-p that can hide the question. | 2353 | ;; because when in y-or-n-p that can hide the question. |
| 2274 | (if (and (if bibtex-maintain-sorted-entries | 2354 | (if (and (listp (bibtex-parse-keys nil t)) |
| 2275 | (bibtex-parse-keys nil nil t) | ||
| 2276 | t) | ||
| 2277 | ;; update bibtex-strings | 2355 | ;; update bibtex-strings |
| 2278 | (bibtex-parse-strings strings-init t)) | 2356 | (listp (bibtex-parse-strings strings-init t))) |
| 2279 | 2357 | ||
| 2280 | ;; remember that parsing was successful | 2358 | ;; remember that parsing was successful |
| 2281 | (setq bibtex-buffer-last-parsed-tick (buffer-modified-tick))))) | 2359 | (setq bibtex-buffer-last-parsed-tick (buffer-modified-tick))))) |
| @@ -2310,7 +2388,9 @@ of a word, all strings are listed. Return completion." | |||
| 2310 | nil)))) | 2388 | nil)))) |
| 2311 | 2389 | ||
| 2312 | (defun bibtex-complete-string-cleanup (str) | 2390 | (defun bibtex-complete-string-cleanup (str) |
| 2313 | "Remove enclosing field delimiters." | 2391 | "Cleanup after inserting string STR. |
| 2392 | Remove enclosing field delimiters for string STR. Display message with | ||
| 2393 | expansion of STR." | ||
| 2314 | (let ((pair (assoc str bibtex-strings))) | 2394 | (let ((pair (assoc str bibtex-strings))) |
| 2315 | (when pair | 2395 | (when pair |
| 2316 | (if (cdr pair) | 2396 | (if (cdr pair) |
| @@ -2348,7 +2428,7 @@ of a word, all strings are listed. Return completion." | |||
| 2348 | (set-window-point window (point)))) | 2428 | (set-window-point window (point)))) |
| 2349 | 2429 | ||
| 2350 | (defun bibtex-pop (arg direction) | 2430 | (defun bibtex-pop (arg direction) |
| 2351 | "Generic function to be used by `bibtex-pop-previous' and `bibtex-pop-next'." | 2431 | "Generic function used by `bibtex-pop-previous' and `bibtex-pop-next'." |
| 2352 | (let (bibtex-help-message) | 2432 | (let (bibtex-help-message) |
| 2353 | (bibtex-find-text nil)) | 2433 | (bibtex-find-text nil)) |
| 2354 | (save-excursion | 2434 | (save-excursion |
| @@ -2407,6 +2487,10 @@ of a word, all strings are listed. Return completion." | |||
| 2407 | (bibtex-find-text nil)) | 2487 | (bibtex-find-text nil)) |
| 2408 | (setq this-command 'bibtex-pop)) | 2488 | (setq this-command 'bibtex-pop)) |
| 2409 | 2489 | ||
| 2490 | (defsubst bibtex-read-key (prompt &optional key) | ||
| 2491 | "Read BibTeX key from minibuffer using PROMPT and default KEY." | ||
| 2492 | (completing-read prompt bibtex-reference-keys | ||
| 2493 | nil nil key 'bibtex-key-history)) | ||
| 2410 | 2494 | ||
| 2411 | ;; Interactive Functions: | 2495 | ;; Interactive Functions: |
| 2412 | 2496 | ||
| @@ -2416,22 +2500,21 @@ of a word, all strings are listed. Return completion." | |||
| 2416 | 2500 | ||
| 2417 | General information on working with BibTeX mode: | 2501 | General information on working with BibTeX mode: |
| 2418 | 2502 | ||
| 2419 | You should use commands as \\[bibtex-Book] to get a template for a | 2503 | You should use commands such as \\[bibtex-Book] to get a template for a |
| 2420 | specific entry. You should then fill in all desired fields using | 2504 | specific entry. You should then fill in all desired fields using |
| 2421 | \\[bibtex-next-field] to jump from field to field. After having filled | 2505 | \\[bibtex-next-field] to jump from field to field. After having filled |
| 2422 | in all desired fields in the entry, you should clean the new entry | 2506 | in all desired fields in the entry, you should clean the new entry |
| 2423 | with command \\[bibtex-clean-entry]. | 2507 | with the command \\[bibtex-clean-entry]. |
| 2424 | 2508 | ||
| 2425 | Some features of BibTeX mode are available only by setting variable | 2509 | Some features of BibTeX mode are available only by setting the variable |
| 2426 | `bibtex-maintain-sorted-entries' to t. However, then BibTeX mode will | 2510 | `bibtex-maintain-sorted-entries' to non-nil. However, then BibTeX mode will |
| 2427 | work with buffer containing only valid (syntactical correct) entries | 2511 | work only with buffers containing valid (syntactical correct) entries |
| 2428 | and with entries being sorted. This is usually the case, if you have | 2512 | and with entries being sorted. This is usually the case, if you have |
| 2429 | created a buffer completely with BibTeX mode and finished every new | 2513 | created a buffer completely with BibTeX mode and finished every new |
| 2430 | entry with \\[bibtex-clean-entry]. | 2514 | entry with \\[bibtex-clean-entry]. |
| 2431 | 2515 | ||
| 2432 | For third party BibTeX buffers, please call the function | 2516 | For third party BibTeX files, call the function `bibtex-convert-alien' |
| 2433 | `bibtex-convert-alien' to fully take advantage of all features of | 2517 | to fully take advantage of all features of BibTeX mode. |
| 2434 | BibTeX mode. | ||
| 2435 | 2518 | ||
| 2436 | 2519 | ||
| 2437 | Special information: | 2520 | Special information: |
| @@ -2443,8 +2526,7 @@ Alternatives from which only one is required start with the string ALT. | |||
| 2443 | The OPT or ALT string may be removed from a field with \\[bibtex-remove-OPT-or-ALT]. | 2526 | The OPT or ALT string may be removed from a field with \\[bibtex-remove-OPT-or-ALT]. |
| 2444 | \\[bibtex-make-field] inserts a new field after the current one. | 2527 | \\[bibtex-make-field] inserts a new field after the current one. |
| 2445 | \\[bibtex-kill-field] kills the current field entirely. | 2528 | \\[bibtex-kill-field] kills the current field entirely. |
| 2446 | \\[bibtex-yank] will yank the last recently killed field after the | 2529 | \\[bibtex-yank] yanks the last recently killed field after the current field. |
| 2447 | current field. | ||
| 2448 | \\[bibtex-remove-delimiters] removes the double-quotes or braces around the text of the current field. | 2530 | \\[bibtex-remove-delimiters] removes the double-quotes or braces around the text of the current field. |
| 2449 | \\[bibtex-empty-field] replaces the text of the current field with the default \"\" or {}. | 2531 | \\[bibtex-empty-field] replaces the text of the current field with the default \"\" or {}. |
| 2450 | 2532 | ||
| @@ -2507,12 +2589,7 @@ non-nil. | |||
| 2507 | (setq major-mode 'bibtex-mode) | 2589 | (setq major-mode 'bibtex-mode) |
| 2508 | (setq mode-name "BibTeX") | 2590 | (setq mode-name "BibTeX") |
| 2509 | (set-syntax-table bibtex-mode-syntax-table) | 2591 | (set-syntax-table bibtex-mode-syntax-table) |
| 2510 | (make-local-variable 'bibtex-strings) | ||
| 2511 | (make-local-variable 'bibtex-reference-keys) | ||
| 2512 | (make-local-variable 'bibtex-buffer-last-parsed-tick) | 2592 | (make-local-variable 'bibtex-buffer-last-parsed-tick) |
| 2513 | (bibtex-parse-strings (bibtex-string-files-init)) | ||
| 2514 | (if bibtex-maintain-sorted-entries | ||
| 2515 | (bibtex-parse-keys nil nil t)) | ||
| 2516 | ;; Install stealthy parse function if not already installed | 2593 | ;; Install stealthy parse function if not already installed |
| 2517 | (unless bibtex-parse-idle-timer | 2594 | (unless bibtex-parse-idle-timer |
| 2518 | (setq bibtex-parse-idle-timer (bibtex-run-with-idle-timer | 2595 | (setq bibtex-parse-idle-timer (bibtex-run-with-idle-timer |
| @@ -2525,6 +2602,7 @@ non-nil. | |||
| 2525 | (set (make-local-variable 'comment-column) 0) | 2602 | (set (make-local-variable 'comment-column) 0) |
| 2526 | (set (make-local-variable 'defun-prompt-regexp) "^[ \t]*@[a-zA-Z0-9]+[ \t]*") | 2603 | (set (make-local-variable 'defun-prompt-regexp) "^[ \t]*@[a-zA-Z0-9]+[ \t]*") |
| 2527 | (set (make-local-variable 'outline-regexp) "[ \t]*@") | 2604 | (set (make-local-variable 'outline-regexp) "[ \t]*@") |
| 2605 | (set (make-local-variable 'fill-paragraph-function) 'bibtex-fill-field) | ||
| 2528 | (set (make-local-variable 'fill-prefix) (make-string (+ bibtex-entry-offset | 2606 | (set (make-local-variable 'fill-prefix) (make-string (+ bibtex-entry-offset |
| 2529 | bibtex-contline-indentation) | 2607 | bibtex-contline-indentation) |
| 2530 | ? )) | 2608 | ? )) |
| @@ -2538,11 +2616,11 @@ non-nil. | |||
| 2538 | ;; brace-delimited ones | 2616 | ;; brace-delimited ones |
| 2539 | ) | 2617 | ) |
| 2540 | nil | 2618 | nil |
| 2541 | (font-lock-syntactic-keywords . bibtex-font-lock-syntactic-keywords))) | 2619 | (font-lock-syntactic-keywords . bibtex-font-lock-syntactic-keywords) |
| 2542 | (set (make-local-variable 'font-lock-mark-block-function) | 2620 | (font-lock-mark-block-function |
| 2543 | (lambda () | 2621 | . (lambda () |
| 2544 | (set-mark (bibtex-end-of-entry)) | 2622 | (set-mark (bibtex-end-of-entry)) |
| 2545 | (bibtex-beginning-of-entry))) | 2623 | (bibtex-beginning-of-entry))))) |
| 2546 | (setq imenu-generic-expression | 2624 | (setq imenu-generic-expression |
| 2547 | (list (list nil bibtex-entry-head bibtex-key-in-head))) | 2625 | (list (list nil bibtex-entry-head bibtex-key-in-head))) |
| 2548 | (make-local-variable 'choose-completion-string-functions) | 2626 | (make-local-variable 'choose-completion-string-functions) |
| @@ -2561,13 +2639,9 @@ After insertion it calls the functions in `bibtex-add-entry-hook'." | |||
| 2561 | bibtex-entry-field-alist | 2639 | bibtex-entry-field-alist |
| 2562 | nil t nil 'bibtex-entry-type-history))) | 2640 | nil t nil 'bibtex-entry-type-history))) |
| 2563 | (list e-t))) | 2641 | (list e-t))) |
| 2564 | (unless (consp bibtex-reference-keys) (bibtex-parse-keys nil t)) | 2642 | (let* (required optional |
| 2565 | (let* (required | ||
| 2566 | optional | ||
| 2567 | (key (if bibtex-maintain-sorted-entries | 2643 | (key (if bibtex-maintain-sorted-entries |
| 2568 | (completing-read (format "%s key: " entry-type) | 2644 | (bibtex-read-key (format "%s key: " entry-type)))) |
| 2569 | bibtex-reference-keys | ||
| 2570 | nil nil nil 'bibtex-key-history))) | ||
| 2571 | (e (assoc-ignore-case entry-type bibtex-entry-field-alist)) | 2645 | (e (assoc-ignore-case entry-type bibtex-entry-field-alist)) |
| 2572 | (r-n-o (elt e 1)) | 2646 | (r-n-o (elt e 1)) |
| 2573 | (c-ref (elt e 2))) | 2647 | (c-ref (elt e 2))) |
| @@ -2603,8 +2677,92 @@ After insertion it calls the functions in `bibtex-add-entry-hook'." | |||
| 2603 | (indent-to-column bibtex-entry-offset) | 2677 | (indent-to-column bibtex-entry-offset) |
| 2604 | (insert (bibtex-entry-right-delimiter) "\n\n")) | 2678 | (insert (bibtex-entry-right-delimiter) "\n\n")) |
| 2605 | (bibtex-next-field t) | 2679 | (bibtex-next-field t) |
| 2680 | (if (member-ignore-case entry-type bibtex-autofill-types) | ||
| 2681 | (bibtex-autofill-entry)) | ||
| 2606 | (run-hooks 'bibtex-add-entry-hook))) | 2682 | (run-hooks 'bibtex-add-entry-hook))) |
| 2607 | 2683 | ||
| 2684 | (defun bibtex-parse-entry () | ||
| 2685 | "Parse entry at point, return an alist. | ||
| 2686 | The alist elements have the form (FIELD . TEXT), where FIELD can also be | ||
| 2687 | the special strings \"=type=\" and \"=key=\"." | ||
| 2688 | (let (alist bounds) | ||
| 2689 | (when (looking-at bibtex-entry-head) | ||
| 2690 | (push (cons "=type=" (match-string bibtex-type-in-head)) alist) | ||
| 2691 | (push (cons "=key=" (match-string bibtex-key-in-head)) alist) | ||
| 2692 | (goto-char (match-end bibtex-key-in-head)) | ||
| 2693 | (while (setq bounds (bibtex-parse-field bibtex-field-name)) | ||
| 2694 | (push (cons (bibtex-name-in-field bounds) | ||
| 2695 | (bibtex-text-in-field-bounds bounds)) | ||
| 2696 | alist) | ||
| 2697 | (goto-char (bibtex-end-of-field bounds)))) | ||
| 2698 | alist)) | ||
| 2699 | |||
| 2700 | (defun bibtex-autofill-entry () | ||
| 2701 | "Try to fill fields based on surrounding entries." | ||
| 2702 | (interactive) | ||
| 2703 | (undo-boundary) ;So you can easily undo it, if it didn't work right. | ||
| 2704 | (bibtex-beginning-of-entry) | ||
| 2705 | (when (looking-at bibtex-entry-head) | ||
| 2706 | (let ((type (match-string bibtex-type-in-head)) | ||
| 2707 | (key (match-string bibtex-key-in-head)) | ||
| 2708 | (key-end (match-end bibtex-key-in-head)) | ||
| 2709 | (case-fold-search t) | ||
| 2710 | tmp other-key other bounds) | ||
| 2711 | ;; The fields we want to change start right after the key. | ||
| 2712 | (goto-char key-end) | ||
| 2713 | ;; First see whether to use the previous or the next entry | ||
| 2714 | ;; for "inspiration". | ||
| 2715 | (save-excursion | ||
| 2716 | (goto-char (1- (match-beginning 0))) | ||
| 2717 | (bibtex-beginning-of-entry) | ||
| 2718 | (when (and | ||
| 2719 | (looking-at bibtex-entry-head) | ||
| 2720 | (equal type (match-string bibtex-type-in-head)) | ||
| 2721 | ;; In case we found ourselves :-( | ||
| 2722 | (not (equal key (setq tmp (match-string bibtex-key-in-head))))) | ||
| 2723 | (setq other-key tmp) | ||
| 2724 | (setq other (point)))) | ||
| 2725 | (save-excursion | ||
| 2726 | (bibtex-end-of-entry) | ||
| 2727 | (bibtex-skip-to-valid-entry) | ||
| 2728 | (when (and | ||
| 2729 | (looking-at bibtex-entry-head) | ||
| 2730 | (equal type (match-string bibtex-type-in-head)) | ||
| 2731 | ;; In case we found ourselves :-( | ||
| 2732 | (not (equal key (setq tmp (match-string bibtex-key-in-head)))) | ||
| 2733 | (or (not other-key) | ||
| 2734 | ;; Check which is the best match. | ||
| 2735 | (< (length (try-completion "" (list key other-key))) | ||
| 2736 | (length (try-completion "" (list key tmp)))))) | ||
| 2737 | (setq other-key tmp) | ||
| 2738 | (setq other (point)))) | ||
| 2739 | ;; Then fill the new entry's fields with the chosen other entry. | ||
| 2740 | (when other | ||
| 2741 | (setq other (save-excursion (goto-char other) (bibtex-parse-entry))) | ||
| 2742 | (setq key-end (point)) ;In case parse-entry changed the buffer. | ||
| 2743 | (while (setq bounds (bibtex-parse-field bibtex-field-name)) | ||
| 2744 | (goto-char (bibtex-start-of-name-in-field bounds)) | ||
| 2745 | (let* ((name (buffer-substring | ||
| 2746 | (if (looking-at "ALT\\|OPT") (match-end 0) (point)) | ||
| 2747 | (bibtex-end-of-name-in-field bounds))) | ||
| 2748 | (text (assoc-ignore-case name other))) | ||
| 2749 | (goto-char (bibtex-start-of-text-in-field bounds)) | ||
| 2750 | (if (not (and (looking-at bibtex-empty-field-re) text)) | ||
| 2751 | (goto-char (bibtex-end-of-field bounds)) | ||
| 2752 | (delete-region (point) (bibtex-end-of-text-in-field bounds)) | ||
| 2753 | (insert (cdr text))))) | ||
| 2754 | ;; Finally try to update the text based on the difference between | ||
| 2755 | ;; the two keys. | ||
| 2756 | (let* ((prefix (try-completion "" (list key other-key))) | ||
| 2757 | ;; If the keys are foo91 and foo92, don't replace 1 for 2 | ||
| 2758 | ;; but 91 for 92 instead. | ||
| 2759 | (_ (if (string-match "[0-9]+\\'" prefix) | ||
| 2760 | (setq prefix (substring prefix 0 (match-beginning 0))))) | ||
| 2761 | (suffix (substring key (length prefix))) | ||
| 2762 | (other-suffix (substring other-key (length prefix)))) | ||
| 2763 | (while (re-search-backward (regexp-quote other-suffix) key-end 'move) | ||
| 2764 | (replace-match suffix))))))) | ||
| 2765 | |||
| 2608 | (defun bibtex-print-help-message () | 2766 | (defun bibtex-print-help-message () |
| 2609 | "Print helpful information about current field in current BibTeX entry." | 2767 | "Print helpful information about current field in current BibTeX entry." |
| 2610 | (interactive) | 2768 | (interactive) |
| @@ -2615,7 +2773,7 @@ After insertion it calls the functions in `bibtex-add-entry-hook'." | |||
| 2615 | (field-name (buffer-substring-no-properties | 2773 | (field-name (buffer-substring-no-properties |
| 2616 | (if (progn (goto-char mb) | 2774 | (if (progn (goto-char mb) |
| 2617 | (looking-at "OPT\\|ALT")) | 2775 | (looking-at "OPT\\|ALT")) |
| 2618 | (+ 3 mb) mb) | 2776 | (match-end 0) mb) |
| 2619 | (bibtex-end-of-name-in-field bounds))) | 2777 | (bibtex-end-of-name-in-field bounds))) |
| 2620 | (entry-type (progn (re-search-backward | 2778 | (entry-type (progn (re-search-backward |
| 2621 | bibtex-entry-maybe-empty-head nil t) | 2779 | bibtex-entry-maybe-empty-head nil t) |
| @@ -2641,82 +2799,86 @@ After insertion it calls the functions in `bibtex-add-entry-hook'." | |||
| 2641 | (message (elt comment 1)) | 2799 | (message (elt comment 1)) |
| 2642 | (message "No comment available"))))) | 2800 | (message "No comment available"))))) |
| 2643 | 2801 | ||
| 2644 | (defun bibtex-make-field (e-t &optional called-by-yank) | 2802 | (defun bibtex-make-field (field &optional called-by-yank) |
| 2645 | "Make a field named E-T in current BibTeX entry." | 2803 | "Make a field named FIELD in current BibTeX entry. |
| 2804 | FIELD is either a string or a list of the form | ||
| 2805 | \(FIELD-NAME COMMENT-STRING INIT ALTERNATIVE-FLAG) as in | ||
| 2806 | `bibtex-entry-field-alist'." | ||
| 2646 | (interactive | 2807 | (interactive |
| 2647 | (list (let* ((entry-type | 2808 | (list (let* ((entry-type |
| 2648 | (save-excursion | 2809 | (save-excursion |
| 2649 | (bibtex-enclosing-entry-maybe-empty-head) | 2810 | (bibtex-enclosing-entry-maybe-empty-head) |
| 2650 | (bibtex-type-in-head))) | 2811 | (bibtex-type-in-head))) |
| 2651 | (fl (cadr (assoc-ignore-case | 2812 | ;; "preliminary" completion list |
| 2652 | entry-type bibtex-entry-field-alist))) | 2813 | (fl (nth 1 (assoc-ignore-case |
| 2653 | (field-list (append (elt fl 0) | 2814 | entry-type bibtex-entry-field-alist))) |
| 2654 | (elt fl 1) | 2815 | ;; "full" completion list |
| 2816 | (field-list (append (nth 0 fl) | ||
| 2817 | (nth 1 fl) | ||
| 2655 | bibtex-user-optional-fields | 2818 | bibtex-user-optional-fields |
| 2656 | (if bibtex-include-OPTcrossref | 2819 | (if (member entry-type |
| 2657 | '(("crossref" nil))) | 2820 | bibtex-include-OPTcrossref) |
| 2821 | '(("crossref"))) | ||
| 2658 | (if bibtex-include-OPTkey | 2822 | (if bibtex-include-OPTkey |
| 2659 | '(("key" nil))))) | 2823 | '(("key"))))) |
| 2660 | (completion-ignore-case t)) | 2824 | (completion-ignore-case t)) |
| 2661 | (completing-read "BibTeX field name: " field-list | 2825 | (completing-read "BibTeX field name: " field-list |
| 2662 | nil nil nil bibtex-field-history)))) | 2826 | nil nil nil bibtex-field-history)))) |
| 2663 | (unless (consp e-t) | 2827 | (unless (consp field) |
| 2664 | (setq e-t (list e-t))) | 2828 | (setq field (list field))) |
| 2665 | (let ((name (if (elt e-t 3) | 2829 | (if (or (interactive-p) called-by-yank) |
| 2666 | (concat "ALT" (car e-t)) | 2830 | (let (bibtex-help-message) |
| 2667 | (car e-t)))) | 2831 | (bibtex-find-text nil t t) |
| 2668 | (if (or (interactive-p) called-by-yank) | 2832 | (if (looking-at "[}\"]") |
| 2669 | (let (bibtex-help-message) | 2833 | (forward-char)))) |
| 2670 | (bibtex-find-text nil t t) | 2834 | (insert ",\n") |
| 2671 | (if (looking-at "[}\"]") | 2835 | (indent-to-column (+ bibtex-entry-offset bibtex-field-indentation)) |
| 2672 | (forward-char)))) | 2836 | (if (nth 3 field) (insert "ALT")) |
| 2673 | (insert ",\n") | 2837 | (insert (car field) " ") |
| 2674 | (indent-to-column (+ bibtex-entry-offset bibtex-field-indentation)) | 2838 | (if bibtex-align-at-equal-sign |
| 2675 | (insert name " ") | 2839 | (indent-to-column (+ bibtex-entry-offset |
| 2676 | (if bibtex-align-at-equal-sign | 2840 | (- bibtex-text-indentation 2)))) |
| 2677 | (indent-to-column (+ bibtex-entry-offset | 2841 | (insert "= ") |
| 2678 | (- bibtex-text-indentation 2)))) | 2842 | (if (not bibtex-align-at-equal-sign) |
| 2679 | (insert "= ") | 2843 | (indent-to-column (+ bibtex-entry-offset |
| 2680 | (if (not bibtex-align-at-equal-sign) | 2844 | bibtex-text-indentation))) |
| 2681 | (indent-to-column (+ bibtex-entry-offset | 2845 | (if (not called-by-yank) (insert (bibtex-field-left-delimiter))) |
| 2682 | bibtex-text-indentation))) | 2846 | (let ((init (nth 2 field))) |
| 2683 | (insert (if called-by-yank | 2847 | (cond ((stringp init) |
| 2684 | "" | 2848 | (insert init)) |
| 2685 | (bibtex-field-left-delimiter)) | 2849 | ((fboundp init) |
| 2686 | (let ((init (elt e-t 2))) | 2850 | (insert (funcall init))))) |
| 2687 | (cond ((stringp init) | 2851 | (if (not called-by-yank) (insert (bibtex-field-right-delimiter))) |
| 2688 | init) | 2852 | (if (interactive-p) |
| 2689 | ((fboundp init) | 2853 | (forward-char -1))) |
| 2690 | (funcall init)) | ||
| 2691 | (t ""))) | ||
| 2692 | (if called-by-yank | ||
| 2693 | "" | ||
| 2694 | (bibtex-field-right-delimiter))) | ||
| 2695 | (if (interactive-p) | ||
| 2696 | (forward-char -1)))) | ||
| 2697 | 2854 | ||
| 2698 | (defun bibtex-beginning-of-entry () | 2855 | (defun bibtex-beginning-of-entry () |
| 2699 | "Move to beginning of BibTeX entry (beginning of line). | 2856 | "Move to beginning of BibTeX entry (beginning of line). |
| 2700 | If inside an entry, move to the beginning of it, otherwise move to the | 2857 | If inside an entry, move to the beginning of it, otherwise move to the |
| 2701 | beginning of the previous entry. | 2858 | beginning of the previous entry. If point is ahead of all BibTeX entries |
| 2702 | If called from a program, this function returns the new location of point." | 2859 | move point to the beginning of buffer. Return the new location of point." |
| 2703 | (interactive) | 2860 | (interactive) |
| 2704 | (skip-chars-forward " \t") | 2861 | (skip-chars-forward " \t") |
| 2705 | (if (looking-at "@") | 2862 | (if (looking-at "@") |
| 2706 | (forward-char)) | 2863 | (forward-char)) |
| 2707 | (re-search-backward "^[ \t]*@" nil 'move)) | 2864 | (re-search-backward "^[ \t]*@" nil 'move) |
| 2865 | (point)) | ||
| 2708 | 2866 | ||
| 2709 | (defun bibtex-end-of-entry () | 2867 | (defun bibtex-end-of-entry () |
| 2710 | "Move to end of BibTeX entry (past the closing brace). | 2868 | "Move to end of BibTeX entry (past the closing brace). |
| 2711 | If inside an entry, move to the end of it, otherwise move to the end | 2869 | If inside an entry, move to the end of it, otherwise move to the end |
| 2712 | of the previous entry. Do not move if ahead of first entry. | 2870 | of the previous entry. Do not move if ahead of first entry. |
| 2713 | If called from a program, this function returns the new location of point." | 2871 | Return the new location of point." |
| 2714 | (interactive) | 2872 | (interactive) |
| 2715 | (let ((case-fold-search t) | 2873 | (let ((case-fold-search t) |
| 2716 | (org (point)) | 2874 | (org (point)) |
| 2717 | (pnt (bibtex-beginning-of-entry)) | 2875 | (pnt (bibtex-beginning-of-entry)) |
| 2718 | err bounds) | 2876 | err bounds) |
| 2719 | (cond ((setq bounds (bibtex-parse-string)) | 2877 | (cond ((looking-at bibtex-valid-entry-whitespace-re) |
| 2878 | (bibtex-search-entry t nil t) | ||
| 2879 | (unless (equal (match-beginning 0) pnt) | ||
| 2880 | (setq err t))) | ||
| 2881 | ((setq bounds (bibtex-parse-string)) | ||
| 2720 | (goto-char (bibtex-end-of-string bounds))) | 2882 | (goto-char (bibtex-end-of-string bounds))) |
| 2721 | ((looking-at "[ \t]*@[ \t]*preamble[ \t\n]*") | 2883 | ((looking-at "[ \t]*@[ \t]*preamble[ \t\n]*") |
| 2722 | (goto-char (match-end 0)) | 2884 | (goto-char (match-end 0)) |
| @@ -2731,10 +2893,6 @@ If called from a program, this function returns the new location of point." | |||
| 2731 | (unless err | 2893 | (unless err |
| 2732 | (goto-char (match-beginning 0)) | 2894 | (goto-char (match-beginning 0)) |
| 2733 | (forward-char))) | 2895 | (forward-char))) |
| 2734 | ((looking-at bibtex-valid-entry-whitespace-re) | ||
| 2735 | (bibtex-search-entry t nil t) | ||
| 2736 | (unless (equal (match-beginning 0) pnt) | ||
| 2737 | (setq err t))) | ||
| 2738 | (t | 2896 | (t |
| 2739 | (if (interactive-p) | 2897 | (if (interactive-p) |
| 2740 | (message "Not on a known BibTeX entry.")) | 2898 | (message "Not on a known BibTeX entry.")) |
| @@ -2777,24 +2935,24 @@ If mark is active it counts entries in region, if not in whole buffer." | |||
| 2777 | (region-end) | 2935 | (region-end) |
| 2778 | (point-max))) | 2936 | (point-max))) |
| 2779 | (goto-char (point-min)) | 2937 | (goto-char (point-min)) |
| 2780 | (bibtex-map-entries (lambda (current) | 2938 | (bibtex-map-entries (lambda (key beg end) |
| 2781 | (setq number (1+ number)))))) | 2939 | (setq number (1+ number)))))) |
| 2782 | (message "%s contains %d entries." | 2940 | (message "%s contains %d entries." |
| 2783 | (if (bibtex-mark-active) "Region" "Buffer") | 2941 | (if (bibtex-mark-active) "Region" "Buffer") |
| 2784 | number))) | 2942 | number))) |
| 2785 | 2943 | ||
| 2786 | (defun bibtex-ispell-entry () | 2944 | (defun bibtex-ispell-entry () |
| 2787 | "Spell whole BibTeX entry." | 2945 | "Spell whole BibTeX entry." |
| 2788 | (interactive) | 2946 | (interactive) |
| 2789 | (ispell-region (bibtex-beginning-of-entry) | 2947 | (ispell-region (save-excursion (bibtex-beginning-of-entry)) |
| 2790 | (bibtex-end-of-entry))) | 2948 | (save-excursion (bibtex-end-of-entry)))) |
| 2791 | 2949 | ||
| 2792 | (defun bibtex-ispell-abstract () | 2950 | (defun bibtex-ispell-abstract () |
| 2793 | "Spell abstract of BibTeX entry." | 2951 | "Spell abstract of BibTeX entry." |
| 2794 | (interactive) | 2952 | (interactive) |
| 2795 | (bibtex-beginning-of-entry) | 2953 | (let ((bounds (save-excursion |
| 2796 | (let ((bounds (bibtex-search-forward-field "abstract" | 2954 | (bibtex-beginning-of-entry) |
| 2797 | (bibtex-end-of-entry)))) | 2955 | (bibtex-search-forward-field "abstract" t)))) |
| 2798 | (if bounds | 2956 | (if bounds |
| 2799 | (ispell-region (bibtex-start-of-text-in-field bounds) | 2957 | (ispell-region (bibtex-start-of-text-in-field bounds) |
| 2800 | (bibtex-end-of-text-in-field bounds)) | 2958 | (bibtex-end-of-text-in-field bounds)) |
| @@ -2815,19 +2973,18 @@ the entries of the BibTeX buffer. Return nil if no entry found." | |||
| 2815 | (let ((case-fold-search t)) | 2973 | (let ((case-fold-search t)) |
| 2816 | (if (re-search-forward bibtex-entry-maybe-empty-head nil t) | 2974 | (if (re-search-forward bibtex-entry-maybe-empty-head nil t) |
| 2817 | (let ((key (bibtex-key-in-head)) | 2975 | (let ((key (bibtex-key-in-head)) |
| 2818 | (entry-name (bibtex-type-in-head))) | 2976 | ;; all entry names should be downcase (for ease of comparison) |
| 2977 | (entry-name (downcase (bibtex-type-in-head)))) | ||
| 2819 | ;; Don't search CROSSREF-KEY if we don't need it. | 2978 | ;; Don't search CROSSREF-KEY if we don't need it. |
| 2820 | (if (equal bibtex-maintain-sorted-entries 'crossref) | 2979 | (if (equal bibtex-maintain-sorted-entries 'crossref) |
| 2821 | (save-excursion | 2980 | (save-excursion |
| 2822 | (save-restriction | 2981 | (bibtex-beginning-of-entry) |
| 2823 | (bibtex-narrow-to-entry) | 2982 | (let ((bounds (bibtex-search-forward-field |
| 2824 | (goto-char (point-min)) | 2983 | "\\(OPT\\)?crossref" t))) |
| 2825 | (let ((bounds (bibtex-search-forward-field | 2984 | (list key |
| 2826 | "\\(OPT\\)?crossref"))) | 2985 | (if bounds (bibtex-text-in-field-bounds bounds t)) |
| 2827 | (list key | 2986 | entry-name)))) |
| 2828 | (if bounds (bibtex-text-in-field-bounds bounds t)) | 2987 | (list key nil entry-name))))) |
| 2829 | entry-name)))) | ||
| 2830 | (list key nil entry-name)))))) | ||
| 2831 | 2988 | ||
| 2832 | (defun bibtex-lessp (index1 index2) | 2989 | (defun bibtex-lessp (index1 index2) |
| 2833 | "Predicate for sorting BibTeX entries with indices INDEX1 and INDEX2. | 2990 | "Predicate for sorting BibTeX entries with indices INDEX1 and INDEX2. |
| @@ -2846,10 +3003,12 @@ The predicate depends on the variable `bibtex-maintain-sorted-entries'." | |||
| 2846 | (string-lessp (nth 0 index1) (nth 1 index2)) | 3003 | (string-lessp (nth 0 index1) (nth 1 index2)) |
| 2847 | (string-lessp (nth 0 index1) (nth 0 index2))))) | 3004 | (string-lessp (nth 0 index1) (nth 0 index2))))) |
| 2848 | ((equal bibtex-maintain-sorted-entries 'entry-class) | 3005 | ((equal bibtex-maintain-sorted-entries 'entry-class) |
| 2849 | (let ((n1 (cdr (assoc-ignore-case (nth 2 index1) | 3006 | (let ((n1 (cdr (or (assoc (nth 2 index1) bibtex-sort-entry-class-alist) |
| 2850 | bibtex-sort-entry-class-alist))) | 3007 | (assoc 'catch-all bibtex-sort-entry-class-alist) |
| 2851 | (n2 (cdr (assoc-ignore-case (nth 2 index2) | 3008 | '(nil . 1000)))) ; if there is nothing else |
| 2852 | bibtex-sort-entry-class-alist)))) | 3009 | (n2 (cdr (or (assoc (nth 2 index2) bibtex-sort-entry-class-alist) |
| 3010 | (assoc 'catch-all bibtex-sort-entry-class-alist) | ||
| 3011 | '(nil . 1000))))) ; if there is nothing else | ||
| 2853 | (or (< n1 n2) | 3012 | (or (< n1 n2) |
| 2854 | (and (= n1 n2) | 3013 | (and (= n1 n2) |
| 2855 | (string-lessp (car index1) (car index2)))))) | 3014 | (string-lessp (car index1) (car index2)))))) |
| @@ -2880,7 +3039,17 @@ ignored." | |||
| 2880 | (defun bibtex-find-crossref (crossref-key) | 3039 | (defun bibtex-find-crossref (crossref-key) |
| 2881 | "Move point to the beginning of BibTeX entry CROSSREF-KEY. | 3040 | "Move point to the beginning of BibTeX entry CROSSREF-KEY. |
| 2882 | Return position of entry if CROSSREF-KEY is found and nil otherwise. | 3041 | Return position of entry if CROSSREF-KEY is found and nil otherwise. |
| 2883 | If position of current entry is after CROSSREF-KEY an error is signaled." | 3042 | If position of current entry is after CROSSREF-KEY an error is signaled. |
| 3043 | If called interactively, CROSSREF-KEY defaults to crossref key of current | ||
| 3044 | entry." | ||
| 3045 | (interactive | ||
| 3046 | (let ((crossref-key | ||
| 3047 | (save-excursion | ||
| 3048 | (bibtex-beginning-of-entry) | ||
| 3049 | (let ((bounds (bibtex-search-forward-field "crossref" t))) | ||
| 3050 | (if bounds | ||
| 3051 | (bibtex-text-in-field-bounds bounds t)))))) | ||
| 3052 | (list (bibtex-read-key "Find crossref key: " crossref-key)))) | ||
| 2884 | (let ((pos (save-excursion (bibtex-find-entry crossref-key)))) | 3053 | (let ((pos (save-excursion (bibtex-find-entry crossref-key)))) |
| 2885 | (if (and pos (> (point) pos)) | 3054 | (if (and pos (> (point) pos)) |
| 2886 | (error "This entry must not follow the crossrefed entry!")) | 3055 | (error "This entry must not follow the crossrefed entry!")) |
| @@ -2889,25 +3058,19 @@ If position of current entry is after CROSSREF-KEY an error is signaled." | |||
| 2889 | (defun bibtex-find-entry (key) | 3058 | (defun bibtex-find-entry (key) |
| 2890 | "Move point to the beginning of BibTeX entry named KEY. | 3059 | "Move point to the beginning of BibTeX entry named KEY. |
| 2891 | Return position of entry if KEY is found or nil if not found." | 3060 | Return position of entry if KEY is found or nil if not found." |
| 2892 | (interactive | 3061 | (interactive (list (bibtex-read-key "Find key: "))) |
| 2893 | (list (if bibtex-maintain-sorted-entries | ||
| 2894 | (completing-read "Find key: " | ||
| 2895 | bibtex-reference-keys | ||
| 2896 | nil nil nil 'bibtex-key-history) | ||
| 2897 | (read-from-minibuffer "Find key: " nil nil nil | ||
| 2898 | 'bibtex-key-history)))) | ||
| 2899 | (let* (case-fold-search | 3062 | (let* (case-fold-search |
| 2900 | (pnt (save-excursion | 3063 | (pnt (save-excursion |
| 2901 | (goto-char (point-min)) | 3064 | (goto-char (point-min)) |
| 2902 | (when (re-search-forward (concat "^[ \t]*\\(" | 3065 | (if (re-search-forward (concat "^[ \t]*\\(" |
| 2903 | bibtex-entry-type | 3066 | bibtex-entry-type |
| 2904 | "\\)[ \t]*[({][ \t\n]*\\(" | 3067 | "\\)[ \t]*[({][ \t\n]*\\(" |
| 2905 | (regexp-quote key) "\\)") | 3068 | (regexp-quote key) |
| 2906 | nil t) | 3069 | "\\)[ \t\n]*[,=]") |
| 2907 | (match-beginning 2))))) | 3070 | nil t) |
| 3071 | (match-beginning 0))))) | ||
| 2908 | (cond (pnt | 3072 | (cond (pnt |
| 2909 | (goto-char pnt) | 3073 | (goto-char pnt)) |
| 2910 | (bibtex-beginning-of-entry)) | ||
| 2911 | ((interactive-p) | 3074 | ((interactive-p) |
| 2912 | (message "Key `%s' not found" key))))) | 3075 | (message "Key `%s' not found" key))))) |
| 2913 | 3076 | ||
| @@ -3019,9 +3182,9 @@ Returns t if test was successful, nil otherwise." | |||
| 3019 | (goto-char (point-min)) | 3182 | (goto-char (point-min)) |
| 3020 | (bibtex-progress-message "Checking correct sort order") | 3183 | (bibtex-progress-message "Checking correct sort order") |
| 3021 | (bibtex-map-entries | 3184 | (bibtex-map-entries |
| 3022 | (lambda (dummy) | 3185 | (lambda (key beg end) |
| 3023 | (bibtex-progress-message) | 3186 | (bibtex-progress-message) |
| 3024 | (bibtex-beginning-of-entry) | 3187 | (goto-char beg) |
| 3025 | (setq current (bibtex-entry-index)) | 3188 | (setq current (bibtex-entry-index)) |
| 3026 | (cond ((or (not previous) | 3189 | (cond ((or (not previous) |
| 3027 | (bibtex-lessp previous current)) | 3190 | (bibtex-lessp previous current)) |
| @@ -3045,11 +3208,9 @@ Returns t if test was successful, nil otherwise." | |||
| 3045 | (questionable-month | 3208 | (questionable-month |
| 3046 | (regexp-opt (mapcar 'car bibtex-predefined-month-strings)))) | 3209 | (regexp-opt (mapcar 'car bibtex-predefined-month-strings)))) |
| 3047 | (bibtex-map-entries | 3210 | (bibtex-map-entries |
| 3048 | (lambda (current) | 3211 | (lambda (key beg end) |
| 3049 | (bibtex-progress-message) | 3212 | (bibtex-progress-message) |
| 3050 | (let* ((beg (bibtex-beginning-of-entry)) | 3213 | (let* ((entry-list (progn |
| 3051 | (end (bibtex-end-of-entry)) | ||
| 3052 | (entry-list (progn | ||
| 3053 | (goto-char beg) | 3214 | (goto-char beg) |
| 3054 | (bibtex-search-entry nil end) | 3215 | (bibtex-search-entry nil end) |
| 3055 | (assoc-ignore-case (bibtex-type-in-head) | 3216 | (assoc-ignore-case (bibtex-type-in-head) |
| @@ -3185,7 +3346,7 @@ Align text and go thereafter to end of text." | |||
| 3185 | (save-excursion | 3346 | (save-excursion |
| 3186 | (goto-char (bibtex-start-of-name-in-field bounds)) | 3347 | (goto-char (bibtex-start-of-name-in-field bounds)) |
| 3187 | (when (looking-at "OPT\\|ALT") | 3348 | (when (looking-at "OPT\\|ALT") |
| 3188 | (delete-char (length "OPT")) | 3349 | (delete-region (match-beginning 0) (match-end 0)) |
| 3189 | ;; make field non-OPT | 3350 | ;; make field non-OPT |
| 3190 | (search-forward "=") | 3351 | (search-forward "=") |
| 3191 | (forward-char -1) | 3352 | (forward-char -1) |
| @@ -3326,37 +3487,43 @@ intermixed with \\[bibtex-pop-previous] (bibtex-pop-previous)." | |||
| 3326 | 3487 | ||
| 3327 | (defun bibtex-clean-entry (&optional new-key called-by-reformat) | 3488 | (defun bibtex-clean-entry (&optional new-key called-by-reformat) |
| 3328 | "Finish editing the current BibTeX entry and clean it up. | 3489 | "Finish editing the current BibTeX entry and clean it up. |
| 3329 | Checks that no required fields are empty and formats entry dependent | 3490 | Check that no required fields are empty and formats entry dependent |
| 3330 | on the value of `bibtex-entry-format'. | 3491 | on the value of `bibtex-entry-format'. |
| 3331 | If the reference key of the entry is empty or a prefix argument is given, | 3492 | If the reference key of the entry is empty or a prefix argument is given, |
| 3332 | calculate a new reference key. (Note: this only will work if fields in entry | 3493 | calculate a new reference key. (Note: this will only work if fields in entry |
| 3333 | begin on separate lines prior to calling `bibtex-clean-entry' or if | 3494 | begin on separate lines prior to calling `bibtex-clean-entry' or if |
| 3334 | 'realign is contained in `bibtex-entry-format'.) | 3495 | 'realign is contained in `bibtex-entry-format'.) |
| 3335 | Don't call this on @String or @Preamble entries. | 3496 | Don't call `bibtex-clean-entry' on @Preamble entries. |
| 3336 | At end of the cleaning process, the functions in | 3497 | At end of the cleaning process, the functions in |
| 3337 | `bibtex-clean-entry-hook' are called with region narrowed to entry." | 3498 | `bibtex-clean-entry-hook' are called with region narrowed to entry." |
| 3338 | ;; Opt. arg called-by-reformat is t if bibtex-clean-entry | 3499 | ;; Opt. arg called-by-reformat is t if bibtex-clean-entry |
| 3339 | ;; is called by bibtex-reformat | 3500 | ;; is called by bibtex-reformat |
| 3340 | (interactive "P") | 3501 | (interactive "P") |
| 3341 | (bibtex-format-entry) | ||
| 3342 | (let ((case-fold-search t) | 3502 | (let ((case-fold-search t) |
| 3343 | key) | 3503 | entry-type key) |
| 3344 | (bibtex-beginning-of-entry) | 3504 | (bibtex-beginning-of-entry) |
| 3345 | (setq key (save-excursion | 3505 | (save-excursion |
| 3346 | (if (re-search-forward bibtex-entry-maybe-empty-head nil t) | 3506 | (when (re-search-forward bibtex-entry-maybe-empty-head nil t) |
| 3347 | (bibtex-key-in-head)))) | 3507 | (setq entry-type (downcase (bibtex-type-in-head))) |
| 3508 | (setq key (bibtex-key-in-head)))) | ||
| 3509 | ;; formatting | ||
| 3510 | (cond ((equal entry-type "preamble") | ||
| 3511 | ;; (bibtex-format-preamble) | ||
| 3512 | (error "No clean up of @Preamble entries")) | ||
| 3513 | ((equal entry-type "string")) | ||
| 3514 | ;; (bibtex-format-string) | ||
| 3515 | (t (bibtex-format-entry))) | ||
| 3516 | ;; set key | ||
| 3348 | (when (or new-key (not key)) | 3517 | (when (or new-key (not key)) |
| 3349 | (setq key (if bibtex-autokey-edit-before-use | 3518 | (setq key (bibtex-generate-autokey)) |
| 3350 | (read-from-minibuffer | 3519 | (if bibtex-autokey-edit-before-use |
| 3351 | "Key to use: " (bibtex-generate-autokey) nil nil | 3520 | (setq key (bibtex-read-key "Key to use: " key))) |
| 3352 | 'bibtex-key-history) | ||
| 3353 | (bibtex-generate-autokey))) | ||
| 3354 | (bibtex-beginning-of-entry) | ||
| 3355 | (re-search-forward bibtex-entry-maybe-empty-head) | 3521 | (re-search-forward bibtex-entry-maybe-empty-head) |
| 3356 | (if (match-beginning bibtex-key-in-head) | 3522 | (if (match-beginning bibtex-key-in-head) |
| 3357 | (delete-region (match-beginning bibtex-key-in-head) | 3523 | (delete-region (match-beginning bibtex-key-in-head) |
| 3358 | (match-end bibtex-key-in-head))) | 3524 | (match-end bibtex-key-in-head))) |
| 3359 | (insert key)) | 3525 | (insert key)) |
| 3526 | ;; sorting | ||
| 3360 | (let* ((start (bibtex-beginning-of-entry)) | 3527 | (let* ((start (bibtex-beginning-of-entry)) |
| 3361 | (end (progn (bibtex-end-of-entry) | 3528 | (end (progn (bibtex-end-of-entry) |
| 3362 | (if (re-search-forward | 3529 | (if (re-search-forward |
| @@ -3368,7 +3535,9 @@ At end of the cleaning process, the functions in | |||
| 3368 | (bibtex-entry-index)))) | 3535 | (bibtex-entry-index)))) |
| 3369 | (delete-region start end) | 3536 | (delete-region start end) |
| 3370 | (unless (prog1 (or called-by-reformat | 3537 | (unless (prog1 (or called-by-reformat |
| 3371 | (if bibtex-maintain-sorted-entries | 3538 | (if (and bibtex-maintain-sorted-entries |
| 3539 | (not (and bibtex-sort-ignore-string-entries | ||
| 3540 | (equal entry-type "string")))) | ||
| 3372 | (bibtex-prepare-new-entry index) | 3541 | (bibtex-prepare-new-entry index) |
| 3373 | (not (bibtex-find-entry (car index))))) | 3542 | (not (bibtex-find-entry (car index))))) |
| 3374 | (insert entry) | 3543 | (insert entry) |
| @@ -3376,20 +3545,66 @@ At end of the cleaning process, the functions in | |||
| 3376 | (bibtex-beginning-of-entry) ; moves backward | 3545 | (bibtex-beginning-of-entry) ; moves backward |
| 3377 | (re-search-forward bibtex-entry-head)) | 3546 | (re-search-forward bibtex-entry-head)) |
| 3378 | (error "New inserted entry yields duplicate key"))) | 3547 | (error "New inserted entry yields duplicate key"))) |
| 3548 | ;; final clean up | ||
| 3379 | (unless called-by-reformat | 3549 | (unless called-by-reformat |
| 3380 | (save-excursion | 3550 | (save-excursion |
| 3381 | (save-restriction | 3551 | (save-restriction |
| 3382 | (bibtex-narrow-to-entry) | 3552 | (bibtex-narrow-to-entry) |
| 3383 | ;; Only update the list of keys if it's been built already. | 3553 | ;; Only update the list of keys if it has been built already. |
| 3384 | (if (consp bibtex-reference-keys) (bibtex-parse-keys t nil)) | 3554 | (cond ((equal entry-type "string") |
| 3555 | (if (listp bibtex-strings) (bibtex-parse-strings t))) | ||
| 3556 | ((listp bibtex-reference-keys) (bibtex-parse-keys t))) | ||
| 3385 | (run-hooks 'bibtex-clean-entry-hook)))))) | 3557 | (run-hooks 'bibtex-clean-entry-hook)))))) |
| 3386 | 3558 | ||
| 3559 | (defun bibtex-fill-field-bounds (bounds justify &optional move) | ||
| 3560 | "Fill BibTeX field delimited by BOUNDS. | ||
| 3561 | If JUSTIFY is non-nil justify as well. | ||
| 3562 | If optional arg MOVE is non-nil move point to end of field." | ||
| 3563 | (let ((end-field (copy-marker (bibtex-end-of-field bounds)))) | ||
| 3564 | (goto-char (bibtex-start-of-field bounds)) | ||
| 3565 | (if justify | ||
| 3566 | (progn | ||
| 3567 | (forward-char) | ||
| 3568 | (bibtex-delete-whitespace) | ||
| 3569 | (open-line 1) | ||
| 3570 | (forward-char) | ||
| 3571 | (indent-to-column (+ bibtex-entry-offset | ||
| 3572 | bibtex-field-indentation)) | ||
| 3573 | (re-search-forward "[ \t\n]*=" end-field) | ||
| 3574 | (replace-match "=") | ||
| 3575 | (forward-char -1) | ||
| 3576 | (if bibtex-align-at-equal-sign | ||
| 3577 | (indent-to-column | ||
| 3578 | (+ bibtex-entry-offset (- bibtex-text-indentation 2))) | ||
| 3579 | (insert " ")) | ||
| 3580 | (forward-char) | ||
| 3581 | (bibtex-delete-whitespace) | ||
| 3582 | (if bibtex-align-at-equal-sign | ||
| 3583 | (insert " ") | ||
| 3584 | (indent-to-column bibtex-text-indentation))) | ||
| 3585 | (re-search-forward "[ \t\n]*=[ \t\n]*" end-field)) | ||
| 3586 | (while (re-search-forward "[ \t\n]+" end-field 'move) | ||
| 3587 | (replace-match " ")) | ||
| 3588 | (do-auto-fill) | ||
| 3589 | (if move (goto-char end-field)))) | ||
| 3590 | |||
| 3591 | (defun bibtex-fill-field (&optional justify) | ||
| 3592 | "Like \\[fill-paragraph], but fill current BibTeX field. | ||
| 3593 | Optional prefix arg JUSTIFY non-nil means justify as well. | ||
| 3594 | In BibTeX mode this function is bound to `fill-paragraph-function'." | ||
| 3595 | (interactive "*P") | ||
| 3596 | (let ((pnt (copy-marker (point))) | ||
| 3597 | (bounds (bibtex-enclosing-field))) | ||
| 3598 | (when bounds | ||
| 3599 | (bibtex-fill-field-bounds bounds justify) | ||
| 3600 | (goto-char pnt)))) | ||
| 3601 | |||
| 3387 | (defun bibtex-fill-entry () | 3602 | (defun bibtex-fill-entry () |
| 3388 | "Fill current BibTeX entry. | 3603 | "Fill current BibTeX entry. |
| 3389 | Realign entry, so that every field starts on a separate line. Field | 3604 | Realign entry, so that every field starts on a separate line. Field |
| 3390 | names appear in column `bibtex-field-indentation', field text starts in | 3605 | names appear in column `bibtex-field-indentation', field text starts in |
| 3391 | column `bibtex-text-indentation' and continuation lines start here, too. | 3606 | column `bibtex-text-indentation' and continuation lines start here, too. |
| 3392 | If `bibtex-align-at-equal-sign' is non-nil, align equal signs also." | 3607 | If `bibtex-align-at-equal-sign' is non-nil, align equal signs, too." |
| 3393 | (interactive "*") | 3608 | (interactive "*") |
| 3394 | (let ((pnt (copy-marker (point))) | 3609 | (let ((pnt (copy-marker (point))) |
| 3395 | (end (copy-marker (bibtex-end-of-entry))) | 3610 | (end (copy-marker (bibtex-end-of-entry))) |
| @@ -3398,31 +3613,7 @@ If `bibtex-align-at-equal-sign' is non-nil, align equal signs also." | |||
| 3398 | (bibtex-delete-whitespace) | 3613 | (bibtex-delete-whitespace) |
| 3399 | (indent-to-column bibtex-entry-offset) | 3614 | (indent-to-column bibtex-entry-offset) |
| 3400 | (while (setq bounds (bibtex-search-forward-field bibtex-field-name end)) | 3615 | (while (setq bounds (bibtex-search-forward-field bibtex-field-name end)) |
| 3401 | (let* ((begin-field (copy-marker (bibtex-start-of-field bounds))) | 3616 | (bibtex-fill-field-bounds bounds t t)) |
| 3402 | (end-field (copy-marker (bibtex-end-of-field bounds)))) | ||
| 3403 | (goto-char begin-field) | ||
| 3404 | (forward-char) | ||
| 3405 | (bibtex-delete-whitespace) | ||
| 3406 | (open-line 1) | ||
| 3407 | (forward-char) | ||
| 3408 | (indent-to-column (+ bibtex-entry-offset | ||
| 3409 | bibtex-field-indentation)) | ||
| 3410 | (re-search-forward "[ \t\n]*=" end) | ||
| 3411 | (replace-match "=") | ||
| 3412 | (forward-char -1) | ||
| 3413 | (if bibtex-align-at-equal-sign | ||
| 3414 | (indent-to-column | ||
| 3415 | (+ bibtex-entry-offset (- bibtex-text-indentation 2))) | ||
| 3416 | (insert " ")) | ||
| 3417 | (forward-char) | ||
| 3418 | (bibtex-delete-whitespace) | ||
| 3419 | (if bibtex-align-at-equal-sign | ||
| 3420 | (insert " ") | ||
| 3421 | (indent-to-column bibtex-text-indentation)) | ||
| 3422 | (while (re-search-forward "[ \t\n]+" end-field 'move) | ||
| 3423 | (replace-match " ")) | ||
| 3424 | (do-auto-fill) | ||
| 3425 | (goto-char end-field))) | ||
| 3426 | (if (looking-at ",") | 3617 | (if (looking-at ",") |
| 3427 | (forward-char)) | 3618 | (forward-char)) |
| 3428 | (bibtex-delete-whitespace) | 3619 | (bibtex-delete-whitespace) |
| @@ -3488,11 +3679,11 @@ If mark is active it reformats entries in region, if not in whole buffer." | |||
| 3488 | (replace-match "\n\\1"))) | 3679 | (replace-match "\n\\1"))) |
| 3489 | (goto-char start-point) | 3680 | (goto-char start-point) |
| 3490 | (bibtex-progress-message "Formatting" 1) | 3681 | (bibtex-progress-message "Formatting" 1) |
| 3491 | (bibtex-map-entries (lambda (current) | 3682 | (bibtex-map-entries (lambda (key beg end) |
| 3492 | (bibtex-progress-message) | 3683 | (bibtex-progress-message) |
| 3493 | (bibtex-clean-entry reformat-reference-keys t) | 3684 | (bibtex-clean-entry reformat-reference-keys t) |
| 3494 | (when (memq 'realign bibtex-entry-format) | 3685 | (when (memq 'realign bibtex-entry-format) |
| 3495 | (bibtex-end-of-entry) | 3686 | (goto-char end) |
| 3496 | (bibtex-delete-whitespace) | 3687 | (bibtex-delete-whitespace) |
| 3497 | (open-line 2)))) | 3688 | (open-line 2)))) |
| 3498 | (bibtex-progress-message 'done)) | 3689 | (bibtex-progress-message 'done)) |
| @@ -3500,8 +3691,7 @@ If mark is active it reformats entries in region, if not in whole buffer." | |||
| 3500 | bibtex-maintain-sorted-entries | 3691 | bibtex-maintain-sorted-entries |
| 3501 | (not called-by-convert-alien)) | 3692 | (not called-by-convert-alien)) |
| 3502 | (bibtex-sort-buffer) | 3693 | (bibtex-sort-buffer) |
| 3503 | (setq bibtex-reference-keys nil) | 3694 | (kill-local-variable 'bibtex-reference-keys)) |
| 3504 | (bibtex-parse-keys nil t t)) | ||
| 3505 | (goto-char pnt))) | 3695 | (goto-char pnt))) |
| 3506 | 3696 | ||
| 3507 | (defun bibtex-convert-alien (&optional do-additional-reformatting) | 3697 | (defun bibtex-convert-alien (&optional do-additional-reformatting) |
| @@ -3534,7 +3724,7 @@ non-nil, read options for reformatting entries from minibuffer." | |||
| 3534 | 3724 | ||
| 3535 | (defun bibtex-complete () | 3725 | (defun bibtex-complete () |
| 3536 | "Complete word fragment before point according to context. | 3726 | "Complete word fragment before point according to context. |
| 3537 | If inside key or crossref field complete key based on | 3727 | If point is inside key or crossref field perform key completion based on |
| 3538 | `bibtex-reference-keys'. Inside any other field perform string | 3728 | `bibtex-reference-keys'. Inside any other field perform string |
| 3539 | completion based on `bibtex-strings'. An error is signaled if point | 3729 | completion based on `bibtex-strings'. An error is signaled if point |
| 3540 | is outside key or BibTeX field." | 3730 | is outside key or BibTeX field." |
| @@ -3570,7 +3760,6 @@ is outside key or BibTeX field." | |||
| 3570 | 3760 | ||
| 3571 | (cond ((equal compl 'key) | 3761 | (cond ((equal compl 'key) |
| 3572 | ;; key completion | 3762 | ;; key completion |
| 3573 | (unless (consp bibtex-reference-keys) (bibtex-parse-keys nil t)) | ||
| 3574 | (setq choose-completion-string-functions | 3763 | (setq choose-completion-string-functions |
| 3575 | (lambda (choice buffer mini-p base-size) | 3764 | (lambda (choice buffer mini-p base-size) |
| 3576 | (bibtex-choose-completion-string choice buffer mini-p base-size) | 3765 | (bibtex-choose-completion-string choice buffer mini-p base-size) |
| @@ -3661,16 +3850,11 @@ is outside key or BibTeX field." | |||
| 3661 | 3850 | ||
| 3662 | (defun bibtex-String (&optional key) | 3851 | (defun bibtex-String (&optional key) |
| 3663 | "Insert a new BibTeX @String entry with key KEY." | 3852 | "Insert a new BibTeX @String entry with key KEY." |
| 3664 | (interactive | 3853 | (interactive (list (completing-read "String key: " bibtex-strings |
| 3665 | (progn (unless (consp bibtex-reference-keys) (bibtex-parse-keys nil t)) | 3854 | nil nil nil 'bibtex-key-history))) |
| 3666 | (list (completing-read "String key: " bibtex-reference-keys | ||
| 3667 | nil nil nil 'bibtex-key-history)))) | ||
| 3668 | ;; If we want to sort String entries only the sorting scheme | ||
| 3669 | ;; entry-class is meaningful | ||
| 3670 | (let ((bibtex-maintain-sorted-entries | 3855 | (let ((bibtex-maintain-sorted-entries |
| 3671 | (if (and (not bibtex-sort-ignore-string-entries) | 3856 | (if (not bibtex-sort-ignore-string-entries) |
| 3672 | bibtex-maintain-sorted-entries) | 3857 | bibtex-maintain-sorted-entries)) |
| 3673 | 'entry-class)) | ||
| 3674 | endpos) | 3858 | endpos) |
| 3675 | (unless (bibtex-prepare-new-entry (list key nil "String")) | 3859 | (unless (bibtex-prepare-new-entry (list key nil "String")) |
| 3676 | (error "Entry with key `%s' already exists" key)) | 3860 | (error "Entry with key `%s' already exists" key)) |
| @@ -3696,11 +3880,11 @@ is outside key or BibTeX field." | |||
| 3696 | (bibtex-move-outside-of-entry) | 3880 | (bibtex-move-outside-of-entry) |
| 3697 | (indent-to-column bibtex-entry-offset) | 3881 | (indent-to-column bibtex-entry-offset) |
| 3698 | (insert "@Preamble" | 3882 | (insert "@Preamble" |
| 3699 | (bibtex-entry-left-delimiter) | 3883 | (bibtex-entry-left-delimiter)) |
| 3700 | (bibtex-entry-right-delimiter) | 3884 | (let ((endpos (point))) |
| 3701 | "\n") | 3885 | (insert (bibtex-entry-right-delimiter) |
| 3702 | (forward-line -1) | 3886 | "\n") |
| 3703 | (forward-char 10)) | 3887 | (goto-char endpos))) |
| 3704 | 3888 | ||
| 3705 | 3889 | ||
| 3706 | ;; Make BibTeX a Feature | 3890 | ;; Make BibTeX a Feature |