From: João Távora Date: Tue, 10 Aug 2021 19:28:35 +0000 (+0100) Subject: Let eglot-flymake-backend be in flymake-d-functions even if eglot off X-Git-Tag: emacs-29.0.90~1616^2~524^2~4^2~126 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=ace1573dfe02fa5969692af545993ccf9475ccaf;p=emacs.git Let eglot-flymake-backend be in flymake-d-functions even if eglot off This is useful when using eglot-stay-out-of and a pattern like: (defun my/js-mode-hook () (add-hook 'flymake-diagnostic-functions 'some-eslint-backend nil t)) (setq-local eglot-stay-out-of '(flymake)) (add-hook 'flymake-diagnostic-functions 'eglot-flymake-backend nil t)) (add-hook 'js-mode-hook 'my/js-mode-hook) Then, _both_ backends will run unconditionally, but Eglot backend only actually reports diagnostics if Eglot is on. * eglot.el (eglot-flymake-backend): If buffer isn't being managed by Eglot, behave as a noop. --- diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index 0f367fd2208..71f7d7ea597 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -2089,10 +2089,13 @@ Calls REPORT-FN (or arranges for it to be called) when the server publishes diagnostics. Between calls to this function, REPORT-FN may be called multiple times (respecting the protocol of `flymake-backend-functions')." - (setq eglot--current-flymake-report-fn report-fn) - ;; Report anything unreported - (when eglot--unreported-diagnostics - (eglot--report-to-flymake (cdr eglot--unreported-diagnostics)))) + (cond (eglot--managed-mode + (setq eglot--current-flymake-report-fn report-fn) + ;; Report anything unreported + (when eglot--unreported-diagnostics + (eglot--report-to-flymake (cdr eglot--unreported-diagnostics)))) + (t + (funcall report-fn nil)))) (defun eglot--report-to-flymake (diags) "Internal helper for `eglot-flymake-backend'."