(defvar-local flymake--diagnostics-buffer-source nil)
-(defvar flymake-diagnostics-buffer-mode-map
- (let ((map (make-sparse-keymap)))
- (define-key map (kbd "RET") 'flymake-goto-diagnostic)
- (define-key map (kbd "SPC") 'flymake-show-diagnostic)
- map))
+(defvar-keymap flymake-diagnostics-buffer-mode-map
+ :doc "Keymap for Flyamke diagnostics list buffers."
+ "RET" #'flymake-diagnostics-buffer-goto-diagnostic
+ "SPC" #'flymake-diagnostics-buffer-show-diagnostic)
+
+(defun flymake-diagnostics-buffer-show-diagnostic (pos &optional action)
+ "Show location of diagnostic at POS.
-(defun flymake-show-diagnostic (pos &optional other-window)
- "Show location of diagnostic at POS."
- (interactive (list (point) t))
+Optional argument ACTION is passed to `display-buffer', which see."
+ (interactive "d")
(let* ((id (or (tabulated-list-get-id pos)
- (user-error "Nothing at point")))
+ (user-error "No diagnostic at this position")))
(diag (plist-get id :diagnostic))
(locus (flymake--diag-locus diag))
- (beg (flymake--diag-beg diag))
- (end (flymake--diag-end diag))
- (visit (lambda (b e)
- (goto-char b)
- (pulse-momentary-highlight-region (point)
- (or e (line-end-position))
- 'highlight))))
+ (beg (flymake--diag-beg diag)))
(with-current-buffer (cond ((bufferp locus) locus)
(t (find-file-noselect locus)))
- (with-selected-window
- (display-buffer (current-buffer) other-window)
+ (with-selected-window (display-buffer (current-buffer) action)
(cond (;; an annotated diagnostic (most common case), or a
;; non-annotated buffer diag
(number-or-marker-p beg)
- (funcall visit beg end))
+ (goto-char beg))
(;; a non-annotated file diag (TODO: could use `end'
;; here, too)
- (pcase-let ((`(,bbeg . ,bend)
+ (pcase-let ((`(,bbeg . ,_)
(flymake-diag-region (current-buffer)
(car beg)
(cdr beg))))
- (funcall visit bbeg bend)))))
+ (goto-char bbeg)))))
(current-buffer))))
-(defun flymake-goto-diagnostic (pos)
+(defun flymake-diagnostics-buffer-goto-diagnostic (pos)
"Show location of diagnostic at POS.
POS can be a buffer position or a button"
(interactive "d")
(pop-to-buffer
- (flymake-show-diagnostic (if (button-type pos) (button-start pos) pos))))
+ (flymake-diagnostics-buffer-show-diagnostic
+ (if (button-type pos) (button-start pos) pos))))
(defun flymake--tabulated-entries-1 (diags project-root)
"Helper for `flymake--diagnostics-buffer-entries'.
mouse-face highlight
help-echo "mouse-2: visit this diagnostic"
face nil
- action flymake-goto-diagnostic
- mouse-action flymake-goto-diagnostic)]
+ action flymake-diagnostics-buffer-goto-diagnostic
+ mouse-action flymake-diagnostics-buffer-goto-diagnostic)]
when (and line col) collect
(list (list :diagnostic diag
:line line
help-echo ,(file-relative-name file project-root)
face nil
mouse-face highlight
- action flymake-goto-diagnostic
- mouse-action flymake-goto-diagnostic )]
+ action flymake-diagnostics-buffer-goto-diagnostic
+ mouse-action flymake-diagnostics-buffer-goto-diagnostic )]
data-vec)
data-vec))))
(defvar-local flymake--project-diagnostic-list-project nil)
-(define-derived-mode flymake-project-diagnostics-mode tabulated-list-mode
+(define-derived-mode flymake-project-diagnostics-mode flymake-diagnostics-buffer-mode
"Flymake diagnostics"
"A mode for listing Flymake diagnostics."
:interactive nil
(revert-buffer)))))
(provide 'flymake)
-
;;; flymake.el ends here