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.devel
Subject: Re: Updating *Completions* as you type
Date: Mon, 16 Oct 2023 14:38:46 +0300
Message-ID: <834jiqpzjt.fsf@gnu.org>
References: <87bkd3z9bi.fsf@catern.com> <86cyxjyr1y.fsf@mail.linkov.net>
 <ier34ye4a3x.fsf@janestreet.com> <86r0lxm7um.fsf@mail.linkov.net>
 <87sf6dx954.fsf@catern.com> <8334ycqv0g.fsf@gnu.org>
 <87h6mryj5o.fsf@catern.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214";
	logging-data="9673"; mail-complaints-to="usenet@ciao.gmane.io"
Cc: emacs-devel@gnu.org
To: sbaugh@catern.com
Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Oct 16 13:39:47 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 1qsLwn-0002HA-P1
	for ged-emacs-devel@m.gmane-mx.org; Mon, 16 Oct 2023 13:39:45 +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 1qsLw8-0006XE-0f; Mon, 16 Oct 2023 07:39: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 <eliz@gnu.org>) id 1qsLw6-0006W0-8T
 for emacs-devel@gnu.org; Mon, 16 Oct 2023 07:39:02 -0400
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 1qsLw5-0001ui-Mt; Mon, 16 Oct 2023 07:39:01 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From:
 Date; bh=sBevXQ5Y/UlVIpYNthUvnj50bo7xNrbAjshl5RV7yvY=; b=nWHlgtH1Wl2cjY0Bx3l0
 U2Au2e1Z/UaZ5zIgg9qxurKm1Fccs1RNnIQRx+p138kgc9aIpPnPDonKI73feW4Jlimr9azMQu3A8
 mPXtkdEtRWUH3MobuNEQ0X0xSPm55N9nNWsB73Kl/fJsp14nGnf3ElCXd72t0FFEWxQH9g0LFMgjR
 HkwHygXlLvjKjLYwVftNWv6QDHe3JPJ+NRsLtXP2pSKwWj3RKdBJn6ekPEYzeZzILKk4LK4RkG+ph
 dxQQvFFG4DtSWe89DjzUMe5kRvGWzjeO2c+XQuq5hhzd867aN2prmEpYR8opY7iSTrs6cQTYf2yY3
 u7V2CS+ItafM2w==;
In-Reply-To: <87h6mryj5o.fsf@catern.com> (sbaugh@catern.com)
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:311517
Archived-At: <http://permalink.gmane.org/gmane.emacs.devel/311517>

> From: sbaugh@catern.com
> Date: Sun, 15 Oct 2023 11:55:47 -0400
> 
> Eli Zaretskii <eliz@gnu.org> writes:
> 
> >> From: sbaugh@catern.com
> >> Date: Sat, 14 Oct 2023 16:05:11 -0400
> >> 
> >> Yes, agreed.  Taking inspiration from zcomplete, I wrote this patch to
> >> provide just this feature, thoughts?
> >
> > I tried this.  The update is slow (most probably because it works off
> > the post-command-hook), and the UX is therefore extremely unpleasant
> > if you type fast enough.
> 
> Interesting.  Can you say more about what completion you're doing for
> which the update is slow?

I started by typing "C-x C-f TAB".

> I would have expected the while-no-input to cause the update to not
> block you if you type fast.

while-no-input lets me type, but does nothing to speed up the updates
of the *Completions* buffer; quite the contrary: it leaves it
outdated.

> >> +    (while-no-input
> >> +      (let ((non-essential t))
> >                 ^^^^^^^^^^^^^^^
> > Why?
> 
> This I borrowed from zcomplete.  It seems sensible, since
> non-essential's docstring says:
> 
>   E.g., it can be used to prevent Tramp from prompting the user for a
>   password when we are [...] displaying possible completions before the
>   user even asked for it.

So completion on remote files will not be able to benefit from this?

> >> +        (when (and (get-buffer-window "*Completions*" 0)
> >> +                   (not (memq this-command completions-no-auto-update-commands)))
> >> +          (redisplay)
> >              ^^^^^^^^^^^
> > Why do you need this?
> 
> post-command-hook's docstring says:
> 
>   It is a bad idea to use this hook for expensive processing.  If
>   unavoidable, wrap your code in ‘(while-no-input (redisplay) CODE)’ to
>   avoid making Emacs unresponsive while the user types.

Did you try this without the 'redisplay' call?