emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Completion functions in message-mode (was: [elpa] externals/ebdb 9e7a96f


From: Eric Abrahamsen
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
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

Stefan Monnier <address@hidden> 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 via email to

[Prev in Thread] Current Thread [Next in Thread]