mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2024-12-16 09:50:25 +00:00
Simplify Flymake diagnostics buffer UX
Don't create text-buttons unnecessarily, just bind RET and SPC in the diagnostics buffer to a command that figures out which diagnostic it was invoked on. * lisp/progmodes/flymake.el (flymake--diagnostics-buffer-mode-keymap): Renamed from flymake--diagnostics-buffer-button-keymap. (flymake-show-diagnostic-at-point): Don't take a button. (flymake-goto-diagnostic-at-point): Don't pass button to flymake-show-diagnostic-at-point. (flymake--diagnostics-buffer-entries): Simplify.
This commit is contained in:
parent
cf4a15b9b6
commit
0e83f5f279
@ -1077,17 +1077,19 @@ applied."
|
|||||||
|
|
||||||
(defvar-local flymake--diagnostics-buffer-source nil)
|
(defvar-local flymake--diagnostics-buffer-source nil)
|
||||||
|
|
||||||
(defvar flymake--diagnostics-buffer-button-keymap
|
(defvar flymake-diagnostics-buffer-mode-map
|
||||||
(let ((map (make-sparse-keymap)))
|
(let ((map (make-sparse-keymap)))
|
||||||
(define-key map [mouse-1] 'push-button)
|
(define-key map [mouse-1] 'flymake-goto-diagnostic-at-point)
|
||||||
(define-key map (kbd "RET") 'push-button)
|
(define-key map (kbd "RET") 'flymake-goto-diagnostic-at-point)
|
||||||
(define-key map (kbd "SPC") 'flymake-show-diagnostic-at-point)
|
(define-key map (kbd "SPC") 'flymake-show-diagnostic-at-point)
|
||||||
map))
|
map))
|
||||||
|
|
||||||
(defun flymake-show-diagnostic-at-point (button)
|
(defun flymake-show-diagnostic-at-point ()
|
||||||
"Show location of diagnostic of BUTTON."
|
"Show location of diagnostic at point."
|
||||||
(interactive (list (button-at (point))))
|
(interactive)
|
||||||
(let* ((overlay (button-get button 'flymake-overlay)))
|
(let* ((id (or (tabulated-list-get-id)
|
||||||
|
(user-error "Nothing at point")))
|
||||||
|
(overlay (plist-get id :overlay)))
|
||||||
(with-current-buffer (overlay-buffer overlay)
|
(with-current-buffer (overlay-buffer overlay)
|
||||||
(with-selected-window
|
(with-selected-window
|
||||||
(display-buffer (current-buffer))
|
(display-buffer (current-buffer))
|
||||||
@ -1097,11 +1099,11 @@ applied."
|
|||||||
'highlight))
|
'highlight))
|
||||||
(current-buffer))))
|
(current-buffer))))
|
||||||
|
|
||||||
(defun flymake-goto-diagnostic-at-point (button)
|
(defun flymake-goto-diagnostic-at-point ()
|
||||||
"Show location of diagnostic of BUTTON."
|
"Show location of diagnostic at point."
|
||||||
(interactive (list (button-at (point))))
|
(interactive)
|
||||||
(pop-to-buffer
|
(pop-to-buffer
|
||||||
(flymake-show-diagnostic-at-point button)))
|
(flymake-show-diagnostic-at-point)))
|
||||||
|
|
||||||
(defun flymake--diagnostics-buffer-entries ()
|
(defun flymake--diagnostics-buffer-entries ()
|
||||||
(with-current-buffer flymake--diagnostics-buffer-source
|
(with-current-buffer flymake--diagnostics-buffer-source
|
||||||
@ -1121,16 +1123,7 @@ applied."
|
|||||||
:severity (flymake--lookup-type-property
|
:severity (flymake--lookup-type-property
|
||||||
type
|
type
|
||||||
'severity (warning-numeric-level :error)))
|
'severity (warning-numeric-level :error)))
|
||||||
`[(,(format "%s" line)
|
`[,(format "%s" line)
|
||||||
keymap ,flymake--diagnostics-buffer-button-keymap
|
|
||||||
action flymake-goto-diagnostic-at-point
|
|
||||||
mouse-action flymake-goto-diagnostic-at-point
|
|
||||||
help-echo ,(mapconcat #'identity
|
|
||||||
'("mouse-1, RET: goto location at point"
|
|
||||||
"SPC: show location at point")
|
|
||||||
"\n")
|
|
||||||
flymake-diagnostic ,diag
|
|
||||||
flymake-overlay ,ov)
|
|
||||||
,(format "%s" col)
|
,(format "%s" col)
|
||||||
,(propertize (format "%s" type)
|
,(propertize (format "%s" type)
|
||||||
'face (flymake--lookup-type-property
|
'face (flymake--lookup-type-property
|
||||||
|
Loading…
Reference in New Issue
Block a user