From: Lars Ingebrigtsen Date: Wed, 20 Apr 2022 11:07:34 +0000 (+0200) Subject: Ensure forward progress in bibtex-map-entries X-Git-Tag: emacs-29.0.90~1931^2~388 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=c32e8b33f4fdd17856e5f7ae8e7e7c6d3b473342;p=emacs.git Ensure forward progress in bibtex-map-entries * lisp/textmodes/bibtex.el (bibtex-map-entries): Ensure forward progress (bug#55036). --- diff --git a/lisp/textmodes/bibtex.el b/lisp/textmodes/bibtex.el index d02eca506a8..b2e0b7f9d09 100644 --- a/lisp/textmodes/bibtex.el +++ b/lisp/textmodes/bibtex.el @@ -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.