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
xref-backend for R mode with etags? #686
Comments
Do I understand correctly that your problem is that
The following works but is not as effient as it could be because xref-backend-definitions is called twice (likely a bug in xref): (defun ess-r-xref-backend ()
(let ((sym (xref-backend-identifier-at-point 'ess-r)))
(when (and sym (xref-backend-definitions 'ess-r sym))
'ess-r)))
(defvar ess-r--xref-cache nil)
(cl-defmethod xref-backend-definitions ((_backend (eql ess-r)) symbol)
(if ess-r--xref-cache
(prog1 ess-r--xref-cache
(setq ess-r--xref-cache nil))
(let ((xref (ess-r-xref--xref symbol)))
(when xref
(setq ess-r--xref-cache (list xref)))))) I am not sure we want to promote this though. One major limitation to this way is that the set of all R completions can no longer be shown if no identifier has been found at point. I believe this is a big deal. As to my mind the optimal solution is to have a dedicated key for etags (I use |
Thanks for looking into this issue. Yes, I expected
It makes sense to me. Thanks. |
@wenjie2wang Thanks for pasting in the code that worked for you. I too have been frustrated at the change of behavior of Unfortunately (and surely because I don't understand what's going on 'under the hood'), I didn't understand this bit of the post by @vspinu
Would one of you mind including the code that I'd need to bind the old functionality (or that of a direct invocation of the etags search functionality) to Also, am I correct in understanding that the change in behavior was a by-product of the code modifications involved in the effort to automatically produce tags-like behavior for any package loaded/sourced via a call to Thanks! |
I have this (defun my-xref-find-etags ()
(interactive)
(let ((xref-backend-functions '(etags--xref-backend))
(thing (xref--read-identifier "Find definitions of: ")))
(xref--find-definitions (replace-regexp-in-string "^\\.\\|\\.$\\|^[^/]+/" "" thing) nil)))
(global-set-key (kbd "M-g M-t") 'my-xref-find-etags) I think there is a simpler built-in solution. I used those internals because I want to simplify the identifier at point in order to maximize the matches which I get at point. |
@vspinu Thanks. That works nicely, albeit: (1) with a ~three second delay each time; (2) always asking for confirmation that I want to search for the symbol at point; and (3) still forcing a launch of an R instance before the first tag-lookup. Thanks also for all the work you've done to develop and improve ESS! |
@JoshOBrien It's strange there should be a delay, and shouldn't force launching an R instance. Have you created a TAGS file with your tags program (etags, ctags, etc.)? If you don't want to be prompted you could use something like
|
Indeed. There is nothing R related in that code, so (3) should not happen. The delay is because I want to be asked for the identifier and it takes time to collect candidates on big etags. @nverno's solution is superior and should better cater to your needs. |
Hello, I found ESS has a xref-backend
ess-r-xref-backend
for finding definitions and it would be enabled for Emacs 25+. When using Emacs < 25, I am able to find definitions or tags byM-x visit-tags-table
a TAGS file andM-.
. However, I find that it does not work for Emacs 25+ by default.A simple solution I find is to enable the etags backend by
M-x xref-etags-mode
. It allows me to "jump to definitions" again. However, I think I had to runM-x xref-etags-mode
for every R file I would like to "jump" from. Is there anything I missed?If so, I think it would be great if the functionality provided by
find-tag
(from etags.el) for Emacs < 25 still works "out-of-box" when using Emacs 25+. A possibly related workaround I find is Pan Xie's example at EmacsWiki: https://www.emacswiki.org/emacs/TagsFile. I did some quick modifications as follows:Will it be a good idea to similarly add etags to the xref-backend for R mode? Thanks!
The text was updated successfully, but these errors were encountered: