GNU bug report logs - #78446
[PATCH] * lisp/emacs-lisp/find-func.el: Fix Eager macro-expansion failure

Previous Next

Package: emacs;

Reported by: Lin Sun <sunlin7 <at> hotmail.com>

Date: Thu, 15 May 2025 22:21:02 UTC

Severity: normal

Tags: patch

Done: Stefan Monnier <monnier <at> iro.umontreal.ca>

To reply to this bug, email your comments to 78446 AT debbugs.gnu.org.
There is no need to reopen the bug first.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#78446; Package emacs. (Thu, 15 May 2025 22:21:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Lin Sun <sunlin7 <at> hotmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 15 May 2025 22:21:02 GMT) Full text and rfc822 format available.

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

From: Lin Sun <sunlin7 <at> hotmail.com>
To: "bug-gnu-emacs <at> gnu.org" <bug-gnu-emacs <at> gnu.org>
Subject: [PATCH] * lisp/emacs-lisp/find-func.el: Fix Eager macro-expansion
 failure
Date: Thu, 15 May 2025 22:14:35 +0000
[Message part 1 (text/plain, inline)]
A build error happened as follow (I upgrade to latest  version db198e0e59bff0c1cb28a591928377f5a0e9d158),
This patch will fix the build error.

Error: error ("Eager macro-expansion failure: (wrong-type-argument symbolp 'find-function-mode)")
  signal(error ("Eager macro-expansion failure: (wrong-type-argument symbolp 'find-function-mode)"))
  error("Eager macro-expansion failure: %S" (wrong-type-argument symbolp 'find-function-mode))
  internal-macroexpand-for-load((custom-declare-variable 'find-function-mode-lower-precedence `(funcall #',(lambda nil "" nil)) "If non-nil, `find-function-mode' defines keys in the global map.\nThis is for compatibility with the historical behavior of\nthe old `find-function-setup-keys'." :type 'boolean :version "31.1" :group 'find-function :set (lambda (symbol value) "hello" (let ((already-on (bound-and-true-p 'find-function-mode))) (when already-on (find-function-mode -1)) (set-default symbol value) (when already-on (find-function-mode 1))))) t)
  eval-buffer(#<buffer  *load*-728608> nil "/tmp/emacs-dbg/lisp/emacs-lisp/find-func.el" nil t)
  load-with-code-conversion("/tmp/emacs-dbg/lisp/emacs-lisp/find-func.el" "/tmp/emacs-dbg/lisp/emacs-lisp/find-func.el" nil t)
  require(find-func)
  eval-buffer(#<buffer  *load*-987386> nil "/tmp/emacs-dbg/lisp/cedet/mode-local.el" nil t)
  load-with-code-conversion("/tmp/emacs-dbg/lisp/cedet/mode-local.el" "/tmp/emacs-dbg/lisp/cedet/mode-local.el" nil t)
  require(mode-local)
  eval-buffer(#<buffer  *load*-671861> nil "/tmp/emacs-dbg/lisp/cedet/semantic/fw.el" nil t)
  load-with-code-conversion("/tmp/emacs-dbg/lisp/cedet/semantic/fw.el" "/tmp/emacs-dbg/lisp/cedet/semantic/fw.el" nil t)
  require(semantic/fw)
  eval-buffer(#<buffer  *load*-479974> nil "/tmp/emacs-dbg/lisp/cedet/semantic/tag.el" nil t)
  load-with-code-conversion("/tmp/emacs-dbg/lisp/cedet/semantic/tag.el" "/tmp/emacs-dbg/lisp/cedet/semantic/tag.el" nil t)
  require(semantic/tag)
  eval-buffer(#<buffer  *load*-715339> nil "/tmp/emacs-dbg/lisp/cedet/semantic.el" nil t)
  load-with-code-conversion("/tmp/emacs-dbg/lisp/cedet/semantic.el" "/tmp/emacs-dbg/lisp/cedet/semantic.el" nil t)
  require(semantic)
  eval-buffer(#<buffer  *load*> nil "/tmp/emacs-dbg/lisp/cedet/semantic/bovine/grammar.el" nil t)
  load-with-code-conversion("/tmp/emacs-dbg/lisp/cedet/semantic/bovine/grammar.el" "/tmp/emacs-dbg/lisp/cedet/semantic/bovine/grammar.el" nil t)
  load("semantic/bovine/grammar" nil t)
  command-line-1(("--eval" "(setq load-prefer-newer t)" "-l" "semantic/bovine/grammar" "-f" "bovine-batch-make-parser" "-o" "../../lisp/cedet/semantic/bovine/c-by.el" "c.by"))
  command-line()
  normal-top-level()
$ "../../src/emacs" "-batch" "--no-site-file" "--no-site-lisp" "--eval" "(setq load-prefer-newer t)" "-l" "semantic/bovine/grammar" "-f" "bovine-batch-make-parser" "-o" "../../lisp/cedet/semantic/bovine/c-by.el" "c.by"
[Message part 2 (text/html, inline)]
[0001-lisp-emacs-lisp-find-func.el-Fix-Eager-macro-expansi.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78446; Package emacs. (Sat, 17 May 2025 10:08:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Lin Sun <sunlin7 <at> hotmail.com>,
 Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 78446 <at> debbugs.gnu.org
Subject: Re: bug#78446: [PATCH] * lisp/emacs-lisp/find-func.el: Fix Eager
 macro-expansion failure
Date: Sat, 17 May 2025 13:06:51 +0300
> From: Lin Sun <sunlin7 <at> hotmail.com>
> Date: Thu, 15 May 2025 22:14:35 +0000
> 
> A build error happened as follow (I upgrade to latest  version
> db198e0e59bff0c1cb28a591928377f5a0e9d158),
> This patch will fix the build error. 
> 
> Error: error ("Eager macro-expansion failure: (wrong-type-argument symbolp 'find-function-mode)")
>   signal(error ("Eager macro-expansion failure: (wrong-type-argument symbolp 'find-function-mode)"))
>   error("Eager macro-expansion failure: %S" (wrong-type-argument symbolp 'find-function-mode))
>   internal-macroexpand-for-load((custom-declare-variable 'find-function-mode-lower-precedence `(funcall #',
> (lambda nil "" nil)) "If non-nil, `find-function-mode' defines keys in the global map.\nThis is for compatibility
> with the historical behavior of\nthe old `find-function-setup-keys'." :type 'boolean :version "31.1" :group
> 'find-function :set (lambda (symbol value) "hello" (let ((already-on (bound-and-true-p 'find-function-mode)))
> (when already-on (find-function-mode -1)) (set-default symbol value) (when already-on (find-function-mode
> 1))))) t)
>   eval-buffer(#<buffer  *load*-728608> nil "/tmp/emacs-dbg/lisp/emacs-lisp/find-func.el" nil t)
>   load-with-code-conversion("/tmp/emacs-dbg/lisp/emacs-lisp/find-func.el"
> "/tmp/emacs-dbg/lisp/emacs-lisp/find-func.el" nil t)
>   require(find-func)
>   eval-buffer(#<buffer  *load*-987386> nil "/tmp/emacs-dbg/lisp/cedet/mode-local.el" nil t)
>   load-with-code-conversion("/tmp/emacs-dbg/lisp/cedet/mode-local.el"
> "/tmp/emacs-dbg/lisp/cedet/mode-local.el" nil t)
>   require(mode-local)
>   eval-buffer(#<buffer  *load*-671861> nil "/tmp/emacs-dbg/lisp/cedet/semantic/fw.el" nil t)
>   load-with-code-conversion("/tmp/emacs-dbg/lisp/cedet/semantic/fw.el"
> "/tmp/emacs-dbg/lisp/cedet/semantic/fw.el" nil t)
>   require(semantic/fw)
>   eval-buffer(#<buffer  *load*-479974> nil "/tmp/emacs-dbg/lisp/cedet/semantic/tag.el" nil t)
>   load-with-code-conversion("/tmp/emacs-dbg/lisp/cedet/semantic/tag.el"
> "/tmp/emacs-dbg/lisp/cedet/semantic/tag.el" nil t)
>   require(semantic/tag)
>   eval-buffer(#<buffer  *load*-715339> nil "/tmp/emacs-dbg/lisp/cedet/semantic.el" nil t)
>   load-with-code-conversion("/tmp/emacs-dbg/lisp/cedet/semantic.el"
> "/tmp/emacs-dbg/lisp/cedet/semantic.el" nil t)
>   require(semantic)
>   eval-buffer(#<buffer  *load*> nil "/tmp/emacs-dbg/lisp/cedet/semantic/bovine/grammar.el" nil t)
>   load-with-code-conversion("/tmp/emacs-dbg/lisp/cedet/semantic/bovine/grammar.el"
> "/tmp/emacs-dbg/lisp/cedet/semantic/bovine/grammar.el" nil t)
>   load("semantic/bovine/grammar" nil t)
>   command-line-1(("--eval" "(setq load-prefer-newer t)" "-l" "semantic/bovine/grammar" "-f"
> "bovine-batch-make-parser" "-o" "../../lisp/cedet/semantic/bovine/c-by.el" "c.by"))
>   command-line()
>   normal-top-level()
> $ "../../src/emacs" "-batch" "--no-site-file" "--no-site-lisp" "--eval" "(setq load-prefer-newer t)" "-l"
> "semantic/bovine/grammar" "-f" "bovine-batch-make-parser" "-o" "../../lisp/cedet/semantic/bovine/c-by.el"
> "c.by"

I'm not sure I understand how this happened to you.  Was that a
bootstrap build?

Stefan, any comments or suggestions?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78446; Package emacs. (Tue, 20 May 2025 03:06:01 GMT) Full text and rfc822 format available.

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

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: Lin Sun <sunlin7 <at> hotmail.com>, 78446 <at> debbugs.gnu.org,
 Sean Whitton <spwhitton <at> spwhitton.name>
Subject: Re: bug#78446: [PATCH] * lisp/emacs-lisp/find-func.el: Fix Eager
 macro-expansion failure
Date: Mon, 19 May 2025 23:05:26 -0400
Eli Zaretskii [2025-05-17 13:06:51] wrote:
>> Error: error ("Eager macro-expansion failure: (wrong-type-argument symbolp 'find-function-mode)")
>>   signal(error ("Eager macro-expansion failure: (wrong-type-argument
>> symbolp 'find-function-mode)"))
>>   error("Eager macro-expansion failure: %S" (wrong-type-argument symbolp 'find-function-mode))
>>   internal-macroexpand-for-load((custom-declare-variable
>> 'find-function-mode-lower-precedence `(funcall #',
>> (lambda nil "" nil)) "If non-nil, `find-function-mode' defines keys in the
>> global map.\nThis is for compatibility
>> with the historical behavior of\nthe old
>> `find-function-setup-keys'." :type 'boolean :version "31.1" :group
>> 'find-function :set (lambda (symbol value) "hello" (let ((already-on
>> (bound-and-true-p 'find-function-mode)))
>> (when already-on (find-function-mode -1)) (set-default symbol value) (when
>> already-on (find-function-mode
>> 1))))) t)
>>   eval-buffer(#<buffer  *load*-728608> nil "/tmp/emacs-dbg/lisp/emacs-lisp/find-func.el" nil t)
>>   load-with-code-conversion("/tmp/emacs-dbg/lisp/emacs-lisp/find-func.el"
>> "/tmp/emacs-dbg/lisp/emacs-lisp/find-func.el" nil t)
>>   require(find-func)
[...]
> I'm not sure I understand how this happened to you.  Was that a
> bootstrap build?

This seems to come from:

    commit 57cef07710d91988b6332ad3ed2f5c4b4b371585
    Author: Sean Whitton <spwhitton <at> spwhitton.name>
    Date:   Sun Mar 9 21:49:44 2025 +0800
    
        Restore find-function-mode-map (bug#76700)
        
        * lisp/emacs-lisp/find-func.el
        (find-function-mode-lower-precedence): New option.
        (find-function-mode-map): Restore.
        (find-function-mode): Don't unconditionally bind keys into the
        global map.  Instead respond to the new user option (bug#76700).
        * etc/NEWS: Mention the new option in existing entry.

because the `:set`ter of `find-function-mode-lower-precedence` uses
functions and variables which are defined only later in the file.
Either it needs to be moved such that when the setter is run we're sure
those vars and functions are available, or it needs to use `(f)boundp`
checks.


        Stefan





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78446; Package emacs. (Tue, 20 May 2025 08:57:02 GMT) Full text and rfc822 format available.

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

From: Sean Whitton <spwhitton <at> spwhitton.name>
To: Eli Zaretskii <eliz <at> gnu.org>, Stefan Monnier <monnier <at> iro.umontreal.ca>,
 Lin Sun <sunlin7 <at> hotmail.com>,  78446 <at> debbugs.gnu.org
Subject: Re: bug#78446: [PATCH] * lisp/emacs-lisp/find-func.el: Fix Eager
 macro-expansion failure
Date: Tue, 20 May 2025 09:55:57 +0100
Hello,

Does this fix it:

> diff --git a/lisp/emacs-lisp/find-func.el b/lisp/emacs-lisp/find-func.el
> index 6bdfb4bc38b..717bac09c81 100644
> --- a/lisp/emacs-lisp/find-func.el
> +++ b/lisp/emacs-lisp/find-func.el
> @@ -207,7 +207,7 @@ find-function-mode-lower-precedence
>    :set (lambda (symbol value)
>           ;; Toggle the mode off before changing this setting in order to
>           ;; avoid getting into an inconsistent state.
> -         (let ((already-on find-function-mode))
> +         (let ((already-on (bound-and-true-p find-function-mode)))
>             (when already-on (find-function-mode -1))
>             (set-default symbol value)
>             (when already-on (find-function-mode 1)))))

-- 
Sean Whitton




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78446; Package emacs. (Tue, 20 May 2025 12:46:01 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Sean Whitton <spwhitton <at> spwhitton.name>
Cc: sunlin7 <at> hotmail.com, monnier <at> iro.umontreal.ca, 78446 <at> debbugs.gnu.org
Subject: Re: bug#78446: [PATCH] * lisp/emacs-lisp/find-func.el: Fix Eager
 macro-expansion failure
Date: Tue, 20 May 2025 15:44:58 +0300
> From: Sean Whitton <spwhitton <at> spwhitton.name>
> Date: Tue, 20 May 2025 09:55:57 +0100
> 
> Hello,
> 
> Does this fix it:
> 
> > diff --git a/lisp/emacs-lisp/find-func.el b/lisp/emacs-lisp/find-func.el
> > index 6bdfb4bc38b..717bac09c81 100644
> > --- a/lisp/emacs-lisp/find-func.el
> > +++ b/lisp/emacs-lisp/find-func.el
> > @@ -207,7 +207,7 @@ find-function-mode-lower-precedence
> >    :set (lambda (symbol value)
> >           ;; Toggle the mode off before changing this setting in order to
> >           ;; avoid getting into an inconsistent state.
> > -         (let ((already-on find-function-mode))
> > +         (let ((already-on (bound-and-true-p find-function-mode)))
> >             (when already-on (find-function-mode -1))
> >             (set-default symbol value)
> >             (when already-on (find-function-mode 1)))))

I'd prefer the other solution, to move the setter function before its
first use, or its first use after the function is defined.  The
bound-and-true-p use looks strange in a file that defines the
function.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78446; Package emacs. (Wed, 21 May 2025 06:42:02 GMT) Full text and rfc822 format available.

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

From: Lin Sun <sunlin7 <at> hotmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>, Sean Whitton <spwhitton <at> spwhitton.name>
Cc: "monnier <at> iro.umontreal.ca" <monnier <at> iro.umontreal.ca>,
 "78446 <at> debbugs.gnu.org" <78446 <at> debbugs.gnu.org>
Subject: Re: bug#78446: [PATCH] * lisp/emacs-lisp/find-func.el: Fix Eager
 macro-expansion failure
Date: Wed, 21 May 2025 06:41:24 +0000
[Message part 1 (text/plain, inline)]
From: Eli Zaretskii <eliz <at> gnu.org>
Sent: Tuesday, May 20, 2025 12:45 PM
> I'd prefer the other solution, to move the setter function before its
> first use, or its first use after the function is defined.  The
> bound-and-true-p use looks strange in a file that defines the
> function.


Agree, and that's should be better.
I found the lisp/jka-cmpr-hook.el:57 has similar behavior that (defvar jka-compr-compression-info-list) first, then defcustom it on the tail for everything been ready.

I attach the patch with defvar find-function-mode-lower-precedence first, then defcustom it at the tail of the file find-func.el (similarly to the jka-comp-hook.el).

Please help review again. Thank you!
[0001-lisp-emacs-lisp-find-func.el-Fix-Eager-macro-expansi.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78446; Package emacs. (Wed, 21 May 2025 12:12:02 GMT) Full text and rfc822 format available.

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

From: Sean Whitton <spwhitton <at> spwhitton.name>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: sunlin7 <at> hotmail.com, monnier <at> iro.umontreal.ca, 78446 <at> debbugs.gnu.org
Subject: Re: bug#78446: [PATCH] * lisp/emacs-lisp/find-func.el: Fix Eager
 macro-expansion failure
Date: Wed, 21 May 2025 13:11:04 +0100
Hello,

On Tue 20 May 2025 at 03:44pm +03, Eli Zaretskii wrote:

> I'd prefer the other solution, to move the setter function before its
> first use, or its first use after the function is defined.  The
> bound-and-true-p use looks strange in a file that defines the
> function.

Yes, good point.

Lin's patch looks good to me; I would prefer review from Eli and/or
Stefan before installing it.

-- 
Sean Whitton




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78446; Package emacs. (Wed, 21 May 2025 13:18:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Sean Whitton <spwhitton <at> spwhitton.name>
Cc: sunlin7 <at> hotmail.com, monnier <at> iro.umontreal.ca, 78446 <at> debbugs.gnu.org
Subject: Re: bug#78446: [PATCH] * lisp/emacs-lisp/find-func.el: Fix Eager
 macro-expansion failure
Date: Wed, 21 May 2025 16:17:10 +0300
> From: Sean Whitton <spwhitton <at> spwhitton.name>
> Cc: sunlin7 <at> hotmail.com,  monnier <at> iro.umontreal.ca,  78446 <at> debbugs.gnu.org
> Date: Wed, 21 May 2025 13:11:04 +0100
> 
> Hello,
> 
> On Tue 20 May 2025 at 03:44pm +03, Eli Zaretskii wrote:
> 
> > I'd prefer the other solution, to move the setter function before its
> > first use, or its first use after the function is defined.  The
> > bound-and-true-p use looks strange in a file that defines the
> > function.
> 
> Yes, good point.
> 
> Lin's patch looks good to me; I would prefer review from Eli and/or
> Stefan before installing it.

It just moves a function into another place in the file, right?

LGTM, except that the comment should begin with a capital letter.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78446; Package emacs. (Wed, 21 May 2025 15:17:01 GMT) Full text and rfc822 format available.

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

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: sunlin7 <at> hotmail.com, 78446 <at> debbugs.gnu.org,
 Sean Whitton <spwhitton <at> spwhitton.name>
Subject: Re: bug#78446: [PATCH] * lisp/emacs-lisp/find-func.el: Fix Eager
 macro-expansion failure
Date: Wed, 21 May 2025 11:16:17 -0400
> LGTM, except that the comment should begin with a capital letter.

+1


        Stefan





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78446; Package emacs. (Wed, 21 May 2025 15:41:01 GMT) Full text and rfc822 format available.

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

From: Lin Sun <sunlin7 <at> hotmail.com>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>, Eli Zaretskii <eliz <at> gnu.org>
Cc: "78446 <at> debbugs.gnu.org" <78446 <at> debbugs.gnu.org>,
 Sean Whitton <spwhitton <at> spwhitton.name>
Subject: Re: bug#78446: [PATCH] * lisp/emacs-lisp/find-func.el: Fix Eager
 macro-expansion failure
Date: Wed, 21 May 2025 15:40:16 +0000
[Message part 1 (text/plain, inline)]
> LGTM, except that the comment should begin with a capital letter.

Sure, fixed in the attached patch. Thanks all of you.
[Message part 2 (text/html, inline)]
[0001-lisp-emacs-lisp-find-func.el-Fix-Eager-macro-expansi.patch (text/x-patch, attachment)]

Reply sent to Stefan Monnier <monnier <at> iro.umontreal.ca>:
You have taken responsibility. (Wed, 21 May 2025 17:20:03 GMT) Full text and rfc822 format available.

Notification sent to Lin Sun <sunlin7 <at> hotmail.com>:
bug acknowledged by developer. (Wed, 21 May 2025 17:20:04 GMT) Full text and rfc822 format available.

Message #37 received at 78446-done <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Lin Sun <sunlin7 <at> hotmail.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>,
 "78446 <at> debbugs.gnu.org" <78446-done <at> debbugs.gnu.org>,
 Sean Whitton <spwhitton <at> spwhitton.name>
Subject: Re: bug#78446: [PATCH] * lisp/emacs-lisp/find-func.el: Fix Eager
 macro-expansion failure
Date: Wed, 21 May 2025 13:19:16 -0400
>> LGTM, except that the comment should begin with a capital letter.
> Sure, fixed in the attached patch. Thanks all of you.

Thanks, pushed to `master`.


        Stefan





This bug report was last modified 16 days ago.

Previous Next


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