diff options
| author | Roland Winkler | 2009-02-14 16:58:04 +0000 |
|---|---|---|
| committer | Roland Winkler | 2009-02-14 16:58:04 +0000 |
| commit | 03db5e5fb8be1ccc7c7cff510508248684899b5d (patch) | |
| tree | 784e475bf3e67033424775558d98822588989b32 | |
| parent | 77730170c0fb941193d3178acb0ffd53c4980140 (diff) | |
| download | emacs-03db5e5fb8be1ccc7c7cff510508248684899b5d.tar.gz emacs-03db5e5fb8be1ccc7c7cff510508248684899b5d.zip | |
(bibtex-global-key-alist, bibtex-initialize): Exclude current buffer
if it does not use bibtex-mode.
(bibtex-parse-strings, bibtex-strings, bibtex-initialize)
(bibtex-sort-buffer, bibtex-search-entry)
(bibtex-prepare-new-entry, bibtex-clean-entry): Use functionp to
test whether bibtex-strings and bibtex-reference-keys have their
initial values.
| -rw-r--r-- | lisp/ChangeLog | 11 | ||||
| -rw-r--r-- | lisp/textmodes/bibtex.el | 63 |
2 files changed, 47 insertions, 27 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 8ad2ee87a88..cf008053348 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,14 @@ | |||
| 1 | 2009-02-14 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de> | ||
| 2 | |||
| 3 | * textmodes/bibtex.el (bibtex-global-key-alist) | ||
| 4 | (bibtex-initialize): Exclude current buffer if it does not use | ||
| 5 | bibtex-mode. | ||
| 6 | (bibtex-parse-strings, bibtex-strings, bibtex-initialize) | ||
| 7 | (bibtex-sort-buffer, bibtex-search-entry) | ||
| 8 | (bibtex-prepare-new-entry, bibtex-clean-entry): Use functionp to | ||
| 9 | test whether bibtex-strings and bibtex-reference-keys have their | ||
| 10 | initial values. | ||
| 11 | |||
| 1 | 2009-02-14 Eli Zaretskii <eliz@gnu.org> | 12 | 2009-02-14 Eli Zaretskii <eliz@gnu.org> |
| 2 | 13 | ||
| 3 | * textmodes/ispell.el (ispell-insert-word): Use `with-no-warnings' | 14 | * textmodes/ispell.el (ispell-insert-word): Use `with-no-warnings' |
diff --git a/lisp/textmodes/bibtex.el b/lisp/textmodes/bibtex.el index 139f9f02d04..ebe17d7e809 100644 --- a/lisp/textmodes/bibtex.el +++ b/lisp/textmodes/bibtex.el | |||
| @@ -2440,8 +2440,10 @@ Concatenate the key: | |||
| 2440 | (apply 'append | 2440 | (apply 'append |
| 2441 | (mapcar (lambda (buf) | 2441 | (mapcar (lambda (buf) |
| 2442 | (with-current-buffer buf bibtex-reference-keys)) | 2442 | (with-current-buffer buf bibtex-reference-keys)) |
| 2443 | (bibtex-initialize t))) | 2443 | ;; include current buffer only if it uses `bibtex-mode' |
| 2444 | bibtex-reference-keys)) | 2444 | (bibtex-initialize (eq major-mode 'bibtex-mode)))) |
| 2445 | (if (eq major-mode 'bibtex-mode) | ||
| 2446 | bibtex-reference-keys))) | ||
| 2445 | 2447 | ||
| 2446 | (defun bibtex-read-key (prompt &optional key global) | 2448 | (defun bibtex-read-key (prompt &optional key global) |
| 2447 | "Read BibTeX key from minibuffer using PROMPT and default KEY. | 2449 | "Read BibTeX key from minibuffer using PROMPT and default KEY. |
| @@ -2531,8 +2533,7 @@ Return alist of strings if parsing was completed, `aborted' otherwise." | |||
| 2531 | (save-excursion | 2533 | (save-excursion |
| 2532 | (save-match-data | 2534 | (save-match-data |
| 2533 | (goto-char (point-min)) | 2535 | (goto-char (point-min)) |
| 2534 | (let ((strings (if (and add | 2536 | (let ((strings (if (and add (not (functionp bibtex-strings))) |
| 2535 | (listp bibtex-strings)) | ||
| 2536 | bibtex-strings)) | 2537 | bibtex-strings)) |
| 2537 | bounds key) | 2538 | bounds key) |
| 2538 | (if (listp add) | 2539 | (if (listp add) |
| @@ -2555,8 +2556,9 @@ Return alist of strings if parsing was completed, `aborted' otherwise." | |||
| 2555 | 2556 | ||
| 2556 | (defun bibtex-strings () | 2557 | (defun bibtex-strings () |
| 2557 | "Return `bibtex-strings'. Initialize this variable if necessary." | 2558 | "Return `bibtex-strings'. Initialize this variable if necessary." |
| 2558 | (if (listp bibtex-strings) bibtex-strings | 2559 | (if (functionp bibtex-strings) |
| 2559 | (bibtex-parse-strings (bibtex-string-files-init)))) | 2560 | (bibtex-parse-strings (bibtex-string-files-init)) |
| 2561 | bibtex-strings)) | ||
| 2560 | 2562 | ||
| 2561 | (defun bibtex-string-files-init () | 2563 | (defun bibtex-string-files-init () |
| 2562 | "Return initialization for `bibtex-strings'. | 2564 | "Return initialization for `bibtex-strings'. |
| @@ -2668,7 +2670,11 @@ When called interactively, FORCE is t, CURRENT is t if current buffer uses | |||
| 2668 | (dolist (file file-list) | 2670 | (dolist (file file-list) |
| 2669 | (if (file-readable-p file) | 2671 | (if (file-readable-p file) |
| 2670 | (push (find-file-noselect file) buffer-list))) | 2672 | (push (find-file-noselect file) buffer-list))) |
| 2671 | ;; include current buffer iff we want it | 2673 | ;; Include current buffer iff we want it. |
| 2674 | ;; Exclude current buffer if it doesn't use `bibtex-mode'. | ||
| 2675 | ;; Thus calling `bibtex-initialize' gives meaningful results for | ||
| 2676 | ;; any current buffer. | ||
| 2677 | (unless (and current (eq major-mode 'bibtex-mode)) (setq current nil)) | ||
| 2672 | (cond ((and current (not (memq (current-buffer) buffer-list))) | 2678 | (cond ((and current (not (memq (current-buffer) buffer-list))) |
| 2673 | (push (current-buffer) buffer-list)) | 2679 | (push (current-buffer) buffer-list)) |
| 2674 | ((and (not current) (memq (current-buffer) buffer-list)) | 2680 | ((and (not current) (memq (current-buffer) buffer-list)) |
| @@ -2676,7 +2682,7 @@ When called interactively, FORCE is t, CURRENT is t if current buffer uses | |||
| 2676 | ;; parse keys | 2682 | ;; parse keys |
| 2677 | (dolist (buffer buffer-list) | 2683 | (dolist (buffer buffer-list) |
| 2678 | (with-current-buffer buffer | 2684 | (with-current-buffer buffer |
| 2679 | (if (or force (nlistp bibtex-reference-keys)) | 2685 | (if (or force (functionp bibtex-reference-keys)) |
| 2680 | (bibtex-parse-keys)))) | 2686 | (bibtex-parse-keys)))) |
| 2681 | ;; select BibTeX buffer | 2687 | ;; select BibTeX buffer |
| 2682 | (if select | 2688 | (if select |
| @@ -3484,7 +3490,7 @@ are ignored." | |||
| 3484 | (bibtex-beginning-of-first-entry) ; Needed by `sort-subr' | 3490 | (bibtex-beginning-of-first-entry) ; Needed by `sort-subr' |
| 3485 | (bibtex-init-sort-entry-class-alist) ; Needed by `bibtex-lessp'. | 3491 | (bibtex-init-sort-entry-class-alist) ; Needed by `bibtex-lessp'. |
| 3486 | (if (and (eq bibtex-maintain-sorted-entries 'crossref) | 3492 | (if (and (eq bibtex-maintain-sorted-entries 'crossref) |
| 3487 | (nlistp bibtex-reference-keys)) | 3493 | (functionp bibtex-reference-keys)) |
| 3488 | (bibtex-parse-keys)) ; Needed by `bibtex-lessp'. | 3494 | (bibtex-parse-keys)) ; Needed by `bibtex-lessp'. |
| 3489 | (sort-subr nil | 3495 | (sort-subr nil |
| 3490 | 'bibtex-skip-to-valid-entry ; NEXTREC function | 3496 | 'bibtex-skip-to-valid-entry ; NEXTREC function |
| @@ -3591,8 +3597,7 @@ mode is not `bibtex-mode', START is nil, and DISPLAY is t." | |||
| 3591 | (while (and (not found) | 3597 | (while (and (not found) |
| 3592 | (setq buffer (pop buffer-list))) | 3598 | (setq buffer (pop buffer-list))) |
| 3593 | (with-current-buffer buffer | 3599 | (with-current-buffer buffer |
| 3594 | (if (and (listp bibtex-reference-keys) | 3600 | (if (cdr (assoc-string key bibtex-reference-keys)) |
| 3595 | (cdr (assoc-string key bibtex-reference-keys))) | ||
| 3596 | ;; `bibtex-search-entry' moves point if key found | 3601 | ;; `bibtex-search-entry' moves point if key found |
| 3597 | (setq found (bibtex-search-entry key))))) | 3602 | (setq found (bibtex-search-entry key))))) |
| 3598 | (cond ((and found display) | 3603 | (cond ((and found display) |
| @@ -3632,7 +3637,7 @@ see `bibtex-validate'. | |||
| 3632 | Return t if preparation was successful or nil if entry KEY already exists." | 3637 | Return t if preparation was successful or nil if entry KEY already exists." |
| 3633 | (bibtex-init-sort-entry-class-alist) ; Needed by `bibtex-lessp'. | 3638 | (bibtex-init-sort-entry-class-alist) ; Needed by `bibtex-lessp'. |
| 3634 | (if (and (eq bibtex-maintain-sorted-entries 'crossref) | 3639 | (if (and (eq bibtex-maintain-sorted-entries 'crossref) |
| 3635 | (nlistp bibtex-reference-keys)) | 3640 | (functionp bibtex-reference-keys)) |
| 3636 | (bibtex-parse-keys)) ; Needed by `bibtex-lessp'. | 3641 | (bibtex-parse-keys)) ; Needed by `bibtex-lessp'. |
| 3637 | (let ((key (nth 0 index)) | 3642 | (let ((key (nth 0 index)) |
| 3638 | key-exist) | 3643 | key-exist) |
| @@ -4247,23 +4252,27 @@ At end of the cleaning process, the functions in | |||
| 4247 | (if (cdr (assoc-string key bibtex-reference-keys)) | 4252 | (if (cdr (assoc-string key bibtex-reference-keys)) |
| 4248 | (error "Duplicate key in %s" (buffer-file-name))))) | 4253 | (error "Duplicate key in %s" (buffer-file-name))))) |
| 4249 | 4254 | ||
| 4250 | ;; Only update the list of keys if it has been built already. | 4255 | ;; Only update `bibtex-strings' and `bibtex-reference-keys' |
| 4256 | ;; if they have been built already. | ||
| 4251 | (cond ((eq entry-type 'string) | 4257 | (cond ((eq entry-type 'string) |
| 4252 | (if (and (listp bibtex-strings) | 4258 | ;; We have a @String entry. |
| 4253 | (not (assoc key bibtex-strings))) | 4259 | (unless (or (functionp bibtex-strings) |
| 4254 | (push (cons key (bibtex-text-in-string | 4260 | (assoc key bibtex-strings)) |
| 4255 | (bibtex-parse-string) t)) | 4261 | (push (cons key (bibtex-text-in-string |
| 4256 | bibtex-strings))) | 4262 | (bibtex-parse-string) t)) |
| 4263 | bibtex-strings))) | ||
| 4257 | ;; We have a normal entry. | 4264 | ;; We have a normal entry. |
| 4258 | ((listp bibtex-reference-keys) | 4265 | ((not (functionp bibtex-reference-keys)) |
| 4259 | (cond ((not (assoc key bibtex-reference-keys)) | 4266 | (let ((found (assoc key bibtex-reference-keys))) |
| 4260 | (push (cons key t) bibtex-reference-keys)) | 4267 | (cond ((not found) |
| 4261 | ((not (cdr (assoc key bibtex-reference-keys))) | 4268 | (push (cons key t) bibtex-reference-keys)) |
| 4262 | ;; Turn a crossref key into a header key | 4269 | ((not (cdr found)) |
| 4263 | (setq bibtex-reference-keys | 4270 | ;; Turn a crossref key into a header key |
| 4264 | (cons (cons key t) | 4271 | (setq bibtex-reference-keys |
| 4265 | (delete (list key) bibtex-reference-keys))))) | 4272 | (cons (cons key t) |
| 4266 | ;; Handle crossref key. | 4273 | (delete (list key) bibtex-reference-keys)))))) |
| 4274 | ;; If entry has a crossref key, it goes into the list | ||
| 4275 | ;; `bibtex-reference-keys', too. | ||
| 4267 | (if (and (nth 1 index) | 4276 | (if (and (nth 1 index) |
| 4268 | (not (assoc (nth 1 index) bibtex-reference-keys))) | 4277 | (not (assoc (nth 1 index) bibtex-reference-keys))) |
| 4269 | (push (list (nth 1 index)) bibtex-reference-keys))))) | 4278 | (push (list (nth 1 index)) bibtex-reference-keys))))) |