From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs 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 Organization: LINKOV.NET Message-ID: <87eepw5nlt.fsf@mail.linkov.net> References: <87r1ulxk48.fsf@mail.linkov.net> <87y2oh8fdv.fsf@mail.linkov.net> <87366ohw5z.fsf@mail.linkov.net> <878sge7jls.fsf@mail.linkov.net> <7e136435-7123-fa42-e4a8-66b82e6595da@yandex.ru> <87pn9pxris.fsf@mail.linkov.net> <83d05ottnw.fsf@gnu.org> <0b42f540-f779-446b-4411-8dae3a50d09d@yandex.ru> <837dvwtrv1.fsf@gnu.org> <835zbgtqps.fsf@gnu.org> <625de669-0715-1467-0bd1-84328b4bee5f@yandex.ru> <83wo3ws4g8.fsf@gnu.org> <83tuyzs2np.fsf@gnu.org> <87h7uuj1v3.fsf@mail.linkov.net> <87h7utjx75.fsf@mail.linkov.net> <3f9e85ba-66a9-abd0-61bf-800ea8bb4ee3@yandex.ru> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="28644"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) Cc: 41821@debbugs.gnu.org To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Jun 30 23:35:47 2020 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 1jqNut-0007Mr-IV for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 30 Jun 2020 23:35:47 +0200 Original-Received: from localhost ([::1]:40404 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jqNus-0008TP-6O for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 30 Jun 2020 17:35:46 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:50068) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jqNtD-0007K6-Cd for bug-gnu-emacs@gnu.org; Tue, 30 Jun 2020 17:34:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:40286) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jqNtD-0003Gx-2t for bug-gnu-emacs@gnu.org; Tue, 30 Jun 2020 17:34:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jqNtD-0007F9-0n for bug-gnu-emacs@gnu.org; Tue, 30 Jun 2020 17:34:03 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 30 Jun 2020 21:34:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 41821 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: fixed Original-Received: via spool by 41821-submit@debbugs.gnu.org id=B41821.159355282827780 (code B ref 41821); Tue, 30 Jun 2020 21:34:02 +0000 Original-Received: (at 41821) by debbugs.gnu.org; 30 Jun 2020 21:33:48 +0000 Original-Received: from localhost ([127.0.0.1]:51826 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jqNsx-0007Du-Rc for submit@debbugs.gnu.org; Tue, 30 Jun 2020 17:33:48 -0400 Original-Received: from relay1-d.mail.gandi.net ([217.70.183.193]:16687) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jqNst-0007DS-2v for 41821@debbugs.gnu.org; Tue, 30 Jun 2020 17:33:46 -0400 X-Originating-IP: 91.129.96.187 Original-Received: from mail.gandi.net (m91-129-96-187.cust.tele2.ee [91.129.96.187]) (Authenticated sender: juri@linkov.net) by relay1-d.mail.gandi.net (Postfix) with ESMTPSA id F27A1240003; Tue, 30 Jun 2020 21:33:35 +0000 (UTC) In-Reply-To: <3f9e85ba-66a9-abd0-61bf-800ea8bb4ee3@yandex.ru> (Dmitry Gutov's message of "Tue, 30 Jun 2020 15:36:26 +0300") 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:182587 Archived-At: --=-=-= Content-Type: text/plain >> 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: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=read-directory-name-project-known-project-roots.patch 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) --=-=-=--