unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Dmitry Gutov <dgutov@yandex.ru>
To: Stefan Kangas <stefan@marxist.se>, Juri Linkov <juri@linkov.net>
Cc: 43153@debbugs.gnu.org
Subject: bug#43153: Add new command project-find-dir (and move binding of project-dired)
Date: Mon, 20 Sep 2021 04:34:43 +0300	[thread overview]
Message-ID: <e63bb0a9-a8df-1d48-4351-793f650e9e27@yandex.ru> (raw)
In-Reply-To: <CADwFkmmhbQ3otaxK6LUCqmUgiccjD0wae8eMjOYd3SFAafb7Fw@mail.gmail.com>

Hi all!

On 19.09.2021 23:42, Stefan Kangas wrote:
> Juri Linkov<juri@linkov.net>  writes:
> 
>> Maybe then better to rename `project-dired' to `project-root-dired',
>> then bind `C-x p D' to `project-root-dired' without the prompt,
>> and bind `project-dired' to `C-x p d' with a prompt that
>> asks for a directory like `C-x p f' (project-find-file).
> Agreed.  Let's see what Dmitry thinks about it.

Here's a quick implementation of this feature inside project-dired:

diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index 563b9c3c90..3a21cc15a4 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -963,7 +963,18 @@ project--completing-read-strict
  (defun project-dired ()
    "Start Dired in the current project's root."
    (interactive)
-  (dired (project-root (project-current t))))
+  (let* ((project (project-current t))
+         (all-files (project-files (project-current)))
+         (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" all-dirs nil nil)))
+    (dired dir)))

  ;;;###autoload
  (defun project-vc-dir ()


It's a little flawed, but that shouldn't stop us from installing it.

Note that the user can simply press RET without typing any directory 
name and that will launch Dired in the project root.

That seems like it might make having a separate command unnecessary, 
since 'C-x p D' and 'C-x p d RET' take the same number of keypresses. 
The latter might make you move your hand farther, though.

But I don't mind having a separate command if you both think it's a good 
idea. Then we either call it project-root-dired, and this new one -- 
just project-dired. Or we move project-dired to 'C-x p D' without 
changing it, and add this functionality in 'project-find-dir', bound to 
'C-x p d'.

OTOH, it might make sense to keep 'project-dired' on 'C-x p d' and move 
project-find-dir to 'C-x p D' because the users of the latter must be 
prepared to do more typing anyway during completion, so having to also 
press Shift once won't hurt their efficiency much. But compatibility 
with Projectile can be important, too.

Cast your votes, everybody ;-)





  reply	other threads:[~2021-09-20  1:34 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-01 10:48 bug#43153: Add new command project-find-dir (and move binding of project-dired) Stefan Kangas
2020-09-01 11:55 ` Dmitry Gutov
2020-09-01 15:32   ` Stefan Kangas
2020-09-03 22:57     ` Dmitry Gutov
2021-09-19 15:34   ` Stefan Kangas
2021-09-19 16:40     ` Juri Linkov
2021-09-19 17:23       ` Stefan Kangas
2021-09-19 17:35         ` Juri Linkov
2021-09-19 20:42           ` Stefan Kangas
2021-09-20  1:34             ` Dmitry Gutov [this message]
2021-09-20  6:54               ` Juri Linkov
2021-09-20 14:31                 ` Dmitry Gutov
2021-09-20 15:17                   ` Juri Linkov
2021-09-20 15:30                     ` Dmitry Gutov
2021-09-21 17:29                       ` Juri Linkov
2021-09-21 17:49                         ` Dmitry Gutov
2021-09-20  7:11               ` Stefan Kangas
2021-09-20 14:33                 ` Dmitry Gutov
2021-09-20 15:29                   ` Stefan Kangas
2021-09-21  0:57                     ` Dmitry Gutov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e63bb0a9-a8df-1d48-4351-793f650e9e27@yandex.ru \
    --to=dgutov@yandex.ru \
    --cc=43153@debbugs.gnu.org \
    --cc=juri@linkov.net \
    --cc=stefan@marxist.se \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).