* Is there a `find-function-noselect' that does not resolve aliases?
@ 2022-01-18 5:08 Eduardo Ochs
2022-01-18 6:07 ` Emanuel Berg via Users list for the GNU Emacs text editor
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Eduardo Ochs @ 2022-01-18 5:08 UTC (permalink / raw)
To: help-gnu-emacs
Hi list,
what is the recommended low-level way to jump to the definition of an
alias? Let me explain my question with a concrete example... if we run
this on a shell,
cat > /tmp/my.el <<'--snip--snip--'
(defalias 'myalias1 'myalias2)
(defalias 'myalias2 'myalias3)
(defalias 'myalias3 'myfunction)
(defun myfunction () 42)
'(
(load (buffer-file-name))
;; This jumps to the definition of `myfunction':
(find-function-noselect 'myalias2)
;; The sexp below generates a "*Help*" buffer in which the
;; first line has a button whose text is "/tmp/my.el".
;; Its action is to jump to the definition of `myalias2'.
(describe-function 'myalias2)
)
--snip--snip--
it will create a file /tmp/my.el that defines three aliases and a
function, and then it has a quoted list that is treated as a comment.
That quoted list contains three sexps that are to be run by hand with
`C-e C-x C-e' or your favorite variation of that.
If we run those three sexps then the first one will load that file.
The second one,
(find-function-noselect 'myalias2)
will (sort of) jump to the definition of the function `myfunction',
instead of to the definition of the alias `myalias2' - so it "resolves
the alias" somehow... but if we run the third sexp, that is
(describe-function 'myalias2)
and we click on its button "/tmp/my.el" then this will jump to the
definition of the alias `myalias2'... so somewhere in the code
associated to that button there's a low-level way of jumping to the
definition of an alias "WITHOUT resolving the alias".
The problem is that the code of that button is too intrincate for me.
I've tried `M-x describe-button', I've tried to inspect its text
properties, I found that on that button the key RET is bound to
`push-button', and I've tried to understand the code of `push-button'
and `help-function-def--button-function', but I'm stuck. Or rather: my
brain is too tiny, and I'm tired. Help, please! =(
Cheers,
Eduardo Ochs
http://angg.twu.net/
P.S.: here's a bit more of context. If we run one of these sexps in
eev - they're equivalent -
(find-efunction-links 'myalias2)
(eek "M-h M-f myalias2")
we get a temporary buffer with lots of sexps "about myalias2". One of
these sexps is:
(find-efunction 'myalias2)
that interprets the result of
(find-function-noselect 'myalias2)
in the right way, and jumps to the definition of the function that
`myalias2' point to. I am trying to write a variant of
`find-efunction', called `find-ealias', that will behave like this: a
sexp like
(find-ealias 'myalias2)
will jump to the definition of the alias `myalias2' "WITHOUT resolving
the alias to a function"...
P.P.S.: sorry for the length - I was trying to avoid getting answers
like "use M-x describe-function" or "look at find-func.el"...
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Is there a `find-function-noselect' that does not resolve aliases?
2022-01-18 5:08 Is there a `find-function-noselect' that does not resolve aliases? Eduardo Ochs
@ 2022-01-18 6:07 ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-01-18 16:35 ` Michael Heerdegen
2022-01-18 20:10 ` Stefan Monnier via Users list for the GNU Emacs text editor
2 siblings, 0 replies; 4+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2022-01-18 6:07 UTC (permalink / raw)
To: help-gnu-emacs
Eduardo Ochs wrote:
> what is the recommended low-level way to jump to the definition of an
> alias? Let me explain my question with a concrete example... if we run
> this on a shell,
>
> cat > /tmp/my.el <<'--snip--snip--'
> (defalias 'myalias1 'myalias2)
> (defalias 'myalias2 'myalias3)
> (defalias 'myalias3 'myfunction)
> (defun myfunction () 42)
>
> '(
>
> (load (buffer-file-name))
>
> ;; This jumps to the definition of `myfunction':
> (find-function-noselect 'myalias2)
>
> ;; The sexp below generates a "*Help*" buffer in which the
> ;; first line has a button whose text is "/tmp/my.el".
> ;; Its action is to jump to the definition of `myalias2'.
> (describe-function 'myalias2)
>
> )
> --snip--snip--
>
> it will create a file /tmp/my.el that defines three aliases and a
> function, and then it has a quoted list that is treated as a comment.
> That quoted list contains three sexps that are to be run by hand with
> `C-e C-x C-e' or your favorite variation of that.
>
> If we run those three sexps then the first one will load that file.
> The second one,
>
> (find-function-noselect 'myalias2)
>
> will (sort of) jump to the definition of the function `myfunction',
> instead of to the definition of the alias `myalias2' - so it "resolves
> the alias" somehow... but if we run the third sexp, that is
>
> (describe-function 'myalias2)
>
> and we click on its button "/tmp/my.el" then this will jump to the
> definition of the alias `myalias2'... so somewhere in the code
> associated to that button there's a low-level way of jumping to the
> definition of an alias "WITHOUT resolving the alias".
>
> The problem is that the code of that button is too intrincate for me.
> I've tried `M-x describe-button', I've tried to inspect its text
> properties, I found that on that button the key RET is bound to
> `push-button', and I've tried to understand the code of `push-button'
> and `help-function-def--button-function', but I'm stuck. Or rather: my
> brain is too tiny, and I'm tired. Help, please! =(
>
> Cheers,
> Eduardo Ochs
> http://angg.twu.net/
>
> P.S.: here's a bit more of context. If we run one of these sexps in
> eev - they're equivalent -
>
> (find-efunction-links 'myalias2)
> (eek "M-h M-f myalias2")
>
> we get a temporary buffer with lots of sexps "about myalias2". One of
> these sexps is:
>
> (find-efunction 'myalias2)
>
> that interprets the result of
>
> (find-function-noselect 'myalias2)
>
> in the right way, and jumps to the definition of the function that
> `myalias2' point to. I am trying to write a variant of
> `find-efunction', called `find-ealias', that will behave like this: a
> sexp like
>
> (find-ealias 'myalias2)
>
> will jump to the definition of the alias `myalias2' "WITHOUT resolving
> the alias to a function"...
>
> P.P.S.: sorry for the length - I was trying to avoid getting answers
> like "use M-x describe-function" or "look at find-func.el"...
If only you could be passionate about it ...
--
underground experts united
https://dataswamp.org/~incal
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Is there a `find-function-noselect' that does not resolve aliases?
2022-01-18 5:08 Is there a `find-function-noselect' that does not resolve aliases? Eduardo Ochs
2022-01-18 6:07 ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2022-01-18 16:35 ` Michael Heerdegen
2022-01-18 20:10 ` Stefan Monnier via Users list for the GNU Emacs text editor
2 siblings, 0 replies; 4+ messages in thread
From: Michael Heerdegen @ 2022-01-18 16:35 UTC (permalink / raw)
To: help-gnu-emacs
Eduardo Ochs <eduardoochs@gmail.com> writes:
> and we click on its button "/tmp/my.el" then this will jump to the
> definition of the alias `myalias2'... so somewhere in the code
> associated to that button there's a low-level way of jumping to the
> definition of an alias "WITHOUT resolving the alias".
The button already "knows" the defining file (see the properties).
What you search for happens earlier, when hitting C-h f. Try to edebug
`help-fns-function-description-header', AFAIU that's the code that you
are looking for, at least in my Emacs master.
Michael.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Is there a `find-function-noselect' that does not resolve aliases?
2022-01-18 5:08 Is there a `find-function-noselect' that does not resolve aliases? Eduardo Ochs
2022-01-18 6:07 ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-01-18 16:35 ` Michael Heerdegen
@ 2022-01-18 20:10 ` Stefan Monnier via Users list for the GNU Emacs text editor
2 siblings, 0 replies; 4+ messages in thread
From: Stefan Monnier via Users list for the GNU Emacs text editor @ 2022-01-18 20:10 UTC (permalink / raw)
To: help-gnu-emacs
> `push-button', and I've tried to understand the code of `push-button'
> and `help-function-def--button-function', but I'm stuck. Or rather: my
But `help-function-def--button-function` has your answer (that's code
used by `C-h f`):
[...]
;; Don't use find-function-noselect because it follows
;; aliases (which fails for built-in functions).
(let* ((location
(find-function-search-for-symbol fun type file))
[...]
From where I sit, it looks like we should change
`find-function-noselect` so it doesn't follow aliases.
Stefan
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-01-18 20:10 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-01-18 5:08 Is there a `find-function-noselect' that does not resolve aliases? Eduardo Ochs
2022-01-18 6:07 ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-01-18 16:35 ` Michael Heerdegen
2022-01-18 20:10 ` Stefan Monnier via Users list for the GNU Emacs text editor
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).