From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#65459: completing-read INITIAL-VALUE unaware of COLLECTION and REQUIRE-MATCH Date: Thu, 24 Aug 2023 17:02:47 -0400 Message-ID: References: <9K_-oO834AqSJEo_pqDrfj7Q1O1vcqy19pPVpFDuVl5tfCjWqlLa8cRgM16uDFBEt63VYEUkj7ueLAZ8XLrfsZAuRPLvU4Mx3von1r73fEE=@protonmail.com> Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="11085"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Eli Zaretskii , 65459@debbugs.gnu.org To: Heime Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Aug 24 23:04:13 2023 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 1qZHUz-0002dP-EH for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 24 Aug 2023 23:04:13 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qZHUm-0002Ut-JF; Thu, 24 Aug 2023 17:04:00 -0400 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 ) id 1qZHUk-0002Ug-GF for bug-gnu-emacs@gnu.org; Thu, 24 Aug 2023 17:03:58 -0400 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 ) id 1qZHUk-0001Zb-8K for bug-gnu-emacs@gnu.org; Thu, 24 Aug 2023 17:03:58 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qZHUo-0004Y4-Bi for bug-gnu-emacs@gnu.org; Thu, 24 Aug 2023 17:04:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 24 Aug 2023 21:04:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 65459 X-GNU-PR-Package: emacs Original-Received: via spool by 65459-submit@debbugs.gnu.org id=B65459.169291102317458 (code B ref 65459); Thu, 24 Aug 2023 21:04:02 +0000 Original-Received: (at 65459) by debbugs.gnu.org; 24 Aug 2023 21:03:43 +0000 Original-Received: from localhost ([127.0.0.1]:38741 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qZHUU-0004XW-MR for submit@debbugs.gnu.org; Thu, 24 Aug 2023 17:03:43 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:2336) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qZHUT-0004XI-1p for 65459@debbugs.gnu.org; Thu, 24 Aug 2023 17:03:42 -0400 Original-Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 366AB1000E5; Thu, 24 Aug 2023 17:03:31 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1692911009; bh=qg4CXiX8FqHot8UvXbZq/uLCGFulqAdFtrhQ6bBjSQM=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=ii/peNdtu2aztoBJcv430imEVmoRXszZIt7VILw614RIeHO+USa3hL321i/I5dSXH JuC5MOtbJchQpwHgyPsryFYr9QQdnIJUR3OXQq3inOV8ULX5kHPqy3Qmfe8g0O1stx MHT29+6gUvMz/wiX4mpwj3PS+l3e6TrYmDwxL1g9WLm7KNhJGJuA2Au9NUcf7eS4SU jLE9/y+nq4fzRrTD1GydDc7ZHYoUUjjil+S1wuOB1+AeSdc+aPRnob2p05BIiJYS20 39UEiPXZbtI1TMxr0efqombHmFnI3NOy22nSG9KpuFzdBVmkTW7kOcYxVqB768lI5F 6JpSJOly1cVtA== Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id C426F100033; Thu, 24 Aug 2023 17:03:29 -0400 (EDT) Original-Received: from lechazo (lechon.iro.umontreal.ca [132.204.27.242]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id B0F131202BC; Thu, 24 Aug 2023 17:03:29 -0400 (EDT) In-Reply-To: <9K_-oO834AqSJEo_pqDrfj7Q1O1vcqy19pPVpFDuVl5tfCjWqlLa8cRgM16uDFBEt63VYEUkj7ueLAZ8XLrfsZAuRPLvU4Mx3von1r73fEE=@protonmail.com> (Heime's message of "Thu, 24 Aug 2023 20:22:45 +0000") 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:268362 Archived-At: >> Using the DEFault arg gives you the same benefit without prefilling the >> minibuffer, so I must be missing something. What would be the advantage >> for the users by prefilling the minibuffer with "Chronological Dating"? > Yes, without prefilling the minibuffer. Prefilling the minibuffer is > quicker for users, giving them the possibility to see the current > stage if they forget default key shortcuts. The `format-prompt` thingy in my example code is there to show to the users what the default will be. > The more we discuss this the more it seems the prefilling > the minbuffer was something we never wanted users to have. Indeed, it was never intended for regular use. It's only meant to be used in specific cases like `read-file-name` where we do have something to prefill that is almost always useful. [ You used the term "dogma" earlier, but I like to think of Emacs design as being rather undogmatic in that we go through a lot of trouble to allow people to do even those things that we don't want them to do. ] >> > > So, IIUC, you have a `completing-read` call asking them which template >> > > to insert, and you want to order the set of completions based on >> > > knowledge of the stage at which they are? >> > > No ordering actually happens, a particular element in collection is used >> > > to prefill the minibuffer entry and consecutive elements in simple >> > > cycling continue through the next stages. >> >> >> Yes, the ordering I'm talking about is the order in the operational >> flow refined such that if the likely next stage is "Composition and >> Provenance", then you'll want to use: >> >> "Composition and Provenance" "Isotope Analysis" "Physical Analysis" "Chronological Dating" >> >> That's what you want, right? > > Correct, but the actual collection might still be > > "Physical_Analysis" "Chronological Dating" "Composition and Provenance" "Isotope Analysis" > > Rather than applying modifications to it, I can just specify the start index. That's an implementation detail. E.g. you can use (defconst my-phases '("Physical_Analysis" "Chronological Dating" "Composition and Provenance" "Isotope Analysis")) (defun my-rotate (collection first) (let ((x (member first collection))) (if (not x) collection (let ((idx (- (length collection) (length x)))) (append x (seq-take collection idx)))))) [...] (let ((next-phase (my-guess-next-phase))) (completing-read (format-prompt "Phase" next-phase) (my-rotate my-phases next-phase) nil t nil nil next-phase)) [...] >> You mean, if they use, say, `icomplete-mode` or `vertico-mode`, you'd >> prefer that those UIs use an alphabetical ordering rather than the one >> based on operational flow? > > I would think that if they use vertico, there is a reason that is convenient > to them to use cempletion, if they are not employing simple cycling (through > repeated use of ). Both `icomplete-mode` and `vertico-mode` offer/encourage the use of cycling (but their cycling code is completely different from the one you're using so it doesn't obey `next-history-element`), so I expect their users would also appreciate if the ordering of the completions is chosen with the same care as what you do for the `next-line-or-history-element` case. > Quite right, and help programmers from the need to go as low level as > calling 'minibuffer-with-setup-hook' hacks. The unfortunate thing is that > the inclusion of INITIAL makes people want to use it, as I did in certain > circumstances. Having to go through 'minibuffer-with-setup-hook' hacks > is not something one looks forward to do in the interactive clause of a > function. +1 I guess we really should work on a replacement for `completing-read`, eh? Stefan