From 004dedd364f5944b51b61acf90c4976f9c974ba9 Mon Sep 17 00:00:00 2001 From: Roland Winkler Date: Sat, 4 Jun 2011 23:58:39 -0500 Subject: [PATCH] lisp/textmodes/bibtex.el: various small bug fixes --- lisp/ChangeLog | 9 +++++++ lisp/textmodes/bibtex.el | 54 +++++++++++++++++++++------------------- 2 files changed, 38 insertions(+), 25 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index e2974bda4c7..8a7b9f4f822 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,12 @@ +2011-06-05 Roland Winkler + + * textmodes/bibtex.el (bibtex-generate-url-list): Fix docstring. + (bibtex-insert-kill): After yanking insert newline if necessary. + (bibtex-initialize): Call bibtex-string-files-init only once. + (bibtex-mode): Do not call easy-menu-add. + (bibtex-validate-globally): Use save-excursion in bibtex buffers. + (bibtex-yank): Set arg properly if nil. + 2011-06-05 Roland Winkler * textmodes/bibtex.el (bibtex-search-entry-globally): New diff --git a/lisp/textmodes/bibtex.el b/lisp/textmodes/bibtex.el index 349ab28b4d9..6d07a6e3950 100644 --- a/lisp/textmodes/bibtex.el +++ b/lisp/textmodes/bibtex.el @@ -923,7 +923,7 @@ The following is a complex example, see URL `http://link.aps.org/'. (((\"journal\" . \"\\\\=<\\(PR[ABCDEL]?\\|RMP\\)\\\\=>\") \"http://link.aps.org/abstract/%s/v%s/p%s\" - (\"journal\" \".*\" downcase) + (\"journal\" \".*\" upcase) (\"volume\" \".*\" 0) (\"pages\" \"\\`[A-Z]?[0-9]+\" 0)))" :group 'bibtex @@ -1892,6 +1892,9 @@ Optional arg COMMA is as in `bibtex-enclosing-field'." (push-mark) (insert (funcall fun 'bibtex-entry-kill-ring-yank-pointer bibtex-entry-kill-ring)) + ;; If we copied an entry from a buffer containing only this one entry, + ;; it can be missing the second "\n". + (unless (looking-back "\n\n") (insert "\n")) (unless (functionp bibtex-reference-keys) ;; update `bibtex-reference-keys' (save-excursion @@ -2723,12 +2726,14 @@ When called interactively, FORCE is t, CURRENT is t if current buffer uses ((and (not current) (memq (current-buffer) buffer-list)) (setq buffer-list (delq (current-buffer) buffer-list)))) ;; parse keys - (dolist (buffer buffer-list) - (with-current-buffer buffer - (if (or force (functionp bibtex-reference-keys)) - (bibtex-parse-keys)) - (unless (functionp bibtex-strings) - (bibtex-parse-strings (bibtex-string-files-init))))) + (let (string-init) + (dolist (buffer buffer-list) + (with-current-buffer buffer + (if (or force (functionp bibtex-reference-keys)) + (bibtex-parse-keys)) + (when (or force (functionp bibtex-strings)) + (unless string-init (setq string-init (bibtex-string-files-init))) + (bibtex-parse-strings string-init))))) ;; select BibTeX buffer (if select (if buffer-list @@ -3043,10 +3048,7 @@ if that value is non-nil. bibtex-font-lock-syntactic-keywords)) (setq imenu-generic-expression (list (list nil bibtex-entry-head bibtex-key-in-head)) - imenu-case-fold-search t) - ;; XEmacs needs `easy-menu-add', Emacs does not care - (easy-menu-add bibtex-edit-menu) - (easy-menu-add bibtex-entry-menu)) + imenu-case-fold-search t)) (defun bibtex-field-list (entry-type) "Return list of allowed fields for entry ENTRY-TYPE. @@ -3873,20 +3875,21 @@ Return t if test was successful, nil otherwise." ;; Check for duplicate keys within BibTeX buffer (dolist (buffer buffer-list) (with-current-buffer buffer - (let (entry-type key key-list) - (goto-char (point-min)) - (while (re-search-forward bibtex-entry-head nil t) - (setq entry-type (bibtex-type-in-head) - key (bibtex-key-in-head)) - (if (or (and strings (bibtex-string= entry-type "string")) - (assoc-string entry-type bibtex-entry-field-alist t)) - (if (member key key-list) - (push (format "%s:%d: Duplicate key `%s'\n" - (buffer-file-name) - (bibtex-current-line) key) - error-list) - (push key key-list)))) - (push (cons buffer key-list) buffer-key-list)))) + (save-excursion + (let (entry-type key key-list) + (goto-char (point-min)) + (while (re-search-forward bibtex-entry-head nil t) + (setq entry-type (bibtex-type-in-head) + key (bibtex-key-in-head)) + (if (or (and strings (bibtex-string= entry-type "string")) + (assoc-string entry-type bibtex-entry-field-alist t)) + (if (member key key-list) + (push (format "%s:%d: Duplicate key `%s'\n" + (buffer-file-name) + (bibtex-current-line) key) + error-list) + (push key key-list)))) + (push (cons buffer key-list) buffer-key-list))))) ;; Check for duplicate keys among BibTeX buffers (while (setq current-buf (pop buffer-list)) @@ -4148,6 +4151,7 @@ More precisely, reinsert the field or entry killed or yanked most recently. With argument N, reinsert the Nth most recently killed BibTeX item. See also the command \\[bibtex-yank-pop]." (interactive "*p") + (unless n (setq n 1)) (bibtex-insert-kill (1- n) t) (setq this-command 'bibtex-yank)) -- 2.39.5