diff options
| author | Jim Blandy | 1992-02-22 21:47:46 +0000 |
|---|---|---|
| committer | Jim Blandy | 1992-02-22 21:47:46 +0000 |
| commit | d30bfc76929289f4ab8e5d0b0dca639533cf5d9c (patch) | |
| tree | c10b1e60cb3b6514d74c5d59b7c74415cf159eb8 | |
| parent | 4e3a36cde9cf4901248cb57b29cd700fc02caf6d (diff) | |
| download | emacs-d30bfc76929289f4ab8e5d0b0dca639533cf5d9c.tar.gz emacs-d30bfc76929289f4ab8e5d0b0dca639533cf5d9c.zip | |
*** empty log message ***
| -rw-r--r-- | lisp/textmodes/bibtex.el | 175 |
1 files changed, 129 insertions, 46 deletions
diff --git a/lisp/textmodes/bibtex.el b/lisp/textmodes/bibtex.el index 17591f658fe..4be2935fc26 100644 --- a/lisp/textmodes/bibtex.el +++ b/lisp/textmodes/bibtex.el | |||
| @@ -17,6 +17,35 @@ | |||
| 17 | ;; along with GNU Emacs; see the file COPYING. If not, write to | 17 | ;; along with GNU Emacs; see the file COPYING. If not, write to |
| 18 | ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | 18 | ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
| 19 | 19 | ||
| 20 | ;;; Mike Newton (newton@gumby.cs.caltech.edu) 92.2.11 | ||
| 21 | ;;; * Fixed bibtex-field string to allow things like: | ||
| 22 | ;;; author = "{S}schr\"odinger" or | ||
| 23 | ;;; author = "{S}schr\"{o}dinger" or | ||
| 24 | ;;; author = "{S}schr{\"o}dinger" or | ||
| 25 | ;;; NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE | ||
| 26 | ;;; NOTE: This is the last update I plan to do. | ||
| 27 | ;;; NOTE: the previous version was submitted and, according to RMS, | ||
| 28 | ;;; accepted as the release version for ver 19. | ||
| 29 | ;;; NOTE: PLEASE DO NOT SEND ME ANY MORE 'PLEASE ADD THIS' MESSAGES. | ||
| 30 | ;;; NOTE: I am no longer taking care of this package. | ||
| 31 | ;;; NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE | ||
| 32 | |||
| 33 | ;;; Mike Newton (newton@gumby.cs.caltech.edu) 91.1.24 | ||
| 34 | ;;; * bibtex-make-optional-field : modified to make fields align up after | ||
| 35 | ;;; the OPT's have been removed. | ||
| 36 | ;;; * bibtex-make-optional-field : modified to check bibtex-use-OPT-prefix | ||
| 37 | ;;; * bibtex-make*field : modified to call new procedure: | ||
| 38 | ;;; * bibtex-insert-field-delimeters : which does delimeter insertion based on | ||
| 39 | ;;; * bibtex-curly-delimeters : a list of atoms | ||
| 40 | ;;; * fixed spelling of bibtex-name-alignment wherever used | ||
| 41 | ;;; * bibtex-inside-field : allows '}'s at end | ||
| 42 | ;;; * bibtex-find-text : allows '{' and '}'s at start or end | ||
| 43 | ;;; * bibtex-enclosing-regexp fixed for case where start-point was at end of | ||
| 44 | ;;; pattern. | ||
| 45 | ;;; * bibtex-clean-entry : allow bibtex-save-OPT to save some optional fields | ||
| 46 | ;;; * bibtex-move-outside-of-entry : could overwrite first line of a following | ||
| 47 | ;;; comment or other text if it did not look like a bibtex entry | ||
| 48 | |||
| 20 | ;;; Mike Newton (newton@gumby.cs.caltech.edu) 91.1.20 | 49 | ;;; Mike Newton (newton@gumby.cs.caltech.edu) 91.1.20 |
| 21 | ;;; * bibtex.el/bibtex-mode : updated comments to indicate new use of | 50 | ;;; * bibtex.el/bibtex-mode : updated comments to indicate new use of |
| 22 | ;;; address, add minor explanations and fix small omissions. | 51 | ;;; address, add minor explanations and fix small omissions. |
| @@ -117,26 +146,35 @@ | |||
| 117 | (define-abbrev-table 'bibtex-mode-abbrev-table ()) | 146 | (define-abbrev-table 'bibtex-mode-abbrev-table ()) |
| 118 | (defvar bibtex-mode-map (make-sparse-keymap) "") | 147 | (defvar bibtex-mode-map (make-sparse-keymap) "") |
| 119 | (defvar bibtex-pop-previous-search-point nil | 148 | (defvar bibtex-pop-previous-search-point nil |
| 120 | "Next point where `bibtex-pop-previous' should start looking for a similar | 149 | "Next point where bibtex-pop-previous should start looking for a similar |
| 121 | entry.") | 150 | entry.") |
| 122 | (defvar bibtex-pop-next-search-point nil | 151 | (defvar bibtex-pop-next-search-point nil |
| 123 | "Next point where `bibtex-pop-next' should start looking for a similar | 152 | "Next point where bibtex-pop-next should start looking for a similar |
| 124 | entry.") | 153 | entry.") |
| 125 | 154 | ||
| 126 | (defvar bibtex-clean-entry-zap-empty-opts t | 155 | (defvar bibtex-clean-entry-zap-empty-opts t |
| 127 | "*If non-nil, `bibtex-clean-entry' will delete all empty optional fields.") | 156 | "*If non-nil, bibtex-clean-entry will delete all empty optional fields.") |
| 128 | (defvar bibtex-include-OPTcrossref t | 157 | (defvar bibtex-include-OPTcrossref t |
| 129 | "*If non-nil, all entries will have an `OPTcrossref' field.") | 158 | "*If non-nil, all entries will have an OPTcrossref field.") |
| 130 | (defvar bibtex-include-OPTkey t | 159 | (defvar bibtex-include-OPTkey t |
| 131 | "*If non-nil, all entries will have an `OPTkey' field.") | 160 | "*If non-nil, all entries will have an OPTkey field.") |
| 132 | (defvar bibtex-include-OPTannote t | 161 | (defvar bibtex-include-OPTannote t |
| 133 | "*If non-nil, all entries will have an `OPTannote' field.") | 162 | "*If non-nil, all entries will have an OPTannote field.") |
| 163 | (defvar bibtex-use-OPT-prefix t | ||
| 164 | "*If non-nil, put OPT string before optionals. Usually desired!") | ||
| 165 | (defvar bibtex-save-OPT nil | ||
| 166 | "*List of atoms (representing strings) which are optional fields that | ||
| 167 | should not be deleted if null.") | ||
| 168 | (defvar bibtex-curly-delimeters nil | ||
| 169 | "List of atoms representing strings (in any case) that should have curly | ||
| 170 | braces used as their delimeters instead of double quotes.") | ||
| 171 | |||
| 134 | 172 | ||
| 135 | ;; note: the user should be allowed to have their own list of always | 173 | ;; note: the user should be allowed to have their own list of always |
| 136 | ;; available optional fields. exs: "keywords" "categories" | 174 | ;; available optional fields. exs: "keywords" "categories" |
| 137 | (defvar bibtex-mode-user-optional-fields nil ;no default value | 175 | (defvar bibtex-mode-user-optional-fields nil ;no default value |
| 138 | "*List of optional fields that user always wants present in a bibtex entry. | 176 | "*List of optional fields that user want to have as always present |
| 139 | One possibility is for ``keywords''") | 177 | when making a bibtex entry. One possibility is for ``keywords''") |
| 140 | 178 | ||
| 141 | 179 | ||
| 142 | ;;; A bibtex file is a sequence of entries, either string definitions | 180 | ;;; A bibtex file is a sequence of entries, either string definitions |
| @@ -149,16 +187,16 @@ One possibility is for ``keywords''") | |||
| 149 | 187 | ||
| 150 | ;;; fields | 188 | ;;; fields |
| 151 | (defun bibtex-cfield (name text) | 189 | (defun bibtex-cfield (name text) |
| 152 | "Create a regexp for a bibtex field of name NAME and text TEXT." | 190 | "Create a regexp for a bibtex field of name NAME and text TEXT" |
| 153 | (concat ",[ \t\n]*\\(" | 191 | (concat ",[ \t\n]*\\(" |
| 154 | name | 192 | name |
| 155 | "\\)[ \t\n]*=[ \t\n]*\\(" | 193 | "\\)[ \t\n]*=[ \t\n]*\\(" |
| 156 | text | 194 | text |
| 157 | "\\)")) | 195 | "\\)")) |
| 158 | (defconst bibtex-name-in-cfield 1 | 196 | (defconst bibtex-name-in-cfield 1 |
| 159 | "The regexp subexpression number of the name part in `bibtex-cfield'.") | 197 | "The regexp subexpression number of the name part in bibtex-cfield.") |
| 160 | (defconst bibtex-text-in-cfield 2 | 198 | (defconst bibtex-text-in-cfield 2 |
| 161 | "The regexp subexpression number of the text part in `bibtex-cfield'.") | 199 | "The regexp subexpression number of the text part in bibtex-cfield.") |
| 162 | 200 | ||
| 163 | (defconst bibtex-field-name "[A-Za-z][---A-Za-z0-9:_+]*" | 201 | (defconst bibtex-field-name "[A-Za-z][---A-Za-z0-9:_+]*" |
| 164 | "Regexp defining the name part of a bibtex field.") | 202 | "Regexp defining the name part of a bibtex field.") |
| @@ -171,17 +209,27 @@ One possibility is for ``keywords''") | |||
| 171 | ;; key = {Volume-2}, | 209 | ;; key = {Volume-2}, |
| 172 | ;; note = "Volume~2 is listed under Knuth \cite{book-full}" | 210 | ;; note = "Volume~2 is listed under Knuth \cite{book-full}" |
| 173 | ;; i have added a few of these, but not all! -- MON | 211 | ;; i have added a few of these, but not all! -- MON |
| 212 | ;; 92.2.11: also must handle: | ||
| 213 | ;; author = "{S}schr\"odinger" or | ||
| 214 | ;; author = "{S}schr\"{o}dinger" or | ||
| 215 | ;; author = "{S}schr{\"o}dinger" or | ||
| 216 | |||
| 174 | 217 | ||
| 175 | (defconst bibtex-field-const | 218 | (defconst bibtex-field-const |
| 176 | "[0-9A-Za-z][---A-Za-z0-9:_+]*" | 219 | "[0-9A-Za-z][---A-Za-z0-9:_+]*" |
| 177 | "Format of a bibtex field constant.") | 220 | "Format of a bibtex field constant.") |
| 178 | (defconst bibtex-field-string | 221 | |
| 222 | (defconst bibtex-field-string ;;was:(concat "\"[^\"]*[^\\\\]\"\\|\"\"") | ||
| 179 | (concat | 223 | (concat |
| 180 | "\"[^\"]*[^\\\\]\"\\|\"\"") | 224 | "\"\\([^\"]*[\\\\][\"]\\)*[^\"]*[^\\\\]\"" |
| 181 | "Match either a string or an empty string.") | 225 | "\\|" ;ie: OR |
| 226 | "\"\"" | ||
| 227 | "\\|" ;ie: OR | ||
| 228 | "\"[^\"]*[^\\\\]\"") | ||
| 229 | "Match either a \"-d string or an empty string or a plain string.") | ||
| 182 | (defconst bibtex-field-string-or-const | 230 | (defconst bibtex-field-string-or-const |
| 183 | (concat bibtex-field-const "\\|" bibtex-field-string) | 231 | (concat bibtex-field-const "\\|" bibtex-field-string) |
| 184 | "Match either `bibtex-field-string' or `bibtex-field-const'.") | 232 | "Match either bibtex-field-string or bibtex-field-const.") |
| 185 | 233 | ||
| 186 | ;(defconst bibtex-field-text | 234 | ;(defconst bibtex-field-text |
| 187 | ; "\"[^\"]*[^\\\\]\"\\|\"\"\\|[0-9A-Za-z][---A-Za-z0-9:_+]*" | 235 | ; "\"[^\"]*[^\\\\]\"\\|\"\"\\|[0-9A-Za-z][---A-Za-z0-9:_+]*" |
| @@ -191,60 +239,64 @@ One possibility is for ``keywords''") | |||
| 191 | (concat | 239 | (concat |
| 192 | "\\(" bibtex-field-string-or-const "\\)" | 240 | "\\(" bibtex-field-string-or-const "\\)" |
| 193 | "\\([ \t\n]+#[ \t\n]+\\(" bibtex-field-string-or-const "\\)\\)*\\|" | 241 | "\\([ \t\n]+#[ \t\n]+\\(" bibtex-field-string-or-const "\\)\\)*\\|" |
| 194 | "{[^{}]*[^\\\\]}") | 242 | "{[^{}]*[^\\\\]}" "\\|" "{}") |
| 195 | "Regexp defining the text part of a bibtex field: either a string, or | 243 | "Regexp defining the text part of a bibtex field: either a string, or |
| 196 | an empty string, or a constant followed by one or more # / constant pairs. | 244 | an empty string, or a constant followed by one or more # / constant pairs. |
| 197 | Also matches simple {...} patterns.") | 245 | Also matches simple {...} patterns, including the special case {}.") |
| 198 | 246 | ||
| 199 | (defconst bibtex-field | 247 | (defconst bibtex-field |
| 200 | (bibtex-cfield bibtex-field-name bibtex-field-text) | 248 | (bibtex-cfield bibtex-field-name bibtex-field-text) |
| 201 | "Regexp defining the format of a bibtex field") | 249 | "Regexp defining the format of a bibtex field") |
| 202 | 250 | ||
| 203 | (defconst bibtex-name-in-field bibtex-name-in-cfield | 251 | (defconst bibtex-name-in-field bibtex-name-in-cfield |
| 204 | "The regexp subexpression number of the name part in `bibtex-field'.") | 252 | "The regexp subexpression number of the name part in bibtex-field") |
| 205 | (defconst bibtex-text-in-field bibtex-text-in-cfield | 253 | (defconst bibtex-text-in-field bibtex-text-in-cfield |
| 206 | "The regexp subexpression number of the text part in `bibtex-field'.") | 254 | "The regexp subexpression number of the text part in bibtex-field") |
| 207 | 255 | ||
| 208 | ;;; references | 256 | ;;; references |
| 209 | (defconst bibtex-reference-type | 257 | (defconst bibtex-reference-type |
| 210 | "@[A-Za-z]+" | 258 | "@[A-Za-z]+" |
| 211 | "Regexp defining the type part of a bibtex reference entry.") | 259 | "Regexp defining the type part of a bibtex reference entry") |
| 260 | |||
| 212 | (defconst bibtex-reference-head | 261 | (defconst bibtex-reference-head |
| 213 | (concat "^[ \t]*\\(" | 262 | (concat "^[ \t]*\\(" |
| 214 | bibtex-reference-type | 263 | bibtex-reference-type |
| 215 | "\\)[ \t]*[({]\\(" | 264 | "\\)[ \t]*[({]\\(" |
| 216 | bibtex-field-name | 265 | bibtex-field-name |
| 217 | "\\)") | 266 | "\\)") |
| 218 | "Regexp defining format of the header line of a bibtex reference entry.") | 267 | "Regexp defining format of the header line of a bibtex reference entry") |
| 219 | (defconst bibtex-type-in-head 1 | 268 | (defconst bibtex-type-in-head 1 |
| 220 | "The regexp subexpression number of the type part in `bibtex-reference-head'.") | 269 | "The regexp subexpression number of the type part in bibtex-reference-head") |
| 221 | (defconst bibtex-key-in-head 2 | 270 | (defconst bibtex-key-in-head 2 |
| 222 | "The regexp subexpression number of the key part in `bibtex-reference-head'.") | 271 | "The regexp subexpression number of the key part in |
| 272 | bibtex-reference-head") | ||
| 223 | 273 | ||
| 224 | (defconst bibtex-reference | 274 | (defconst bibtex-reference |
| 225 | (concat bibtex-reference-head | 275 | (concat bibtex-reference-head |
| 226 | "\\([ \t\n]*" bibtex-field "\\)*" | 276 | "\\([ \t\n]*" bibtex-field "\\)*" |
| 227 | "[ \t\n]*[})]") | 277 | "[ \t\n]*[})]") |
| 228 | "Regexp defining the format of a bibtex reference entry.") | 278 | "Regexp defining the format of a bibtex reference entry") |
| 229 | (defconst bibtex-type-in-reference bibtex-type-in-head | 279 | (defconst bibtex-type-in-reference bibtex-type-in-head |
| 230 | "The regexp subexpression number of the type part in `bibtex-reference'.") | 280 | "The regexp subexpression number of the type part in bibtex-reference") |
| 231 | (defconst bibtex-key-in-reference bibtex-key-in-head | 281 | (defconst bibtex-key-in-reference bibtex-key-in-head |
| 232 | "The regexp subexpression number of the key part in `bibtex-reference'.") | 282 | "The regexp subexpression number of the key part in |
| 283 | bibtex-reference") | ||
| 233 | 284 | ||
| 234 | ;;; strings | 285 | ;;; string definitions. note bibtex-string is a constant and a defun ! |
| 235 | (defconst bibtex-string | 286 | (defconst bibtex-string |
| 236 | (concat "^[ \t]*@[sS][tT][rR][iI][nN][gG][ \t\n]*[({][ \t\n]*\\(" | 287 | (concat "^[ \t]*@[sS][tT][rR][iI][nN][gG][ \t\n]*[({][ \t\n]*\\(" |
| 237 | bibtex-field-name | 288 | bibtex-field-name |
| 238 | "\\)[ \t\n]*=[ \t\n]*\\(" | 289 | "\\)[ \t\n]*=[ \t\n]*\\(" |
| 239 | bibtex-field-text | 290 | bibtex-field-text |
| 240 | "\\)[ \t\n]*[})]") | 291 | "\\)[ \t\n]*[})]") |
| 241 | "Regexp defining the format of a bibtex string entry.") | 292 | "Regexp defining the format of a bibtex string entry") |
| 293 | |||
| 242 | (defconst bibtex-name-in-string 1 | 294 | (defconst bibtex-name-in-string 1 |
| 243 | "The regexp subexpression of the name part in `bibtex-string'.") | 295 | "The regexp subexpression of the name part in bibtex-string") |
| 244 | (defconst bibtex-text-in-string 2 | 296 | (defconst bibtex-text-in-string 2 |
| 245 | "The regexp subexpression of the text part in `bibtex-string'.") | 297 | "The regexp subexpression of the text part in bibtex-string") |
| 246 | 298 | ||
| 247 | (defconst bibtex-name-alignement 2 | 299 | (defconst bibtex-name-alignment 2 |
| 248 | "Alignment for the name part in BibTeX fields. | 300 | "Alignment for the name part in BibTeX fields. |
| 249 | Chosen on aesthetic grounds only.") | 301 | Chosen on aesthetic grounds only.") |
| 250 | 302 | ||
| @@ -254,7 +306,6 @@ Equal to the space needed for the longest name part.") | |||
| 254 | 306 | ||
| 255 | ;;; bibtex mode: | 307 | ;;; bibtex mode: |
| 256 | 308 | ||
| 257 | ;;;###autoload | ||
| 258 | (defun bibtex-mode () | 309 | (defun bibtex-mode () |
| 259 | "Major mode for editing bibtex files. | 310 | "Major mode for editing bibtex files. |
| 260 | 311 | ||
| @@ -409,7 +460,9 @@ non-nil." | |||
| 409 | (t | 460 | (t |
| 410 | (backward-paragraph) | 461 | (backward-paragraph) |
| 411 | (forward-paragraph))) | 462 | (forward-paragraph))) |
| 412 | (re-search-forward "[ \t\n]*" (point-max) t)) | 463 | (re-search-forward "[ \t\n]*" (point-max) t) |
| 464 | (insert "\n") | ||
| 465 | (forward-char -1)) | ||
| 413 | 466 | ||
| 414 | ;; | 467 | ;; |
| 415 | ;; note: this should really take lists of strings OR of lists. in the | 468 | ;; note: this should really take lists of strings OR of lists. in the |
| @@ -436,22 +489,40 @@ non-nil." | |||
| 436 | (up-list -1) | 489 | (up-list -1) |
| 437 | (forward-char 1)) | 490 | (forward-char 1)) |
| 438 | 491 | ||
| 492 | (defun bibtex-insert-field-delimeters (str) | ||
| 493 | "Insert double quotes (default) or, if STR is in the list | ||
| 494 | bibtex-curly-delimeters, insert curly brackets." | ||
| 495 | (if (and (boundp 'bibtex-curly-delimeters) | ||
| 496 | bibtex-curly-delimeters | ||
| 497 | (memq (car (read-from-string (downcase str))) | ||
| 498 | bibtex-curly-delimeters)) | ||
| 499 | (insert "\{\}") | ||
| 500 | (insert "\"\""))) | ||
| 501 | |||
| 439 | (defun bibtex-make-field (str) | 502 | (defun bibtex-make-field (str) |
| 440 | (interactive "sBibTeX entry type: ") | 503 | (interactive "sBibTeX entry type: ") |
| 441 | (insert ",\n") | 504 | (insert ",\n") |
| 442 | (indent-to-column bibtex-name-alignement) | 505 | (indent-to-column bibtex-name-alignment) |
| 443 | (insert str " = ") | 506 | (insert str " = ") |
| 444 | (indent-to-column bibtex-text-alignment) | 507 | (indent-to-column bibtex-text-alignment) |
| 445 | (insert "\"\"") | 508 | (bibtex-insert-field-delimeters str) |
| 446 | nil) | 509 | nil) |
| 447 | 510 | ||
| 511 | ;; modified to make fields align up _after_ the OPT's have been removed | ||
| 512 | |||
| 448 | (defun bibtex-make-optional-field (str) | 513 | (defun bibtex-make-optional-field (str) |
| 449 | (interactive "sOptional BibTeX entry type: ") | 514 | (interactive "sOptional BibTeX entry type: ") |
| 450 | (insert ",\n") | 515 | (insert ",\n") |
| 451 | (indent-to-column bibtex-name-alignement) | 516 | (indent-to-column bibtex-name-alignment) |
| 452 | (insert "OPT" str " = ") | 517 | (insert str " = ") |
| 453 | (indent-to-column bibtex-text-alignment) | 518 | (indent-to-column bibtex-text-alignment) ;align nicely, then,... |
| 454 | (insert "\"\"") | 519 | (bibtex-insert-field-delimeters str) |
| 520 | (if bibtex-use-OPT-prefix | ||
| 521 | (progn | ||
| 522 | (beginning-of-line) | ||
| 523 | (move-to-column bibtex-name-alignment) ;go back to name and put in OPT | ||
| 524 | (insert "OPT") | ||
| 525 | (end-of-line))) | ||
| 455 | nil) | 526 | nil) |
| 456 | 527 | ||
| 457 | ;; What to do about crossref? if present, journal and year are | 528 | ;; What to do about crossref? if present, journal and year are |
| @@ -594,10 +665,10 @@ non-nil." | |||
| 594 | (if arg | 665 | (if arg |
| 595 | (progn | 666 | (progn |
| 596 | (goto-char (match-beginning bibtex-text-in-field)) | 667 | (goto-char (match-beginning bibtex-text-in-field)) |
| 597 | (if (looking-at "\"") | 668 | (if (or (looking-at "\"") (looking-at "{")) |
| 598 | (forward-char 1))) | 669 | (forward-char 1))) |
| 599 | (goto-char (match-end bibtex-text-in-field)) | 670 | (goto-char (match-end bibtex-text-in-field)) |
| 600 | (if (= (preceding-char) ?\") | 671 | (if (or (= (preceding-char) ?\") (= (preceding-char) ?})) |
| 601 | (forward-char -1)))) | 672 | (forward-char -1)))) |
| 602 | 673 | ||
| 603 | (defun bibtex-remove-OPT () | 674 | (defun bibtex-remove-OPT () |
| @@ -618,7 +689,7 @@ non-nil." | |||
| 618 | (skip-chars-backward " \t") ;delete these chars? -- MON | 689 | (skip-chars-backward " \t") ;delete these chars? -- MON |
| 619 | (cond ((= (preceding-char) ?,) | 690 | (cond ((= (preceding-char) ?,) |
| 620 | (forward-char -1))) | 691 | (forward-char -1))) |
| 621 | (cond ((= (preceding-char) ?\") | 692 | (cond ((or (= (preceding-char) ?\") (= (preceding-char) ?\})) |
| 622 | (forward-char -1)))) ;only go back if quote | 693 | (forward-char -1)))) ;only go back if quote |
| 623 | 694 | ||
| 624 | 695 | ||
| @@ -835,7 +906,7 @@ an undefined location. | |||
| 835 | (re-search-forward regexp right nil 1) | 906 | (re-search-forward regexp right nil 1) |
| 836 | (if (> (match-beginning 0) initial) | 907 | (if (> (match-beginning 0) initial) |
| 837 | (signal 'search-failed (list regexp))) | 908 | (signal 'search-failed (list regexp))) |
| 838 | (while (<= (match-end 0) initial) | 909 | (while (< (match-end 0) initial) ;<= --> < -- MON |
| 839 | (re-search-forward regexp right nil 1) | 910 | (re-search-forward regexp right nil 1) |
| 840 | (if (> (match-beginning 0) initial) | 911 | (if (> (match-beginning 0) initial) |
| 841 | (signal 'search-failed (list regexp)))) | 912 | (signal 'search-failed (list regexp)))) |
| @@ -862,9 +933,16 @@ an undefined location. | |||
| 862 | (looking-at "OPT") | 933 | (looking-at "OPT") |
| 863 | bibtex-clean-entry-zap-empty-opts) | 934 | bibtex-clean-entry-zap-empty-opts) |
| 864 | (goto-char begin-text) | 935 | (goto-char begin-text) |
| 865 | (if (looking-at "\"\"") ; empty: delete whole field | 936 | (if (and (looking-at "\"\"") ; empty: delete whole field |
| 937 | (boundp 'bibtex-save-OPT) | ||
| 938 | bibtex-save-OPT | ||
| 939 | (not (memq (car (read-from-string | ||
| 940 | (buffer-substring | ||
| 941 | (+ begin-name 3) | ||
| 942 | end-name))) | ||
| 943 | bibtex-save-OPT))) | ||
| 866 | (delete-region begin-field end-field) | 944 | (delete-region begin-field end-field) |
| 867 | ; otherwise: not empty, delete "OPT" | 945 | ;; otherwise: not empty, delete "OPT" |
| 868 | (goto-char begin-name) | 946 | (goto-char begin-name) |
| 869 | (delete-char (length "OPT")) | 947 | (delete-char (length "OPT")) |
| 870 | (goto-char begin-field) ; and loop to go through next test | 948 | (goto-char begin-field) ; and loop to go through next test |
| @@ -888,7 +966,12 @@ an undefined location. | |||
| 888 | (equal (buffer-substring | 966 | (equal (buffer-substring |
| 889 | begin-name | 967 | begin-name |
| 890 | (+ begin-name 3)) | 968 | (+ begin-name 3)) |
| 891 | "opt"))) | 969 | "opt") |
| 970 | (memq (car (read-from-string | ||
| 971 | (buffer-substring | ||
| 972 | begin-name | ||
| 973 | end-name))) | ||
| 974 | bibtex-save-OPT))) | ||
| 892 | (error "Mandatory field ``%s'' is empty" | 975 | (error "Mandatory field ``%s'' is empty" |
| 893 | (buffer-substring begin-name end-name)))) | 976 | (buffer-substring begin-name end-name)))) |
| 894 | (t | 977 | (t |