Subject: bug#70816: 29.2; Flymake fails in latex-mode when the buffer is narrowed

From: Spencer Baugh <[email-masked]>
Date: Sat, 18 May 2024 10:51:35 -0400

Can you test with the following patch, please?

diff --git a/lisp/progmodes/flymake.el b/lisp/progmodes/flymake.el
index ef190ff0cb5..146aae06253 100644
--- a/lisp/progmodes/flymake.el
+++ b/lisp/progmodes/flymake.el
@@ -430,6 +430,8 @@ flymake-diag-region
         (let ((line (min (max line 1)
                          (line-number-at-pos (point-max) 'absolute))))
           (save-excursion
+            (save-restriction
+              (widen)
             (save-match-data
               (goto-char (point-min))
               (forward-line (1- line))
@@ -463,7 +465,7 @@ flymake-diag-region
                               (fallback-eol beg))))
                   (let* ((beg (fallback-bol))
                          (end (fallback-eol beg)))
-                    (cons beg end))))))))
+                    (cons beg end)))))))))
     (error (flymake-log :warning "Invalid region line=%s col=%s" line col)
            nil)))