From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Recommendation for CAPF setup when you don't know completion string in advance Date: Sat, 03 Apr 2021 23:20:12 -0400 Message-ID: References: <4B051055-CC87-419A-A106-C5F2A7674869@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="1918"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: emacs-devel@gnu.org To: JD Smith Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Apr 04 05:21:48 2021 Return-path: 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 ) id 1lStKe-0000Q9-AV for ged-emacs-devel@m.gmane-mx.org; Sun, 04 Apr 2021 05:21:48 +0200 Original-Received: from localhost ([::1]:46496 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lStKd-0007Ts-C5 for ged-emacs-devel@m.gmane-mx.org; Sat, 03 Apr 2021 23:21:47 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:39740) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lStJD-0006vP-HK for emacs-devel@gnu.org; Sat, 03 Apr 2021 23:20:19 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:53993) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lStJA-0002QC-In for emacs-devel@gnu.org; Sat, 03 Apr 2021 23:20:18 -0400 Original-Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id D1D7F441589; Sat, 3 Apr 2021 23:20:15 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 70A10441522; Sat, 3 Apr 2021 23:20:14 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1617506414; bh=o65jGru75G1LH0VWSKsAzMts7hRiJZOXWzS8z2Yz9VE=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=BfqGPRqyARDY67NwQ2m2DY7w9Tqnc2+oFdyBsNSf/Vs6C35BR5ejNmHVhn+UfkBVC NvhDVFOtEj/gX4aJK+f2sEVcC2BrErXcEsCActvPb5o/t7xjJsT6tHjagQUtft6lCa MEy2J6sqZG1Q+nlMUWWWziA25geH4AiL4Wi+8rTrxCb7zUzOsXvuWhuFRySihmB5Sc 6gutzLF05hTp4pLmso/Oy8g3qQmQOr/L+3X7RZLxUl9K7LSlJUAcJ88h/S8A+8AUmF CoqzdOKAI7K/X3cE3tTivVCw9sBSZaHXiR9qqDR6Eecqd5HJcj7aMsEE4XrRyEWmVu AZwyS6KPpI84g== Original-Received: from alfajor (104-222-126-84.cpe.teksavvy.com [104.222.126.84]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id AFFC212023B; Sat, 3 Apr 2021 23:20:13 -0400 (EDT) In-Reply-To: <4B051055-CC87-419A-A106-C5F2A7674869@gmail.com> (JD Smith's message of "Sat, 3 Apr 2021 22:52:25 -0400") Received-SPF: pass client-ip=132.204.25.50; envelope-from=monnier@iro.umontreal.ca; helo=mailscanner.iro.umontreal.ca X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:267378 Archived-At: > There=E2=80=99s one thing I=E2=80=99m unclear on: how long does the compl= etion engine in > Emacs hold on to a collection aka "completion table" function? As long as needed. It all depends on the situation. E.g. if the completion table is passed to `completing-read`, then it will be used during the whole lifetime of the minibuffer. When the completion table comes from CAPF, it's usually used for a much shorter duration, among other things because we have to regularly call CAPF in order to detect when changes to the buffer's content or to `point` have caused a change in the kind of things we're completing. > I=E2=80=99d expect this function to live only throughout a single =E2=80= =9Cevent" of > completion (M-tab or what have you). It will often live a little longer, but not much, usually, indeed. This said, it all depends on the UI. I can imagine a UI where CAPF is called once and then the completion is performed within a kind of modal interface which insures that CAPF doesn't need to be re-called, in which case the completion-table may be used for quite a while, just as is the case in minibuffers. > I=E2=80=99m confused by why `completion-table-with-cache=E2=80=99 needs t= o test: > > (string-prefix-p last-arg arg ignore-case) This was designef for completion-tables in general (rather than only those used in a particular kind of situation). Furthermore, even a single M-TAB completion may easily query the completion table several times with different prefix strings (because of `completion-styles`). > Won=E2=80=99t this _always_ be true for the custom-wrapped closure which > `completion-table-with-cache=E2=80=99 constructs? I'm pretty sure there will be cases where this is not the case, no. E.g. you may have a first call for the `basic` completion style with a prefix "foo" which ends up returning nothing, after which we fall back to `substring` completion style and hence query the completion table again with a prefix of "". Stefan