]> git.eshelyaron.com Git - emacs.git/commitdiff
lisp/textmodes/bibtex.el (bibtex-search-entries): Bug fix
authorRoland Winkler <winkler@gnu.org>
Sat, 13 Apr 2013 20:45:03 +0000 (15:45 -0500)
committerRoland Winkler <winkler@gnu.org>
Sat, 13 Apr 2013 20:45:03 +0000 (15:45 -0500)
lisp/ChangeLog
lisp/textmodes/bibtex.el

index de1ba013d1c8215b2fc727fa7346381881e14c41..47af4d554338d9580174cb99513b396d12481ced 100644 (file)
@@ -1,3 +1,8 @@
+2013-04-13  Roland Winkler  <winkler@gnu.org>
+
+       * 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  <winkler@gnu.org>
 
        * textmodes/bibtex.el (bibtex-url): Doc fix.
index 1daa0186bdbd9673e8ed87495165a8877ed36afd..01a126eb38126edfca1d3d2008c822bd91147047 100644 (file)
@@ -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