all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#65411: 29.1; setopt of xref-after-jump-hook gives warning
@ 2023-08-20 15:03 Howard Melman
  2023-08-20 15:36 ` Eli Zaretskii
  0 siblings, 1 reply; 7+ messages in thread
From: Howard Melman @ 2023-08-20 15:03 UTC (permalink / raw)
  To: 65411


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

(FYI, I'm doing this in the macport and haven't tried it yet
in GNU Emacs)

I thought I could because I copied the format from xref.el:

	(defcustom xref-after-jump-hook '(recenter
	                                  xref-pulse-momentarily)

and if instead I do this:

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

and check the value of xref-after-jump-hook it is:

    (reposition-window xref-pulse-momentarily)

which is what I want but confuses me why recenter from the
default value isn't there.  I don't see xref-after-jump-hook used
anywhere else in my init or installed packages.

Howard




In GNU Emacs 29.1 (build 1, x86_64-apple-darwin21.6.0,
Carbon Version 165 AppKit 2113.6) of 2023-08-08 built on
Mac-1691500888998.local
Repository revision: e173249a143cee72d59ae78c4e11038512f5a00f
Repository branch: 29.1-mac-10.0
Windowing system distributor 'Apple Inc.', version 12.6.8
System Description:  macOS 12.6.8

Configured using:
'configure --with-mac
--enable-locallisppath=/usr/local/share/emacs/site-lisp:/opt/homebrew/share/emacs/site-lisp
--enable-mac-app=/Users/runner/work/homebrew-emacsmacport/homebrew-emacsmacport/build-scripts/build_out/tmproot
--prefix=/Users/runner/work/homebrew-emacsmacport/homebrew-emacsmacport/build-scripts/build_out/tmproot
--enable-mac-self-contained --with-modules --with-xwidgets
--with-tree-sitter --without-lcms2 --without-webp'

Configured features:
ACL GMP GNUTLS JSON LIBXML2 MODULES NOTIFY KQUEUE PDUMPER
SQLITE3 THREADS TOOLKIT_SCROLL_BARS TREE_SITTER XWIDGETS
ZLIB

Important settings:
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: GFM

Minor modes in effect:
  flyspell-mode: t
  writegood-mode: t
  recentf-mode: t
  outline-minor-mode: t
  wrap-region-mode: t
  diff-hl-flydiff-mode: t
  server-mode: t
  marginalia-mode: t
  corfu-indexed-mode: t
  corfu-history-mode: t
  global-corfu-mode: t
  corfu-mode: t
  vertico-multiform-mode: t
  savehist-mode: t
  vertico-mode: t
  which-key-mode: t
  global-hl-todo-mode: t
  hl-todo-mode: t
  beacon-mode: t
  global-page-break-lines-mode: t
  gcmh-mode: t
  repeat-mode: t
  global-hl-line-mode: t
  which-function-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mac-mouse-wheel-mode: t
  tool-bar-mode: t
  prettify-symbols-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  context-menu-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  size-indication-mode: t
  column-number-mode: t
  line-number-mode: t
  visual-line-mode: t
  indent-tabs-mode: t
  transient-mark-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  abbrev-mode: t

Load-path shadows:
/Users/hmelman/.emacs.d/elpa/transient-20230812.2142/transient hides /Applications/Emacs.app/Contents/Resources/lisp/transient
/Users/hmelman/.emacs.d/elpa/eglot-20221020.1010/eglot hides /Applications/Emacs.app/Contents/Resources/lisp/progmodes/eglot

Features:
(shadow sort mail-extr hippie-exp emacsbug message
yank-media puny rfc822 mml mml-sec epa derived epg rfc6068
epg-config gnus-util mm-decode mm-bodies mm-encode
mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail
rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils
autorevert filenotify notes3 embark-consult embark ffap
info-colors helpful cc-langs cc-vars cc-defs trace edebug
debug backtrace info-look f f-shortdoc elisp-refs s rect
dabbrev dired dired-loaddefs mwim mule-util orderless
flyspell ispell writegood-mode face-remap markdown-mode
edit-indirect easy-kill pulse color reposition help-fns
radix-tree find-func consult-xref consult bookmark thingatpt
xref warnings project char-fold misearch multi-isearch
vc-git recentf tree-widget rg files-x rg-info-hack rg-menu
rg-ibuffer rg-result wgrep-rg wgrep rg-history rg-header
ibuf-ext ibuffer ibuffer-loaddefs grep compile
text-property-search comint ansi-osc ansi-color time-date
vertico-directory exec-path-from-shell add-log jka-compr
disp-table bug-reference lisp-mnt noutline outline
wrap-region dash diff-hl-flydiff diff diff-hl log-view
pcvs-util vc-dir ewoc vc vc-dispatcher diff-mode easy-mmode
server marginalia corfu-indexed corfu-history corfu
vertico-multiform savehist vertico package-commits ace-link
avy ring which-key hl-todo dim beacon page-break-lines gcmh
cus-edit pp cus-load icons wid-edit repeat hl-line
which-func imenu hrm-tabs saveplace cape-autoloads
corfu-autoloads diff-hl-autoloads consult-autoloads
embark-autoloads exec-path-from-shell-autoloads
flycheck-autoloads gptel-autoloads helpful-autoloads
json-mode-autoloads rx literate-calc-mode-autoloads
magit-todos-autoloads magit-autoloads pcase
magit-section-autoloads hl-todo-autoloads
marginalia-autoloads mastodon-autoloads org-modern-autoloads
package-lint-autoloads page-break-lines-autoloads transient
cl-extra help-mode format-spec edmacro kmacro compat
compat-29 reformatter-autoloads rust-mode-autoloads
markdown-mode-autoloads transient-autoloads advice info
package browse-url url url-proxy url-privacy url-expand
url-methods url-history url-cookie generate-lisp-file
url-domsuf url-util mailcap url-handlers url-parse
auth-source cl-seq eieio eieio-core cl-macs password-cache
json subr-x map byte-opt gv bytecomp byte-compile url-vars
cl-loaddefs cl-lib rmc iso-transl tooltip cconv eldoc paren
electric uniquify ediff-hook vc-hooks lisp-float-type
elisp-mode mwheel term/mac-win mac-win term/common-win
tool-bar dnd fontset image regexp-opt fringe tabulated-list
replace newcomment text-mode lisp-mode prog-mode register
page tab-bar menu-bar rfn-eshadow isearch easymenu timer
select scroll-bar mouse jit-lock font-lock syntax font-core
term/tty-colors frame minibuffer nadvice seq simple
cl-generic indonesian philippine cham georgian utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao korean
japanese eucjp-ms cp51932 hebrew greek romanian slovak czech
european ethiopic indian cyrillic chinese composite
emoji-zwj charscript charprop case-table epa-hook
jka-cmpr-hook help abbrev obarray oclosure cl-preloaded
button loaddefs theme-loaddefs faces cus-face macroexp files
window text-properties overlay sha1 md5 base64 format env
code-pages mule custom widget keymap
hashtable-print-readable backquote threads xwidget-internal
kqueue mac multi-tty make-network-process emacs)

Memory information:
((conses 16 277984 207394)
(symbols 48 23953 7)
(strings 32 108960 65911)
(string-bytes 1 3474112)
(vectors 16 50528)
(vector-slots 8 1308035 602096)
(floats 8 533 1057)
(intervals 56 1493 1393)
(buffers 984 18))

-- 

Howard





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#65411: 29.1; setopt of xref-after-jump-hook gives warning
  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
  0 siblings, 1 reply; 7+ messages in thread
From: Eli Zaretskii @ 2023-08-20 15:36 UTC (permalink / raw)
  To: Howard Melman; +Cc: 65411

> From: Howard Melman <hmelman@gmail.com>
> 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.





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#65411: 29.1; setopt of xref-after-jump-hook gives warning
  2023-08-20 15:36 ` Eli Zaretskii
@ 2023-08-20 16:12   ` Howard Melman
  2023-08-20 18:12     ` Eli Zaretskii
  0 siblings, 1 reply; 7+ messages in thread
From: Howard Melman @ 2023-08-20 16:12 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 65411

On Aug 20, 2023, at 11:36 AM, Eli Zaretskii <eliz@gnu.org> wrote:
> 
>> From: Howard Melman <hmelman@gmail.com>
>> 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?  AFAIU the xref-pulse-momentarily in the value
is just a symbol and I don't see the warning until I call xref-find-definition which
loads xref. And it works using setq without loading xref.

The warning shows double parentheses which I also don't understand how 
that happened (I see it does some widget conversion).  If there's some extra
restriction on using setopt to set hooks (which are user options), could it be 
explained in the manual or docstring?

Howard





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#65411: 29.1; setopt of xref-after-jump-hook gives warning
  2023-08-20 16:12   ` Howard Melman
@ 2023-08-20 18:12     ` Eli Zaretskii
  2023-08-21  0:21       ` Howard Melman
  0 siblings, 1 reply; 7+ messages in thread
From: Eli Zaretskii @ 2023-08-20 18:12 UTC (permalink / raw)
  To: Howard Melman; +Cc: 65411

> From: Howard Melman <hmelman@gmail.com>
> Date: Sun, 20 Aug 2023 12:12:13 -0400
> Cc: 65411@debbugs.gnu.org
> 
> On Aug 20, 2023, at 11:36 AM, Eli Zaretskii <eliz@gnu.org> wrote:
> > 
> >> From: Howard Melman <hmelman@gmail.com>
> >> 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".





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#65411: 29.1; setopt of xref-after-jump-hook gives warning
  2023-08-20 18:12     ` Eli Zaretskii
@ 2023-08-21  0:21       ` Howard Melman
  2023-08-21 12:01         ` Eli Zaretskii
  0 siblings, 1 reply; 7+ messages in thread
From: Howard Melman @ 2023-08-21  0:21 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 65411



> On Aug 20, 2023, at 2:12 PM, Eli Zaretskii <eliz@gnu.org> wrote:
> 
>> From: Howard Melman <hmelman@gmail.com>
>> Date: Sun, 20 Aug 2023 12:12:13 -0400
>> Cc: 65411@debbugs.gnu.org
>> 
>> 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".

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))

So I guess setopt defers the type check? I get the error when the
hook is run (at which time xref is loaded so I'm still confused about
that).

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?

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.

Howard




^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#65411: 29.1; setopt of xref-after-jump-hook gives warning
  2023-08-21  0:21       ` Howard Melman
@ 2023-08-21 12:01         ` Eli Zaretskii
  2023-08-21 13:19           ` Howard Melman
  0 siblings, 1 reply; 7+ messages in thread
From: Eli Zaretskii @ 2023-08-21 12:01 UTC (permalink / raw)
  To: Howard Melman; +Cc: 65411

> 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))
> 
> So I guess setopt defers the type check?

No, it just verifies that the symbol's function slot is valid.

> 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 ;-)

> 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.





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#65411: 29.1; setopt of xref-after-jump-hook gives warning
  2023-08-21 12:01         ` Eli Zaretskii
@ 2023-08-21 13:19           ` Howard Melman
  0 siblings, 0 replies; 7+ messages in thread
From: Howard Melman @ 2023-08-21 13:19 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 65411



> 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








^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-08-21 13:19 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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

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.