unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Eric Abrahamsen <eric@ericabrahamsen.net>
To: emacs-devel@gnu.org
Subject: Re: [elpa] externals/ebdb 9e7a96f: Add experimental ebdb-completion-at-point-function
Date: Fri, 23 Mar 2018 13:50:31 +0800	[thread overview]
Message-ID: <877eq3732w.fsf@ericabrahamsen.net> (raw)
In-Reply-To: jwv605njs69.fsf-monnier+emacsdiffs@gnu.org

Stefan Monnier <monnier@IRO.UMontreal.CA> writes:

>> +;; 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.

Thanks for these notes!

In part I was wondering if it would be useful to provide completion on
contact names in other contexts besides message headers, but I suppose
the right thing to do is just add contact names to the user's personal
spelling dictionary, and allow them to complete names as part of
spell-checking/ispell-complete-word. EBDB provides other tools for
inserting contact information in random contexts.

So this completion function should be targeted specifically at
message/mail-mode header lines. I'll no longer override <TAB> in that
message-mode, but instead tie into what's already there.

In message-mode, c-a-p-f contains `message-completion-function', which
consults `message-completion-alist' (which contains a FIXME: "Make it
possible to use the standard completion UI."), which hands off to
`message-expand-name', which is hard-coded to use either eudc, bbdb, or
`expand-abbrev'. There is a user option,
`message-expand-name-databases', but it's mostly useless as putting new
databases in there won't actually let you use them.

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?

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?

Thanks,
Eric




  reply	other threads:[~2018-03-23  5:50 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 [this message]
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
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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=877eq3732w.fsf@ericabrahamsen.net \
    --to=eric@ericabrahamsen.net \
    --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 public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).