Function: flymake--publish-diagnostics
flymake--publish-diagnostics is a byte-compiled function defined in
flymake.el.gz.
Signature
(flymake--publish-diagnostics DIAGS &key BACKEND STATE REGION)
Documentation
Helper for flymake--handle-report.
Publish DIAGS, which contain diagnostics for the current buffer and other buffers.
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/flymake.el.gz
(cl-defun flymake--publish-diagnostics (diags &key backend state region)
"Helper for `flymake--handle-report'.
Publish DIAGS, which contain diagnostics for the current buffer
and other buffers."
(dolist (d diags) (setf (flymake--diag-backend d) backend))
(save-restriction
(widen)
;; First, clean up. Remove diagnostics from bookkeeping lists and
;; their overlays from buffers.
;;
(cond
(;; If there is a `region' arg, only affect the diagnostics whose
;; overlays are in a certain region. Ignore "foreign"
;; diagnostics.
region
(cl-loop for diag in (flymake--state-diags state)
for ov = (flymake--diag-overlay diag)
if (or (not (overlay-buffer ov))
(flymake--intersects-p
(overlay-start ov) (overlay-end ov)
(car region) (cdr region)))
do (flymake--delete-overlay ov)
else collect diag into surviving
finally (setf (flymake--state-diags state)
surviving)))
(;; Else, if this is the first report, fully clear this state.
(not (flymake--state-reported-p state))
(flymake--clear-state state))
(;; If this is not the first report, do no cleanup.
t))
;; Now place new overlays for all diagnostics: "domestic"
;; diagnostics are for the current buffer; "foreign" may be for a
;; some other live buffer or for a file name that hasn't a buffer
;; yet. If a foreign diagnostic is for a buffer, convert to a
;; file name, protecting it against that buffer's killing.
;;
(cl-loop
for d in diags
for locus = (flymake--diag-locus d)
do (cond ((eq locus (current-buffer))
(push d (flymake--state-diags state))
(flymake--highlight-line d))
(t
(when (or (buffer-live-p locus)
(setq locus (find-buffer-visiting locus)))
(with-current-buffer locus
(when flymake-mode (flymake--highlight-line d 'foreign))
;; Ensure locus of a foreign diag is always a file-name
;; string, even if created from a buffer.
(setf (flymake--diag-locus d) (buffer-file-name))))
(cl-assert (stringp (flymake--diag-locus d)))
(push d (gethash (flymake--diag-locus d)
(flymake--state-foreign-diags state))))))
;; Finally, flush some caches
(setq flymake--mode-line-counter-cache nil)))