]> git.eshelyaron.com Git - emacs.git/commitdiff
Ensure forward progress in bibtex-map-entries
authorLars Ingebrigtsen <larsi@gnus.org>
Wed, 20 Apr 2022 11:07:34 +0000 (13:07 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Wed, 20 Apr 2022 11:07:34 +0000 (13:07 +0200)
* lisp/textmodes/bibtex.el (bibtex-map-entries): Ensure forward
progress (bug#55036).

lisp/textmodes/bibtex.el

index d02eca506a865223fd73dd8adc0e8623528aa95b..b2e0b7f9d0972642aeb161eaf7263ab5fbb1d5a8 100644 (file)
@@ -2298,11 +2298,17 @@ is non-nil, FUN is not called for @String entries."
     (set-marker-insertion-type end-marker t)
     (save-excursion
       (goto-char (point-min))
-      (while (setq found (bibtex-skip-to-valid-entry))
-        (set-marker end-marker (cdr found))
-        (looking-at bibtex-any-entry-maybe-empty-head)
-        (funcall fun (bibtex-key-in-head "") (car found) end-marker)
-        (goto-char end-marker)))))
+      (let ((prev (point)))
+        (while (setq found (bibtex-skip-to-valid-entry))
+          ;; If we have invalid entries, ensure that we have forward
+          ;; progress so that we don't infloop.
+          (if (= (point) prev)
+              (forward-line 1)
+            (setq prev (point))
+            (set-marker end-marker (cdr found))
+            (looking-at bibtex-any-entry-maybe-empty-head)
+            (funcall fun (bibtex-key-in-head "") (car found) end-marker)
+            (goto-char end-marker)))))))
 
 (defun bibtex-progress-message (&optional flag interval)
   "Echo a message about progress of current buffer.