GNU bug report logs - #79380
31.0.50; Flymake does not check Elisp code anymore

Previous Next

Package: emacs;

Reported by: Daniel Mendler <mail <at> daniel-mendler.de>

Date: Wed, 3 Sep 2025 21:31:02 UTC

Severity: normal

Found in version 31.0.50

Done: Eli Zaretskii <eliz <at> gnu.org>

Full log


Message #38 received at 79380 <at> debbugs.gnu.org (full text, mbox):

From: Spencer Baugh <sbaugh <at> janestreet.com>
To: Daniel Mendler <mail <at> daniel-mendler.de>
Cc: 79380 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>
Subject: Re: bug#79380: 31.0.50; Flymake does not check Elisp code anymore,
 [PATCH] Fix null values of elisp-flymake-byte-compile-executable
Date: Sat, 06 Sep 2025 11:14:24 -0400
[Message part 1 (text/plain, inline)]
Daniel Mendler <mail <at> daniel-mendler.de> writes:

> Eli Zaretskii <eliz <at> gnu.org> writes:
>
>>> From: Spencer Baugh <sbaugh <at> janestreet.com>
>>> Cc: 79380 <at> debbugs.gnu.org,  Eli Zaretskii <eliz <at> gnu.org>
>>> Date: Fri, 05 Sep 2025 14:26:49 -0400
>>> 
>>> > Right, even better.  Like this:
>>> 
>>> Ping, I'd like to install this patch to fix the breakage on master.
>>
>> I was waiting for Daniel to test the patch and say that there are no
>> further issues with it.
>>
>> Daniel, please chime in and ack.
>
> Works for me, yes.
>
> But there is still a small inconsistency in the patch. If the defcustom
> is set to an invalid type there will be an error. But if it is set to an
> invalid executable we will get a warning. Is this desired?

That was deliberate, yes.  If a user sets
elisp-flymake-byte-compile-executable to "src/emacs" in dir-locals in
the Emacs repo, but they haven't compiled Emacs yet, I figure they would
prefer that flymake fall back to using their running Emacs instance
rather than error because repo/src/emacs doesn't exist.

That being said, since this is unclear I think the message for that case
could be improved.  Also, some of the nested conditionals indeed can be
removed.  Hence, this patch, which I think seems good to me.  (We don't
need to check file-executable-p in the absolute file name case, where we
don't need to fall back; start-process will just error, just like it
would if (expand-file-name invocation-name invocation-directory) doesn't
exist anymore)

>> Thanks.  However, the log message still says the defcustom is being
>> modified, which the patch doesn't do.

Fixed, thanks.

[0001-Fix-null-values-of-elisp-flymake-byte-compile-execut.patch (text/x-patch, inline)]
From 8684d0e973a788165d8c7f521703413b5d1e937f Mon Sep 17 00:00:00 2001
From: Spencer Baugh <sbaugh <at> janestreet.com>
Date: Thu, 4 Sep 2025 10:36:17 -0400
Subject: [PATCH] Fix null values of elisp-flymake-byte-compile-executable

* lisp/progmodes/elisp-mode.el
(elisp-flymake-byte-compile--executable): Properly check for
nil, and simplify code. (bug#79380)
---
 lisp/progmodes/elisp-mode.el | 31 +++++++++++++++++--------------
 1 file changed, 17 insertions(+), 14 deletions(-)

diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el
index aebc93d1ddb..42653069feb 100644
--- a/lisp/progmodes/elisp-mode.el
+++ b/lisp/progmodes/elisp-mode.el
@@ -2301,20 +2301,23 @@ elisp-flymake-byte-compile-executable
 (declare-function project-root "project" (project))
 (defun elisp-flymake-byte-compile--executable ()
   "Return absolute file name of the Emacs executable for flymake byte-compilation."
-  (let ((filename
-         (cond
-          ((file-name-absolute-p elisp-flymake-byte-compile-executable)
-           elisp-flymake-byte-compile-executable)
-          ((stringp elisp-flymake-byte-compile-executable)
-           (when-let* ((pr (project-current)))
-             (file-name-concat (project-root pr)
-                               elisp-flymake-byte-compile-executable))))))
-    (if (file-executable-p filename)
-        filename
-      (when elisp-flymake-byte-compile-executable
-        (message "No such `elisp-flymake-byte-compile-executable': %s"
-                 filename))
-      (expand-file-name invocation-name invocation-directory))))
+  (cond
+   ((null elisp-flymake-byte-compile-executable)
+    (expand-file-name invocation-name invocation-directory))
+   ((not (stringp elisp-flymake-byte-compile-executable))
+    (error "Invalid `elisp-flymake-byte-compile-executable': %s"
+           elisp-flymake-byte-compile-executable))
+   ((file-name-absolute-p elisp-flymake-byte-compile-executable)
+    elisp-flymake-byte-compile-executable)
+   (t ; relative file name
+    (let ((filename (file-name-concat (project-root (project-current))
+                                      elisp-flymake-byte-compile-executable)))
+      (if (file-executable-p filename)
+          filename
+        ;; The user might not have built Emacs yet, so just fall back.
+        (message "`elisp-flymake-byte-compile-executable' (%s) doesn't exist"
+                 elisp-flymake-byte-compile-executable)
+        (expand-file-name invocation-name invocation-directory))))))
 
 ;;;###autoload
 (defun elisp-flymake-byte-compile (report-fn &rest _args)
-- 
2.43.7


This bug report was last modified 6 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.