diff options
| author | Juri Linkov | 2020-06-24 02:59:31 +0300 |
|---|---|---|
| committer | Juri Linkov | 2020-06-24 02:59:31 +0300 |
| commit | bfd96e995dae796fd3f68301fcc4921fb4c42745 (patch) | |
| tree | 54e6b155fcf79fdc9158440344ea3f9164f2bcea | |
| parent | 4e04ca847fc04ad0b2845143e0788485de0ed997 (diff) | |
| download | emacs-bfd96e995dae796fd3f68301fcc4921fb4c42745.tar.gz emacs-bfd96e995dae796fd3f68301fcc4921fb4c42745.zip | |
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.
| -rw-r--r-- | etc/NEWS | 3 | ||||
| -rw-r--r-- | lisp/progmodes/project.el | 6 | ||||
| -rw-r--r-- | lisp/vc/vc-dir.el | 2 | ||||
| -rw-r--r-- | lisp/vc/vc-hooks.el | 5 | ||||
| -rw-r--r-- | lisp/vc/vc.el | 6 |
5 files changed, 19 insertions, 3 deletions
| @@ -176,6 +176,9 @@ directories with the help of new command 'dired-vc-next-action'. | |||
| 176 | *** More vc commands that don't change VC state can be used from non-file buffers. | 176 | *** More vc commands that don't change VC state can be used from non-file buffers. |
| 177 | Such non-file buffers should have default-directory under vc. | 177 | Such non-file buffers should have default-directory under vc. |
| 178 | 178 | ||
| 179 | *** Typing 'M-n' in the minibuffer that asks for a vc directory in vc commands | ||
| 180 | can retrieve directories of previously used vc projects. | ||
| 181 | |||
| 179 | *** New command 'vc-dir-root' uses the root directory without asking. | 182 | *** New command 'vc-dir-root' uses the root directory without asking. |
| 180 | 183 | ||
| 181 | *** New commands 'vc-dir-mark-registered-files' (bound to '* r') and | 184 | *** New commands 'vc-dir-mark-registered-files' (bound to '* r') and |
diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el index 2f213dab8b1..42715dc9dcf 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." | |||
| 935 | (read-directory-name "Select directory: " default-directory nil t) | 935 | (read-directory-name "Select directory: " default-directory nil t) |
| 936 | pr-dir))) | 936 | pr-dir))) |
| 937 | 937 | ||
| 938 | ;;;###autoload | ||
| 939 | (defun project-known-roots () | ||
| 940 | "Return a list of known project roots." | ||
| 941 | (project--ensure-read-project-list) | ||
| 942 | project--list) | ||
| 943 | |||
| 938 | 944 | ||
| 939 | ;;; Project switching | 945 | ;;; Project switching |
| 940 | 946 | ||
diff --git a/lisp/vc/vc-dir.el b/lisp/vc/vc-dir.el index cdf8ab984e8..46be9b73801 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: | |||
| 1366 | ;; Otherwise if you do C-x v d -> C-x C-f -> C-x v d | 1366 | ;; Otherwise if you do C-x v d -> C-x C-f -> C-x v d |
| 1367 | ;; you may get a new *vc-dir* buffer, different from the original | 1367 | ;; you may get a new *vc-dir* buffer, different from the original |
| 1368 | (file-truename (read-directory-name "VC status for directory: " | 1368 | (file-truename (read-directory-name "VC status for directory: " |
| 1369 | (vc-root-dir) nil t | 1369 | (vc-root-dir) (vc-known-roots) t |
| 1370 | nil)) | 1370 | nil)) |
| 1371 | (if current-prefix-arg | 1371 | (if current-prefix-arg |
| 1372 | (intern | 1372 | (intern |
diff --git a/lisp/vc/vc-hooks.el b/lisp/vc/vc-hooks.el index ce72a49b955..9675c364bb7 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." | |||
| 299 | (set-buffer-modified-p nil) | 299 | (set-buffer-modified-p nil) |
| 300 | t)) | 300 | t)) |
| 301 | 301 | ||
| 302 | (declare-function project-try-vc "project") | ||
| 303 | (defun vc-known-roots () | ||
| 304 | "Return a list of known vc roots." | ||
| 305 | (seq-filter #'project-try-vc (mapcar #'car (project-known-roots)))) | ||
| 306 | |||
| 302 | (defun vc-find-root (file witness) | 307 | (defun vc-find-root (file witness) |
| 303 | "Find the root of a checked out project. | 308 | "Find the root of a checked out project. |
| 304 | The function walks up the directory tree from FILE looking for WITNESS. | 309 | 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 65775f8e46e..49323ef47d2 100644 --- a/lisp/vc/vc.el +++ b/lisp/vc/vc.el | |||
| @@ -2001,7 +2001,8 @@ saving the buffer." | |||
| 2001 | rootdir working-revision) | 2001 | rootdir working-revision) |
| 2002 | (if backend | 2002 | (if backend |
| 2003 | (setq rootdir (vc-call-backend backend 'root default-directory)) | 2003 | (setq rootdir (vc-call-backend backend 'root default-directory)) |
| 2004 | (setq rootdir (read-directory-name "Directory for VC root-diff: ")) | 2004 | (setq rootdir (read-directory-name "Directory for VC root-diff: " |
| 2005 | nil (vc-known-roots))) | ||
| 2005 | (setq backend (vc-responsible-backend rootdir)) | 2006 | (setq backend (vc-responsible-backend rootdir)) |
| 2006 | (if backend | 2007 | (if backend |
| 2007 | (setq default-directory rootdir) | 2008 | (setq default-directory rootdir) |
| @@ -2545,7 +2546,8 @@ with its diffs (if the underlying VCS supports that)." | |||
| 2545 | rootdir) | 2546 | rootdir) |
| 2546 | (if backend | 2547 | (if backend |
| 2547 | (setq rootdir (vc-call-backend backend 'root default-directory)) | 2548 | (setq rootdir (vc-call-backend backend 'root default-directory)) |
| 2548 | (setq rootdir (read-directory-name "Directory for VC revision log: ")) | 2549 | (setq rootdir (read-directory-name "Directory for VC revision log: " |
| 2550 | nil (vc-known-roots))) | ||
| 2549 | (setq backend (vc-responsible-backend rootdir)) | 2551 | (setq backend (vc-responsible-backend rootdir)) |
| 2550 | (unless backend | 2552 | (unless backend |
| 2551 | (error "Directory is not version controlled"))) | 2553 | (error "Directory is not version controlled"))) |