Skip to main content
Share Your Experience: Take the 2024 Developer Survey
3 votes

calling xref-find-definitions within lisp code

You can call xref-find-definitions programatically by (xref-find-definitions (symbol-name (symbol-at-point))) or if you want to be prompted for an identifier (funcall-interactively #'xref-find-...
Kevin's user avatar
  • 96
2 votes
Accepted

Longer flashing of search string during multi-file searches

(setq pulse-delay 0.09) works for me, and really increases the duration of the pulse. The problem is likely in how you change that value.
Dmitry's user avatar
  • 3,803
2 votes
Accepted

How can I highlight cursor or line in unselected frames?

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 ...
Drew's user avatar
  • 77.9k
2 votes

How to call xref-find-definitions without being prompted?

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 ...
Drew's user avatar
  • 77.9k
2 votes
Accepted

Read Xref manual in Emacs

It's part of the Emacs manual: do C-h i m emacs RET i xref RET and you should get there. The i xref RET part looks for xref in the index of the Emacs manual.
NickD's user avatar
  • 30.6k
2 votes
Accepted

xref-find-defnition not finding any definition

You need create tags file in project root first. Run etags in project root to create tags file whose name is TAGS. etags is a command line program bundled with Emacs. See https://www.gnu.org/software/...
chen bin's user avatar
  • 4,877
2 votes

Automatic "push-mark" when navigating with xref, find-grep, etc?

Certaily with xref, Use revert: M-, is the default. xref-pop-marker-stack M-, (translated from <escape> ,) runs the command xref-pop-marker-stack (found in global-map), which is an ...
RichieHH's user avatar
  • 873
2 votes
Accepted

How to automatically go to file when there is only one match in xref?

xref-show-definitions-buffer Show the definitions list in a regular window. When only one definition found, jump to it right away instead. You can also keep using xref-show-definitions-buffer (to ...
Dmitry's user avatar
  • 3,803
2 votes
Accepted

Improving Etags support for fortran?

The simple solution: Use ctags -e instead of etags (assuming "Exuberant Ctags"[1]) While man ctags explicitly says that etags is preferred for use with emacs, ctags seems to have much better fortran ...
kdb's user avatar
  • 1,561
1 vote
Accepted

semantic-symref-filepattern-alist is void until I try to use xref features

Add the appropriate require before evaluating the add-to-list call in your init file: (require 'semantic/symref/grep) (add-to-list 'semantic-symref-filepattern-alist '(js-mode "*.js")) ...
NickD's user avatar
  • 30.6k
1 vote
Accepted

`recenter` issue in `xref-go-back` when using `lsp-mode`

This is in fact one of the effects of setting scroll-conservatively: when a point moves inside a buffer, the window is scrolled in this particular way. Anyway, to solve this specifically for xref-go-...
Dmitry's user avatar
  • 3,803
1 vote
Accepted

make projectile search functions work for non project files? (or include them as project files?)

If you didn't generate a TAGS file manually (and you probably didn't), Projectile doesn't have anything to do with xref-find-definitions. You should find your which Xref backend is being used in your ...
Dmitry's user avatar
  • 3,803
1 vote
Accepted

xref-find-apropos vs vc-git-grep

The main difference is vc-git-grep is always a textual search which will give you matches against all lines in the checked in files. xref-find-apropos searches for function definitions (and other ...
Dmitry's user avatar
  • 3,803
1 vote

Xref-find-definitions 'no definitions found' for emacs source

If you open TAGS file you may find out that all paths it has are relative. And xref-find-definitions also works under the same assumption, i.e. that to know whether to check a TAGS file it first goes ...
Hi-Angel's user avatar
  • 766
1 vote
Accepted

Store output of xref-find-apropos in a variable within elisp code

We can ask for references from the LSP backend directly: (lsp-request "workspace/symbol" `(:query ,symbol)) This returns a hashmap I can further parse and find locations by looking at 'uri' ...
Evgenii.Balai's user avatar
1 vote

Store output of xref-find-apropos in a variable within elisp code

By inspecting the xref-find-apropos -> xref--find-xrefs -> xref--create-fetcher functions, we find that xref-backend-apropos is the working horse. Calling that function with the appropriate ...
dalanicolai's user avatar
  • 7,865
1 vote

How do I update xref-backend-functions?

It's a hook variable. A hook variable has a global part, and the buffer-local part(s), the latter can be different between many modes. In your example (eglot-xref-backend t) is a buffer-local value (...
Dmitry's user avatar
  • 3,803
1 vote

xref-find-references and its seemingly random "Select project: " behavior

This happens when none of the directories up the path are git repositories (or other repositories of another source control system that your project package can recognize). Solution: navigate to what ...
anon2328's user avatar
1 vote

How to disable momentary highlighting of a match by xref and ggtags?

A good approach for finding such info is to look for hooks and user options. I found these answers just by looking in the relevant source files. For Xref: (remove-hook 'xref-after-return-hook 'xref-...
Drew's user avatar
  • 77.9k
1 vote
Accepted

Make 'ctags' detect fortran's "module procedure" pattern?

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/ ...
chen bin's user avatar
  • 4,877
1 vote
Accepted

Given a list of (filepath line column), how to make this open as an xref buffer?

This function creates an xref buffer from a list of references (thanks to @Dmitry's answer). (defun my-xref-from-file-references (file-references) "Create an xref buffer from FILE-REFERENCES ((...
ideasman42's user avatar
  • 8,826
1 vote

Given a list of (filepath line column), how to make this open as an xref buffer?

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-...
Dmitry's user avatar
  • 3,803
1 vote
Accepted

How to prevent highlighting when using ‘xref-pop-marker-stack’

You can customize xref-after-return-hook and remove xref-pulse-momentarily from it.
Dmitry's user avatar
  • 3,803
1 vote

How to use xref-find-references on Elisp files without "No references found for" errors

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. ...
bgoodr's user avatar
  • 341
1 vote

How to use xref-find-references on Elisp files without "No references found for" errors

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 ...
chen bin's user avatar
  • 4,877
1 vote

How do I use xref-find-definitions with multiple source directories?

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 ...
Dmitry's user avatar
  • 3,803
1 vote

Using advice to run function before tag symbol lookup

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-...
Tobias's user avatar
  • 33.3k

Only top scored, non community-wiki answers of a minimum length are eligible