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 EVENT)

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 event)
  "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
   (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 event-diags)
                           (save-excursion
                             (goto-char event-point)
                             (setq event-lbp (line-beginning-position)
                                   event-lep (min (1+ (line-end-position))
                                                  (point-max))))
                           (setq event-diags
                                 (flymake-diagnostics event-lbp
                                                      event-lep))
                           (unless event-diags
                             (error "No diagnostics here"))
                           event-diags)))))
             (flymake-diagnostics (point))))
          (diag (car diags)))
     (list diag last-input-event)))
  (when-let* ((_ (mouse-event-p event))
              (window (posn-window (event-start event)))
              (_ (windowp window))
              (_ (not (eq (selected-window) window))))
    (mouse-select-window event))
  (unless flymake-mode
    (user-error "Flymake mode is not enabled in the current buffer"))
  (unless (flymake-diagnostics)
    (user-error "No diagnostics 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)))))))