Subject: bug#34949: 27.0.50; Docstring of `vc-deduce-fileset' incomplete

From: Juri Linkov <[email-masked]>
Date: Wed, 25 Mar 2020 00:36:15 +0200

>>>> Maybe then a shorter name vc-root-dir-action?
>>>
>>> The word "action" there seems to hold no particular meaning.
>>>
>>> vc-root-dir-with-dwim-selection, maybe?
>> Shorter names:
>> vc-dir-root-registered
>> or just
>> vc-dir-registered
>
> These either sound like callbacks, or alternatively make an impression that
> only registered files will be *shown* (not marked).

Then the name could be vc-dir-and-mark-registered,
but maybe it's not needed given the below.

> Are you sure you don't want to split it into a new command that will simply
> mark a set of files you expect here? E.g. all belonging to "registered"
> statuses. That might require extra keypress, but vc-dir-root-registered is
> probably not going to have the same short combination that vc-dir has
> anyway. So it might be a wash, keypresses-wise.

VC-Dir needs the same key prefix as is provided by Dired:

* %             dired-mark-files-regexp
* *             dired-mark-executables
* /             dired-mark-directories
* ?             dired-unmark-all-files
* @             dired-mark-symlinks
* s             dired-mark-subdir-files

Then VC-Dir could provide, for example:

* r             vc-dir-mark-registered
* u             vc-dir-mark-unregistered
...

> And vc-dir-root can just be "vc-dir in the repository root" that we both
> have wanted for a while.

Finally settled with the following patch.

>> Also there is a command 'vc-register' (C-x v i).
>> Its counterpart could be named 'vc-dir-register'
>> and will open a vc-dir buffer where only unregistered
>> files will be marked.
>
> Are you sure you will remember the new commands and use them on a regular
> basis? I most likely won't.
>
> And similarly, we can add a special command to mark only unregistered
> files. Although it's usually not a problem to navigate to the first 
> unregistered one and press 'M'.

Often this is a minor problem, but given the above, a keybinding
like `* u' should be of a little help.

diff --git a/lisp/vc/vc-dir.el b/lisp/vc/vc-dir.el
index 38b4937e85..8c45ad9b80 100644
--- a/lisp/vc/vc-dir.el
+++ b/lisp/vc/vc-dir.el
@@ -1286,6 +1309,16 @@ vc-dir-deduce-fileset
 	(setq model (vc-checkout-model vc-dir-backend only-files-list))))
     (list vc-dir-backend files only-files-list state model)))
 
+;;;###autoload
+(defun vc-dir-root ()
+  "Run `vc-dir' in the repository root directory without prompt.
+If the default directory of the current buffer is
+not under version control, prompt for the directory."
+  (interactive)
+  (let ((root-dir (vc-root-dir)))
+    (if root-dir (vc-dir root-dir)
+      (call-interactively 'vc-dir))))
+
 ;;;###autoload
 (defun vc-dir (dir &optional backend)
   "Show the VC status for \"interesting\" files in and below DIR.
diff --git a/lisp/vc/vc-hooks.el b/lisp/vc/vc-hooks.el
index 345a28d3f1..1a92cd867c 100644
--- a/lisp/vc/vc-hooks.el
+++ b/lisp/vc/vc-hooks.el
@@ -972,9 +972,9 @@ vc-menu-map
     (bindings--define-key map [vc-ignore]
       '(menu-item "Ignore File..." vc-ignore
 		  :help "Ignore a file under current version control system"))
-    (bindings--define-key map [vc-dir]
-      '(menu-item "VC Dir"  vc-dir
-		  :help "Show the VC status of files in a directory"))
+    (bindings--define-key map [vc-dir-root]
+      '(menu-item "VC Dir"  vc-dir-root
+		  :help "Show the VC status of the repository"))
     map))
 
 (defalias 'vc-menu-map vc-menu-map)