• João Távora's avatar
    Flymake backends can report multiple times per check · f6e909b4
    João Távora authored
    Rewrote a significant part of the Flymake backend API.  Flymake now
    ignores the return value of backend functions: a function can either
    returns or errors.  If it doesn't error, a backend is no longer
    constrained to call REPORT-FN exactly once.  It may do so any number
    of times, cumulatively reporting diagnostics.  Flymake keeps track of
    outdated REPORT-FN instances and disconsiders obsolete reports.
    Backends should avoid reporting obsolete data by cancelling any
    ongoing processing at every renewed call to the backend function.
    
    Consolidated flymake.el internal data structures to require less
    buffer-local variables.  Adjusted Flymake's mode-line indicator to the
    new semantics.
    
    Adapted and simplified the implementation of elisp and legacy
    backends, fixing potential race conditions when calling backends in
    rapid succession.
    
    Added a new test for a backend that calls REPORT-FN multiple
    times.  Simplify test infrastructure.
    
    * lisp/progmodes/flymake-elisp.el (flymake-elisp-checkdoc)
    (flymake-elisp-byte-compile): Error instead of returning nil
    if not in emacs-lisp-mode.
    (flymake-elisp--byte-compile-process): New buffer-local variable.
    (flymake-elisp-byte-compile): Mark (and kill) previous process
    obsolete process before starting a new one.  Don't report if
    obsolete process.
    
    * lisp/progmodes/flymake-proc.el
    (flymake-proc--current-process): New buffer-local variable.
    (flymake-proc--processes): Remove.
    (flymake-proc--process-filter): Don't bind
    flymake-proc--report-fn.
    (flymake-proc--process-sentinel): Rewrite.  Don't report if
    obsolete process.
    (flymake-proc-legacy-flymake): Rewrite.  Mark (and kill)
    previous process obsolete process before starting a new
    one.  Integrate flymake-proc--start-syntax-check-process
    helper.
    (flymake-proc--start-syntax-check-process): Delete.
    (flymake-proc-stop-all-syntax-checks): Don't use
    flymake-proc--processes, iterate buffers.
    (flymake-proc-compile):
    
    * lisp/progmodes/flymake.el (subr-x): Require it
    explicitly.
    (flymake-diagnostic-functions): Reword docstring.
    (flymake--running-backends, flymake--disabled-backends)
    (flymake--diagnostics-table): Delete.
    (flymake--backend-state): New buffer-local variable and new defstruct.
    (flymake--with-backend-state, flymake--collect)
    (flymake-running-backends, flymake-disabled-backends)
    (flymake-reporting-backends): New helpers.
    (flymake-is-running): Use flymake-running-backends.
    (flymake--handle-report): Rewrite.
    (flymake-make-report-fn): Ensure REPORT-FN runs in the correct
    buffer or not at all.
    (flymake--disable-backend, flymake--run-backend): Rewrite.
    (flymake-start): Rewrite.
    (flymake-mode): Set flymake--backend-state.
    (flymake--mode-line-format): Rewrite.
    
    * test/lisp/progmodes/flymake-tests.el
    (flymake-tests--wait-for-backends): New helper.
    (flymake-tests--call-with-fixture): Use it.
    (included-c-header-files): Fix whitespace.
    (flymake-tests--diagnose-words): New helper.
    (dummy-backends): Rewrite for new semantics.  Use cl-letf.
    (flymake-tests--assert-set): Use quote.
    (recurrent-backend): New test.
    f6e909b4
flymake.el 37.5 KB