emacs-31 d365328e6d9: Fix false positive warnings in 'elisp-flymake-checkdoc' when narrowed

Eli Zaretskii <[email protected]> Tue, 21 Jul 2026 07:23:22 -0400 (EDT)
Newsgroups gmane.emacs.diffs
Message-ID <[email protected]>
branch: emacs-31
commit d365328e6d9992d080e0a564d5811dc5e0a5ce4a
Author: James Cherti <[email protected]>
Commit: Eli Zaretskii <[email protected]>

    Fix false positive warnings in 'elisp-flymake-checkdoc' when narrowed
    
    * lisp/progmodes/elisp-mode.el (elisp-flymake-checkdoc): Temporarily
    widen the buffer before calling 'checkdoc-current-buffer'.  This
    prevents checkdoc from reporting missing file-level structural
    elements when the user has narrowed the buffer.  (Bug#81258)
---
 lisp/progmodes/elisp-mode.el | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el
index be98e03d342..c293789cee3 100644
--- a/lisp/progmodes/elisp-mode.el
+++ b/lisp/progmodes/elisp-mode.el
@@ -2618,11 +2618,12 @@ Calls REPORT-FN directly."
             (generate-new-buffer " *checkdoc-temp*")))
       (unwind-protect
           (save-excursion
-            ;; checkdoc-current-buffer can error if there are
-            ;; unbalanced parens, for example, but this shouldn't
-            ;; disable the backend (bug#29176).
-            (ignore-errors
-              (checkdoc-current-buffer t)))
+            (without-restriction
+              ;; checkdoc-current-buffer can error if there are
+              ;; unbalanced parens, for example, but this shouldn't
+              ;; disable the backend (bug#29176).
+              (ignore-errors
+                (checkdoc-current-buffer t))))
         (kill-buffer checkdoc-diagnostic-buffer)))
     (funcall report-fn
              (cl-loop for (text start end _unfixable) in