From mboxrd@z Thu Jan  1 00:00:00 1970
Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail
From: Eli Zaretskii <eliz@gnu.org>
Newsgroups: gmane.emacs.bugs
Subject: bug#67310: [PATCH] Include the project--list as history when
 prompting for a project
Date: Thu, 23 Nov 2023 08:38:33 +0200
Message-ID: <83bkblgeja.fsf@gnu.org>
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>
Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214";
	logging-data="6399"; mail-complaints-to="usenet@ciao.gmane.io"
Cc: 67310@debbugs.gnu.org, dmitry@gutov.dev, juri@linkov.net
To: Spencer Baugh <sbaugh@janestreet.com>
Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Nov 23 07:39:18 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 1r63Mr-0001TN-U9
	for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 23 Nov 2023 07:39:17 +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 1r63Ma-0006Zy-Vq; Thu, 23 Nov 2023 01:39: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 1r63MY-0006Zk-VB
 for bug-gnu-emacs@gnu.org; Thu, 23 Nov 2023 01:38: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 1r63MY-0007Pk-Mn
 for bug-gnu-emacs@gnu.org; Thu, 23 Nov 2023 01:38:58 -0500
Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2)
 (envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1r63Mb-0002ve-VB
 for bug-gnu-emacs@gnu.org; Thu, 23 Nov 2023 01:39:01 -0500
X-Loop: help-debbugs@gnu.org
Resent-From: Eli Zaretskii <eliz@gnu.org>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces@debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@gnu.org
Resent-Date: Thu, 23 Nov 2023 06:39:01 +0000
Resent-Message-ID: <handler.67310.B67310.170072153411245@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.170072153411245
 (code B ref 67310); Thu, 23 Nov 2023 06:39:01 +0000
Original-Received: (at 67310) by debbugs.gnu.org; 23 Nov 2023 06:38:54 +0000
Original-Received: from localhost ([127.0.0.1]:60420 helo=debbugs.gnu.org)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <debbugs-submit-bounces@debbugs.gnu.org>)
 id 1r63MU-0002vI-DH
 for submit@debbugs.gnu.org; Thu, 23 Nov 2023 01:38:54 -0500
Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:40130)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@gnu.org>) id 1r63MR-0002v6-Up
 for 67310@debbugs.gnu.org; Thu, 23 Nov 2023 01:38:53 -0500
Original-Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@gnu.org>)
 id 1r63MH-0007Hk-LW; Thu, 23 Nov 2023 01:38:41 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=e4mF4TPgCHKbtypqO6Ps0yMo9JzUT2v2IfYoWsedwu4=; b=WecQ7r3zxHPu
 t6k+ACzd+KV14KhNFST/QDw6vPXwGRFeLnF0peme+5UBSSNvKGvDnND1SFB06GtJOQ/pFxouW4fM0
 zt/qU/HP+KJYDRBrAnDXaj4tQMYs1bfIHyFaArgvuyC6qtH6wzftuWvNTrA/7pvf7kf0wMjat8t3D
 ZlvRRj5wiXqdtkcorBMCkrrHeLgJrfTA9rUDwocd+M6jYCsSrWwyvBb56UtoAGmT/6T55TH/fdgKk
 Fce5HJTgAGYHe2j/TtonIrAMFCAskRnfKtCrLAbPOhxeB1cvCteW+WnnFxJTxPlRgulgneHSimoXv
 5mzgA9yorMFxtvVmXZbh2w==;
In-Reply-To: <iercyw1l6rz.fsf@janestreet.com> (message from Spencer Baugh on
 Wed, 22 Nov 2023 18:14:56 -0500)
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:274792
Archived-At: <http://permalink.gmane.org/gmane.emacs.bugs/274792>

> From: Spencer Baugh <sbaugh@janestreet.com>
> Cc: 67310@debbugs.gnu.org,  eliz@gnu.org,  juri@linkov.net
> Date: Wed, 22 Nov 2023 18:14:56 -0500
> 
>  (defvar project--list 'unset
> -  "List structure containing root directories of known projects.
> -With some possible metadata (to be decided).")
> +  "List of root directories of known projects.
> +
> +This is also the minibuffer history variable for
> +`project-prompt-project-dir' and `project-prompt-project-name'.")

Please add here cross-reference(s) to command(s) or option(s) used for
minibuffer-history handling.  IOW, don't assume that when you say
"minibuffer history variable", the reader immediately understands what
you mean and how this aspect is significant.

I also question the decision of making this variable an internal one.
I don't think any other minibuffer-history variables we have are
internal ones, and for good reasons.

> +      (let q((history-delete-duplicates t)
              ^^^
Typo?

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

What is the "correct" order?

> -              (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.

> +            (let ((history-add-new-input nil))

Why this non-standard way of let-binding a variable to nil?

> +        (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?

> -  (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?

Thanks.