GNU bug report logs - #77809
adding next-error support for flymake diagnostics buffers

Previous Next

Package: emacs;

Reported by: matthewktromp <at> gmail.com

Date: Mon, 14 Apr 2025 21:08:02 UTC

Severity: normal

Tags: patch

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 77809 in the body.
You can then email your comments to 77809 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#77809; Package emacs. (Mon, 14 Apr 2025 21:08:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to matthewktromp <at> gmail.com:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 14 Apr 2025 21:08:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: matthewktromp <at> gmail.com
To: bug-gnu-emacs <at> gnu.org
Subject: adding next-error support for flymake diagnostics buffers
Date: Mon, 14 Apr 2025 17:06:21 -0400
[Message part 1 (text/plain, inline)]
Tags: patch

This patch adds next-error support for flymake diagnostics buffers.
Buffers created with `flymake-show-buffer-diagnostics' and
`flymake-show-project-diagnostics' are now next-error enabled, and
`next-error' and `previous-error' will navigate through their listed
diagnostics.

In GNU Emacs 30.1.50 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo
version 1.18.2, Xaw3d scroll bars)
Windowing system distributor 'The X.Org Foundation', version 11.0.12101016
System Description: NixOS 24.11 (Vicuna)

Configured using:
 'configure
 --prefix=/nix/store/yffwm14bwi3vask5wfx6pcrdgxck61ba-emacs-30.1
 --disable-build-details --with-modules --with-x-toolkit=lucid
 --with-cairo --with-xft --with-compress-install
 --with-toolkit-scroll-bars --with-native-compilation
 --without-imagemagick --with-mailutils --without-small-ja-dic
 --with-tree-sitter --with-xinput2 --without-xwidgets --with-dbus
 --with-selinux'

[0001-next-error-support-for-flymake-diagnostics-buffers.patch (text/patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#77809; Package emacs. (Tue, 15 Apr 2025 06:32:02 GMT) Full text and rfc822 format available.

Message #8 received at 77809 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: matthewktromp <at> gmail.com, Spencer Baugh <sbaugh <at> janestreet.com>
Cc: 77809 <at> debbugs.gnu.org
Subject: Re: bug#77809: adding next-error support for flymake diagnostics
 buffers
Date: Tue, 15 Apr 2025 09:30:23 +0300
> From: matthewktromp <at> gmail.com
> Date: Mon, 14 Apr 2025 17:06:21 -0400
> 
> Tags: patch
> 
> This patch adds next-error support for flymake diagnostics buffers.
> Buffers created with `flymake-show-buffer-diagnostics' and
> `flymake-show-project-diagnostics' are now next-error enabled, and
> `next-error' and `previous-error' will navigate through their listed
> diagnostics.

Many buffers which use Flymake already support next-error, don't they?
Won't this conflict with those cases?

Adding Spencer to the discussion.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#77809; Package emacs. (Tue, 15 Apr 2025 15:37:03 GMT) Full text and rfc822 format available.

Message #11 received at 77809 <at> debbugs.gnu.org (full text, mbox):

From: Spencer Baugh <sbaugh <at> janestreet.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 77809 <at> debbugs.gnu.org, matthewktromp <at> gmail.com
Subject: Re: bug#77809: adding next-error support for flymake diagnostics
 buffers
Date: Tue, 15 Apr 2025 11:36:30 -0400
Thank you for this long-awaited contribution!

Eli Zaretskii <eliz <at> gnu.org> writes:
>> From: matthewktromp <at> gmail.com
>> Date: Mon, 14 Apr 2025 17:06:21 -0400
>> 
>> Tags: patch
>> 
>> This patch adds next-error support for flymake diagnostics buffers.
>> Buffers created with `flymake-show-buffer-diagnostics' and
>> `flymake-show-project-diagnostics' are now next-error enabled, and
>> `next-error' and `previous-error' will navigate through their listed
>> diagnostics.
>
> Many buffers which use Flymake already support next-error, don't they?
> Won't this conflict with those cases?

No, I think this is just giving the diagnostic overview buffers a
next-error-function, so that when you use those buffers they will
integrate with next-error.

>> diff --git a/lisp/progmodes/flymake.el b/lisp/progmodes/flymake.el
>> index 6cc7e1f7a79..002e587b029 100644
>> --- a/lisp/progmodes/flymake.el
>> +++ b/lisp/progmodes/flymake.el
>> @@ -1390,6 +1390,10 @@ flymake-mode-map
>>                 (format "<%s> <mouse-1>" flymake-fringe-indicator-position)
>>                 #'flymake-show-buffer-diagnostics-at-event-line)
>>  
>> +(defvar-local flymake-current-diagnostic-line 0
>> +  "The line of the most recently focused diagnostic in the flymake
>> +diagnostics buffer.")
>> +
>>  ;;;###autoload
>>  (define-minor-mode flymake-mode
>>    "Toggle Flymake mode on or off.
>> @@ -1881,7 +1885,8 @@ flymake-pulse-momentary-highlight-region
>>  (defun flymake-show-diagnostic (pos &optional other-window)
>>    "Show location of diagnostic at POS."
>>    (interactive (list (point) t))
>> -  (let* ((id (or (tabulated-list-get-id pos)
>> +  (let* ((diagnostics-buffer (current-buffer))
>> +         (id (or (tabulated-list-get-id pos)
>>                   (user-error "Nothing at point")))
>>           (diag (plist-get id :diagnostic))
>>           (locus (flymake--diag-locus diag))
>> @@ -1890,6 +1895,7 @@ flymake-show-diagnostic
>>           (visit (lambda (b e)
>>                    (goto-char b)
>>                    (flymake-pulse-momentary-highlight-region b e))))
>> +    (setq flymake-current-diagnostic-line (line-number-at-pos pos))
>>      (with-current-buffer (cond ((bufferp locus) locus)
>>                                 (t (find-file-noselect locus)))
>>        (with-selected-window
>> @@ -1905,6 +1911,8 @@ flymake-show-diagnostic
>>                                                   (car beg)
>>                                                   (cdr beg))))
>>                   (funcall visit bbeg bend)))))
>> +      (setq next-error-buffer diagnostics-buffer
>> +            next-error-last-buffer diagnostics-buffer)

Setting next-error-last-buffer makes sense and matches other buffers
which set next-error-function (e.g. xref-goto-xref), but do we need to
set next-error-buffer?  It seems like setting that is managed by
next-error itself.

>>        (current-buffer))))
>>  
>>  (defun flymake-goto-diagnostic (pos)
>> @@ -2008,6 +2016,23 @@ flymake--diagnostics-base-tabulated-list-format
>>      ("Backend" 8 t)
>>      ("Message" 0 t)])
>>  
>> +(defun flymake--diagnostics-next-error (n &optional reset)
>> +  "`next-error-function' for flymake diagnostics buffers.
>> +N is an integer representing how many errors to move.
>> +If RESET is non-nil, returns to the beginning of the errors before
>> +moving."
>> +  (let ((line (if reset 1 flymake-current-diagnostic-line))
>> +        (total-lines (count-lines (point-min) (point-max))))
>> +    (goto-char (point-min))
>> +    (unless (zerop total-lines)
>> +      (let ((target-line (+ line n)))
>> +        (setq target-line (max 1 target-line))
>> +        (setq target-line (min target-line total-lines))
>> +        (forward-line (1- target-line))))
>> +    (when-let ((win (get-buffer-window nil t)))
>> +      (set-window-point win (point)))
>> +    (flymake-goto-diagnostic (point))))
>> +
>>  (define-derived-mode flymake-diagnostics-buffer-mode tabulated-list-mode
>>    "Flymake diagnostics"
>>    "A mode for listing Flymake diagnostics."
>> @@ -2015,6 +2040,9 @@ flymake-diagnostics-buffer-mode
>>    (setq tabulated-list-format flymake--diagnostics-base-tabulated-list-format)
>>    (setq tabulated-list-entries
>>          'flymake--diagnostics-buffer-entries)
>> +
>> +  (setq-local next-error-function #'flymake--diagnostics-next-error)
>> +

This should be set in the major mode initialization (the body of the
define-derived-mode).

>>    (tabulated-list-init-header))
>>  
>>  (defun flymake--diagnostics-buffer-name ()
>> @@ -2036,6 +2064,7 @@ flymake-show-buffer-diagnostics
>>                         (current-buffer)))))
>>      (with-current-buffer target
>>        (setq flymake--diagnostics-buffer-source source)
>> +      (setq next-error-last-buffer (current-buffer))
>>        (revert-buffer)
>>        (display-buffer (current-buffer)
>>                        `((display-buffer-reuse-window
>> @@ -2085,6 +2114,9 @@ flymake-project-diagnostics-mode
>>    (setq tabulated-list-format
>>          (vconcat [("File" 25 t)]
>>                   flymake--diagnostics-base-tabulated-list-format))
>> +
>> +  (setq-local next-error-function #'flymake--diagnostics-next-error)
>> +

Likewise, this should be set in the major mode initialization (the body
of the define-derived-mode).

>>    (setq tabulated-list-entries
>>          'flymake--project-diagnostics-entries)
>>    (tabulated-list-init-header))
>> @@ -2149,6 +2181,7 @@ flymake-show-project-diagnostics
>>      (with-current-buffer buffer
>>        (flymake-project-diagnostics-mode)
>>        (setq-local flymake--project-diagnostic-list-project prj)
>> +      (setq next-error-last-buffer (current-buffer))
>>        (revert-buffer)
>>        (display-buffer (current-buffer)
>>                        `((display-buffer-reuse-window
>> 




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#77809; Package emacs. (Tue, 15 Apr 2025 22:05:06 GMT) Full text and rfc822 format available.

Message #14 received at 77809 <at> debbugs.gnu.org (full text, mbox):

From: matthewktromp <at> gmail.com
To: Spencer Baugh <sbaugh <at> janestreet.com>
Cc: 77809 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>
Subject: Re: bug#77809: adding next-error support for flymake diagnostics
 buffers
Date: Tue, 15 Apr 2025 18:02:45 -0400
[Message part 1 (text/plain, inline)]
Spencer Baugh <sbaugh <at> janestreet.com> writes:
>>>                   (funcall visit bbeg bend)))))
>>> +      (setq next-error-buffer diagnostics-buffer
>>> +            next-error-last-buffer diagnostics-buffer)
>
> Setting next-error-last-buffer makes sense and matches other buffers
> which set next-error-function (e.g. xref-goto-xref), but do we need to
> set next-error-buffer?  It seems like setting that is managed by
> next-error itself.

I think you're right.  That should be removed.

>>>  (define-derived-mode flymake-diagnostics-buffer-mode tabulated-list-mode
>>>    "Flymake diagnostics"
>>>    "A mode for listing Flymake diagnostics."
>>> @@ -2015,6 +2040,9 @@ flymake-diagnostics-buffer-mode
>>>    (setq tabulated-list-format flymake--diagnostics-base-tabulated-list-format)
>>>    (setq tabulated-list-entries
>>>          'flymake--diagnostics-buffer-entries)
>>> +
>>> +  (setq-local next-error-function #'flymake--diagnostics-next-error)
>>> +
>
> This should be set in the major mode initialization (the body of the
> define-derived-mode).

It is set in the body of the define-derived-mode.

>>> @@ -2085,6 +2114,9 @@ flymake-project-diagnostics-mode
>>>    (setq tabulated-list-format
>>>          (vconcat [("File" 25 t)]
>>>                   flymake--diagnostics-base-tabulated-list-format))
>>> +
>>> +  (setq-local next-error-function #'flymake--diagnostics-next-error)
>>> +
>
> Likewise, this should be set in the major mode initialization (the body
> of the define-derived-mode).

Ditto here.

See this patch for changes:
[0001-next-error-support-for-flymake-diagnostics-buffers.patch (text/x-patch, inline)]
diff --git a/lisp/progmodes/flymake.el b/lisp/progmodes/flymake.el
index 6cc7e1f7a79..8d478f3489a 100644
--- a/lisp/progmodes/flymake.el
+++ b/lisp/progmodes/flymake.el
@@ -1390,6 +1390,10 @@ flymake-mode-map
                (format "<%s> <mouse-1>" flymake-fringe-indicator-position)
                #'flymake-show-buffer-diagnostics-at-event-line)
 
+(defvar-local flymake-current-diagnostic-line 0
+  "The line of the most recently focused diagnostic in the flymake
+diagnostics buffer.")
+
 ;;;###autoload
 (define-minor-mode flymake-mode
   "Toggle Flymake mode on or off.
@@ -1881,7 +1885,8 @@ flymake-pulse-momentary-highlight-region
 (defun flymake-show-diagnostic (pos &optional other-window)
   "Show location of diagnostic at POS."
   (interactive (list (point) t))
-  (let* ((id (or (tabulated-list-get-id pos)
+  (let* ((diagnostics-buffer (current-buffer))
+         (id (or (tabulated-list-get-id pos)
                  (user-error "Nothing at point")))
          (diag (plist-get id :diagnostic))
          (locus (flymake--diag-locus diag))
@@ -1890,6 +1895,7 @@ flymake-show-diagnostic
          (visit (lambda (b e)
                   (goto-char b)
                   (flymake-pulse-momentary-highlight-region b e))))
+    (setq flymake-current-diagnostic-line (line-number-at-pos pos))
     (with-current-buffer (cond ((bufferp locus) locus)
                                (t (find-file-noselect locus)))
       (with-selected-window
@@ -1905,6 +1911,8 @@ flymake-show-diagnostic
                                                  (car beg)
                                                  (cdr beg))))
                  (funcall visit bbeg bend)))))
+      ;; Emacs < 27
+      (setq next-error-last-buffer diagnostics-buffer)
       (current-buffer))))
 
 (defun flymake-goto-diagnostic (pos)
@@ -2008,6 +2016,23 @@ flymake--diagnostics-base-tabulated-list-format
     ("Backend" 8 t)
     ("Message" 0 t)])
 
+(defun flymake--diagnostics-next-error (n &optional reset)
+  "`next-error-function' for flymake diagnostics buffers.
+N is an integer representing how many errors to move.
+If RESET is non-nil, returns to the beginning of the errors before
+moving."
+  (let ((line (if reset 1 flymake-current-diagnostic-line))
+        (total-lines (count-lines (point-min) (point-max))))
+    (goto-char (point-min))
+    (unless (zerop total-lines)
+      (let ((target-line (+ line n)))
+        (setq target-line (max 1 target-line))
+        (setq target-line (min target-line total-lines))
+        (forward-line (1- target-line))))
+    (when-let ((win (get-buffer-window nil t)))
+      (set-window-point win (point)))
+    (flymake-goto-diagnostic (point))))
+
 (define-derived-mode flymake-diagnostics-buffer-mode tabulated-list-mode
   "Flymake diagnostics"
   "A mode for listing Flymake diagnostics."
@@ -2015,6 +2040,9 @@ flymake-diagnostics-buffer-mode
   (setq tabulated-list-format flymake--diagnostics-base-tabulated-list-format)
   (setq tabulated-list-entries
         'flymake--diagnostics-buffer-entries)
+
+  (setq-local next-error-function #'flymake--diagnostics-next-error)
+
   (tabulated-list-init-header))
 
 (defun flymake--diagnostics-buffer-name ()
@@ -2036,6 +2064,7 @@ flymake-show-buffer-diagnostics
                        (current-buffer)))))
     (with-current-buffer target
       (setq flymake--diagnostics-buffer-source source)
+      (setq next-error-last-buffer (current-buffer))
       (revert-buffer)
       (display-buffer (current-buffer)
                       `((display-buffer-reuse-window
@@ -2085,6 +2114,9 @@ flymake-project-diagnostics-mode
   (setq tabulated-list-format
         (vconcat [("File" 25 t)]
                  flymake--diagnostics-base-tabulated-list-format))
+
+  (setq-local next-error-function #'flymake--diagnostics-next-error)
+
   (setq tabulated-list-entries
         'flymake--project-diagnostics-entries)
   (tabulated-list-init-header))
@@ -2149,6 +2181,7 @@ flymake-show-project-diagnostics
     (with-current-buffer buffer
       (flymake-project-diagnostics-mode)
       (setq-local flymake--project-diagnostic-list-project prj)
+      (setq next-error-last-buffer (current-buffer))
       (revert-buffer)
       (display-buffer (current-buffer)
                       `((display-buffer-reuse-window

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#77809; Package emacs. (Wed, 16 Apr 2025 17:43:08 GMT) Full text and rfc822 format available.

Message #17 received at 77809 <at> debbugs.gnu.org (full text, mbox):

From: Spencer Baugh <sbaugh <at> janestreet.com>
To: matthewktromp <at> gmail.com
Cc: 77809 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>
Subject: Re: bug#77809: adding next-error support for flymake diagnostics
 buffers
Date: Wed, 16 Apr 2025 13:42:21 -0400
matthewktromp <at> gmail.com writes:

> Spencer Baugh <sbaugh <at> janestreet.com> writes:
>>>>                   (funcall visit bbeg bend)))))
>>>> +      (setq next-error-buffer diagnostics-buffer
>>>> +            next-error-last-buffer diagnostics-buffer)
>>
>> Setting next-error-last-buffer makes sense and matches other buffers
>> which set next-error-function (e.g. xref-goto-xref), but do we need to
>> set next-error-buffer?  It seems like setting that is managed by
>> next-error itself.
>
> I think you're right.  That should be removed.

OK, make sure to include that in the next version of the patch, if one
is needed.

>>>>  (define-derived-mode flymake-diagnostics-buffer-mode tabulated-list-mode
>>>>    "Flymake diagnostics"
>>>>    "A mode for listing Flymake diagnostics."
>>>> @@ -2015,6 +2040,9 @@ flymake-diagnostics-buffer-mode
>>>>    (setq tabulated-list-format flymake--diagnostics-base-tabulated-list-format)
>>>>    (setq tabulated-list-entries
>>>>          'flymake--diagnostics-buffer-entries)
>>>> +
>>>> +  (setq-local next-error-function #'flymake--diagnostics-next-error)
>>>> +
>>
>> This should be set in the major mode initialization (the body of the
>> define-derived-mode).
>
> It is set in the body of the define-derived-mode.
>
>>>> @@ -2085,6 +2114,9 @@ flymake-project-diagnostics-mode
>>>>    (setq tabulated-list-format
>>>>          (vconcat [("File" 25 t)]
>>>>                   flymake--diagnostics-base-tabulated-list-format))
>>>> +
>>>> +  (setq-local next-error-function #'flymake--diagnostics-next-error)
>>>> +
>>
>> Likewise, this should be set in the major mode initialization (the body
>> of the define-derived-mode).

Oh, my mistake, sorry.

This looks good to me then, seems to work fine.  Let's wait a few more
days for comments and then I think this can be installed.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#77809; Package emacs. (Tue, 22 Apr 2025 19:38:02 GMT) Full text and rfc822 format available.

Message #20 received at 77809 <at> debbugs.gnu.org (full text, mbox):

From: Spencer Baugh <sbaugh <at> janestreet.com>
To: matthewktromp <at> gmail.com
Cc: 77809 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>
Subject: Re: bug#77809: adding next-error support for flymake diagnostics
 buffers
Date: Tue, 22 Apr 2025 15:37:49 -0400
[Message part 1 (text/plain, inline)]
Spencer Baugh <sbaugh <at> janestreet.com> writes:
> This looks good to me then, seems to work fine.  Let's wait a few more
> days for comments and then I think this can be installed.

I think this is ready to be installed.  I went ahead and updated your
commit message to include a changelog entry - please include that in
future changes, see "Generating ChangeLog entries" in CONTRIBUTE.

Eli, can you please install the attached change?

[0001-Add-next-error-support-for-flymake-diagnostics-buffe.patch (text/x-patch, inline)]
From cdfac45643803685b60c09d0f45b7d6e2f8f4289 Mon Sep 17 00:00:00 2001
From: Matthew Tromp <matthewktromp <at> gmail.com>
Date: Tue, 22 Apr 2025 15:27:58 -0400
Subject: [PATCH] Add next-error support for flymake diagnostics buffers

This patch adds next-error support for flymake diagnostics buffers.
Buffers created with `flymake-show-buffer-diagnostics' and
`flymake-show-project-diagnostics' are now next-error enabled, and
`next-error' and `previous-error' will navigate through their listed
diagnostics.

* lisp/progmodes/flymake.el (flymake-current-diagnostic-line)
(flymake--diagnostics-next-error): Add.
(flymake-show-diagnostic, flymake-show-buffer-diagnostics)
(flymake-show-project-diagnostics): Set next-error-last-buffer.
(flymake--tabulated-setup): Set next-error-function. (bug#77809)
---
 lisp/progmodes/flymake.el | 30 +++++++++++++++++++++++++++++-
 1 file changed, 29 insertions(+), 1 deletion(-)

diff --git a/lisp/progmodes/flymake.el b/lisp/progmodes/flymake.el
index 8d63b23f2b8..3e2c24339a8 100644
--- a/lisp/progmodes/flymake.el
+++ b/lisp/progmodes/flymake.el
@@ -1457,6 +1457,10 @@ flymake-mode-map
     map)
   "Keymap for `flymake-mode'")
 
+(defvar-local flymake-current-diagnostic-line 0
+  "The line of the most recently focused diagnostic in the flymake
+diagnostics buffer.")
+
 ;;;###autoload
 (define-minor-mode flymake-mode
   "Toggle Flymake mode on or off.
@@ -1917,7 +1921,8 @@ flymake-diagnostics-buffer-mode-map
 (defun flymake-show-diagnostic (pos &optional other-window)
   "From Flymake diagnostics buffer, show source of diagnostic at POS."
   (interactive (list (point) t))
-  (let* ((id (or (tabulated-list-get-id pos)
+  (let* ((diagnostics-buffer (current-buffer))
+         (id (or (tabulated-list-get-id pos)
                  (user-error "Nothing at point")))
          (diag (plist-get id :diagnostic))
          (locus (flymake--diag-locus diag))
@@ -1927,6 +1932,7 @@ flymake-show-diagnostic
                   (goto-char b)
                   (pulse-momentary-highlight-region
                    b (or e (line-end-position))))))
+    (setq flymake-current-diagnostic-line (line-number-at-pos pos))
     (with-current-buffer (cond ((bufferp locus) locus)
                                (t (find-file-noselect locus)))
       (with-selected-window
@@ -1942,6 +1948,8 @@ flymake-show-diagnostic
                                                  (car beg)
                                                  (cdr beg))))
                  (funcall visit bbeg bend)))))
+      ;; Emacs < 27
+      (setq next-error-last-buffer diagnostics-buffer)
       (current-buffer))))
 
 (defun flymake-goto-diagnostic (pos)
@@ -2055,6 +2063,7 @@ flymake--tabulated-setup-1
 (defun flymake--tabulated-setup (use-project)
   "Helper for `flymake-diagnostics-buffer-mode'.
 And also `flymake-project-diagnostics-mode'."
+  (setq-local next-error-function #'flymake--diagnostics-next-error)
   (let ((saved-r-b-f revert-buffer-function)
         (refresh
          (lambda ()
@@ -2084,6 +2093,23 @@ flymake--tabulated-setup
             (funcall refresh)
             (apply saved-r-b-f args)))))
 
+(defun flymake--diagnostics-next-error (n &optional reset)
+  "`next-error-function' for flymake diagnostics buffers.
+N is an integer representing how many errors to move.
+If RESET is non-nil, returns to the beginning of the errors before
+moving."
+  (let ((line (if reset 1 flymake-current-diagnostic-line))
+        (total-lines (count-lines (point-min) (point-max))))
+    (goto-char (point-min))
+    (unless (zerop total-lines)
+      (let ((target-line (+ line n)))
+        (setq target-line (max 1 target-line))
+        (setq target-line (min target-line total-lines))
+        (forward-line (1- target-line))))
+    (when-let ((win (get-buffer-window nil t)))
+      (set-window-point win (point)))
+    (flymake-goto-diagnostic (point))))
+
 (define-derived-mode flymake-diagnostics-buffer-mode tabulated-list-mode
   "Flymake diagnostics"
   "A mode for listing Flymake diagnostics."
@@ -2140,6 +2166,7 @@ flymake-show-buffer-diagnostics
          window)
     (with-current-buffer target
       (setq flymake--diagnostics-buffer-source source)
+      (setq next-error-last-buffer (current-buffer))
       (revert-buffer)
       (setq window
             (display-buffer (current-buffer)
@@ -2246,6 +2273,7 @@ flymake-show-project-diagnostics
     (with-current-buffer buffer
       (flymake-project-diagnostics-mode)
       (setq-local flymake--project-diagnostic-list-project prj)
+      (setq next-error-last-buffer (current-buffer))
       (revert-buffer)
       (display-buffer (current-buffer)
                       `((display-buffer-reuse-window
-- 
2.39.3


Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#77809; Package emacs. (Wed, 23 Apr 2025 11:47:04 GMT) Full text and rfc822 format available.

Message #23 received at 77809 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Spencer Baugh <sbaugh <at> janestreet.com>
Cc: 77809 <at> debbugs.gnu.org, matthewktromp <at> gmail.com
Subject: Re: bug#77809: adding next-error support for flymake diagnostics
 buffers
Date: Wed, 23 Apr 2025 14:46:37 +0300
> From: Spencer Baugh <sbaugh <at> janestreet.com>
> Cc: 77809 <at> debbugs.gnu.org,  Eli Zaretskii <eliz <at> gnu.org>
> Date: Tue, 22 Apr 2025 15:37:49 -0400
> 
> I think this is ready to be installed.  I went ahead and updated your
> commit message to include a changelog entry - please include that in
> future changes, see "Generating ChangeLog entries" in CONTRIBUTE.
> 
> Eli, can you please install the attached change?

See below.

> +(defvar-local flymake-current-diagnostic-line 0
> +  "The line of the most recently focused diagnostic in the flymake
> +diagnostics buffer.")

The first line of a doc string should be a single complete sentence.

> +(defun flymake--diagnostics-next-error (n &optional reset)
> +  "`next-error-function' for flymake diagnostics buffers.
> +N is an integer representing how many errors to move.
> +If RESET is non-nil, returns to the beginning of the errors before
                        ^^^^^^^
"return"

Thanks.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#77809; Package emacs. (Fri, 25 Apr 2025 17:45:02 GMT) Full text and rfc822 format available.

Message #26 received at 77809 <at> debbugs.gnu.org (full text, mbox):

From: Matthew Tromp <matthewktromp <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 77809 <at> debbugs.gnu.org, Spencer Baugh <sbaugh <at> janestreet.com>
Subject: Re: bug#77809: adding next-error support for flymake diagnostics
 buffers
Date: Fri, 25 Apr 2025 13:43:57 -0400
[Message part 1 (text/plain, inline)]
Here you go

On Wed, Apr 23, 2025 at 7:46 AM Eli Zaretskii <eliz <at> gnu.org> wrote:
>
> > From: Spencer Baugh <sbaugh <at> janestreet.com>
> > Cc: 77809 <at> debbugs.gnu.org,  Eli Zaretskii <eliz <at> gnu.org>
> > Date: Tue, 22 Apr 2025 15:37:49 -0400
> >
> > I think this is ready to be installed.  I went ahead and updated your
> > commit message to include a changelog entry - please include that in
> > future changes, see "Generating ChangeLog entries" in CONTRIBUTE.
> >
> > Eli, can you please install the attached change?
>
> See below.
>
> > +(defvar-local flymake-current-diagnostic-line 0
> > +  "The line of the most recently focused diagnostic in the flymake
> > +diagnostics buffer.")
>
> The first line of a doc string should be a single complete sentence.
>
> > +(defun flymake--diagnostics-next-error (n &optional reset)
> > +  "`next-error-function' for flymake diagnostics buffers.
> > +N is an integer representing how many errors to move.
> > +If RESET is non-nil, returns to the beginning of the errors before
>                         ^^^^^^^
> "return"
>
> Thanks.
[0001-Add-next-error-support-for-flymake-diagnostics-buffe.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#77809; Package emacs. (Sun, 27 Apr 2025 07:41:02 GMT) Full text and rfc822 format available.

Message #29 received at 77809 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Matthew Tromp <matthewktromp <at> gmail.com>
Cc: 77809 <at> debbugs.gnu.org, sbaugh <at> janestreet.com
Subject: Re: bug#77809: adding next-error support for flymake diagnostics
 buffers
Date: Sun, 27 Apr 2025 10:40:19 +0300
> From: Matthew Tromp <matthewktromp <at> gmail.com>
> Date: Fri, 25 Apr 2025 13:43:57 -0400
> Cc: Spencer Baugh <sbaugh <at> janestreet.com>, 77809 <at> debbugs.gnu.org
> 
> Here you go
> 
> On Wed, Apr 23, 2025 at 7:46 AM Eli Zaretskii <eliz <at> gnu.org> wrote:
> >
> > > From: Spencer Baugh <sbaugh <at> janestreet.com>
> > > Cc: 77809 <at> debbugs.gnu.org,  Eli Zaretskii <eliz <at> gnu.org>
> > > Date: Tue, 22 Apr 2025 15:37:49 -0400
> > >
> > > I think this is ready to be installed.  I went ahead and updated your
> > > commit message to include a changelog entry - please include that in
> > > future changes, see "Generating ChangeLog entries" in CONTRIBUTE.
> > >
> > > Eli, can you please install the attached change?
> >
> > See below.
> >
> > > +(defvar-local flymake-current-diagnostic-line 0
> > > +  "The line of the most recently focused diagnostic in the flymake
> > > +diagnostics buffer.")
> >
> > The first line of a doc string should be a single complete sentence.
> >
> > > +(defun flymake--diagnostics-next-error (n &optional reset)
> > > +  "`next-error-function' for flymake diagnostics buffers.
> > > +N is an integer representing how many errors to move.
> > > +If RESET is non-nil, returns to the beginning of the errors before
> >                         ^^^^^^^
> > "return"
> >
> > Thanks.

Thanks.  Byte-compiling the modified flymake.el produces this warning:

    ELC      progmodes/flymake.elc

  In flymake--diagnostics-next-error:
  progmodes/flymake.el:2111:6: Warning: `when-let' is an obsolete macro (as of 31.1); use `when-let*' or `and-let*' instead.

Could you please fix the code to avoid this warning?

Also, you don't seem to have copyright assignment on file.  So we can
accept this contribution from you, but any further contributions will
require that you do the paperwork of assigning the copyright to the
FSF.  If you agree, I will send you the form to fill and the
instructions to go with them, so you could get your legal paperwork
rolling.

Thanks.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#77809; Package emacs. (Sun, 27 Apr 2025 15:25:02 GMT) Full text and rfc822 format available.

Message #32 received at 77809 <at> debbugs.gnu.org (full text, mbox):

From: Matthew Tromp <matthewktromp <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 77809 <at> debbugs.gnu.org, sbaugh <at> janestreet.com
Subject: Re: bug#77809: adding next-error support for flymake diagnostics
 buffers
Date: Sun, 27 Apr 2025 11:23:40 -0400
[Message part 1 (text/plain, inline)]
Okay, here you go.

Yes, please send me the copyright assignment paperwork.

On Sun, Apr 27, 2025 at 3:40 AM Eli Zaretskii <eliz <at> gnu.org> wrote:
>
> > From: Matthew Tromp <matthewktromp <at> gmail.com>
> > Date: Fri, 25 Apr 2025 13:43:57 -0400
> > Cc: Spencer Baugh <sbaugh <at> janestreet.com>, 77809 <at> debbugs.gnu.org
> >
> > Here you go
> >
> > On Wed, Apr 23, 2025 at 7:46 AM Eli Zaretskii <eliz <at> gnu.org> wrote:
> > >
> > > > From: Spencer Baugh <sbaugh <at> janestreet.com>
> > > > Cc: 77809 <at> debbugs.gnu.org,  Eli Zaretskii <eliz <at> gnu.org>
> > > > Date: Tue, 22 Apr 2025 15:37:49 -0400
> > > >
> > > > I think this is ready to be installed.  I went ahead and updated your
> > > > commit message to include a changelog entry - please include that in
> > > > future changes, see "Generating ChangeLog entries" in CONTRIBUTE.
> > > >
> > > > Eli, can you please install the attached change?
> > >
> > > See below.
> > >
> > > > +(defvar-local flymake-current-diagnostic-line 0
> > > > +  "The line of the most recently focused diagnostic in the flymake
> > > > +diagnostics buffer.")
> > >
> > > The first line of a doc string should be a single complete sentence.
> > >
> > > > +(defun flymake--diagnostics-next-error (n &optional reset)
> > > > +  "`next-error-function' for flymake diagnostics buffers.
> > > > +N is an integer representing how many errors to move.
> > > > +If RESET is non-nil, returns to the beginning of the errors before
> > >                         ^^^^^^^
> > > "return"
> > >
> > > Thanks.
>
> Thanks.  Byte-compiling the modified flymake.el produces this warning:
>
>     ELC      progmodes/flymake.elc
>
>   In flymake--diagnostics-next-error:
>   progmodes/flymake.el:2111:6: Warning: `when-let' is an obsolete macro (as of 31.1); use `when-let*' or `and-let*' instead.
>
> Could you please fix the code to avoid this warning?
>
> Also, you don't seem to have copyright assignment on file.  So we can
> accept this contribution from you, but any further contributions will
> require that you do the paperwork of assigning the copyright to the
> FSF.  If you agree, I will send you the form to fill and the
> instructions to go with them, so you could get your legal paperwork
> rolling.
>
> Thanks.
[0001-Add-next-error-support-for-flymake-diagnostics-buffe.patch (text/x-patch, attachment)]

Reply sent to Eli Zaretskii <eliz <at> gnu.org>:
You have taken responsibility. (Sat, 03 May 2025 08:54:01 GMT) Full text and rfc822 format available.

Notification sent to matthewktromp <at> gmail.com:
bug acknowledged by developer. (Sat, 03 May 2025 08:54:02 GMT) Full text and rfc822 format available.

Message #37 received at 77809-done <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Matthew Tromp <matthewktromp <at> gmail.com>
Cc: 77809-done <at> debbugs.gnu.org, sbaugh <at> janestreet.com
Subject: Re: bug#77809: adding next-error support for flymake diagnostics
 buffers
Date: Sat, 03 May 2025 11:53:01 +0300
> From: Matthew Tromp <matthewktromp <at> gmail.com>
> Date: Sun, 27 Apr 2025 11:23:40 -0400
> Cc: sbaugh <at> janestreet.com, 77809 <at> debbugs.gnu.org
> 
> Okay, here you go.

Thanks, installed on the master branch, and closing the bug.

> Yes, please send me the copyright assignment paperwork.

Form sent off-list.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 31 May 2025 11:24:08 GMT) Full text and rfc822 format available.

This bug report was last modified 14 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.