Subject: 28.0.91; project-find-regexp (C-x p g) twice results in searching different projects
From: [email-masked]
To: [email-masked]
Date: Sat, 29 Jan 2022 19:11:35 +0000 (UTC)
List-Id: <debbugs-submit.debbugs.gnu.org>

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.

In GNU Emacs 28.0.91 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.30, cairo version 1.16.0)
Repository revision: 525dc6e5c428185b62c72d7958cd4fe17937f126
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12011000
System Description: NixOS 21.05 (Okapi)

Configured using:
 'configure
 --prefix=/nix/store/023rdncicx7hz02dq986rnnpl12l1kas-emacs-git-20220115.0
 --disable-build-details --with-modules --with-x-toolkit=gtk3 --with-xft
 --with-cairo'

Configured features:
CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG JSON
LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES NOTIFY INOTIFY
PDUMPER PNG RSVG SECCOMP SOUND THREADS TIFF TOOLKIT_SCROLL_BARS X11 XDBE
XIM XPM GTK3 ZLIB

Important settings:
  value of $EMACSLOADPATH: 
  value of $EMACSNATIVELOADPATH: /nix/store/fs7slsl0rz28h6dq8rnhgk4ddkk8dh0w-emacs-packages-deps/share/emacs/native-lisp::
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: notmuch-hello

Minor modes in effect:
  windmove-mode: t
  envrc-global-mode: t
  envrc-mode: t
  global-git-commit-mode: t
  magit-auto-revert-mode: t
  shell-dirtrack-mode: t
  savehist-mode: t
  save-place-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tab-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Load-path shadows:
/home/sbaugh/.nix-profile/share/emacs/site-lisp/site-start hides /nix/store/fs7slsl0rz28h6dq8rnhgk4ddkk8dh0w-emacs-packages-deps/share/emacs/site-lisp/site-start
/home/sbaugh/.nix-profile/share/emacs/site-lisp/site-start hides /nix/store/023rdncicx7hz02dq986rnnpl12l1kas-emacs-git-20220115.0/share/emacs/site-lisp/site-start
/nix/store/fs7slsl0rz28h6dq8rnhgk4ddkk8dh0w-emacs-packages-deps/share/emacs/site-lisp/elpa/transient-20220112.1305/transient hides /nix/store/023rdncicx7hz02dq986rnnpl12l1kas-emacs-git-20220115.0/share/emacs/28.0.91/lisp/transient
/nix/store/fs7slsl0rz28h6dq8rnhgk4ddkk8dh0w-emacs-packages-deps/share/emacs/site-lisp/elpa/let-alist-1.0.6/let-alist hides /nix/store/023rdncicx7hz02dq986rnnpl12l1kas-emacs-git-20220115.0/share/emacs/28.0.91/lisp/emacs-lisp/let-alist

Features:
(shadow emacsbug ibuf-ext sh-script executable pulse qp sort tabify man
git-rebase pcmpl-unix image-file image-converter korea-util novice
timezone network-stream url-http url-gw nsm url-auth ggtags etags
fileloop ewoc two-column skeleton dumb-jump popup s xref quail log-view
magit-extras ibuffer ibuffer-loaddefs em-unix em-term term disp-table
ehelp em-script em-prompt em-ls em-hist em-pred em-glob em-cmpl em-dirs
esh-var em-basic em-banner em-alias esh-mode eshell esh-cmd esh-ext
esh-opt esh-proc esh-io esh-arg esh-module esh-groups esh-util make-mode
find-dired grep mhtml-mode css-mode js cc-mode cc-fonts cc-guess
cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs sgml-mode
facemenu org-attach org-id warnings mail-extr nix-mode ffap smie
nix-repl nix-shell nix-store nix-instantiate nix-shebang nix-format nix
project reposition rect misc vc-mtn vc-hg vc-bzr vc-src vc-sccs vc-svn
vc-cvs vc-rcs vc bug-reference finder-inf deuglify gnus-async gnus-cite
gnus-cus gnus-demon gnus-diary nndiary gnus-draft gnus-agent nnvirtual
nntp gnus-cache nndraft nnmh gnus-dup gnus-fun gnus-html url-cache
gnus-kill gnus-logic gnus-mh mh-comp mh-scan mh-gnus mh-e mh-compat
mh-buffers mh-loaddefs gnus-registry registry eieio-base gnus-salt
gnus-score score-mode gnus-srvr gnus-topic gnus-uu yenc gnus-vm gnus-msg
sendmail cus-dep autoload lisp-mnt cus-theme cl-print shortdoc
hippie-exp windmove help-fns radix-tree compile shr-color color
mule-util cus-edit pp notmuch notmuch-tree notmuch-jump notmuch-hello
notmuch-show notmuch-print notmuch-crypto notmuch-mua notmuch-message
notmuch-draft notmuch-maildir-fcc notmuch-address notmuch-company
notmuch-parser notmuch-wash coolj notmuch-query goto-addr icalendar
diary-lib diary-loaddefs notmuch-tag notmuch-lib notmuch-compat pcase
hl-line ol-eww eww xdg url-queue mm-url ol-rmail ol-mhe ol-irc ol-info
ol-gnus nnselect gnus-search eieio-opt speedbar ezimage dframe gnus-art
mm-uu mml2015 mm-view mml-smime smime dig gnus-sum shr kinsoku svg dom
gnus-group gnus-undo gnus-start gnus-dbus dbus xml gnus-cloud nnimap
nnmail mail-source utf7 netrc nnoo gnus-spec gnus-int gnus-range
gnus-win gnus nnheader wid-edit ol-docview doc-view jka-compr image-mode
exif ol-bibtex ol-bbdb ol-w3m ol-doi org-link-doi vc-git vc-dispatcher
python tramp-sh tramp tramp-loaddefs trampver tramp-integration files-x
tramp-compat parse-time ls-lisp face-remap misearch multi-isearch
cus-start cus-load dired-aux envrc inheritenv page-ext dired-x
magit-submodule magit-obsolete magit-blame magit-stash magit-reflog
magit-bisect magit-push magit-pull magit-fetch magit-clone magit-remote
magit-commit magit-sequence magit-notes magit-worktree magit-tag
magit-merge magit-branch magit-reset magit-files magit-refs magit-status
magit magit-repos magit-apply magit-wip magit-log which-func imenu
magit-diff smerge-mode diff git-commit log-edit message rmc dired
dired-loaddefs rfc822 mml mml-sec epa derived epg rfc6068 epg-config
gnus-util rmail rmail-loaddefs text-property-search mm-decode mm-bodies
mm-encode mail-parse rfc2231 rfc2047 rfc2045 mm-util ietf-drums
mail-prsvr mailabbrev mail-utils gmm-utils mailheader pcvs-util add-log
magit-core magit-autorevert autorevert filenotify magit-margin
magit-transient magit-process with-editor shell server magit-mode
transient cl-extra magit-git magit-section magit-utils crm dash
lui-autopaste circe diff-mode lui-irc-colors irc gnutls puny lcs
lui-logging lui-format lui tracking shorten thingatpt help-mode flyspell
ispell circe-compat ox-odt rng-loc rng-uri rng-parse rng-match rng-dt
rng-util rng-pttrn nxml-parse nxml-ns nxml-enc xmltok nxml-util ox-latex
ox-icalendar org-agenda org-refile ox-html table ox-ascii ox-publish ox
org-element avl-tree generator org ob ob-tangle ob-ref ob-lob ob-table
ob-exp org-macro org-footnote org-src ob-comint org-pcomplete pcomplete
org-list org-faces org-entities noutline outline org-version
ob-emacs-lisp ob-core ob-eval org-table oc-basic bibtex iso8601
time-date ol rx org-keys oc org-compat advice org-macs org-loaddefs
format-spec find-func cal-menu calendar cal-loaddefs gdb-mi gud
easy-mmode comint ansi-color ring cyberpunk-theme better-defaults
savehist saveplace ido tex-site edmacro kmacro info package browse-url
url url-proxy url-privacy url-expand url-methods url-history url-cookie
url-domsuf url-util mailcap url-handlers url-parse auth-source cl-seq
eieio eieio-core cl-macs eieio-loaddefs password-cache json subr-x map
url-vars seq byte-opt gv bytecomp byte-compile cconv cl-loaddefs cl-lib
iso-transl tooltip eldoc paren electric uniquify ediff-hook vc-hooks
lisp-float-type elisp-mode mwheel term/x-win x-win term/common-win x-dnd
tool-bar dnd fontset image regexp-opt fringe tabulated-list replace
newcomment text-mode lisp-mode prog-mode register page tab-bar menu-bar
rfn-eshadow isearch easymenu timer select scroll-bar mouse jit-lock
font-lock syntax font-core term/tty-colors frame minibuffer cl-generic
cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao
korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech
european ethiopic indian cyrillic chinese composite emoji-zwj charscript
charprop case-table epa-hook jka-cmpr-hook help simple abbrev obarray
cl-preloaded nadvice button loaddefs faces cus-face macroexp files
window text-properties overlay sha1 md5 base64 format env code-pages
mule custom widget hashtable-print-readable backquote threads dbusbind
inotify dynamic-setting system-font-setting font-render-setting cairo
move-toolbar gtk x-toolkit x multi-tty make-network-process emacs)

Memory information:
((conses 16 1076574 118416)
 (symbols 48 46869 2)
 (strings 32 222312 21193)
 (string-bytes 1 8226000)
 (vectors 16 108694)
 (vector-slots 8 1962697 150648)
 (floats 8 695 502)
 (intervals 56 63651 321)
 (buffers 992 195))