fix(emacs-lisp): add elisp flymake load path advice

We set flycheck-emacs-lisp-load-path to 'inherit, which evaluates
load-path when spawning the Emacs subprocess. flymake relies on a static
variable, hence the advice. elisp-flymake-byte-compile is autoloaded by
elisp-mode, so there is little reason to condition on `:checkers syntax
+flymake`.

Ref: e56e30d8c6/flycheck.el (L8725-L8727)
Ref: https://git.savannah.gnu.org/cgit/emacs.git/tree/lisp/progmodes/elisp-mode.el?h=emacs-29.1#n2166
Ref: https://emacs.stackexchange.com/questions/48661/how-do-i-get-flymake-to-recognize-files-in-my-load-path
This commit is contained in:
Liam Hupfer 2023-09-09 12:07:27 -05:00 committed by Henrik Lissner
parent d509d8bea1
commit 6666685993

View file

@ -101,6 +101,13 @@ See `+emacs-lisp-non-package-mode' for details.")
;; original in the flycheck instance (see `+emacs-lisp-linter-warnings'). ;; original in the flycheck instance (see `+emacs-lisp-linter-warnings').
(add-hook 'flycheck-mode-hook #'+emacs-lisp-non-package-mode) (add-hook 'flycheck-mode-hook #'+emacs-lisp-non-package-mode)
(defadvice! +syntax--fix-elisp-flymake-load-path (orig-fn &rest args)
"Set load path for elisp byte compilation Flymake backend"
:around #'elisp-flymake-byte-compile
(let ((elisp-flymake-byte-compile-load-path
(append elisp-flymake-byte-compile-load-path load-path)))
(apply orig-fn args)))
;; Enhance elisp syntax highlighting, by highlighting Doom-specific ;; Enhance elisp syntax highlighting, by highlighting Doom-specific
;; constructs, defined symbols, and truncating :pin's in `package!' calls. ;; constructs, defined symbols, and truncating :pin's in `package!' calls.
(font-lock-add-keywords (font-lock-add-keywords