From mboxrd@z Thu Jan  1 00:00:00 1970
Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail
From: Dmitry Gutov <dmitry@gutov.dev>
Newsgroups: gmane.emacs.bugs
Subject: bug#67310: [PATCH] Include the project--list as history when
 prompting for a project
Date: Tue, 12 Dec 2023 02:21:07 +0200
Message-ID: <8c67f590-d31a-44be-1c33-c0c75e4da63c@gutov.dev>
References: <ier8r6s42on.fsf@janestreet.com>
 <dc5ad8f4-b857-ea87-d178-bae903cee517@gutov.dev>
 <421e3ea8-d150-566e-f645-cbf1ccbcba61@gutov.dev>
 <ier34wz3zkx.fsf@janestreet.com>
 <81b6ed58-3fdc-3b5a-41a9-84d66475d5f1@gutov.dev>
 <ierr0khlq19.fsf@janestreet.com>
 <5c3eb6a1-38da-8af4-419a-e0567b163e3a@gutov.dev>
 <iercyw1l6rz.fsf@janestreet.com>
 <dc3b5328-8719-8948-e617-e3e8cf13f274@gutov.dev>
 <ier8r6nkv58.fsf@janestreet.com> <8634wr6s1t.fsf@mail.linkov.net>
 <dfbd2b3e-a14b-b5b4-a7c0-aa837ea6220c@gutov.dev>
 <861qbujehq.fsf@mail.linkov.net>
 <780dbb13-c0ca-9082-936b-3c2ab34084dc@gutov.dev>
 <861qbtq630.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="10537"; mail-complaints-to="usenet@ciao.gmane.io"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
 Thunderbird/102.13.0
Cc: 67310@debbugs.gnu.org, Spencer Baugh <sbaugh@janestreet.com>, eliz@gnu.org
To: Juri Linkov <juri@linkov.net>
Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Dec 12 01:22:07 2023
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 1rCqXG-0002VW-I0
	for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 12 Dec 2023 01:22:07 +0100
Original-Received: from localhost ([::1] helo=lists1p.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.90_1)
	(envelope-from <bug-gnu-emacs-bounces@gnu.org>)
	id 1rCqWz-0000IW-Am; Mon, 11 Dec 2023 19:21:49 -0500
Original-Received: from eggs.gnu.org ([2001:470:142:3::10])
 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 1rCqWx-0000II-G5
 for bug-gnu-emacs@gnu.org; Mon, 11 Dec 2023 19:21:47 -0500
Original-Received: from debbugs.gnu.org ([2001:470:142:5::43])
 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 1rCqWx-00076E-8R
 for bug-gnu-emacs@gnu.org; Mon, 11 Dec 2023 19:21:47 -0500
Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2)
 (envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1rCqXC-00023g-8O
 for bug-gnu-emacs@gnu.org; Mon, 11 Dec 2023 19:22:02 -0500
X-Loop: help-debbugs@gnu.org
Resent-From: Dmitry Gutov <dmitry@gutov.dev>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces@debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@gnu.org
Resent-Date: Tue, 12 Dec 2023 00:22:02 +0000
Resent-Message-ID: <handler.67310.B67310.17023405007877@debbugs.gnu.org>
Resent-Sender: help-debbugs@gnu.org
X-GNU-PR-Message: followup 67310
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: patch
Original-Received: via spool by 67310-submit@debbugs.gnu.org id=B67310.17023405007877
 (code B ref 67310); Tue, 12 Dec 2023 00:22:02 +0000
Original-Received: (at 67310) by debbugs.gnu.org; 12 Dec 2023 00:21:40 +0000
Original-Received: from localhost ([127.0.0.1]:55013 helo=debbugs.gnu.org)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <debbugs-submit-bounces@debbugs.gnu.org>)
 id 1rCqWp-00022z-GL
 for submit@debbugs.gnu.org; Mon, 11 Dec 2023 19:21:39 -0500
Original-Received: from wout2-smtp.messagingengine.com ([64.147.123.25]:59063)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dmitry@gutov.dev>) id 1rCqWh-00022a-MP
 for 67310@debbugs.gnu.org; Mon, 11 Dec 2023 19:21:38 -0500
Original-Received: from compute5.internal (compute5.nyi.internal [10.202.2.45])
 by mailout.west.internal (Postfix) with ESMTP id AE30A320193A;
 Mon, 11 Dec 2023 19:21:10 -0500 (EST)
Original-Received: from mailfrontend1 ([10.202.2.162])
 by compute5.internal (MEProxy); Mon, 11 Dec 2023 19:21:11 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gutov.dev; h=cc
 :cc:content-transfer-encoding:content-type:content-type:date
 :date:from:from:in-reply-to:in-reply-to:message-id:mime-version
 :references:reply-to:subject:subject:to:to; s=fm3; t=1702340470;
 x=1702426870; bh=dXEY2DoUD7ndk4PVtJz1uy2Eoq/yrEHdLgbhf7GKnfc=; b=
 G4cmOrF2lnf/ls4MukfH56IplYR18xknDFdbymonhOSbheIO2TmFmTeOY0kqjm0g
 1p9VTWLHHubP5KBuYtQMtoOX7b2vA2gUab7Fil6zVeWeSkqpjFTcHonPLRegCAj4
 QqtGd38DgP9vLX15gJIa9rFBrrykBbJSPymeONw/bVBK9iHoVtFn2Nut5kICZLSV
 y8HJJk4XNZe0L632vS3Q8uQs32iNlcSaFb1TqRoWGP6aGUHHb+2sTGg7CkMziY+E
 1kIgkRyCUQcfOGmC7LGmT3lcyM4GH7G7p147qlMitozTgvn9ImwrstriqXQsGc3H
 MTvclBeO0njidrBZvonbyQ==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=
 messagingengine.com; h=cc:cc:content-transfer-encoding
 :content-type:content-type:date:date:feedback-id:feedback-id
 :from:from:in-reply-to:in-reply-to:message-id:mime-version
 :references:reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy
 :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1702340470; x=
 1702426870; bh=dXEY2DoUD7ndk4PVtJz1uy2Eoq/yrEHdLgbhf7GKnfc=; b=F
 I9pEd6lk5qPit+V2Rzw6hSRuJGuaA/Iop4VSJfM0S/tn1x17VgiCIMthjvSab6nQ
 mt4yRgsaXfduBqq8YLRxfF2HgzXSkhcSiutQRAb/FLzvLg6i1JP+vVUlDyKWrdmP
 G1S5WxGkwMTYb0l6/1q5PapFD7BxYelEpWGGKxHKPLndFCsR+ONV7D3PpwYVeTG2
 dBk3LVA+X7dBQLYx4UVwl4YAS0LSc6iAlNV3gSXTwgzKIJ34RSUEdyIbmtcnNjyf
 chgTkvNf1YN7Ht5A6+AsMnMdw6qqk3LgIa0g8fHRbcqao4Y5n1gH3Z7ttFPfM1qQ
 WI22yYo/VHg433TjI2jOA==
X-ME-Sender: <xms:dad3ZfUVacYHyDwwpcoYKCnmqQoTeZJx0BLd0Xyb0VeXdXJ6l7GxTg>
 <xme:dad3ZXmTSuB7LJhrBIWrMeoeEbxY0EI9RpY8tIZAdfEOrChge0JXN7vEb9bx4QeAi
 vHRUPCh7QIbGUP3cpI>
X-ME-Received: <xmr:dad3ZbbYK1kFYUmMtJhpywWzdv-FuAh07Tv3i2fx9fEh4-GTEtgLS-L1mwiDFRF8FNJEJw>
X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrudelfedgvdduucetufdoteggodetrfdotf
 fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen
 uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne
 cujfgurhepkfffgggfuffvvehfhfgjtgfgsehtjeertddtfeejnecuhfhrohhmpeffmhhi
 thhrhicuifhuthhovhcuoegumhhithhrhiesghhuthhovhdruggvvheqnecuggftrfgrth
 htvghrnhephfeutdekveeggeetteekfeejffegudduudfhueevleeftdffffeggeeivddv
 jeelnecuffhomhgrihhnpehgnhhurdhorhhgnecuvehluhhsthgvrhfuihiivgeptdenuc
 frrghrrghmpehmrghilhhfrhhomhepughmihhtrhihsehguhhtohhvrdguvghv
X-ME-Proxy: <xmx:dad3ZaU1Cj0otyqkzo7EAT9qH3RYHW5up9C0tHIxl68bmfRB3ZGHeg>
 <xmx:dad3ZZnZ6u-Nxh7XBmplw222z9xxPckvB6rxQpjqObMa2odDYQSDXw>
 <xmx:dad3ZXe4cO7loBf4pSCX2FwefCffy-4_IEL2OqtHnLJz7q4W1Hc0VA>
 <xmx:dqd3ZewgVAFkdRk3Ih_WPIhxS-3zHu2Rl3eJOEyQnIzlLtcZOEwLeg>
Feedback-ID: i0e71465a:Fastmail
Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon,
 11 Dec 2023 19:21:08 -0500 (EST)
Content-Language: en-US
In-Reply-To: <861qbtq630.fsf@mail.linkov.net>
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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org
Xref: news.gmane.io gmane.emacs.bugs:276009
Archived-At: <http://permalink.gmane.org/gmane.emacs.bugs/276009>

On 11/12/2023 19:12, Juri Linkov wrote:
>>>>> This change broke the order of 'C-x p p M-n M-n ...',
>>>> Could you remind me which behavior in 'M-n M-n' the aforementioned change
>>>> relates to? Is this supposed to be like input history as well, or the
>>>> contents of the completions table in a certain order?
>>> It's inappropriate to overwrite the history with the recently visited projects.
>>> Only user input should be added to history variables because it's actually
>>> the history of user input.  Therefore, the remaining way to access a list
>>> of recently visited projects is the future history with 'M-n M-n'.
>>
>> But... we do overwrite it now, manually constructing the value of input
>> history from project--list every time.
>>
>> So it seems like both "past history" and "future history" show the same
>> information now. If so, it might make sense to keep only one.
> 
> It's usually not good to overwrite past history.  So it's better
> to keep only future history.

I'm not sure the actual input history is useful here: in most cases, it 
will be empty or almost empty. project history is different from all 
others because we almost always detect it automatically. And also 
because the total set of projects is relatively small, for each user.

And "future history" is different for every command, including the logic 
of how it's formed. Most users are also unaware of its existence, so it 
wouldn't be a good idea to rely only on it.

>>>> I just tried find-file, and the future history is empty there, so I suppose
>>>> this is something we added particularly for project-find-file.
>>> Unlike with project--list, we don't keep a list of recently visited files.
>>> Once we conducted an experiment to add all visited files to the input file history,
>>> even when a file was visited without reading a file name in the minibuffer,
>>> e.g. by typing RET in Dired.  But no one liked this behavior.
>>
>> I don't remember that experiment,
> 
> It was in https://debbugs.gnu.org/12915#121
> 
> #+begin_src emacs-lisp
> (add-hook 'first-change-hook 'add-file-name-to-history)
> (add-hook 'find-file-hook 'add-file-name-to-history)
> (defun add-file-name-to-history ()
>    (when (and buffer-file-name (not buffer-read-only))
>      (add-to-history 'file-name-history buffer-file-name)))
> #+end_src
> 
> but this clutters the file history too much.

That makes sense.

>> but the description sounds like recentf. Which must have its audience
>> (and I use it through Ido's "virtual buffers").
> 
> 'recentf-list' looks like the right thing to add to future history
> of 'C-x C-f', but not to its past history.  This prototype works nicely:
> 
> #+begin_src emacs-lisp
> (define-advice find-file (:around (ofun &rest args) recentf-list)
>    (interactive (lambda (spec)
>                   (minibuffer-with-setup-hook
>                       (lambda ()
>                         (when (featurep 'recentf)
>                           (setq-local minibuffer-default-add-function
>                                       (lambda () recentf-list))))
>                     (advice-eval-interactive-spec spec))))
>    (apply ofun args))
> #+end_src
> 
> so this could be enabled by default when recentf.el is loaded.

Interesting. This way the difference between "forward history" and the 
regular one happens due to "exotic" ways to visit a file. E.g. from 
ido's "virtual buffers", or 'M-x recentf', to some older versions of 
project-find-file. I might actually be happy if they showed up in 
find-file's history too. Though if we're talking about buffers restored 
by desktop-read, for example, then no. The problem is messing with 
history's order.

Anyway, I'm mildly positive on your suggestion above, but it's probably 
a good idea to ask somebody else as well.