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.devel
Subject: Re: Turning completion table lambdas into symbols
Date: Fri, 1 Dec 2023 02:36:09 +0200
Message-ID: <3b79a7f4-604e-2d55-1392-5a9737f7296f@gutov.dev>
References: <87bkd3z9bi.fsf@catern.com> <ierleas4fcr.fsf@janestreet.com>
 <86v89ws5t3.fsf@mail.linkov.net> <iercyw445tu.fsf@janestreet.com>
 <86v89vzf1o.fsf@mail.linkov.net> <87pm03jn3w.fsf@catern.com>
 <861qcjw3ch.fsf@mail.linkov.net> <ier1qcin8db.fsf@janestreet.com>
 <86r0ki2on3.fsf@mail.linkov.net> <ierttpdlqe4.fsf@janestreet.com>
 <86leao519y.fsf@mail.linkov.net> <87fs0wk5oq.fsf@catern.com>
 <86edgfin4v.fsf@mail.linkov.net> <87o7fhixzv.fsf@catern.com>
 <86o7fhy9ae.fsf@mail.linkov.net> <87v89ohc6f.fsf@catern.com>
 <86il5nhdvh.fsf@mail.linkov.net> <87plzuuend.fsf@catern.com>
 <86wmu1j2hh.fsf@mail.linkov.net> <87a5qxv4bh.fsf@catern.com>
 <36fa158d-e063-683f-38b8-27d2e1312e52@gutov.dev>
 <ieredg8744f.fsf@janestreet.com>
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="17183"; 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
To: Spencer Baugh <sbaugh@janestreet.com>, emacs-devel@gnu.org
Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Dec 01 01:37:05 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 1r8rWi-0004Fu-0Z
	for ged-emacs-devel@m.gmane-mx.org; Fri, 01 Dec 2023 01:37:04 +0100
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 1r8rW2-0005mo-5V; Thu, 30 Nov 2023 19:36:22 -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 <dmitry@gutov.dev>) id 1r8rVx-0005kv-5e
 for emacs-devel@gnu.org; Thu, 30 Nov 2023 19:36:18 -0500
Original-Received: from out5-smtp.messagingengine.com ([66.111.4.29])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <dmitry@gutov.dev>) id 1r8rVu-0000p9-Ik
 for emacs-devel@gnu.org; Thu, 30 Nov 2023 19:36:16 -0500
Original-Received: from compute6.internal (compute6.nyi.internal [10.202.2.47])
 by mailout.nyi.internal (Postfix) with ESMTP id 76D6C5C00DA;
 Thu, 30 Nov 2023 19:36:12 -0500 (EST)
Original-Received: from mailfrontend1 ([10.202.2.162])
 by compute6.internal (MEProxy); Thu, 30 Nov 2023 19:36:12 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gutov.dev; h=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=
 1701390972; x=1701477372; bh=cdW5b5Qlk1gDhzs6sWvFuJNgzk/ik4GCo5E
 6uRlYZgg=; b=bUrl/mytnFXJeOzAR6cQ6fItZVdh7R1hPdqqc4TtPuek3fxSlZ5
 zO/8ViFETo0xS4T8vjV/wTsF8clt7Zunc4Ab/woyruFvahxfXlPzlIdhIKWxRPf/
 ihFfiiZ90aMP4Falx6Y4O7lWsMbrU6D+pCQDdGbmw2aOX2IOMe35BlNLtBFnnyoL
 BQMQYOl4skBkcHUK/YQ1i00qrxgrr4mWCQ+LP3sYwRAV9Pu6i+5OH1TBT0EUBpol
 C0ZfN/bLcsHBPtetG/oOHwN5QhVJhwkQvdo/lO0tm+H3bbimOnpoQ1I7v6qB/rd/
 GShAcSdSUiUQHbn3z93Z11gTdZdI/hxZDXw==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=
 messagingengine.com; h=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=1701390972; x=
 1701477372; bh=cdW5b5Qlk1gDhzs6sWvFuJNgzk/ik4GCo5E6uRlYZgg=; b=e
 P9dkTV1yr3+Ds058eXsCjwzxvqWaUaQaW8KVdL+M2+0EZxF9PhzK61UEbfCOp5dM
 OUbl+uua2gsZSozmiwCq2VJiVYbd5wgYP84SiA71IDIWwVUK8NSXbty0a64+VYlX
 qF0bViW7F2qkdR/oASMJ/Tdo3lKIv58qbpwUA00zwle7E76ESbRbQ1on0suNqLj9
 DTISedgke4STgakyQ/FMvWSiu7GWJE35OyMVO9HSrEZHQBwH5+FSLYbBYR1pq5o1
 8aCCvI0FTkf/t3KiSX+5f+/EbBHm2M2SoAQJhVhJt7IR/cfWVqlDRDAv8986PChk
 dOAVZacy8V8aiRD+sxFig==
X-ME-Sender: <xms:fCppZU77VkWsy4p2DFxRlw_tkQX5_64Sg1nNJfNydNQ2f3UJEc39Rg>
 <xme:fCppZV4wr0P5nxN02Ox_JrBlpAXd-HOCGhKxR6u-Poa6Ict84TeRxf3hTBqF0Z5_f
 SrQGxTGF7ZvHEWnsaM>
X-ME-Received: <xmr:fCppZTdkFEm8Kv8kH_UBIY0Smnl-MA0tWI9wxlD0qoud4-ABAyMqgjNVSO6viQYNO7n4kA>
X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrudeikedgvdegucetufdoteggodetrfdotf
 fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen
 uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne
 cujfgurhepkfffgggfuffvfhfhjggtgfesthejredttdefjeenucfhrhhomhepffhmihht
 rhihucfiuhhtohhvuceoughmihhtrhihsehguhhtohhvrdguvghvqeenucggtffrrghtth
 gvrhhnpedvfeelfeeuteehgeelheefleekieeiudfgteefkeegjeelveefvedtiedvheek
 ieenucffohhmrghinhepghhnuhdrohhrghdpghhithhhuhgsrdgtohhmnecuvehluhhsth
 gvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepughmihhtrhihsehguhht
 ohhvrdguvghv
X-ME-Proxy: <xmx:fCppZZKBT8nMLr1s9H8WFrV0u3s3UYrLPvBJjvRf-xifV0UEgk6rOw>
 <xmx:fCppZYIbH3CAKPQxwJhbFcgWTdzp_4WwZ_T2esvnJCPbhASMCI0PIw>
 <xmx:fCppZawetEh3Qeepn4s4AHke03QuMHCF7icvYJblIc8hrIMgvs_4kQ>
 <xmx:fCppZSwxH-PTV2fuLt7yZ2QjIR3OTB5LB-mz9WwqvX1zYaYUZOm5GQ>
Feedback-ID: i0e71465a:Fastmail
Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu,
 30 Nov 2023 19:36:11 -0500 (EST)
Content-Language: en-US
In-Reply-To: <ieredg8744f.fsf@janestreet.com>
Received-SPF: pass client-ip=66.111.4.29; envelope-from=dmitry@gutov.dev;
 helo=out5-smtp.messagingengine.com
X-Spam_score_int: -49
X-Spam_score: -5.0
X-Spam_bar: -----
X-Spam_report: (-5.0 / 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, NICE_REPLY_A=-2.177,
 RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001,
 SPF_HELO_PASS=-0.001, SPF_PASS=-0.001,
 T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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:313410
Archived-At: <http://permalink.gmane.org/gmane.emacs.devel/313410>

On 29/11/2023 21:26, Spencer Baugh wrote:
>> For CAPF and Company, we also discussed the idea of a "session object"
>> some time ago, but that's not in the current API so far.
> Right, I think I'd much rather some kind of "session object" at the
> level of completing-read/the programmed completion API.
> 
> Do you have a link to the previous discussion?

It's been here and there, but the last mention was right in the middle 
of this:

https://debbugs.gnu.org/cgi/bugreport.cgi?bug=47711#272
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=47711#320

> I haven't thought too much about it, but maybe some new dynamic variable
> which is bound to nil at the top level of completing-read-default, so
> the completion table can change it over time and preserve state through
> the course of the completion.  Works fine with nested completing-reads.

That could work. If you further progress on this (in a new thread?), I 
suggest you tag all the interested parties (or include Stefan, at least).

> Alternatively, if today a completion table is always invoked with the
> same current buffer (probably the case?), we could formalize that and
> just let a completion table store state in buffer-local variables.
> Maybe with some new 'initialize operation in completion tables which is
> called when a new completing-read starts, or maybe the completion table
> can just detect that somehow and initialize the variables itself.  That
> is nicer than having a single variable which all completion tables
> share.  However, completion table writers would need to be careful not
> to break when doing nested completing-reads on the same table.

It's not rocket science, but the hard part is to pick a protocol that's 
backward-compatible and weave it through all the related pieces of code.

Also see the note about backspacing around here: 
https://github.com/minad/corfu/wiki#configuring-corfu-for-eglot (where 
doing an edit before the current BEG doesn't abort completion but does 
make the cache invalid), but that might be something to handle in the 
caching logic anyway.