jacktasia / dumb-jump

an Emacs "jump to definition" package for 50+ languages
GNU General Public License v3.0
1.56k stars 148 forks source link

Consider implementing `xref-backend-references` #433

Open harto opened 1 year ago

harto commented 1 year ago

Hello, thanks for this very useful library. I was wondering if you had considered implementing the "find references to symbol" part of xref.

Right now, M-. works great for jumping to a symbol. But once I'm there, if I type M-?, xref falls back to a really slow find … | grep thing. I was wondering if it would be feasible to reuse the same ag/rg searching instead.

I don't know much about the internals of either xref or dumb-jump, but I'm happy to poke at this if it seems like something you would consider merging.

catern commented 1 year ago

I'm very interested in this too. Specifically, I have a somewhat interesting use case: I have another xref backend which supports jump-to-definition efficiently, but doesn't support jump-to-references, so it would be nice to use dump-jump to provide that latter functionality.

That being said, after you mentioned this I looked at the default xref-backend-references implementation, and it actually looks like it might be plausible to improve the default in upstream Emacs. Like, instead of using find | grep, use something based on ag/rg when those commands are avilable, automatically, upstream. I say this because the semantic backend which xref is using seems to already have decent support for fallbacks like that.

catern commented 1 year ago

FWIW I went ahead and did exactly what I just said, just improved the default xref-backend-references implementation to not be slow https://debbugs.gnu.org/cgi/bugreport.cgi?bug=62837