[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Is there a `find-function-noselect' that does not resolve aliases?
From: |
Emanuel Berg |
Subject: |
Re: Is there a `find-function-noselect' that does not resolve aliases? |
Date: |
Tue, 18 Jan 2022 07:07:34 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) |
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