emacs-diffs
[Top][All Lists]
Advanced

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

master df1d4f5: New command: project-find-dir


From: Dmitry Gutov
Subject: master df1d4f5: New command: project-find-dir
Date: Mon, 20 Sep 2021 20:53:42 -0400 (EDT)

branch: master
commit df1d4f58948b6db8a4063c1458748deb684d4a1b
Author: Dmitry Gutov <dgutov@yandex.ru>
Commit: Dmitry Gutov <dgutov@yandex.ru>

    New command: project-find-dir
    
    * 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 |  7 ++++++-
 lisp/progmodes/project.el  | 25 +++++++++++++++++++++++--
 2 files changed, 29 insertions(+), 3 deletions(-)

diff --git a/doc/emacs/maintaining.texi b/doc/emacs/maintaining.texi
index b692c99..f98e7b1 100644
--- a/doc/emacs/maintaining.texi
+++ b/doc/emacs/maintaining.texi
@@ -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.
 
diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index 67c34b4..f1437c6 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -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)
@@ -931,6 +932,26 @@ is used as part of \"future history\"."
                      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."
   (interactive)
@@ -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.



reply via email to

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