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

From: Stefan Monnier <[email-masked]>
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 <[email-masked]>
    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