diff --git a/doc/emacs/vc1-xtra.texi b/doc/emacs/vc1-xtra.texi index c768910349f..72e660a2def 100644 --- a/doc/emacs/vc1-xtra.texi +++ b/doc/emacs/vc1-xtra.texi @@ -285,7 +285,11 @@ tree. Add a new working tree. @item C-x v w w -Visit this file in another working tree. +Visit this file or directory in another working tree. + +@item C-x v w s +Invoke @kbd{C-x p p} (@code{project-switch-project}) but limited to +other working trees. @item C-x v w x Delete a working tree you no longer need. @@ -313,12 +317,24 @@ new working tree. @findex vc-switch-working-tree Once your repository has other working trees, you can use the command @kbd{C-x v w w} (@code{vc-switch-working-tree}) to switch between them. -It tries to find the analogue of the current buffer's file -under another working tree. Typically the sets of workfiles -under different working trees differ more in file contents than in which -files do and do not exist. In other words, the file the -current buffer visits probably exists in other working trees too, and -this command lets you switch to those versions of the file. +It tries to find the analogue of the current buffer's file or directory +under another working tree. Typically the sets of workfiles under +different working trees differ more in file contents than in which files +do and do not exist. In other words, the file or directory the current +buffer visits probably exists in other working trees too, and this +command lets you switch to those versions of the file. + +@kindex C-x v w s +@findex vc-working-tree-switch-project +An alternative way to switch between working trees is @kbd{C-x v w s} +(@code{vc-working-tree-switch-project}). This prompts you to select a +working tree, and then displays a menu of commands to operate on it. +This is in fact just @kbd{C-x p p} (@code{project-switch-project}) +(@pxref{Switching Projects}) but with the selection of projects limited +to other working trees. The main difference between @kbd{C-x v w w} and +@kbd{C-x v w s} is that the former looks for an analogue of the current +buffer in the other working tree while the latter considers the other +working tree as a whole, independent project. @kindex C-x v w x @kindex C-x v w R diff --git a/etc/NEWS b/etc/NEWS index b29a3985b93..c06be2301d4 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1946,6 +1946,7 @@ other working trees: - 'C-x v w c': Add a new working tree. - 'C-x v w w': Visit this file in another working tree. +- 'C-x v w s': Like 'C-x p p' but limited to other working trees. - 'C-x v w x': Delete a working tree you no longer need. - 'C-x v w R': Relocate a working tree to another file name. diff --git a/lisp/vc/vc-hooks.el b/lisp/vc/vc-hooks.el index 9fdc7fcf5a9..7d46f9f0ee3 100644 --- a/lisp/vc/vc-hooks.el +++ b/lisp/vc/vc-hooks.el @@ -968,6 +968,7 @@ In the latter case, VC mode is deactivated for this buffer." "!" #'vc-edit-next-command "w c" #'vc-add-working-tree "w w" #'vc-switch-working-tree + "w s" #'vc-working-tree-switch-project "w x" #'vc-delete-working-tree "w R" #'vc-move-working-tree) (fset 'vc-prefix-map vc-prefix-map) diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el index 1d527d3aa4e..558054e7338 100644 --- a/lisp/vc/vc.el +++ b/lisp/vc/vc.el @@ -4443,6 +4443,20 @@ to the root of this working tree." (let ((project-current-directory-override directory)) (project-find-matching-buffer))) +;;;###autoload +(defun vc-working-tree-switch-project (dir) + "Like \\[project-switch-project] but limited to projects with the same backing repository. +Must be called from within an existing VC working tree. +Prompts for the directory file name of the other working tree." + ;; There is no point in calling this from Lisp as opposed to calling + ;; `project-switch-project' directly because it is a trivial wrapper. + (declare (interactive-only project-switch-project)) + (interactive + (list + (vc--prompt-other-working-tree (vc-responsible-backend default-directory) + "Other working tree to switch to"))) + (project-switch-project dir)) + ;;;###autoload (defun vc-delete-working-tree (backend directory) "Delete working tree DIRECTORY with same backing repository as this tree.