From mboxrd@z Thu Jan  1 00:00:00 1970
Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail
From: Spencer Baugh <sbaugh@catern.com>
Newsgroups: gmane.emacs.devel
Subject: Re: Updating *Completions* as you type
Date: Wed, 18 Oct 2023 12:47:45 +0000 (UTC)
Message-ID: <87o7gwumfj.fsf@catern.com>
References: <87bkd3z9bi.fsf@catern.com> <86cyxjyr1y.fsf@mail.linkov.net>
 <ier34ye4a3x.fsf@janestreet.com> <86r0lxm7um.fsf@mail.linkov.net>
 <87o7gxwaxe.fsf@catern.com> <86a5shyw48.fsf@mail.linkov.net>
 <874jiox1km.fsf@catern.com> <86jzrk8lui.fsf@mail.linkov.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214";
	logging-data="27611"; mail-complaints-to="usenet@ciao.gmane.io"
Cc: emacs-devel@gnu.org
To: Juri Linkov <juri@linkov.net>
Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Oct 18 14:49:35 2023
Return-path: <emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org>
Envelope-to: ged-emacs-devel@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 <emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org>)
	id 1qt5zS-0006qU-5v
	for ged-emacs-devel@m.gmane-mx.org; Wed, 18 Oct 2023 14:49:34 +0200
Original-Received: from localhost ([::1] helo=lists1p.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.90_1)
	(envelope-from <emacs-devel-bounces@gnu.org>)
	id 1qt5y0-0002H3-S1; Wed, 18 Oct 2023 08:48:04 -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 <bounces+21787432-489d-emacs-devel=gnu.org@em8926.catern.com>)
 id 1qt5xn-0001uH-BI
 for emacs-devel@gnu.org; Wed, 18 Oct 2023 08:47:55 -0400
Original-Received: from s.wrqvtbkv.outbound-mail.sendgrid.net ([149.72.123.24])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1)
 (envelope-from <bounces+21787432-489d-emacs-devel=gnu.org@em8926.catern.com>)
 id 1qt5xk-0003er-MV
 for emacs-devel@gnu.org; Wed, 18 Oct 2023 08:47:51 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=catern.com;
 h=from:subject:in-reply-to:references:mime-version:to:cc:content-type:
 content-transfer-encoding:cc:content-type:from:subject:to;
 s=s1; bh=hOhydzcZRIgm7ZG+BnZ+Oi7w5qnHwR4y6J4PUkPXl7I=;
 b=dfipVmTuHSN3sCxORQe6Z7Wu+nEOBhGNZ4PQvkgSfLER4pOvR2Dpn/6SgielN4tBv/qf
 xz7gu/dlQsyh+KtfF5cDRwfcrYKWYhMtSTlTZLgFywYK9jpAAGMh42kq1q5y6l0NgPNc6j
 VzolEgBQ6tnrOnux3Yngk1AnZ5FtNofBk0BJXMrkbk7kcoyXoTCeWwwZKrPiTLBtVw7kmJ
 n0J3AYs+0FfEJhHOEE89xP1j8nxmn1Wgiy5rk35QupJcHKOdNqxz2EobRael6/rW5Me57s
 hm465Rf7ayiLzAP5sHa56CsR0S72URAqFt8uYeHOjdti1XuBHwCje8+ByutXEYBw==
Original-Received: by filterdrecv-b85775b64-rmgnt with SMTP id
 filterdrecv-b85775b64-rmgnt-1-652FD3F1-C
 2023-10-18 12:47:45.443643848 +0000 UTC m=+65210.160556766
Original-Received: from earth.catern.com (unknown) by geopod-ismtpd-14 (SG) with ESMTP
 id CIKKeb01QsON-elTKYozpQ Wed, 18 Oct 2023 12:47:45.160 +0000 (UTC)
X-Comment: SPF check N/A for local connections - client-ip=::1; helo=localhost;
 envelope-from=sbaugh@catern.com; receiver=linkov.net 
Original-Received: from localhost (localhost [IPv6:::1])
 by earth.catern.com (Postfix) with ESMTPSA id AE48366BDF;
 Wed, 18 Oct 2023 08:47:44 -0400 (EDT)
In-Reply-To: <86jzrk8lui.fsf@mail.linkov.net>
X-SG-EID: =?us-ascii?Q?GW3oCMoYnalRiojMOuLzE6x2H5kORXvlCdz1UwQVRMVT4fbh9ODEfCogOe74cO?=
 =?us-ascii?Q?rI4e0V+MFZgakz9Re5a6=2FCgp8czVfwS0KF1WODs?=
 =?us-ascii?Q?8o0JJdLMa2z3gHxsGqq2NhcisowP7t8xDcDYL3a?=
 =?us-ascii?Q?jOxbQog4PTl9GxMXnP9Nr9I4iOd=2FJwtdo+GqqLb?=
 =?us-ascii?Q?2U3+oxyKl0irbi=2FbsB0NDEk9V=2Fl6HSL+nOEOJL6?=
 =?us-ascii?Q?9BojlqyXZxA0YK2l3ZKbPyuCqX3qDaNzPdZZ3r?=
X-Entity-ID: d/0VcHixlS0t7iB1YKCv4Q==
Received-SPF: pass client-ip=149.72.123.24;
 envelope-from=bounces+21787432-489d-emacs-devel=gnu.org@em8926.catern.com;
 helo=s.wrqvtbkv.outbound-mail.sendgrid.net
X-Spam_score_int: -7
X-Spam_score: -0.8
X-Spam_bar: /
X-Spam_report: (-0.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
 RCVD_IN_BL_SPAMCOP_NET=1.347, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001,
 SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001 autolearn=no autolearn_force=no
X-Spam_action: no action
X-BeenThere: emacs-devel@gnu.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: "Emacs development discussions." <emacs-devel.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/emacs-devel>,
 <mailto:emacs-devel-request@gnu.org?subject=unsubscribe>
List-Archive: <https://lists.gnu.org/archive/html/emacs-devel>
List-Post: <mailto:emacs-devel@gnu.org>
List-Help: <mailto:emacs-devel-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/emacs-devel>,
 <mailto:emacs-devel-request@gnu.org?subject=subscribe>
Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org
Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org
Xref: news.gmane.io gmane.emacs.devel:311557
Archived-At: <http://permalink.gmane.org/gmane.emacs.devel/311557>

Juri Linkov <juri@linkov.net> writes:

>>> I think preselecting the default value in the middle of completions
>>> would make sense only when completions were sorted by the order of the
>>> list of default values (from M-n M-n ...).  Then the first default value
>>> would be at the top of completions, and it would easier for users
>>> to navigate completions top-down.
>>
>> Yes, that was the case that inspired this specific idea: the case where
>> completions are sorted by the list of defaults, and so the default value
>> is the first completion.
>>
>> But it occured to me that there's no reason to limit to just the case
>> where the default value is the first completion.  We can just always
>> move point to the default wherever it occurs in the completions, as long
>> as it occurs somewhere.  Seems like a nice improvement.
>>
>> Although I guess it does cause M-<down> to no longer go to the first
>> completion, and M-<up> to no longer go to the last one.  Which is a bit
>> annoying.
>
> Indeed.
>
>> Maybe we should have bindings to move to the first and last completions.
>> Whatever they are, they should also work in completion-in-region-mode,
>> though, so M-< and M-> definitely won't work... Maybe M-0 M-<down> to go
>> to the first, and M-0 M-<up> to go to the last?  (Or vice versa?)
>
> M-< and M-> work in the minibuffer as well as in the normal buffer.
> But they don't work with your first patch ;-)

Right right, I was just saying one reason we can't use M-< and M-> for
said bindings.

Anyway, I realized that we already have a nice way to move to the first
and last completions: ? M-<up> and ? M-<down>.

That is, run minibuffer-completion-help to recreate *Completions* and
wipe out the current value of point, then go down or up to access the
first or last.

Seems great so let's just stick with that.

>>> BTW, while looking at this case I found a problem with your first patch:
>>> after navigating in *Completions* and switching back to the minibuffer
>>> point is reset to the beginning of the *Completions* buffer.
>>
>> Good catch!  If you see my other patch which I posted in this thread,
>> "Keep point on the same completion in the completions buffer", that is a
>> nice orthogonal improvement which incidentally also fixes that bug in
>> completions-auto-update.
>
> Your third patch adds a new feature that just hides the bug by forcing
> the previous position over the wrong new one.  I think the proper fix
> would be to add more commands to completions-no-auto-update-commands
> in your first patch.  Or to change it from opt-out to opt-in by renaming
> to completions-auto-update-commands.

I would much rather not list commands as opt-in or opt-out at all, I'd
rather all commands just work without special cases.  So I'm working on
features to allow that.

I don't agree with the characterization of "it just hides the bug".  The
bug is that point in *Completions* gets wiped out by auto-updating.  My
third patch preserves point across auto-updating.  That's very directly
solving the bug.

>> OK, so maybe the thing I want to propose is not "we'll change the
>> default to whatever the current selected completion is" but instead "RET
>> with an empty minibuffer will submit the current selected completion".
>> That's equivalent, if I drop the ideas of changing the prompt and
>> changing M-RET.
>
> Agreed, I think the idea of changing the prompt on the fly won't fly.
>
>>>> I think this has some nice benefits in reducing the number of concepts
>>>> people need to track.  If the minibuffer is empty, they can just use
>>>> minibuffer-next-completion a few times followed by RET to select a
>>>> completion, no need to use M-RET.  Plus, the new M-RET and C-u M-RET
>>>> would be useful even to users who don't use minibuffer-next-completion.
>>>> True, good analysis.
>>>
>>> Specifically though it's about the case when the minibuffer is empty.  I
>>> think it would be nice for RET to submit the highlighted candidate in
>>> that case, if there is one.
>>>
>>> That matches icomplete-mode's behavior, actually, which is nice.
>>
>> Oh, actually it doesn't.  It matches ido-mode and fido-mode and a host
>> of completion mechanisms outside core, though.  I still think it's
>> desirable, at least as a user option.
>
> But then such idiosyncrasy of fido-mode causes a lot of bug reports
> like bug#55800.

But we would not have those kinds of issues because when completion
starts, by default, there is no highlighted candidate.