* Variable predicate
@ 2024-09-24 12:25 Garklein
2024-09-25 15:47 ` Sebastián Monía
0 siblings, 1 reply; 2+ messages in thread
From: Garklein @ 2024-09-24 12:25 UTC (permalink / raw)
To: emacs-devel
In help-fns.el, two different ways are used to check if a symbol is a variable.
`describe-function' uses
(lambda (vv)
(or (get vv 'variable-documentation)
(and (not (keywordp vv))
;; Since the variable may only exist in the
;; original buffer, we have to look for it
;; there.
(buffer-local-boundp vv orig-buffer))))
and `variable-at-point' just uses `boundp'.
Is there any difference between these two methods? Which should I use?
Thank you,
Garklein
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Variable predicate
2024-09-24 12:25 Variable predicate Garklein
@ 2024-09-25 15:47 ` Sebastián Monía
0 siblings, 0 replies; 2+ messages in thread
From: Sebastián Monía @ 2024-09-25 15:47 UTC (permalink / raw)
To: Garklein; +Cc: emacs-devel
Hi Garklein,
I am not sure I am the most qualified person to reply, but if I am
wrong, we'll get corrections soon enough ;)
Garklein <garklein97@gmail.com> writes:
> In help-fns.el, two different ways are used to check if a symbol is a
> variable.
>
> `describe-function' uses
>
> (lambda (vv)
> (or (get vv 'variable-documentation)
> (and (not (keywordp vv))
> ;; Since the variable may only exist in the
> ;; original buffer, we have to look for it
> ;; there.
> (buffer-local-boundp vv orig-buffer))))
After checking the code, I think you meant this is how
'describe-variable' works.
The predicate is not checking "is the symbol a variable", but if it has
a documentation slot in its property list, -or- if it is bound
buffer-local.
The selection of symbols to run by the predicate comes from
help--symbol-completion-table which does....a lot more.
> and `variable-at-point' just uses `boundp'.
You can check this one using `describe-function' on `boundp' :)
> Is there any difference between these two methods? Which should I use?
They do very different things, if you _only_ want to know if a symbol
has been bound as a variable, boundp should be enough.
Hope that helps!
--
Sebastián Monía
https://site.sebasmonia.com/
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-09-25 15:47 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-24 12:25 Variable predicate Garklein
2024-09-25 15:47 ` Sebastián Monía
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).