]> git.eshelyaron.com Git - emacs.git/commitdiff
New command: project-find-dir
authorDmitry Gutov <dgutov@yandex.ru>
Tue, 21 Sep 2021 00:34:00 +0000 (03:34 +0300)
committerDmitry Gutov <dgutov@yandex.ru>
Tue, 21 Sep 2021 00:53:21 +0000 (03:53 +0300)
* doc/emacs/maintaining.texi (Project File Commands):
Mention the new command and update the bindings information.

* lisp/progmodes/project.el (project-find-dir):
New command (bug#43153).
(project-prefix-map): Use 'd' as its binding.
Move 'project-dired' to 'D'.
(project-switch-commands):
Replace 'project-dired' with 'project-find-dir'.

doc/emacs/maintaining.texi
lisp/progmodes/project.el

index b692c995513f56bb25250dcd9fcfa3ceeaf93c10..f98e7b1edafe4915bcf78d0b6f14ef117924d885 100644 (file)
@@ -1769,8 +1769,13 @@ Replace}), and continues to the next match after you respond.  If your
 response causes Emacs to exit the query-replace loop, you can later
 continue with @w{@kbd{M-x fileloop-continue @key{RET}}}.
 
+@findex project-find-dir
+  The command @kbd{C-x p d} (@code{project-find-dir}) prompts you to
+choose a directory inside the current project, with completion.
+And opens a Dired buffer (@pxref{Dired}) listing the files in it.
+
 @findex project-dired
-  The command @kbd{C-x p d} (@code{project-dired}) opens a Dired
+  The command @kbd{C-x p D} (@code{project-dired}) opens a Dired
 buffer (@pxref{Dired}) listing the files in the current project's root
 directory.
 
index 67c34b4e5c5daf01b918b726ca23b224e9a1bcd2..f1437c6a2380ea24350ec063382dde0b6f166ef0 100644 (file)
@@ -674,7 +674,8 @@ DIRS must contain directory names."
     (define-key map "F" 'project-or-external-find-file)
     (define-key map "b" 'project-switch-to-buffer)
     (define-key map "s" 'project-shell)
-    (define-key map "d" 'project-dired)
+    (define-key map "d" 'project-find-dir)
+    (define-key map "D" 'project-dired)
     (define-key map "v" 'project-vc-dir)
     (define-key map "c" 'project-compile)
     (define-key map "e" 'project-eshell)
@@ -930,6 +931,26 @@ is used as part of \"future history\"."
                      nil
                      hist)))
 
+;;;###autoload
+(defun project-find-dir ()
+  "Start Dired in a directory inside the current project."
+  (interactive)
+  (let* ((project (project-current t))
+         (all-files (project-files project))
+         (completion-ignore-case read-file-name-completion-ignore-case)
+         ;; FIXME: This misses directories without any files directly
+         ;; inside.  Consider DIRS-ONLY as an argument for
+         ;; `project-files-filtered', and see
+         ;; https://stackoverflow.com/a/50685235/615245 for possible
+         ;; implementation.
+         (all-dirs (mapcar #'file-name-directory all-files))
+         (dir (funcall project-read-file-name-function
+                       "Dired"
+                       ;; Some completion UIs show duplicates.
+                       (delete-dups all-dirs)
+                       nil nil)))
+    (dired dir)))
+
 ;;;###autoload
 (defun project-dired ()
   "Start Dired in the current project's root."
@@ -1342,7 +1363,7 @@ It's also possible to enter an arbitrary directory not in the list."
 (defcustom project-switch-commands
   '((project-find-file "Find file")
     (project-find-regexp "Find regexp")
-    (project-dired "Dired")
+    (project-find-dir "Find directory")
     (project-vc-dir "VC-Dir")
     (project-eshell "Eshell"))
   "Alist mapping commands to descriptions.