Hi Bram,

[email protected] writes:

> Thanks for the follow-up, I've attached a minimal latex example that contains:
> - an ignored warning (about a package's options)
> - a non-ignored warning (missing citation label)
>
> After compiling, the infinite loop is triggered when invoking
> `TeX-previous-error' after invoking `TeX-next-error'.

many thanks for your response, and my apologies for my late reaction.  I
can reproduce the behavior you describe.  I would install the change
attached under your name.  Please let me know if it's Ok for you and I
will push it.

Again, thanks and sorry for being late.

Best, Arash
>From ba018eacac098c4ae01b092ca0e5817c228bb7b1 Mon Sep 17 00:00:00 2001
From: Bram Adams <[email protected]>
Date: Sun, 30 Nov 2025 17:13:36 +0100
Subject: [PATCH] Fix infinite loop with `TeX-previous-error'

* tex.el (TeX-parse-TeX): Fix behavior of `TeX-previous-error'
when `TeX-debug-warnings' and `TeX-suppress-ignored-warnings' are
enabled.  (Bug#79037)

Copyright-paperwork-exempt: yes
---
 tex.el | 27 ++++++++++++++++-----------
 1 file changed, 16 insertions(+), 11 deletions(-)

diff --git a/tex.el b/tex.el
index 286e33c2..d7bb9c28 100644
--- a/tex.el
+++ b/tex.el
@@ -9524,21 +9524,26 @@ already in an Emacs buffer) and the cursor is placed at the error."
             ;; warnings.
             (while (null (zerop arg))
               (setq TeX-error-last-visited
-                    ;; Increase or decrese `TeX-error-last-visited' depending on
-                    ;; the sign of `arg'.  Note: `signum' is a function from
-                    ;; `cl' library, do not be tempted to use it.
+                    ;; Increase or decrese `TeX-error-last-visited'
+                    ;; depending on the sign of `arg'.  Note: `signum'
+                    ;; is a function from `cl' library, do not be
+                    ;; tempted to use it.
                     (if (> arg 0)
                         (1+ TeX-error-last-visited)
                       (1- TeX-error-last-visited))
                     item (nth TeX-error-last-visited TeX-error-list))
-              ;; Increase or decrease `arg' only if the warning isn't to be
-              ;; skipped.
-              (unless (TeX-error-list-skip-warning-p (nth 0 item) (nth 10 item))
-                ;; Note: `signum' is a function from `cl' library, do not be
-                ;; tempted to use it.
-                (setq arg (if (> arg 0)
-                              (1- arg)
-                            (1+ arg)))))
+              ;; Increase or decrease `arg' only if the warning isn't to
+              ;; be skipped, or `TeX-error-last-visited' has dropped
+              ;; below 0 with a negative `arg'.
+              (if (or (and (< arg 0)
+                           (< TeX-error-last-visited 0))
+                      (not (TeX-error-list-skip-warning-p (nth 0 item)
+                                                          (nth 10 item))))
+                  ;; Note: `signum' is a function from `cl' library, do
+                  ;; not be tempted to use it.
+                  (setq arg (if (> arg 0)
+                                (1- arg)
+                              (1+ arg)))))
             (if (< TeX-error-last-visited -1)
                 (setq TeX-error-last-visited -1))
             (cond ((or (null item)
-- 
2.52.0

_______________________________________________
bug-auctex mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/bug-auctex

Reply via email to