Certaily with xref, Use revert: M-, is the default.
M-, (translated from <escape> ,) runs the command
xref-pop-marker-stack (found in global-map), which is an interactive
compiled Lisp function in xref.el.
It is bound to M-,, <menu-bar> <edit> <goto> <xref-pop>.
You will need to convert that list to "xref item" values.
See xref--collect-matches-1 for how this is done. Since your locations are not "xref matches", though, you will call xref-make instead of xref-make-match, and won't need the length argument.
Note that you will also need the string contents on that line (it will be shown in the xref ...
The question is unclear. What identifier do you want it to find the definition of?
By default it uses the identifier at point - and it doesn't prompt you.
If there's no identifier at point, it prompts you.
(To be more precise, it depends on the current command. If (xref--prompt-p this-command) returns non-nil then it will also prompt you, even if there'...
Note: This is a very complicated solution. See How to use xref-find-references on Elisp files without "No references found for" errors for when I came to my senses and simplified things.
Problems and fixes
I found multiple things that I did that tripped me up:
I had an ~/ID file that is generated using ID Utils. xref, or
something beneath it, ...
xref provides UI for code navigation. The actual functionalities are provided by the backend. In you case, the backend is etags.
If you open TAGS file, its format is very simple. It has only the information of tag definition. So you can not find reference of tag.
So you got two solutions,
Install lsp-mode and some language server, hope they ...
ctags supports regular expression which could be used to parse tags.
Add below code into ~/.ctags,
--regex-fortran=/^[ \t]*MODULE[ \t]+(PROCEDURE|SUBROUTINE)[ \t]+([a-zA-Z0-9_]+)/\2/s,subroutines/
hello.f is like,
MODULE PROCEDURE MySubroutineName1 ! or
MODULE SUBROUTINE MySubRoutineName2
Then run ctags -e hello.f to test.
The simple solution: Use ctags -e instead of etags (assuming "Exuberant Ctags")
While man ctags explicitly says that etags is preferred for use with emacs, ctags seems to have much better fortran support. I now use:
ctags -e --recurse
# : :
# : `- Recursive processing of subdirectories.
# : Apparently also filters by ...
It seems you can call xref-find-definitions programatically by
(xref-find-definitions (symbol-name (symbol-at-point)))
or if you to be prompted for an identifier
(funcall-interactively #'xref-find-definitions (xref--read-identifier "Find definitions of: "))
While working on its code, you can open /src/<packages>/fileA.el and call M-x eval-buffer. Do the same for the rest of the files in the said package that you might want to navigate to. That will make Emacs remember the new locations of the functions in this package.
This is a solution for the built-in elisp xref backend. Not need for xref-etags-mode ...
You should use the new advice system `nadvice` instead of the old one.
xref-find-definitions prompts the user already in its `interactive-form`. So you need to run `open-tags-file` in the interactive-form of your advice for the case that xref-find-definitions is called interactively.
I use the interactive specification of xref-find-definitions of emacs 25.3....
global-hl-line-mode, from standard library hl-line.el highlights the current line. If option global-hl-line-sticky-flag is non-nil then it does this in all windows.
Library crosshairs.el (see Crosshair Highlighting) highlights also the current column, but it does so only in the selected window.
You can have crosshairs shown in any buffers or modes, either ...