From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: [elpa] externals/ebdb 9e7a96f: Add experimental ebdb-completion-at-point-function Date: Fri, 23 Mar 2018 01:18:51 -0400 Message-ID: References: <20180323044822.32467.63948@vcs0.savannah.gnu.org> <20180323044823.1A70C20BDE@vcs0.savannah.gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1521782235 363 195.159.176.226 (23 Mar 2018 05:17:15 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 23 Mar 2018 05:17:15 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: Eric Abrahamsen To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Mar 23 06:17:11 2018 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ezF4g-0008SV-Q4 for ged-emacs-devel@m.gmane.org; Fri, 23 Mar 2018 06:17:10 +0100 Original-Received: from localhost ([::1]:36085 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ezF6j-0001uC-NY for ged-emacs-devel@m.gmane.org; Fri, 23 Mar 2018 01:19:17 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:46640) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ezF6X-0001sW-4Q for emacs-devel@gnu.org; Fri, 23 Mar 2018 01:19:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ezF6T-0001X9-Vg for emacs-devel@gnu.org; Fri, 23 Mar 2018 01:19:05 -0400 Original-Received: from chene.dit.umontreal.ca ([132.204.246.20]:52913) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ezF6T-0001Wz-Og for emacs-devel@gnu.org; Fri, 23 Mar 2018 01:19:01 -0400 Original-Received: from ceviche.home (lechon.iro.umontreal.ca [132.204.27.242]) by chene.dit.umontreal.ca (8.14.7/8.14.1) with ESMTP id w2N5IqCE010541; Fri, 23 Mar 2018 01:18:52 -0400 Original-Received: by ceviche.home (Postfix, from userid 20848) id D4CE966352; Fri, 23 Mar 2018 01:18:51 -0400 (EDT) In-Reply-To: <20180323044823.1A70C20BDE@vcs0.savannah.gnu.org> (Eric Abrahamsen's message of "Fri, 23 Mar 2018 00:48:22 -0400 (EDT)") X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 2 Rules triggered EDT_SA_DN_PASS=0, RV6248=0 X-NAI-Spam-Version: 2.3.0.9418 : core <6248> : inlines <6514> : streams <1782000> : uri <2613204> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 132.204.246.20 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:223933 Archived-At: > +;; Experimental completion-at-point function. I'm not sure this is a > +;; good idea yet -- with a large enough EBDB database, nearly any > +;; string is completable, meaning the other completion-at-point > +;; functions will rarely get a chance. > +(defun ebdb-completion-at-point-function () [...] > + (when completions > + (list start (point) > + (mapcar > + (lambda (str) > + ;; Gross. > + (if (string-match-p "@" str) > + str > + (capitalize str))) > + completions) > + '(:exclusive no))))) Completion-at-point-functions are expected to be cheap/fast (it's normal to call it in post-command-hook) and in order to work correctly the completion table it returns should ideally not depend on the text between START and END (i.e. it's OK to look at the text between START..END in order to choose between an email completion table and a file completion table, but it shouldn't throw away emails just because they don't seem to match the text between START..END). Also in order to be effective, you want them to be selective, e.g. only match when we're pretty sure that the completion-table we return is relevant (e.g. we're on a "To:" line in a message-mode buffer), so it usually depends on the major mode in which it's used. EBDB might elect not to provide a completion-at-point-function but instead to provide only a completion-table (or a bunch of completion tables). Then message-mode could use that completion-table when it determines that we're completing an email address. Stefan