* 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.
*** 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
(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)
+
\f
;;; Project switching
;; 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
(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.
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)
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")))