Function: flymake-start
flymake-start is an interactive and byte-compiled function defined in
flymake.el.gz.
Signature
(flymake-start &optional DEFERRED FORCE)
Documentation
Start a syntax check for the current buffer.
DEFERRED is a list of symbols designating conditions to wait for
before actually starting the check. If it is nil (the list is
empty), start it immediately, else defer the check to when those
conditions are met. Currently recognized conditions are
post-command, for waiting until the current command is over,
on-display, for waiting until the buffer is actually displayed
in a window. If DEFERRED is t, wait for all known conditions.
With optional FORCE run even disabled backends.
Interactively, with a prefix arg, FORCE is t.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/flymake.el.gz
(defun flymake-start (&optional deferred force)
"Start a syntax check for the current buffer.
DEFERRED is a list of symbols designating conditions to wait for
before actually starting the check. If it is nil (the list is
empty), start it immediately, else defer the check to when those
conditions are met. Currently recognized conditions are
`post-command', for waiting until the current command is over,
`on-display', for waiting until the buffer is actually displayed
in a window. If DEFERRED is t, wait for all known conditions.
With optional FORCE run even disabled backends.
Interactively, with a prefix arg, FORCE is t."
(interactive (list nil current-prefix-arg))
(let ((deferred (if (eq t deferred)
'(post-command on-display)
deferred))
(buffer (current-buffer)))
(cl-labels
((visible-buffer-window ()
(and (or (not (daemonp))
(not (eq (selected-frame) terminal-frame)))
(get-buffer-window (current-buffer))))
(start-post-command ()
(remove-hook 'post-command-hook #'start-post-command
nil)
;; The buffer may have disappeared already, e.g. because of
;; code like `(with-temp-buffer (python-mode) ...)'.
(when (buffer-live-p buffer)
(with-current-buffer buffer
(flymake-start (remove 'post-command deferred) force))))
(start-on-display ()
(remove-hook 'window-configuration-change-hook #'start-on-display
'local)
;; Double check that buffer is actually visible (bug#77313)
(if (visible-buffer-window)
(setq deferred (remove 'on-display deferred)))
(flymake-start deferred force)))
(cond ((and (memq 'post-command deferred)
this-command)
(add-hook 'post-command-hook
#'start-post-command
'append nil))
((and (memq 'on-display deferred)
(not (visible-buffer-window)))
(add-hook 'window-configuration-change-hook
#'start-on-display
'append 'local))
(flymake-mode
;; The buffer about to be annotated is visible. Check
;; necessary conditions to auto-set margins here (bug#77313)
(when-let* ((w (and (eq flymake-indicator-type 'auto)
flymake-autoresize-margins
(visible-buffer-window))))
(unless (flymake--suitably-fringed-p w)
(flymake--resize-margins)))
(setq flymake-check-start-time (float-time))
(let ((backend-args
(and
flymake--recent-changes
(list :recent-changes
flymake--recent-changes
:changes-start
(cl-reduce
#'min (mapcar #'car flymake--recent-changes))
:changes-end
(cl-reduce
#'max (mapcar #'cadr flymake--recent-changes))))))
(setq flymake--recent-changes nil)
;; Delete all overlays that didn't come from one of the
;; current diagnostic functions.
;; Sometimes diagnostic functions are removed from
;; `flymake-diagnostic-functions' (e.g. by eglot). This
;; leaves overlays in the buffer which otherwise won't be
;; cleaned up until `flymake-mode' is restarted.
;; See bug#78862
(maphash (lambda (backend state)
(unless (memq backend flymake-diagnostic-functions)
(flymake--clear-state state)))
flymake--state)
(run-hook-wrapped
'flymake-diagnostic-functions
(lambda (backend)
(flymake--with-backend-state backend state
(setf (flymake--state-reported-p state) nil))))
(run-hook-wrapped
'flymake-diagnostic-functions
(lambda (backend)
(cond
((and (not force)
(flymake--with-backend-state backend state
(flymake--state-disabled state)))
(flymake-log :debug "Backend %s is disabled, not starting"
backend))
(t
(flymake--run-backend backend backend-args)))
nil)))
(flymake--import-foreign-diagnostics))))))