From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.ciao.gmane.org!not-for-mail From: Daniele Nicolodi Newsgroups: gmane.emacs.devel Subject: Re: Documentation about the completion framework Date: Mon, 21 Jan 2019 19:02:47 -0700 Message-ID: References: <62c8a43a-16f4-cd86-da24-df3dcbe68537@grinta.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.org; posting-host="ciao.gmane.org:195.159.176.228"; logging-data="151122"; mail-complaints-to="usenet@ciao.gmane.org" User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Jan 22 03:03:11 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gllP9-000d3n-7z for ged-emacs-devel@m.gmane.org; Tue, 22 Jan 2019 03:03:07 +0100 Original-Received: from localhost ([127.0.0.1]:37147 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gllP3-0006Ma-5H for ged-emacs-devel@m.gmane.org; Mon, 21 Jan 2019 21:03:01 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:42823) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gllOx-0006MS-4v for emacs-devel@gnu.org; Mon, 21 Jan 2019 21:02:55 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gllOw-0000ly-9P for emacs-devel@gnu.org; Mon, 21 Jan 2019 21:02:55 -0500 Original-Received: from zed.grinta.net ([109.74.203.128]:51404) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gllOv-0000kt-PN for emacs-devel@gnu.org; Mon, 21 Jan 2019 21:02:54 -0500 Original-Received: from black.hsd1.co.comcast.net (c-98-245-163-4.hsd1.co.comcast.net [98.245.163.4]) (Authenticated sender: daniele) by zed.grinta.net (Postfix) with ESMTPSA id 1C710E3D0D for ; Tue, 22 Jan 2019 02:02:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=grinta.net; s=mail; t=1548122571; bh=yF1kyv5rkJVRCBCPcQCM+SMyw/3bPPfhL1SsimLEZFI=; h=Subject:To:References:From:Date:In-Reply-To:From; b=J4ou2iRxGscTbww8y7nivUJy3ntrvMyv0Lkq71zqOZpwBQBAncUdKaXuxNtY1fmry ZB5Wg5UjUXOkVu1iOe7m4daqZsHQ108L7ca8vmWwvFyJAvJJXrEoOr97FiWuujkOrK FvvNRBnjEhyRPZZMROupYzGlerNwbJgp7QpYhjNI= Openpgp: preference=signencrypt In-Reply-To: Content-Language: en-US X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 109.74.203.128 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 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.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:232596 Archived-At: Hi Stefan, On 21/01/2019 14:17, Stefan Monnier wrote: > Yes: don't collect candidates when that function is called. > Instead, the function should return a completion table which will > compute the candidates only if it's called. E.g.: > > (defun my-completion-at-point-function () > (when (relevant) > (let (candidates > (candidates-computed nil) > (start ...) > (end ...) > (completion-table > (lambda (string pred action) > (unless candidates-computed > (setq candidates-computed t) > (setq candidates (my-collect-candidates))) > (complete-with-action action candidates string pred)))) > (list start end completion-table)))) Trying to understand this code: how is this different from computing candidates directly in my-completion-at-point-function and passing it down? I must be missing something. Thank you! Cheers, Dan