Subject: Re: bug#65411: 29.1; setopt of xref-after-jump-hook gives warning

From: Eli Zaretskii <[email-masked]>
Date: Sun, 20 Aug 2023 21:12:28 +0300

> From: Howard Melman <[email-masked]>
> Date: Sun, 20 Aug 2023 12:12:13 -0400
> Cc: [email-masked]
> 
> On Aug 20, 2023, at 11:36 AM, Eli Zaretskii <[email-masked]> wrote:
> > 
> >> From: Howard Melman <[email-masked]>
> >> Date: Sun, 20 Aug 2023 11:03:50 -0400
> >> 
> >> 
> >> In Emacs 29.1 should I be able to do this:
> >> 
> >>    (setopt xref-after-jump-hook '(reposition-window xref-pulse-momentarily))
> >> 
> >> When I do in my init and then use xref-find-definition I get this warning:
> >> 
> >>    ⛔ Warning (emacs): Value `((reposition-window xref-pulse-momentarily))' for `xref-after-jump-hook' does not match type hook
> > 
> > xref-pulse-momentarily is not an autoloaded function, and xref.el is
> > not preloaded.  You need to load xref.el, and then the above will
> > work; it does for me.
> 
> Thanks very much. Indeed, doing this works fine for me:
> 
> (with-eval-after-load 'xref
>   (setopt xref-after-jump-hook '(reposition-window xref-pulse-momentarily)))
> 
> Also I found doing (just) this works fine:
> 
> (setq xref-after-jump-hook '(reposition-window xref-pulse-momentarily))
> 
> So why does it fail using setopt?

Because until xref is loaded, Emacs doesn't know that
'xref-pulse-momentarily' is a symbol of function, whereas the
defcustom's type is 'hook', which stands for "a list of functions".