unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Eric Abrahamsen <eric@ericabrahamsen.net>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: Lars Ingebrigtsen <larsi@gnus.org>, emacs-devel@gnu.org
Subject: Completion functions in message-mode (was: [elpa] externals/ebdb 9e7a96f: Add experimental ebdb-completion-at-point-function)
Date: Fri, 13 Apr 2018 18:02:58 -0700	[thread overview]
Message-ID: <87h8oer459.fsf_-_@ericabrahamsen.net> (raw)
In-Reply-To: <jwvzi2zrntc.fsf-monnier+gmane.emacs.devel@gnu.org> (Stefan Monnier's message of "Fri, 23 Mar 2018 08:23:07 -0400")

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> 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`).

Okay, I'm finally coming back around to this, and I need a bit more of
an overview to know what to do. Lars seems to have come in from the
cold, so I'm copying him here.

Leaving backward compatibility aside for a second, here's my take on
things:

What we've got is:

message-mode binds TAB to `message-tab', which calls
`completion-at-point' and, if that doesn't work, falls back to other
things. message-mode adds `message-completion-function' to
`completion-functions-at-point', so TAB ends up calling that function
first. If point is in a viable header, the function calls
`message-expand-group' or `message-expand-name' depending on the header,
but either way _always_ returns a value so that it prevents any other
capf functions from running. If point isn't in a viable header, we get
the "falls back to other things" behavior.

`message-expand-name' is the one that hands off to EUDC, BBDB, etc. The
whole issue is that these package functions do their own completion,
rather than interfacing with `completion-at-point'.

What we _want_ is (and I'm partially guessing here): 

message-mode adds message-expand-group and message-tab-body-function to
`completion-at-point-functions'. Both of these functions check if
they're in an appropriate location, and bail if not, allowing other
functions to do their thing.

Packages such as EUDC and BBDB put their own functions in
`completion-at-point-functions' (in the message-mode hook). The first
thing these functions do is test if they're in an appropriate header,
and bail if not. Otherwise they return an appropriate value for c-a-p,
ie (START END COLLECTION), rather than doing their own completion.

Does this seem about right? Backwards compatibility is still an issue,
but that's what Stefan's patch addresses.

Eric



  reply	other threads:[~2018-04-14  1:02 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
2018-04-14  1:02         ` Eric Abrahamsen [this message]
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=87h8oer459.fsf_-_@ericabrahamsen.net \
    --to=eric@ericabrahamsen.net \
    --cc=emacs-devel@gnu.org \
    --cc=larsi@gnus.org \
    --cc=monnier@iro.umontreal.ca \
    /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).