Function: flymake-show-diagnostic

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

Signature

(flymake-show-diagnostic POS &optional OTHER-WINDOW)

Documentation

From Flymake diagnostics buffer, show source of diagnostic at POS.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/flymake.el.gz
(defun flymake-show-diagnostic (pos &optional other-window)
  "From Flymake diagnostics buffer, show source of diagnostic at POS."
  (interactive (list (point) t))
  (let* ((diagnostics-buffer (current-buffer))
         (id (or (tabulated-list-get-id pos)
                 (user-error "Nothing at point")))
         (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
                   b (or e (line-end-position))))))
    (setq flymake-current-diagnostic-line (line-number-at-pos pos))
    (with-current-buffer (cond ((bufferp locus) locus)
                               (t (find-file-noselect locus)))
      (with-selected-window
          (display-buffer (current-buffer) other-window)
        (cond (;; an annotated diagnostic (most common case), or a
               ;; non-annotated buffer diag
               (number-or-marker-p beg)
               (funcall visit beg end))
              (;; a non-annotated file diag (TODO: could use `end'
               ;; here, too)
               (pcase-let ((`(,bbeg . ,bend)
                            (flymake-diag-region (current-buffer)
                                                 (car beg)
                                                 (cdr beg))))
                 (funcall visit bbeg bend)))))
      ;; Emacs < 27
      (setq next-error-last-buffer diagnostics-buffer)
      (current-buffer))))