unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@linkov.net>
To: Dmitry Gutov <dgutov@yandex.ru>
Cc: 41821@debbugs.gnu.org
Subject: bug#41821: 28.0.50; read-directory-name in vc commands should provide defaults from projects
Date: Tue, 30 Jun 2020 23:50:06 +0300	[thread overview]
Message-ID: <87eepw5nlt.fsf@mail.linkov.net> (raw)
In-Reply-To: <3f9e85ba-66a9-abd0-61bf-800ea8bb4ee3@yandex.ru> (Dmitry Gutov's message of "Tue, 30 Jun 2020 15:36:26 +0300")

[-- Attachment #1: Type: text/plain, Size: 2500 bytes --]

>> Note the same prefix 'project-vc' for vc backend of project.el.
>> Then 'project-vc-known-roots' in project.el be like this:
>> (defun project-vc-known-roots ()
>>    "Return a list of known vc roots."
>>    (seq-filter #'project-try-vc (project-known-project-roots)))
>
> You suggested this before. Special-casing a particular backend in a general
> purpose public function is not a good idea.

It's not a general purpose function.  Its prefix 'project-vc-' indicates that
this public function is specific to project-vc backend.

>> Also every command that visits a directory in vc could register their dir
>> in the project list when project.el is loaded, for example:
>>    (defun vc-dir (dir &optional backend)
>>     ...
>>     (when (featurep 'project)
>>      ;; Add current vc project dir to project list
>>      (let ((default-directory dir))
>>       (project-current t)))
>
> Having considered it more, I now have more doubt on whether this approach
> is a good idea in general.
>
> See, even when the project backend is VC, there is no guarantee that its
> root will be the repository's root.

Isn't the project's root the same as the repository's root in 99% cases?

> First, there are submodules (and whether a submodule root is a project
> root is customizable).

This is a general problem currently discussed in other threads.

> Second, there is an existing feature request to use also some other
> project root markers, even inside VC repos (the "monorepo"
> case). These might end up in the 'vc' backend as well.

I don't see how is this related to the subject of this bug report.
It's not a big problem when some directories provided by M-n
are not repository root directories in 1% of cases.

> So things as they are, I'd rather VC has a separate roots history,
> or we at least put this feature request on hold (and, for now, revert
> the installed patches).

Look, what I'm trying to say is that there are users who want
to use project directories from ~/.emacs.d/projects in vc commands.
Of course, there are users with no free memory available that can't
afford loading project.el to the memory.  Addressing the needs of users
who don't use project.el is a separate issue.  But in this report
I'm addressing the needs of users who want to use project.el in vc commands.

Also I'm sure that most users will want to use project directories from
~/.emacs.d/projects not only in vc commands, but in more places for
non-vc commands.  Here's a similar patch for grep commands:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: read-directory-name-project-known-project-roots.patch --]
[-- Type: text/x-diff, Size: 2102 bytes --]

diff --git a/lisp/progmodes/grep.el b/lisp/progmodes/grep.el
index 7731be5965..331abf0f38 100644
--- a/lisp/progmodes/grep.el
+++ b/lisp/progmodes/grep.el
@@ -1078,8 +1078,12 @@ lgrep
        (error "grep.el: No `grep-template' available"))
       (t (let* ((regexp (grep-read-regexp))
 		(files (grep-read-files regexp))
-		(dir (read-directory-name "In directory: "
-					  nil default-directory t))
+		(dir (read-directory-name
+                      "In directory: " nil
+                      (if (featurep 'project)
+                          (project-known-project-roots)
+                        default-directory)
+                      t))
 		(confirm (equal current-prefix-arg '(4))))
 	   (list regexp files dir confirm))))))
   (when (and (stringp regexp) (> (length regexp) 0))
@@ -1166,8 +1170,12 @@ rgrep
        (error "grep.el: No `grep-find-template' available"))
       (t (let* ((regexp (grep-read-regexp))
 		(files (grep-read-files regexp))
-		(dir (read-directory-name "Base directory: "
-					  nil default-directory t))
+		(dir (read-directory-name
+                      "Base directory: " nil
+                      (if (featurep 'project)
+                          (project-known-project-roots)
+                        default-directory)
+                      t))
 		(confirm (equal current-prefix-arg '(4))))
 	   (list regexp files dir confirm))))))
   (when (and (stringp regexp) (> (length regexp) 0))
@@ -1297,8 +1305,12 @@ zrgrep
 	 (error "grep.el: No `grep-find-template' available"))
 	(t (let* ((regexp (grep-read-regexp))
 		  (files (grep-read-files regexp))
-		  (dir (read-directory-name "Base directory: "
-					    nil default-directory t))
+		  (dir (read-directory-name
+                        "Base directory: " nil
+                        (if (featurep 'project)
+                            (project-known-project-roots)
+                          default-directory)
+                        t))
 		  (confirm (equal current-prefix-arg '(4))))
 	     (list regexp files dir confirm grep-find-template)))))))
   (let ((grep-find-template template)

  reply	other threads:[~2020-06-30 20:50 UTC|newest]

Thread overview: 61+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-11 23:03 bug#41821: 28.0.50; read-directory-name in vc commands should provide defaults from projects Juri Linkov
2020-06-12 13:43 ` Dmitry Gutov
2020-06-18 23:28   ` Juri Linkov
2020-06-20  1:35     ` Dmitry Gutov
2020-06-20 23:51       ` Juri Linkov
2020-06-21  0:12         ` Dmitry Gutov
2020-06-21 22:49           ` Juri Linkov
2020-06-22  0:08             ` Dmitry Gutov
2020-06-22 23:45               ` Juri Linkov
2020-06-23  0:37                 ` Dmitry Gutov
2020-06-23 23:59                   ` Juri Linkov
2020-06-24 14:39                     ` Eli Zaretskii
2020-06-24 14:52                       ` Basil L. Contovounesios
2020-06-24 15:16                         ` Eli Zaretskii
2020-06-24 15:10                       ` Dmitry Gutov
2020-06-24 15:18                         ` Eli Zaretskii
2020-06-24 15:42                           ` Eli Zaretskii
2020-06-24 18:13                             ` Dmitry Gutov
2020-06-24 18:29                               ` Eli Zaretskii
2020-06-24 18:44                                 ` Dmitry Gutov
2020-06-24 23:25                                   ` Juri Linkov
2020-06-25 11:19                                     ` Dmitry Gutov
2020-06-25 13:20                                   ` Eli Zaretskii
2020-06-25 13:50                                     ` Dmitry Gutov
2020-06-25 16:31                                       ` Eli Zaretskii
2020-06-25 16:45                                         ` Dmitry Gutov
2020-06-25 17:09                                           ` Eli Zaretskii
2020-06-25 17:19                                             ` Dmitry Gutov
2020-06-25 17:45                                               ` Eli Zaretskii
2020-06-25 17:50                                                 ` Dmitry Gutov
2020-06-25 18:03                                                   ` Eli Zaretskii
2020-06-25 18:13                                                     ` Dmitry Gutov
2020-06-25 18:29                                                       ` Eli Zaretskii
2020-06-27 23:51                                     ` Juri Linkov
2020-06-28 14:33                                       ` Eli Zaretskii
2020-06-28 21:55                                         ` Juri Linkov
2020-06-28 21:51                                     ` Juri Linkov
2020-06-28 22:37                                       ` Dmitry Gutov
2020-06-29 22:58                                         ` Juri Linkov
2020-06-30 12:36                                           ` Dmitry Gutov
2020-06-30 20:50                                             ` Juri Linkov [this message]
2020-06-30 21:59                                               ` Dmitry Gutov
2020-07-01 14:42                                                 ` Eli Zaretskii
2020-07-01 20:24                                                   ` Dmitry Gutov
2020-07-02 13:36                                                     ` Eli Zaretskii
2020-07-02 14:43                                                       ` Dmitry Gutov
2020-07-02 17:41                                                         ` Eli Zaretskii
2020-07-02 19:37                                                           ` Dmitry Gutov
2020-07-03  5:55                                                             ` Eli Zaretskii
2020-07-03 10:23                                                               ` Dmitry Gutov
2020-07-03 11:48                                                                 ` Eli Zaretskii
2020-07-03 13:13                                                                   ` Dmitry Gutov
2020-07-01 22:10                                             ` Juri Linkov
2020-07-02 14:39                                               ` Dmitry Gutov
2020-06-24 23:22                             ` Juri Linkov
2020-06-24 18:29                     ` Dmitry Gutov
2020-06-27 23:44                       ` Juri Linkov
2020-06-28  0:19                         ` Dmitry Gutov
2020-06-28 21:49                           ` Juri Linkov
2020-06-28 22:42                             ` Dmitry Gutov
     [not found] <<87r1ulxk48.fsf@mail.linkov.net>
     [not found] ` <<ed4d76c6-3ef2-cf0b-5f8b-3b3bd61bdee5@yandex.ru>
     [not found]   ` <<87366ohw5z.fsf@mail.linkov.net>
     [not found]     ` <<c9db50b6-fa5a-aa0b-076b-0fbcbcdec7b4@yandex.ru>
     [not found]       ` <<878sge7jls.fsf@mail.linkov.net>
     [not found]         ` <<7e136435-7123-fa42-e4a8-66b82e6595da@yandex.ru>
     [not found]           ` <<87pn9pxris.fsf@mail.linkov.net>
     [not found]             ` <<83d05ottnw.fsf@gnu.org>
     [not found]               ` <<0b42f540-f779-446b-4411-8dae3a50d09d@yandex.ru>
     [not found]                 ` <<837dvwtrv1.fsf@gnu.org>
     [not found]                   ` <<835zbgtqps.fsf@gnu.org>
     [not found]                     ` <<625de669-0715-1467-0bd1-84328b4bee5f@yandex.ru>
     [not found]                       ` <<83wo3ws4g8.fsf@gnu.org>
     [not found]                         ` <<f9cd868b-ca2f-bb8e-9b48-af37cc215855@yandex.ru>
     [not found]                           ` <<83tuyzs2np.fsf@gnu.org>
     [not found]                             ` <<87h7uuj1v3.fsf@mail.linkov.net>
     [not found]                               ` <<d93d0f5a-7067-de6a-c2f5-c263864c479e@yandex.ru>
     [not found]                                 ` <<87h7utjx75.fsf@mail.linkov.net>
     [not found]                                   ` <<3f9e85ba-66a9-abd0-61bf-800ea8bb4ee3@yandex.ru>
     [not found]                                     ` <<87eepw5nlt.fsf@mail.linkov.net>
     [not found]                                       ` <<faccdab8-153d-b31c-4be6-81bb924a200b@yandex.ru>
     [not found]                                         ` <<83v9j7xpoj.fsf@gnu.org>
     [not found]                                           ` <<990a9046-c4e6-efb2-01dd-60198994127b@yandex.ru>
     [not found]                                             ` <<831rluxcll.fsf@gnu.org>
     [not found]                                               ` <<c75015c8-9291-6a70-df7a-a02c112b5973@yandex.ru>
     [not found]                                                 ` <<83r1ttx196.fsf@gnu.org>
     [not found]                                                   ` <<9c09977f-18c2-facd-c1e2-e7fe488ee92c@yandex.ru>
     [not found]                                                     ` <<83eeptw3a9.fsf@gnu.org>
2020-07-03 16:05                                                       ` Drew Adams

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=87eepw5nlt.fsf@mail.linkov.net \
    --to=juri@linkov.net \
    --cc=41821@debbugs.gnu.org \
    --cc=dgutov@yandex.ru \
    /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).