From mboxrd@z Thu Jan  1 00:00:00 1970
Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail
From: Juri Linkov <juri@linkov.net>
Newsgroups: gmane.emacs.bugs
Subject: bug#41821: 28.0.50;
 read-directory-name in vc commands should provide defaults from
 projects
Date: Thu, 02 Jul 2020 01:10:00 +0300
Organization: LINKOV.NET
Message-ID: <87y2o2c2l6.fsf@mail.linkov.net>
References: <87r1ulxk48.fsf@mail.linkov.net>
 <dbb82a30-fdbc-f9af-49c0-b7b857933637@yandex.ru>
 <87y2oh8fdv.fsf@mail.linkov.net>
 <ed4d76c6-3ef2-cf0b-5f8b-3b3bd61bdee5@yandex.ru>
 <87366ohw5z.fsf@mail.linkov.net>
 <c9db50b6-fa5a-aa0b-076b-0fbcbcdec7b4@yandex.ru>
 <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>
 <f9cd868b-ca2f-bb8e-9b48-af37cc215855@yandex.ru>
 <83tuyzs2np.fsf@gnu.org> <87h7uuj1v3.fsf@mail.linkov.net>
 <d93d0f5a-7067-de6a-c2f5-c263864c479e@yandex.ru>
 <87h7utjx75.fsf@mail.linkov.net>
 <3f9e85ba-66a9-abd0-61bf-800ea8bb4ee3@yandex.ru>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214";
	logging-data="11475"; 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 <dgutov@yandex.ru>
Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Jul 02 00:11:14 2020
Return-path: <bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org>
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 <bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org>)
	id 1jqkwk-0002tJ-A6
	for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 02 Jul 2020 00:11:14 +0200
Original-Received: from localhost ([::1]:38372 helo=lists1p.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.90_1)
	(envelope-from <bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org>)
	id 1jqkwj-0002pB-0k
	for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 01 Jul 2020 18:11:13 -0400
Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:37856)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <Debian-debbugs@debbugs.gnu.org>)
 id 1jqkwY-0002ok-PV
 for bug-gnu-emacs@gnu.org; Wed, 01 Jul 2020 18:11:02 -0400
Original-Received: from debbugs.gnu.org ([209.51.188.43]:42321)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <Debian-debbugs@debbugs.gnu.org>)
 id 1jqkwY-000382-Fn
 for bug-gnu-emacs@gnu.org; Wed, 01 Jul 2020 18:11:02 -0400
Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2)
 (envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1jqkwY-0005lx-AL
 for bug-gnu-emacs@gnu.org; Wed, 01 Jul 2020 18:11:02 -0400
X-Loop: help-debbugs@gnu.org
Resent-From: Juri Linkov <juri@linkov.net>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces@debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@gnu.org
Resent-Date: Wed, 01 Jul 2020 22:11:02 +0000
Resent-Message-ID: <handler.41821.B41821.159364143622154@debbugs.gnu.org>
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.159364143622154
 (code B ref 41821); Wed, 01 Jul 2020 22:11:02 +0000
Original-Received: (at 41821) by debbugs.gnu.org; 1 Jul 2020 22:10:36 +0000
Original-Received: from localhost ([127.0.0.1]:53866 helo=debbugs.gnu.org)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <debbugs-submit-bounces@debbugs.gnu.org>)
 id 1jqkw8-0005lG-HA
 for submit@debbugs.gnu.org; Wed, 01 Jul 2020 18:10:36 -0400
Original-Received: from relay12.mail.gandi.net ([217.70.178.232]:59823)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <juri@linkov.net>) id 1jqkw7-0005kf-2g
 for 41821@debbugs.gnu.org; Wed, 01 Jul 2020 18:10:35 -0400
Original-Received: from mail.gandi.net (m91-129-96-187.cust.tele2.ee [91.129.96.187])
 (Authenticated sender: juri@linkov.net)
 by relay12.mail.gandi.net (Postfix) with ESMTPSA id 00CF8200005;
 Wed,  1 Jul 2020 22:10:27 +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" <bug-gnu-emacs.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/bug-gnu-emacs>,
 <mailto:bug-gnu-emacs-request@gnu.org?subject=unsubscribe>
List-Archive: <https://lists.gnu.org/archive/html/bug-gnu-emacs>
List-Post: <mailto:bug-gnu-emacs@gnu.org>
List-Help: <mailto:bug-gnu-emacs-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/bug-gnu-emacs>,
 <mailto:bug-gnu-emacs-request@gnu.org?subject=subscribe>
Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org
Original-Sender: "bug-gnu-emacs"
 <bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org>
Xref: news.gmane.io gmane.emacs.bugs:182621
Archived-At: <http://permalink.gmane.org/gmane.emacs.bugs/182621>

> we at least put this feature request on hold (and, for now,
> revert the installed patches).

Ok, reverted the installed patches.

It's easy to achieve the same in the init file with these
simple advises.  Now this works perfectly from POV of users
who prefer to use project directories everywhere in all prompts
that ask for a directory:

#+begin_src emacs-lisp
;; When a prompt of some commands such as 'rgrep' or 'vc-print-log' asks for
;; a directory name, allow 'M-n' to access the most recently used project
;; directories saved in ~/.emacs.d/projects:

(advice-add 'read-directory-name :around
            (lambda (orig-fun prompt &optional dir default-dirname
                              mustmatch initial)
              (when (featurep 'project)
                (setq default-dirname
                      (append (cond
                               ((null default-dirname)
                                (list (or dir default-directory)))
                               ((consp default-dirname)
                                default-dirname)
                               (t
                                (list default-dirname)))
                              (project-known-project-roots))))
              (let ((ret (funcall orig-fun prompt dir default-dirname
                                  mustmatch initial)))
                (when (featurep 'project)
                  ;; Update project list with selected project dir
                  (let ((default-directory ret))
                    (project-current t)))
                ret))
            '((name . read-directory-name-project-defaults)))

(advice-add 'vc-dir :after
            (lambda (dir &optional _backend)
              (when (featurep 'project)
                ;; Add current vc project dir to project list
                (let ((default-directory dir))
                  (project-current t))))
            '((name . vc-dir-add-project)))
#+end_src