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: Sat, 25 Nov 2023 03:54:13 +0200
Message-ID: <ab8f5ad1-356e-e90d-eab4-d36a0b0821fc@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> <83bkblgeja.fsf@gnu.org>
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="39552"; 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, juri@linkov.net
To: Eli Zaretskii <eliz@gnu.org>, Spencer Baugh <sbaugh@janestreet.com>
Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Nov 25 02:55:23 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 1r6htB-000A4V-Pe
	for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 25 Nov 2023 02:55:22 +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 1r6hsr-0004Vt-5H; Fri, 24 Nov 2023 20:55:01 -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 1r6hsn-0004Vj-QP
 for bug-gnu-emacs@gnu.org; Fri, 24 Nov 2023 20:54:59 -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 1r6hsn-0000bP-D9
 for bug-gnu-emacs@gnu.org; Fri, 24 Nov 2023 20:54:57 -0500
Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2)
 (envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1r6hsr-0005Rz-PS
 for bug-gnu-emacs@gnu.org; Fri, 24 Nov 2023 20:55:01 -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: Sat, 25 Nov 2023 01:55:01 +0000
Resent-Message-ID: <handler.67310.B67310.170087727120912@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.170087727120912
 (code B ref 67310); Sat, 25 Nov 2023 01:55:01 +0000
Original-Received: (at 67310) by debbugs.gnu.org; 25 Nov 2023 01:54:31 +0000
Original-Received: from localhost ([127.0.0.1]:37527 helo=debbugs.gnu.org)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <debbugs-submit-bounces@debbugs.gnu.org>)
 id 1r6hsM-0005RE-WE
 for submit@debbugs.gnu.org; Fri, 24 Nov 2023 20:54:31 -0500
Original-Received: from out5-smtp.messagingengine.com ([66.111.4.29]:44789)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dmitry@gutov.dev>) id 1r6hsL-0005R1-4N
 for 67310@debbugs.gnu.org; Fri, 24 Nov 2023 20:54:30 -0500
Original-Received: from compute3.internal (compute3.nyi.internal [10.202.2.43])
 by mailout.nyi.internal (Postfix) with ESMTP id 15E8D5C0196;
 Fri, 24 Nov 2023 20:54:19 -0500 (EST)
Original-Received: from mailfrontend1 ([10.202.2.162])
 by compute3.internal (MEProxy); Fri, 24 Nov 2023 20:54:19 -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:sender:subject:subject:to:to; s=fm3; t=
 1700877259; x=1700963659; bh=+84e6iUofD21Py+B/Z8vOvEQU4vpdmJygTR
 4IY9+HTM=; b=gCbnpFFud2rWS+Qojf5O7W4Iwwq4qqHF5IZJ1JZP7+1OyadWX2b
 sSc3UnlheyCaK9DJvlzqPgcv3+Abol9tynRFlgOrqMdyVqVBQlvLaHda/OenKyv+
 bKEboZmk4S8kYwkSySk7Amv4lNe2OJajlpikHQfUnlqxVEooLqAOlIt2NKwuguhV
 z1tIv5USBc2G0Ar/bnibM8G77shLucI4zeylcUmGp45yhSS1i3kwJ3U5ozuFd6Zn
 bvBQk5us6J32RcghRkArw3NRW8ojwWXSWe2aZEBUajs8G2jbRsKviKRnz5KczNlU
 fUhGwadFqGwNfj1Iz3dqZk52VXT/RpQPgCA==
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:sender:subject:subject:to:to:x-me-proxy
 :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=
 1700877259; x=1700963659; bh=+84e6iUofD21Py+B/Z8vOvEQU4vpdmJygTR
 4IY9+HTM=; b=qDcOhTCsQ2S0k1mNfo4+y4z7zRQJ+ISyW6MyNZ3ZRj3jH+21neR
 QTZAU5QLJYXEAk+CZ5sXbxhLuG+YlY6TsgDKU8qhel6wo2Q9Wj3A3KVBTy4V849F
 NX4SuYUhEgz6999fd93IqZZe/I1idtrOpFL1O5Rq2PxM6h6Lxv293IczxhzVk4Uq
 xpmKpbjkV6Lf+vOhJX8Cv+Cn+Hy6lixlU5sdNl9bR7koq57KR6qdr8Rfp2EYi9+V
 ZjhcM/D1U1HMaiVJIpwherU50r2ACJZvKdyaZwq4OY+CIfppSWhhiT0HI8zEO1xh
 rFhIrgTFiRcxQ8KShasoMaCqWW48TTrlFcg==
X-ME-Sender: <xms:ylNhZUCo_FRxpBV8rCe5TRL4f7P3QYX68U8mR7CcnygV7HMcm-vHng>
 <xme:ylNhZWg_sxH6FyjreoafPE3XbzhRRp1-ihpmVj_KFPriwm0WsaoS2cNc3Wep8Rils
 5OtSsgZwZ3MwwobYCc>
X-ME-Received: <xmr:ylNhZXnHiS8iFm-BR2GH9Vy9uj7eu2yjLabEcpkxN1PBVKnnA5qGzK6iKQu2y5MsnrA22g>
X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrudehiedggedvucetufdoteggodetrfdotf
 fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen
 uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne
 cujfgurhepkfffgggfuffvvehfhfgjtgfgsehtjeertddtfeejnecuhfhrohhmpeffmhhi
 thhrhicuifhuthhovhcuoegumhhithhrhiesghhuthhovhdruggvvheqnecuggftrfgrth
 htvghrnhepiefgteevheevveffheeltdeukeeiieekueefgedugfefgefhudelgfefveel
 vdevnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepug
 hmihhtrhihsehguhhtohhvrdguvghv
X-ME-Proxy: <xmx:ylNhZawQUB0Uh9dgKiAUcJnQsoNZ9vbUxpEUaP16av4C4XXaw33Xdw>
 <xmx:ylNhZZRl5Swh52S7lTToQKOY-fyukV1EXF51BWopofObNZcKPKUcNg>
 <xmx:ylNhZVbURbTVhTgg3EicRJrkvqbnfJO4wkUsa2c-t1np2M2aJ_gZRg>
 <xmx:y1NhZUcR2JrVQqdClg9roMyx6SCQPvGjjSnTRBRmuEvxZj6YvjwTdA>
Feedback-ID: i0e71465a:Fastmail
Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri,
 24 Nov 2023 20:54:17 -0500 (EST)
Content-Language: en-US
In-Reply-To: <83bkblgeja.fsf@gnu.org>
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:274902
Archived-At: <http://permalink.gmane.org/gmane.emacs.bugs/274902>

I'll try to answer some of the questions that are still relevant to the 
latest patch, myself.

On 23/11/2023 08:38, Eli Zaretskii wrote:

>> +            ;; Iterate in reverse order so project--name-history is in
>> +            ;; the correct order.
> 
> What is the "correct" order?

Their order in project--list.

Iteration and construction of a new list with 'push' leads to the 
reverse order, hence the use of reversion at the beginning to counteract 
that.

>> -              (if-let (proj (project--find-in-directory dir))
>> -                  (push (cons (project-name proj) proj) ret)))
>> +              (when-let (proj (project--find-in-directory dir))
>> +                (let ((name (project-name proj)))
>> +                  (push name project--name-history)
>> +                  (push (cons name proj) ret))))
> 
> Not sure I understand why you replaced if-let with when-let here.

To reduce the amount of indentation, perhaps.

>> +            (let ((history-add-new-input nil))
> 
> Why this non-standard way of let-binding a variable to nil?

I use this myself sometimes to make the change more explicit.

Anyway, amended.

>> +        (let ((history-delete-duplicates t)
>> +              (history-length t))
>> +          (add-to-history 'project--list root))
> 
> Why are you overriding the values of these two user options?

To implement the current behavior (how additions to project--list) 
happen. I've described that behavior in one of the earlier messages here.

>> -  (let ((dirs (if recursive
>> -                  (directory-files-recursively dir "" t)
>> -                (directory-files dir t)))
>> -        (known (make-hash-table :size (* 2 (length project--list))
>> -                                :test #'equal))
>> -        (count 0))
>> -    (dolist (project (mapcar #'car project--list))
>> +  (let* ((dirs (if recursive
>> +                   (directory-files-recursively dir "" t)
>> +                 (directory-files dir t)))
>> +         (roots (project-known-project-roots))
>> +         (known (make-hash-table :size (* 2 (length roots))
>> +                                 :test #'equal))
>> +         (count 0))
> 
> Is it really necessary to use let* here?

'known' depend on 'roots'.