Subject: Re: bug#48452: 28.0.50; flymake for elisp does not respect `load-path`

From: Max Brieiev <[email-masked]>
Date: Thu, 14 Jul 2022 12:22:53 +0300

Lars Ingebrigtsen <[email-masked]> writes:

> Do you have a complete step by step recipe that demonstrates the
> problem?  I tried the original instructions, but got no messages from
> flymake (except complaining that the .emacs file doesn't start with ;;;
> Commentary).

`elisp-flymake-byte-compile' is a flymake backend for the elisp-mode.

It runs emacs in batch mode with -Q flag as a child process to provide
diagnostics for the current buffer.

In this case the `load-path' of the child process includes only builtin
packages, while the `load-path' of the parent process includes all the
directories added by the normal bootstrap process.

The load-path for the child process is controlled with
`elisp-flymake-byte-compile-load-path'. By default, it contains only
current directory.

The following hack "fixed" the issue for me:

diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el
index 0c4a9bfdbe..db3592b903 100644
--- a/lisp/progmodes/elisp-mode.el
+++ b/lisp/progmodes/elisp-mode.el
@@ -2145,7 +2145,7 @@ current buffer state and calls REPORT-FN when done."
                    "--batch"
                    ;; "--eval" "(setq load-prefer-newer t)" ; for testing
                    ,@(mapcan (lambda (path) (list "-L" path))
-                             elisp-flymake-byte-compile-load-path)
+                             load-path)
                    "-f" "elisp-flymake--batch-compile-for-flymake"
                    ,temp-file)
         :connection-type 'pipe

Can we add some user-friendly knobs to control this behavior of flymake?