flymake-show-buffer-diagnostics: Fix interactive form

* lisp/progmodes/flymake.el (flymake-show-buffer-diagnostics):
Return just one diagnostic when last-command-event was not a
mouse event (bug#81786).
This commit is contained in:
Sean Whitton 2026-09-04 14:26:20 +01:00
parent 6f230503c8
commit c709b66dcb

View file

@ -2104,24 +2104,26 @@ diagnostics at point.
This function doesn't move point"
(interactive
(if (mouse-event-p last-command-event)
(with-selected-window (posn-window (event-end last-command-event))
(with-current-buffer (window-buffer)
(let* ((event-point (posn-point (event-end last-command-event)))
(diags
(or
(flymake-diagnostics event-point)
(let (event-lbp event-lep)
(save-excursion
(goto-char event-point)
(setq event-lbp (line-beginning-position)
event-lep (line-end-position)))
(flymake-diagnostics event-lbp event-lep))))
(diag (car diags)))
(unless diag
(error "No diagnostics here"))
(list diag))))
(flymake-diagnostics (point))))
(let* ((diags
(if (mouse-event-p last-command-event)
(with-selected-window
(posn-window (event-end last-command-event))
(with-current-buffer (window-buffer)
(let ((event-point (posn-point
(event-end last-command-event))))
(or (flymake-diagnostics event-point)
(let (event-lbp event-lep)
(save-excursion
(goto-char event-point)
(setq event-lbp (line-beginning-position)
event-lep (line-end-position)))
(flymake-diagnostics event-lbp
event-lep))))))
(flymake-diagnostics (point))))
(diag (car diags)))
(unless diag
(error "No diagnostics here"))
(list diag)))
(unless flymake-mode
(user-error "Flymake mode is not enabled in the current buffer"))
(let* ((name (flymake--diagnostics-buffer-name))