Emacs xref stopped working on Macs with dumb-jump

Recently I found that xref in Emacs had stopped working for me on my mac laptop. Today I finally tried to figure out what went wrong. xref is just a front-end, all the work is done by backends. It took a while for me to realize (ie remember) that I was using the excellent dumb-jump package as the backend. dumb-jump uses a range of fast search commands (such as ag and ripgrep) to detect references without using the awkward tags tables that Emacs used to rely on.

The command flow between xref and dumb-jump is difficult to follow, but looking at the dumb-jump customization page alerted me to dumb-jump having a debug option. With this enabled, I could see what command dumb-jump was sending to the operating system. By default it uses git grep while in a git repo (almost everything I do is in a git repo). Its git grep command is quite complex, using regexps to (I assume) get more sensible results. I tried out the command it issued in my own terminal and it failed to find anything, while a simple git grep worked fine.

Armed with a better knowledge of what was failing, I dug into dumb-jump’s issues and found Issue with git-grep. Reading that, I discovered that a change to git grep means that how git grep processes regexes differs depending on the operating system. This would mean that dumb-jump would need to detect git-grep’s version and the underlying OS to pick the right regexes for its search.

The fix for me is to force dumb-jump to use another searcher with (setq dumb-jump-force-searcher 'rg). With that my xref commands worked again.

https://martinfowler.com/articles/2023-xref-problem.html

Creată 2y | 19 mai 2023, 17:20:29


Autentifică-te pentru a adăuga comentarii

Alte posturi din acest grup

How is GenAI different from other code generators?

How is code generation with GenAI different from more "traditional" code generators? The newest memo in Birgitta Böckeler's explorations of GenAI talks abou

18 oct. 2023, 20:10:05 | Martin Fowler
How is GenAI different from other code generators?

How is code generation with GenAI different from more "traditional" code generators? The newest memo in Birgitta Böckeler's explorations of GenAI talks abou

19 sept. 2023, 10:10:06 | Martin Fowler
TDD with GitHub Copilot

At Thoughtworks, we are strong practitioners of Test Driven Development (TDD). Naturally this leads to the question of how generative AI can

17 aug. 2023, 20:30:07 | Martin Fowler