Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could CIDER provide an xref backend instead of hijacking M-. and M-,? #2831

Closed
stig opened this issue Apr 17, 2020 · 10 comments
Closed

Could CIDER provide an xref backend instead of hijacking M-. and M-,? #2831

stig opened this issue Apr 17, 2020 · 10 comments
Labels
feature request help wanted pinned Tickets immune to staleness checks

Comments

@stig
Copy link
Contributor

stig commented Apr 17, 2020

Is your feature request related to a problem? Please describe.

I'm frustrated with the way CIDER hijacks M-. in all clojure-mode buffers, even for projects where you don't connect to CIDER. I don't always want to connect to CIDER to navigate projects efficiently.

Describe the solution you'd like

I would love for CIDER to provide an xref backend instead of hijacking M-., similar to how clojure-lsp does.

My hope is that this would mean xref would present results both from CIDER and clojure-lsp, and other backends.

Describe alternatives you've considered

A simpler (though less ideal) fix would perhaps be to fall back to xref-find-definitions if there's no CIDER connection for the project.

Additional context

Add any other context or screenshots about the feature request here.

@bbatsov
Copy link
Member

bbatsov commented Apr 17, 2020

Yeah, we can certainly do this. CIDER predates the existence of xref in Emacs, which is the reason for the current state of affairs. I meant to play with xref a few times, but never got to doing so. It's mostly a matter of finding time.

@bbatsov
Copy link
Member

bbatsov commented Apr 25, 2020

@stig Btw, are there some packages implementing this outside of Emacs that I can take a look at? Or any documentation on the subject?

@stig
Copy link
Contributor Author

stig commented Apr 26, 2020

I didn't find any documentation, but I appear to have three packages that implements it, according to documentation for xref-backend-definitions:

[...]
Implementations:

((backend (eql xref-lsp)) identifier) in ‘lsp-mode.el’.

Undocumented

((backend (eql etags)) symbol) in ‘etags.el’.

Undocumented

((backend (eql elisp)) identifier) in ‘elisp-mode.el’.

Undocumented

@stale
Copy link

stale bot commented Jul 25, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contribution and understanding!

@stale stale bot added the stale label Jul 25, 2020
@bbatsov bbatsov added the pinned Tickets immune to staleness checks label Jul 25, 2020
@stale stale bot removed the stale label Jul 25, 2020
@bbatsov
Copy link
Member

bbatsov commented Jul 25, 2020

I've started work on this a while ago, but it turned out to be more involved than I anticipated and I've paused it for now. I plan to revisit this down the road, but anyone's welcome to beat me to it. :-)

@bbatsov
Copy link
Member

bbatsov commented Oct 7, 2020

Here's some useful reference pythonic-emacs/anaconda-mode@39b1cf8

@jiacai2050
Copy link
Contributor

@bbatsov Any news for this?

@bbatsov
Copy link
Member

bbatsov commented Jun 14, 2021

No progress. I've been pretty busy lately.

@jiacai2050
Copy link
Contributor

@bbatsov I would like to try submit a PR to fix this, maybe in two/three weeks.

@juszczakn
Copy link

juszczakn commented Oct 30, 2021

This isn't working for me, for some reason. I keep getting the prompt Visit tags table (default TAGS): /some/path/...

I'm going to try debugging it, but I'm not really much of an elisp guru /shrug

Edit:
Ok, it seems like my xref-backend-functions is evaling to a list with t as the first value. Removing t seems to resolve the issue for me.

> xref-backend-functions
(t cider--xref-backend)

I'm temporarily fixing this in my init.el by just getting rid of the t with:

(add-hook 'cider-mode
          (lambda ()
            (setq xref-backend-functions '(cider--xref-backend))))

which is definitely not a good thing, I'm sure, but it's working for me, for now /shrug.

My guess is that Emacs is working through the list, finds t, and just assumes it should use the default, which is etags?
This is Emacs 26.3 on Ubuntu 20.04.


Edit2:

Hook ended up not really working very well, seems like upgrading to emacs 27.2 (using the ppa) has fixed it, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request help wanted pinned Tickets immune to staleness checks
Projects
None yet
Development

No branches or pull requests

4 participants