From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.bugs Subject: bug#43153: Add new command project-find-dir (and move binding of project-dired) Date: Mon, 20 Sep 2021 04:34:43 +0300 Message-ID: References: <3071f53f-4334-6ed6-e69e-b49122492a1b@yandex.ru> <87czp4ikng.fsf@mail.linkov.net> <87h7egfoz2.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="19002"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 Cc: 43153@debbugs.gnu.org To: Stefan Kangas , Juri Linkov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Sep 20 03:35:11 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mS8D8-0004j5-Tk for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 20 Sep 2021 03:35:11 +0200 Original-Received: from localhost ([::1]:59356 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mS8D7-0003xw-0t for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 19 Sep 2021 21:35:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:52570) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mS8D0-0003xW-5T for bug-gnu-emacs@gnu.org; Sun, 19 Sep 2021 21:35:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:57062) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mS8Cz-0002uN-Tu for bug-gnu-emacs@gnu.org; Sun, 19 Sep 2021 21:35:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mS8Cz-0001mo-Oy for bug-gnu-emacs@gnu.org; Sun, 19 Sep 2021 21:35:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 20 Sep 2021 01:35:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 43153 X-GNU-PR-Package: emacs Original-Received: via spool by 43153-submit@debbugs.gnu.org id=B43153.16321017006856 (code B ref 43153); Mon, 20 Sep 2021 01:35:01 +0000 Original-Received: (at 43153) by debbugs.gnu.org; 20 Sep 2021 01:35:00 +0000 Original-Received: from localhost ([127.0.0.1]:40375 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mS8Cx-0001mV-Oh for submit@debbugs.gnu.org; Sun, 19 Sep 2021 21:35:00 -0400 Original-Received: from mail-wr1-f41.google.com ([209.85.221.41]:41876) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mS8Cv-0001mI-Gn for 43153@debbugs.gnu.org; Sun, 19 Sep 2021 21:34:58 -0400 Original-Received: by mail-wr1-f41.google.com with SMTP id w29so25864122wra.8 for <43153@debbugs.gnu.org>; Sun, 19 Sep 2021 18:34:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=dx2I7aKe6lDsEG0VQKVAGADhsSUK37LWv8LJwl4NSFM=; b=OGzP9tnlWIeJKib6DGCldFP8ZzrnrdD1ekzCQ0st296ckSGcN8rX/J56B8VCjVjdrZ HrUi2WmQdQMV/A3oNWA6PuXrTsvjR4e+RrTKo/J0ERUMLAgcVDbmnvmS0JuqMsqfd3fo 6xfB6V3HD22UEJVsQrXX0GY5B0POc4ae1AVJ/dpR7ROyTE1P+RYECF9VHZiNIFS6KouT IekwnJZlCdFpi08+HwoZK/LfNVfwA6PoDBGt1eKnewAvkc80u1zXDW7FpHks3UtMAKwh h7eqmG3dhYeTEtX1bUSrYs2eba110t877cy3k7kCrVoyUgCOLO8zfEO+u7HuMpHilFyR Auaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:subject:to:cc:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=dx2I7aKe6lDsEG0VQKVAGADhsSUK37LWv8LJwl4NSFM=; b=20NisQ+C+V36AxaXx6Xj9WBTCA/rEILT8GLvdufkc8VXdpU9Lw4x4XAUvWEZ5bCHLM 2NfOHk5kMUUQsQwY67JzAsO741vkjJAt67S71H5OSoH87x7qo2PT+zseBYMHTWO5Czgj HFdrjQSrToq7XY6ULAXK5JvjCbzPY7RENmXaLauS34MnDYx8EggZ3GcpTVZFgFtuQJy7 8x4fCEW0+ncEh2dYwAO170Sl0h+MKijgRITFA8xRvUvkztXKtiEqEBJKEEAQ/UcHLtCj 0utxJRS2n60aqq8i90SoqQ0vXzOOxh9ZJEzIKG9QkxUSWH7462dH50AwMSSbUtiyY03/ 8cxw== X-Gm-Message-State: AOAM532QZs1lwIiE5sC6WdrcUhz3qrcP+a4da64kJGqrlqysY7oRtdeY 6Yn6qF3w9Ipo61Tl9L7QNvGuOq8qDdA= X-Google-Smtp-Source: ABdhPJy1QgDCPq5ZqFfAXfoW2kEn5c0PGTHQIgaOU/e+3lfGOPNfzZ12tUcGVWzKIUG299lr0/2bpg== X-Received: by 2002:adf:cf10:: with SMTP id o16mr24999613wrj.12.1632101691522; Sun, 19 Sep 2021 18:34:51 -0700 (PDT) Original-Received: from [192.168.0.6] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id v18sm13484269wml.44.2021.09.19.18.34.49 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 19 Sep 2021 18:34:51 -0700 (PDT) In-Reply-To: Content-Language: en-US X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:214807 Archived-At: Hi all! On 19.09.2021 23:42, Stefan Kangas wrote: > Juri Linkov 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 ;-)