dumb-jump-go doesn't jump to definition even though there is only 1 result in dumb-jump-selector
shaunvxc opened this issue · 9 comments
I'm noticing some strange behavior when using dumb-jump-go
Per the below image, when I try to dumb-jump-go
to sv-pkgs
, instead of jumping to the module, it instead renders the selector
(despite it showing only 1 result). I would expect this only in the case where there are multiple candidates.
Strangely, this behavior is inconsistent. For example, when I dumb-jump-go
to the sv-magit
module (2 lines below), it behaves as I expect.
Apologies in advance if this is something that has been documented/resolved in the past. I did some searching through the issues and couldn't find anything like it.
Out of curiosity, does the same issue also occur with when using xref?
Did you decide to use xref, or was the issue resolved otherwise?
I decided to use xref ... issue was not resolved otherwise. Per the readme tho dumb-jump-go
is no longer the "core" function to use?
There is some debate around this, but there has been an attempt to mark dumb-jump-go
as a deprecated function, and to instead promote the xref as the default. But because a lot of people are still using the "legacy" commands, they should still work.
Btw, I noticed your emacs.d repository, and specifically this commit. Maybe it might be better to use
(call-interactively #'xref-find-definitions)
instead of calling xref-find-definitions
manually. That xref and dumb-jump take care of detecting the symbol at point.
@phikal I tried your suggestion (replacing the line my call to (xref-find-definitions '(symbol-name (symbol-at-point)))
with (call-interactively #'xref-find-definitions)
.
When run this way, a helm-xref buffer is prompting me every time before jumping [see below screenshot].
The way I had it written before it was jumping without a prompt. Am I doing something wrong?
I actually didn't try it out, and only now noticed that it doesn't work because Xref checks if the command invoking xref-find-definitions
.
(let ((xref-prompt-for-identifier nil)) (call-interactively #'xref-find-definitions))
should work, by overriding the list of functions that prompt. Sorry about that.
@phikal Thanks a lot for this! I'm a long time emacs user but only recently really doubled down on rebuilding my own config (so i'm far from an elisp expert).
I want to understand what the real difference is between your suggested approach and what I was doing before? (given that the end behavior is the same)
The main difference is that by using call-interactivly
you tell Emacs to reuse the interactive specification every command has to supply it's argument list, instead of passing them manually as you do. For xref-find-definitions
this is
(interactive (list (xref--read-identifier "Find definitions of: ")))
where xref--read-identifier
uses the xref-backend-identifier-at-point
method to guess what the "identifier" is you want to query. dumb-jump implements this here. The core is the same as your implementation (ie. symbol-at-point) but it attaches context data to via text properties to improve the query as well. The context can filter out certain definitions (see dumb-jump-language-contexts
) to make sure you don't get function results when querying a variable, and vice versa.