From: Stefan Monnier <monnier@iro.umontreal.ca>
To: emacs-devel@gnu.org
Subject: Re: [elpa] externals/ebdb 9e7a96f: Add experimental ebdb-completion-at-point-function
Date: Fri, 23 Mar 2018 08:23:07 -0400 [thread overview]
Message-ID: <jwvzi2zrntc.fsf-monnier+gmane.emacs.devel@gnu.org> (raw)
In-Reply-To: 877eq3732w.fsf@ericabrahamsen.net
> 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)
next prev parent reply other threads:[~2018-03-23 12:23 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20180323044822.32467.63948@vcs0.savannah.gnu.org>
[not found] ` <20180323044823.1A70C20BDE@vcs0.savannah.gnu.org>
2018-03-23 5:18 ` [elpa] externals/ebdb 9e7a96f: Add experimental ebdb-completion-at-point-function Stefan Monnier
2018-03-23 5:50 ` Eric Abrahamsen
2018-03-23 10:54 ` Thomas Fitzsimmons
2018-03-23 12:10 ` Eric Abrahamsen
2018-03-23 12:11 ` Eric Abrahamsen
2018-03-23 12:23 ` Stefan Monnier [this message]
2018-04-14 1:02 ` Completion functions in message-mode (was: [elpa] externals/ebdb 9e7a96f: Add experimental ebdb-completion-at-point-function) Eric Abrahamsen
2018-04-14 1:17 ` Completion functions in message-mode Stefan Monnier
2018-04-14 2:33 ` Eric Abrahamsen
2018-04-14 17:37 ` Stefan Monnier
2018-04-25 19:24 ` Eric Abrahamsen
2018-06-06 21:09 ` Eric Abrahamsen
2018-04-14 12:59 ` Lars Ingebrigtsen
2018-04-14 16:17 ` Eric Abrahamsen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=jwvzi2zrntc.fsf-monnier+gmane.emacs.devel@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.