all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Howard Melman <hmelman@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 65411@debbugs.gnu.org
Subject: bug#65411: 29.1; setopt of xref-after-jump-hook gives warning
Date: Mon, 21 Aug 2023 09:19:23 -0400	[thread overview]
Message-ID: <BB9BB609-E7D3-4F91-B931-B7B3AD9EECD9@gmail.com> (raw)
In-Reply-To: <83jztovc3g.fsf@gnu.org>



> On Aug 21, 2023, at 8:01 AM, Eli Zaretskii <eliz@gnu.org> wrote:
> 
>> From: Howard Melman <hmelman@gmail.com>
>> Date: Sun, 20 Aug 2023 20:21:39 -0400
>> Cc: 65411@debbugs.gnu.org
>> 
>>>> 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".
>> 
>> Well, that must be correct because doing this also worked fine:
>> 
>>  (declare-function xref-pulse-momentarily "xref" ())
>>  (setopt xref-after-jump-hook '(reposition-window xref-pulse-momentarily))
>> 

Thanks for the continued responses.

>> So I guess setopt defers the type check?
> 
> No, it just verifies that the symbol's function slot is valid.

I'd call that part of the type check, is it doing other stuff too?

>> I get the error when the hook is run (at which time xref is loaded
>> so I'm still confused about that).
> 
> declare-function doesn't provider an actual function definition, it
> just provides a declaration.  IOW, you lie to Emacs, and Emacs bites
> you when it can ;-)

Yes, I understand declare-function, but it feels extra mean that
Emacs decides it wants to bite for something and waits until after
I correct that to do so. ;)

>> I'm familiar with reading the lisp code but the innards of custom and
>> the c code are a bit beyond me.  Is it the custom-check-value property
>> in setopt--set?
> 
> Yes.
> 
>> If I'm supposed to resolve this warning on my own, then a comment
>> in setopt--set or something in setopt's docstring (or the manual)
>> mentioning the asynchrony would help.
> 
> setopt is a non-interactive version of defcustom.  Like defcustom will
> not accept a value that contradicts the :type of the option, so will
> setopt.  I don't think there's anything subtle to be documented here.

But something seems off.  Let me reiterate, I put this in my init:

    (setopt xref-after-jump-hook '(reposition-window xref-pulse-momentarily))

The value is properly formatted and is what custom would store in
custom-file had I used M-x custom.  In fact, if put this in the
custom-file's custom-set-variables' call:

    '(xref-after-jump-hook '(reposition-window xref-pulse-momentarily))

and restart emacs, it works fine, with no warning at init or run time.

So setopt behaves differently than defcustom, for the same value,
giving an unclear warning (with extra parentheses around the value
which I didn't put there and not mentioning anything being undefined)
at an odd time where the cause is already resolved at warning time.

I don't see how "Like defcustom will not accept a value that
contradicts the :type of the option, so will setopt." is the issue
here.

Howard








      reply	other threads:[~2023-08-21 13:19 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-20 15:03 bug#65411: 29.1; setopt of xref-after-jump-hook gives warning Howard Melman
2023-08-20 15:36 ` Eli Zaretskii
2023-08-20 16:12   ` Howard Melman
2023-08-20 18:12     ` Eli Zaretskii
2023-08-21  0:21       ` Howard Melman
2023-08-21 12:01         ` Eli Zaretskii
2023-08-21 13:19           ` Howard Melman [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=BB9BB609-E7D3-4F91-B931-B7B3AD9EECD9@gmail.com \
    --to=hmelman@gmail.com \
    --cc=65411@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.