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 08:23:07 -0400 Message-ID: References: <20180323044822.32467.63948@vcs0.savannah.gnu.org> <20180323044823.1A70C20BDE@vcs0.savannah.gnu.org> <877eq3732w.fsf@ericabrahamsen.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1521807779 2577 195.159.176.226 (23 Mar 2018 12:22:59 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 23 Mar 2018 12:22:59 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Mar 23 13:22:55 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 1ezLig-0000aU-QE for ged-emacs-devel@m.gmane.org; Fri, 23 Mar 2018 13:22:54 +0100 Original-Received: from localhost ([::1]:37745 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ezLkk-0004Zl-7u for ged-emacs-devel@m.gmane.org; Fri, 23 Mar 2018 08:25:02 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:32880) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ezLj9-0003jV-Ov for emacs-devel@gnu.org; Fri, 23 Mar 2018 08:23:24 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ezLj5-0000it-Qm for emacs-devel@gnu.org; Fri, 23 Mar 2018 08:23:23 -0400 Original-Received: from [195.159.176.226] (port=49578 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ezLj5-0000hj-J9 for emacs-devel@gnu.org; Fri, 23 Mar 2018 08:23:19 -0400 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1ezLgx-00077O-As for emacs-devel@gnu.org; Fri, 23 Mar 2018 13:21:07 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 71 Original-X-Complaints-To: usenet@blaine.gmane.org Cancel-Lock: sha1:2PiWbFtmGreO8TaEUI+anwiOXBs= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 195.159.176.226 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:223956 Archived-At: > Looks like you added that FIXME! If you outline how you think this ought > to look, I can take a stab at patching message.el. At what level should > these functions be intervening? One of the main issue is preserving backward compatibility with existing functions the user may have set in message-completion-alist. I have already some local patches to try and do some of that, so see patch below (I hand-edited it to remove irrelevant other cosmetic changes, so don't try to pass it to `patch`). > My only reservation is that BBDB/EBDB mail completion first completes a > contact mail address, and subsequently cycles through that contact's > other addresses. Is this something that the standard mechanisms can > replicate? You can get cycling via completion-cycle-threshold, yes. Stefan diff --git a/lisp/gnus/message.el b/lisp/gnus/message.el index e452c80e26..c99708845d 100644 --- a/lisp/gnus/message.el +++ b/lisp/gnus/message.el @@ -7930,6 +7936,8 @@ message-tab (defvar mail-abbrev-mode-regexp) +(defvar message--old-style-completion-functions nil) + (defun message-completion-function () (let ((alist message-completion-alist)) (while (and alist @@ -7938,9 +7946,21 @@ message-completion-function (setq alist (cdr alist))) (when (cdar alist) (let ((fun (cdar alist))) - ;; Even if completion fails, return a non-nil value, so as to avoid - ;; falling back to message-tab-body-function. - (lambda () (funcall fun) 'completion-attempted))))) + (if (member fun message--old-style-completion-functions) + ;; Even if completion fails, return a non-nil value, so as to avoid + ;; falling back to message-tab-body-function. + (lambda () (funcall fun) 'completion-attempted) + (let ((ticks-before (buffer-chars-modified-tick)) + (data (funcall fun))) + (if (and (eq ticks-before (buffer-chars-modified-tick)) + (or (null data) + (integerp (car-safe data)))) + data + (push fun message--old-style-completion-functions) + ;; Completion was already performed, so just return a dummy + ;; function that prevents trying any further. + (lambda () 'completion-attempted)))))))) + (defun message-expand-group () "Expand the group name under point." @@ -7966,7 +8083,9 @@ message-expand-group group) collection)) gnus-active-hashtb)) - (completion-in-region b e collection))) + ;; FIXME: Add `category' metadata to the collection, so we can use + ;; substring matching on it. + (list b e collection))) (defun message-expand-name () (cond ((and (memq 'eudc message-expand-name-databases)