Function: flymake-show-buffer-diagnostics

flymake-show-buffer-diagnostics is an interactive and byte-compiled function defined in flymake.el.gz.

Signature

(flymake-show-buffer-diagnostics &optional DIAGNOSTIC)

Documentation

Show listing of Flymake diagnostics for current buffer.

With optional DIAGNOSTIC, find and highlight this diagnostic in the listing.

Interactively, grab DIAGNOSTIC from context. For mouse events in margins and fringes, use the first diagnostic in the corresponding line, else look in the click position. For non-mouse events, look for diagnostics at point.

This function doesn't move point

Probably introduced at or before Emacs version 28.1.

Key Bindings

Aliases

flymake-show-diagnostics-buffer (obsolete since 1.2.1)

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/flymake.el.gz
(defun flymake-show-buffer-diagnostics (&optional diagnostic)
  "Show listing of Flymake diagnostics for current buffer.
With optional DIAGNOSTIC, find and highlight this diagnostic in the
listing.

Interactively, grab DIAGNOSTIC from context.  For mouse events in
margins and fringes, use the first diagnostic in the corresponding line,
else look in the click position.  For non-mouse events, look for
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))))
  (unless flymake-mode
    (user-error "Flymake mode is not enabled in the current buffer"))
  (let* ((name (flymake--diagnostics-buffer-name))
         (source (current-buffer))
         (target (or (get-buffer name)
                     (with-current-buffer (get-buffer-create name)
                       (flymake-diagnostics-buffer-mode)
                       (current-buffer))))
         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)
                            `((display-buffer-reuse-window
                               display-buffer-below-selected)
                              (window-height . flymake--fit-diagnostics-window))))
      (when (and window diagnostic)
        (with-selected-window window
          (cl-loop initially (goto-char (point-min))
                   until (eobp)
                   until (eq (plist-get (tabulated-list-get-id) :diagnostic)
                             diagnostic)
                   do (forward-line)
                   finally
                   (recenter)
                   (pulse-momentary-highlight-one-line
                    (point) 'highlight)))))))