Subject: bug#53626: 28.0.91; project-find-regexp (C-x p g) twice results in searching different projects

From: Dmitry Gutov <[email-masked]>
Date: Thu, 3 Feb 2022 05:15:40 +0200

Hi!

On 29.01.2022 21:11, [email-masked] wrote:
> An existing*xref*  buffer doesn't have its default-directory changed
> when running project-find-regexp.  Since project-find-regexp switches to
> *xref*, that means running project-find-regexp twice in a row may search
> two different projects, which is unexpected.
> 
> Steps to reproduce:
> 
> With buffers in two different projects as detected by project.el, do the
> following sequence:
> 
> 1. Switch to a buffer in project A
> 
> 2. project-find-regexp, which will search project A, and create and
> switch to an*xref*  buffer with a default-directory pointing at the
> project root of A
> 
> 3. project-find-regexp again, which will search project A again. (This
> is the desired behavior)
> 
> 4. Switch to a buffer in project B
> 
> 5. project-find-regexp, which will search project B and switch to the
> existing*xref*  buffer (which is still pointing at project A)
> 
> 6. project-find-regexp again, which will search project A instead of B.
> 
> Suggested fix:
> 
> Change project-find-regexp to reset the default-directory of the*xref*
> buffer used to the most recently used project root.

This sounds like something that was fixed in commit b99848c72cb2570c 
(meaning, about a year ago).

I have tried to quickly reproduce this in my build from master, and 
hadn't managed to.

How recent is Emacs that you're trying this in? Do you perhaps have an 
older version of project.el or xref installed through ELPA?

Or did you maybe use project-switch-project, doing a search from its 
menu, like Sean seems to be hinting?