emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master bfd96e9: M-n in read-directory-name of vc commands gets project d


From: Juri Linkov
Subject: master bfd96e9: M-n in read-directory-name of vc commands gets project dirs (bug#41821)
Date: Tue, 23 Jun 2020 19:59:39 -0400 (EDT)

branch: master
commit bfd96e995dae796fd3f68301fcc4921fb4c42745
Author: Juri Linkov <juri@linkov.net>
Commit: Juri Linkov <juri@linkov.net>

    M-n in read-directory-name of vc commands gets project dirs (bug#41821)
    
    * lisp/progmodes/project.el (project-known-roots): New autoloaded function.
    
    * lisp/vc/vc-hooks.el (vc-known-roots): New function.
    
    * lisp/vc/vc.el (vc-root-diff, vc-print-root-log):
    * lisp/vc/vc-dir.el (vc-dir): Use 'vc-known-roots' for default
    values for read-directory-name.
---
 etc/NEWS                  | 3 +++
 lisp/progmodes/project.el | 6 ++++++
 lisp/vc/vc-dir.el         | 2 +-
 lisp/vc/vc-hooks.el       | 5 +++++
 lisp/vc/vc.el             | 6 ++++--
 5 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index 32ceec1..6d42fd4 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -176,6 +176,9 @@ directories with the help of new command 
'dired-vc-next-action'.
 *** More vc commands that don't change VC state can be used from non-file 
buffers.
 Such non-file buffers should have default-directory under vc.
 
+*** Typing 'M-n' in the minibuffer that asks for a vc directory in vc commands
+can retrieve directories of previously used vc projects.
+
 *** New command 'vc-dir-root' uses the root directory without asking.
 
 *** New commands 'vc-dir-mark-registered-files' (bound to '* r') and
diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index 2f213da..42715dc 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -935,6 +935,12 @@ It's also possible to enter an arbitrary directory not in 
the list."
         (read-directory-name "Select directory: " default-directory nil t)
       pr-dir)))
 
+;;;###autoload
+(defun project-known-roots ()
+  "Return a list of known project roots."
+  (project--ensure-read-project-list)
+  project--list)
+
 
 ;;; Project switching
 
diff --git a/lisp/vc/vc-dir.el b/lisp/vc/vc-dir.el
index cdf8ab9..46be9b7 100644
--- a/lisp/vc/vc-dir.el
+++ b/lisp/vc/vc-dir.el
@@ -1366,7 +1366,7 @@ These are the commands available for use in the file 
status buffer:
     ;; Otherwise if you do C-x v d -> C-x C-f -> C-x v d
     ;; you may get a new *vc-dir* buffer, different from the original
     (file-truename (read-directory-name "VC status for directory: "
-                                       (vc-root-dir) nil t
+                                       (vc-root-dir) (vc-known-roots) t
                                        nil))
     (if current-prefix-arg
        (intern
diff --git a/lisp/vc/vc-hooks.el b/lisp/vc/vc-hooks.el
index ce72a49..9675c36 100644
--- a/lisp/vc/vc-hooks.el
+++ b/lisp/vc/vc-hooks.el
@@ -299,6 +299,11 @@ non-nil if FILE exists and its contents were successfully 
inserted."
     (set-buffer-modified-p nil)
     t))
 
+(declare-function project-try-vc "project")
+(defun vc-known-roots ()
+  "Return a list of known vc roots."
+  (seq-filter #'project-try-vc (mapcar #'car (project-known-roots))))
+
 (defun vc-find-root (file witness)
   "Find the root of a checked out project.
 The function walks up the directory tree from FILE looking for WITNESS.
diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el
index 65775f8..49323ef 100644
--- a/lisp/vc/vc.el
+++ b/lisp/vc/vc.el
@@ -2001,7 +2001,8 @@ saving the buffer."
          rootdir working-revision)
       (if backend
          (setq rootdir (vc-call-backend backend 'root default-directory))
-       (setq rootdir (read-directory-name "Directory for VC root-diff: "))
+       (setq rootdir (read-directory-name "Directory for VC root-diff: "
+                                           nil (vc-known-roots)))
        (setq backend (vc-responsible-backend rootdir))
        (if backend
            (setq default-directory rootdir)
@@ -2545,7 +2546,8 @@ with its diffs (if the underlying VCS supports that)."
         rootdir)
     (if backend
        (setq rootdir (vc-call-backend backend 'root default-directory))
-      (setq rootdir (read-directory-name "Directory for VC revision log: "))
+      (setq rootdir (read-directory-name "Directory for VC revision log: "
+                                         nil (vc-known-roots)))
       (setq backend (vc-responsible-backend rootdir))
       (unless backend
         (error "Directory is not version controlled")))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]