Subject: Re: bug#41821: 28.0.50; read-directory-name in vc commands should provide defaults from projects

From: Juri Linkov <[email-masked]>
Date: Tue, 23 Jun 2020 02:45:55 +0300

>> But it would be nice to share these directories between project.el and vc.el.
>
> Perhaps there could be a public function in project.el called
> project-known-roots.

Like this?

diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index 2f213dab8b..f489145e92 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -935,6 +935,12 @@ project-prompt-project-dir
         (read-directory-name "Select directory: " default-directory nil t)
       pr-dir)))
 
+;;;###autoload
+(defun project-known-roots ()
+  "Return a list of known roots."
+  (project--ensure-read-project-list)
+  (mapcar #'project-try-vc (mapcar #'car project--list)))
+
 
 ;;; Project switching
 
diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el
index 9b12d44978..cc83d9a7a1 100644
--- a/lisp/vc/vc.el
+++ b/lisp/vc/vc.el
@@ -2547,7 +2555,10 @@ vc-print-root-log
 	 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
+                                         (mapcan (lambda (r) (when (eq (car r) 'vc)
+                                                               (list (cdr r))))
+                                                 (project-known-roots))))
       (setq backend (vc-responsible-backend rootdir))
       (unless backend
         (error "Directory is not version controlled")))