Function: flymake-proc-legacy-flymake

flymake-proc-legacy-flymake is an interactive and byte-compiled function defined in flymake-proc.el.gz.

Signature

(flymake-proc-legacy-flymake REPORT-FN &rest ARGS)

Documentation

Flymake backend based on the original Flymake implementation.

This function is suitable for inclusion in flymake-diagnostic-functions. For backward compatibility, it can also be executed interactively independently of flymake-mode(var)/flymake-mode(fun).

Key Bindings

Aliases

flymake-start-syntax-check (obsolete since 26.1)

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/flymake-proc.el.gz
(defun flymake-proc-legacy-flymake (report-fn &rest args)
  "Flymake backend based on the original Flymake implementation.
This function is suitable for inclusion in
`flymake-diagnostic-functions'.  For backward compatibility, it
can also be executed interactively independently of
`flymake-mode'."
  ;; Interactively, behave as if flymake had invoked us through its
  ;; `flymake-diagnostic-functions' with a suitable ID so flymake can
  ;; clean up consistently
  (interactive (list
                (lambda (diags &rest args)
                  (apply (flymake-make-report-fn 'flymake-proc-legacy-flymake)
                         diags
                         (append args '(:force t))))
                :interactive t))
  (let ((interactive (plist-get args :interactive))
        (proc flymake-proc--current-process)
        (flymake-proc--report-fn report-fn))
    (when (processp proc)
      (process-put proc 'flymake-proc--obsolete t)
      (flymake-log 3 "marking %s obsolete" (process-id proc))
      (when (process-live-p proc)
        (when interactive
          (user-error
           "There's already a Flymake process running in this buffer")
          (kill-process proc))))
    (when
        ;; This particular situation make us not want to error right
        ;; away (and disable ourselves), in case the situation changes
        ;; in the near future.
        (and (or (not flymake-proc-compilation-prevents-syntax-check)
                 (not (flymake-proc--compilation-is-running))))
      (let ((init-f
             (and
              buffer-file-name
              ;; Since we write temp files in current dir, there's no point
              ;; trying if the directory is read-only (bug#8954).
              (file-writable-p (file-name-directory buffer-file-name))
              (flymake-proc--get-init-function buffer-file-name))))
        (unless init-f (error "Can't find a suitable init function"))
        (flymake-proc--clear-buildfile-cache)
        (flymake-proc--clear-project-include-dirs-cache)

        (let ((cleanup-f (flymake-proc--get-cleanup-function buffer-file-name))
              (success nil))
          (unwind-protect
              (let* ((cmd-and-args (funcall init-f))
                     (cmd          (nth 0 cmd-and-args))
                     (args         (nth 1 cmd-and-args))
                     (dir          (nth 2 cmd-and-args)))
                (cond
                 ((not cmd-and-args)
                  (flymake-log 1 "init function %s for %s failed, cleaning up"
                               init-f buffer-file-name))
                 (t
                  (setq proc
                        (let ((default-directory (or dir default-directory)))
                          (when dir
                            (flymake-log 3 "starting process on dir %s" dir))
                          (make-process
                           :name "flymake-proc"
                           :buffer (current-buffer)
                           :command (cons cmd args)
                           :noquery t
                           :filter
                           (lambda (proc string)
                             (let ((flymake-proc--report-fn report-fn))
                               (flymake-proc--process-filter proc string)))
                           :sentinel
                           (lambda (proc event)
                             (let ((flymake-proc--report-fn report-fn))
                               (flymake-proc--process-sentinel proc event))))))
                  (process-put proc 'flymake-proc--output-buffer
                               (generate-new-buffer
                                (format " *flymake output for %s*" (current-buffer))))
                  (process-put proc 'flymake-proc--temp-source-file-name
                               flymake-proc--temp-source-file-name)
                  (process-put proc 'flymake-proc--temp-master-file-name
                               flymake-proc--temp-master-file-name)
                  (setq flymake-proc--current-process proc)
                  (flymake-log 2 "started process %d, command=%s, dir=%s"
                               (process-id proc) (process-command proc)
                               default-directory)
                  (setq success t))))
            (unless success
              (funcall cleanup-f))))))))