diff options
| author | Matthew Tromp | 2025-05-19 15:45:21 -0400 |
|---|---|---|
| committer | Eli Zaretskii | 2025-05-31 17:23:08 +0300 |
| commit | 9d6a4fdd7e4e82ea804a83f428e395ffbbc3e8dd (patch) | |
| tree | c54a8f0b2601637a73463cc2269759bd2b7ab940 | |
| parent | b247b1e0b16a5133ce11c92a110240f4c0217b06 (diff) | |
| download | emacs-9d6a4fdd7e4e82ea804a83f428e395ffbbc3e8dd.tar.gz emacs-9d6a4fdd7e4e82ea804a83f428e395ffbbc3e8dd.zip | |
Add additional keybindings for flymake diagnostics modes
This adds keybindings for C-o and C-m, and changes the bindings
for n and m, in `flymake-diagnostics-buffer-mode' and
`flymake-project-diagnostics-mode' buffers.
Previously, `flymake-project-diagnostics-mode' did not use the
keybindings for `flymake-diagnostics-buffer-mode'. RET and SPC
were never bound in `flymake-project-diagnostics-mode' buffers.
This seems to have been an oversight: since the filename and
message are buttons which call `flymake-goto-diagnostic',
pressing RET still brought users to the diagnostic at point
most of the time. This change adds a
`flymake-project-diagnostics-mode-map' which inherits from
`flymake-diagnostics-buffer-mode-map'.
C-o and C-m now show and jump to the diagnostic currently at point,
similar to how `compilation-mode' works.
n and p now show the diagnostic newly under point after moving up or
down a line, which is also intended to make behavior more similar to
`compilation-mode'.
In order that other next-error buffers do not interfere with
navigation in the diagnostics buffers, this change introduces and
uses new functions, `next-error-this-buffer-no-select' and
`previous-error-this-buffer-no-select'. If we instead used
`next-error-no-select' and `previous-error-no-select', then a user
who runs `flymake-show-diagnostics-buffer', then e.g. `compile',
then returns to the diagnostics buffer and presses 'n', would be
navigated to the next error in the compilation buffer.
* lisp/progmodes/flymake.el (flymake-diagnostics-buffer-mode-map): Add
bindings.
(flymake-project-diagnostics-mode-map): Inherit bindings from
`flymake-diagnostics-buffer-mode'
* lisp/simple.el (next-error-this-buffer-no-select):
(previous-error-this-buffer-no-select): Add new commands.
(Bug#78619)
Copyright-paperwork-exempt: yes
| -rw-r--r-- | lisp/progmodes/flymake.el | 9 | ||||
| -rw-r--r-- | lisp/simple.el | 20 |
2 files changed, 29 insertions, 0 deletions
diff --git a/lisp/progmodes/flymake.el b/lisp/progmodes/flymake.el index 8a072b94a17..e911faf603d 100644 --- a/lisp/progmodes/flymake.el +++ b/lisp/progmodes/flymake.el | |||
| @@ -1891,6 +1891,10 @@ TYPE is usually keyword `:error', `:warning' or `:note'." | |||
| 1891 | (let ((map (make-sparse-keymap))) | 1891 | (let ((map (make-sparse-keymap))) |
| 1892 | (define-key map (kbd "RET") 'flymake-goto-diagnostic) | 1892 | (define-key map (kbd "RET") 'flymake-goto-diagnostic) |
| 1893 | (define-key map (kbd "SPC") 'flymake-show-diagnostic) | 1893 | (define-key map (kbd "SPC") 'flymake-show-diagnostic) |
| 1894 | (keymap-set map "C-o" #'flymake-show-diagnostic) | ||
| 1895 | (keymap-set map "C-m" #'flymake-goto-diagnostic) | ||
| 1896 | (keymap-set map "n" #'next-error-this-buffer-no-select) | ||
| 1897 | (keymap-set map "p" #'previous-error-this-buffer-no-select) | ||
| 1894 | map)) | 1898 | map)) |
| 1895 | 1899 | ||
| 1896 | (defun flymake-show-diagnostic (pos &optional other-window) | 1900 | (defun flymake-show-diagnostic (pos &optional other-window) |
| @@ -2187,6 +2191,11 @@ some of this variable's contents the diagnostic listings.") | |||
| 2187 | 2191 | ||
| 2188 | (defvar-local flymake--project-diagnostic-list-project nil) | 2192 | (defvar-local flymake--project-diagnostic-list-project nil) |
| 2189 | 2193 | ||
| 2194 | (defvar flymake-project-diagnostics-mode-map | ||
| 2195 | (let ((map (make-sparse-keymap))) | ||
| 2196 | (set-keymap-parent map flymake-diagnostics-buffer-mode-map) | ||
| 2197 | map)) | ||
| 2198 | |||
| 2190 | (define-derived-mode flymake-project-diagnostics-mode tabulated-list-mode | 2199 | (define-derived-mode flymake-project-diagnostics-mode tabulated-list-mode |
| 2191 | "Flymake diagnostics" | 2200 | "Flymake diagnostics" |
| 2192 | "A mode for listing Flymake diagnostics in a project." | 2201 | "A mode for listing Flymake diagnostics in a project." |
diff --git a/lisp/simple.el b/lisp/simple.el index f686907ad68..fa173b26289 100644 --- a/lisp/simple.el +++ b/lisp/simple.el | |||
| @@ -478,6 +478,16 @@ select the source buffer." | |||
| 478 | '(nil (inhibit-same-window . t)))) | 478 | '(nil (inhibit-same-window . t)))) |
| 479 | (next-error n)))) | 479 | (next-error n)))) |
| 480 | 480 | ||
| 481 | (defun next-error-this-buffer-no-select (&optional n) | ||
| 482 | "Move point to the next error in the current buffer and highlight match. | ||
| 483 | Prefix arg N says how many error messages to move forwards (or | ||
| 484 | backwards, if negative). | ||
| 485 | Finds and highlights the source line like \\[next-error], but does not | ||
| 486 | select the source buffer." | ||
| 487 | (interactive "p") | ||
| 488 | (next-error-select-buffer (current-buffer)) | ||
| 489 | (next-error-no-select n)) | ||
| 490 | |||
| 481 | (defun previous-error-no-select (&optional n) | 491 | (defun previous-error-no-select (&optional n) |
| 482 | "Move point to the previous error in the `next-error' buffer and highlight match. | 492 | "Move point to the previous error in the `next-error' buffer and highlight match. |
| 483 | Prefix arg N says how many error messages to move backwards (or | 493 | Prefix arg N says how many error messages to move backwards (or |
| @@ -487,6 +497,16 @@ select the source buffer." | |||
| 487 | (interactive "p") | 497 | (interactive "p") |
| 488 | (next-error-no-select (- (or n 1)))) | 498 | (next-error-no-select (- (or n 1)))) |
| 489 | 499 | ||
| 500 | (defun previous-error-this-buffer-no-select (&optional n) | ||
| 501 | "Move point to the previous error in the current buffer and highlight match. | ||
| 502 | Prefix arg N says how many error messages to move forwards (or | ||
| 503 | backwards, if negative). | ||
| 504 | Finds and highlights the source line like \\[previous-error], but does not | ||
| 505 | select the source buffer." | ||
| 506 | (interactive "p") | ||
| 507 | (next-error-select-buffer (current-buffer)) | ||
| 508 | (previous-error-no-select n)) | ||
| 509 | |||
| 490 | ;; Internal variable for `next-error-follow-mode-post-command-hook'. | 510 | ;; Internal variable for `next-error-follow-mode-post-command-hook'. |
| 491 | (defvar next-error-follow-last-line nil) | 511 | (defvar next-error-follow-last-line nil) |
| 492 | 512 | ||