Subject: bug#59559: 28.1; `minibuffer-with-setup-hook' with :append

From: Michael Heerdegen <[email-masked]>
Date: Mon, 23 Jan 2023 01:15:37 +0100

Drew Adams <[email-masked]> writes:

> Whether FUN is or is not of that :append form, per
> your presumption - "the terminology used in the rest
> of Emacs", the UNevaluated sexp is meant.  But that's
> not the case here.
>
> Try it:
>
> (defun toto () (message "@@@@@@@@@@@@@@"))
> (minibuffer-with-setup-hook toto (message "************"))
>
> Debugger entered--Lisp error: (void-variable toto)
>   (let ((fun toto)
>     (setup-hook (make-symbol "minibuffer-setup")))
>     (fset setup-hook
>           #'(lambda nil
>               (remove-hook 'minibuffer-setup-hook setup-hook)
>               (funcall fun)))
>     (unwind-protect (progn (add-hook 'minibuffer-setup-hook setup-hook)
>                            (message "************"))
>       (remove-hook 'minibuffer-setup-hook setup-hook)))
>
> Not to mention that the unevaluated form (:append toto)
> also exhibits the same problem - it too doesn't fit
> "the terminology used in the rest of Emacs".

Well yes, I know, I expected that behavior after reading the docstring.
You obviously don't.

Nowhere is said that FUN should be a function _name_ or a symbol.

Unless stated otherwise, what you specify as an argument is an
expression.  Here only with the exception that two syntaxes are
possible, the alternative one is a list, like we e.g. know from cl
arglists.

My patch tried to make that part clearer: the argument is of the form
FUN or (:append FUN) (an macro _argument_ described as of a certain form
always speaks about the unevaluated s-exp), and FUN is an expression
evaluating to the function that will be added to the hook.

Michael.