From: Roland Winkler Date: Sat, 13 Apr 2013 20:45:03 +0000 (-0500) Subject: lisp/textmodes/bibtex.el (bibtex-search-entries): Bug fix X-Git-Tag: emacs-24.3.90~173^2^2~42^2~45^2~387^2~2026^2~476 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=7ae9f0fb9927a99846f164785d81e72ba639f359;p=emacs.git lisp/textmodes/bibtex.el (bibtex-search-entries): Bug fix --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index de1ba013d1c..47af4d55433 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2013-04-13 Roland Winkler + + * textmodes/bibtex.el (bibtex-search-entries): Bug fix. Use match + data before it gets modified by bibtex-beginning-of-entry. + 2013-04-13 Roland Winkler * textmodes/bibtex.el (bibtex-url): Doc fix. diff --git a/lisp/textmodes/bibtex.el b/lisp/textmodes/bibtex.el index 1daa0186bdb..01a126eb381 100644 --- a/lisp/textmodes/bibtex.el +++ b/lisp/textmodes/bibtex.el @@ -5241,19 +5241,22 @@ where FILE is the BibTeX file of ENTRY." (if (string= "" field) ;; Unrestricted search. (while (re-search-forward regexp nil t) - (let ((beg (bibtex-beginning-of-entry)) - (end (bibtex-end-of-entry)) - key) - (if (and (<= beg (match-beginning 0)) - (<= (match-end 0) end) - (save-excursion - (goto-char beg) - (and (looking-at bibtex-entry-head) - (setq key (bibtex-key-in-head)))) - (not (assoc key entries))) - (push (list key file - (buffer-substring-no-properties beg end)) - entries)))) + (save-excursion + (let ((mbeg (match-beginning 0)) + (mend (match-end 0)) + (beg (bibtex-beginning-of-entry)) + (end (bibtex-end-of-entry)) + key) + (if (and (<= beg mbeg) + (<= mend end) + (progn + (goto-char beg) + (looking-at bibtex-entry-head)) + (setq key (bibtex-key-in-head)) + (not (assoc key entries))) + (push (list key file + (buffer-substring-no-properties beg end)) + entries))))) ;; The following is slow. But it works reliably even in more ;; complicated cases with BibTeX string constants and crossrefed ;; entries. If you prefer speed over reliability, perform an