Subject: Re: bug#79126: vc-switch-working-tree does not work if there is no matching file

From: Dmitry Gutov <[email-masked]>
Date: Wed, 6 Aug 2025 17:37:50 +0300

On 06/08/2025 17:08, Sean Whitton wrote:
> +;; The default value works for file-visiting and Dired buffers.
> +;; Non-file-visiting major modes (other than `dired-mode'), where there
> +;; is a sensible notion of a matching buffer, can set this.
> +;; File-visiting major modes shouldn't set it, except possibly some
> +;; highly specialized ones.
> +(defvar project-find-matching-buffer-function #'project-find-matching-file
> +  "Function to switch to a matching buffer in another project.
> +Usually set buffer-locally by non-file-visiting major modes.
> +The function will be called with no arguments.  If the other project is
> +already determined, `project-current-directory-override' will be bound
> +to a directory under that other project.  Otherwise the function should
> +prompt for the other project, usually with `project-read-project'.")

How about we try to simplify that hook?

The command will check whether there is an overriding project and pass 
that value as an argument to project-find-matching-buffer-function. Or 
just the root directory, is that is simpler.

Or two arguments: current-root and new-root. That should cut the default 
function's definition by about a third, and do even better for the 
specialized ones.