unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [Emacs] Using notmuch-address with EUDC, and completion-at-point
@ 2022-07-22 14:50 Alexander Adolf
  2022-07-30 12:37 ` David Bremner
  0 siblings, 1 reply; 7+ messages in thread
From: Alexander Adolf @ 2022-07-22 14:50 UTC (permalink / raw)
  To: notmuch

[-- Attachment #1: Type: text/plain, Size: 1002 bytes --]

Hello,

I recently switched in-buffer completion from company [1] to
completion-at-point with corfu [2] as the UI.

As I wanted email address completion via completion-at-point in
message-mode too, I implemented a new EUDC function to go into
completion-at-point-functions [3].

[1] https://company-mode.github.io
[2] https://github.com/minad/corfu
[3] https://github.com/emacs-mirror/emacs/blob/master/lisp/net/eudc-capf.el

To close the loop, I also wrote an EUDC back-end to get candidates from
notmuch-address (which attached).

Now, with a eudc-server-hotlist value of

(("localhost" . notmuch-address)
 ("localhost" . macos-contacts))

and eudc-capf-complete among completion-at-point-functions in
message-mode, I get combined email address completion candidates from
both sources offered by completion-at-point when composing a new email.

Life can be a breeze at times... ;-)

I hope anyone else finds this useful.


Hoping to have helped, and looking forward to your thoughts,

  --alexander


[-- Attachment #2: eudcb-notmuch-address.el --]
[-- Type: application/emacs-lisp, Size: 3378 bytes --]

[-- Attachment #3: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Emacs] Using notmuch-address with EUDC, and completion-at-point
  2022-07-22 14:50 [Emacs] Using notmuch-address with EUDC, and completion-at-point Alexander Adolf
@ 2022-07-30 12:37 ` David Bremner
  2022-08-02 15:26   ` Alexander Adolf
  0 siblings, 1 reply; 7+ messages in thread
From: David Bremner @ 2022-07-30 12:37 UTC (permalink / raw)
  To: Alexander Adolf, notmuch

Alexander Adolf <alexander.adolf@condition-alpha.com> writes:

> As I wanted email address completion via completion-at-point in
> message-mode too, I implemented a new EUDC function to go into
> completion-at-point-functions [3].
>
> [1] https://company-mode.github.io
> [2] https://github.com/minad/corfu
> [3] https://github.com/emacs-mirror/emacs/blob/master/lisp/net/eudc-capf.el
>

I will have to leave to others to test this, since I'm personally still
running emacs 27 (and that is likely to continue for a while, at least
on some machines).

> To close the loop, I also wrote an EUDC back-end to get candidates from
> notmuch-address (which attached).

Is this something that you think should be included with notmuch? If so,
is it testable without requiring any extra packages?

d


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Emacs] Using notmuch-address with EUDC, and completion-at-point
  2022-07-30 12:37 ` David Bremner
@ 2022-08-02 15:26   ` Alexander Adolf
  2022-08-12 10:28     ` David Bremner
  0 siblings, 1 reply; 7+ messages in thread
From: Alexander Adolf @ 2022-08-02 15:26 UTC (permalink / raw)
  To: David Bremner, notmuch

Hello David,

thanks for your comments and questions.

David Bremner <david@tethera.net> writes:

> Alexander Adolf <alexander.adolf@condition-alpha.com> writes:
>
>> As I wanted email address completion via completion-at-point in
>> message-mode too, I implemented a new EUDC function to go into
>> completion-at-point-functions [3].
>>
>> [1] https://company-mode.github.io
>> [2] https://github.com/minad/corfu
>> [3] https://github.com/emacs-mirror/emacs/blob/master/lisp/net/eudc-capf.el
>>
>
> I will have to leave to others to test this, since I'm personally still
> running emacs 27 (and that is likely to continue for a while, at least
> on some machines).

You could do

     (require 'eudcb-notmuch-address)
     (eudc-notmuch-address-set-server "localhost")

and bind the function eudc-expand-inline to a key chord of your choice
in message-mode-map.

Then you'd no longer have to tweak message-completion-alist.

This assumes that eudc-expand-inline is present in Emacs 27, of course,
which I admittedly haven't checked.

What you'd probably lose (or no longer need, whichever way you view it)
is any company-mode integration.

>> To close the loop, I also wrote an EUDC back-end to get candidates from
>> notmuch-address (which attached).
>
> Is this something that you think should be included with notmuch?

Good question. From my point of view: why not?

Its added value would be "separation of concerns", i.e. you could drop
any company-mode integration (and resort to whatever UI
completion-at-point uses), you could stop modifying
message-completion-alist, and notmuch-address-command could stay set to
'internal in all configurations.

BUT, using the full potential depends on some core Emacs infrastructure,
which will not be released until Emacs 29.

Thus, from your point of view, it could be a two step process.

In the first step, you could describe in the documentation how to bind
eudc-expand-inline in message-mode-map, and how to set notmuch-address
as the eudc-server. Just as I described above for your Emacs 27 setup.
This would allow you to refrain from modifying message-completion-alist,
and you could also drop any company mode integration from
notmuch-address.el

In the second step, when Emacs 29 will be released, the need for using
eudc-expan-inline will be removed, and adding notmuch-address as an EUDC
server alone will be enough.

> If so, is it testable without requiring any extra packages?

The short answer is yes.

On an Emacs prior to version 29, there will be two restrictions: there
won't be any way of having EUDC contribute to completion-at-point, and
there won't be any multi-server query support in EUDC either. That said,
you can still use it in a less versatile way as I have described above
for your Emacs 27 setup.

On an Emacs 29 or better, both gaps are filled (EUDC multi-server query,
and completion-at-point), and message.el is updated to give the EUDC
completion-at-point function a "foot in the door", i.e. it will be
called _before_ message-completion-function when completion-at-point is
invoked. Thus, if you add notmuch-address to eudc-server-hotlist,
completion candidates from normuch-address will automagically show up
without any further tweaking of message-mode on your part.


Many thanks and looking forward to your thoughts,

  --alexander

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Emacs] Using notmuch-address with EUDC, and completion-at-point
  2022-08-02 15:26   ` Alexander Adolf
@ 2022-08-12 10:28     ` David Bremner
  2022-08-16 17:35       ` Alexander Adolf
  0 siblings, 1 reply; 7+ messages in thread
From: David Bremner @ 2022-08-12 10:28 UTC (permalink / raw)
  To: Alexander Adolf, notmuch

Alexander Adolf <alexander.adolf@condition-alpha.com> writes:

> Hello David,
>
> thanks for your comments and questions.
>
> David Bremner <david@tethera.net> writes:
>
>> Alexander Adolf <alexander.adolf@condition-alpha.com> writes:
>>
>>> As I wanted email address completion via completion-at-point in
>>> message-mode too, I implemented a new EUDC function to go into
>>> completion-at-point-functions [3].
>>>
>>> [1] https://company-mode.github.io
>>> [2] https://github.com/minad/corfu
>>> [3] https://github.com/emacs-mirror/emacs/blob/master/lisp/net/eudc-capf.el
>>>
>>
>> I will have to leave to others to test this, since I'm personally still
>> running emacs 27 (and that is likely to continue for a while, at least
>> on some machines).
>
> You could do
>
>      (require 'eudcb-notmuch-address)
>      (eudc-notmuch-address-set-server "localhost")
>
> and bind the function eudc-expand-inline to a key chord of your choice
> in message-mode-map.
>
> Then you'd no longer have to tweak message-completion-alist.

I stopped my investigations at the point it looked like I needed to edit
notmuch-address.el. I guess another patch or two is needed to do notmuch
integration. And of course we would need tests (in the notmuch test
suite) and documentation before actually merging the functionality, but
those can probably wait until we have a clearer idea what benefits the
change would bring.

> This assumes that eudc-expand-inline is present in Emacs 27, of course,
> which I admittedly haven't checked.

The function exists here in Emacs 27.1.

> What you'd probably lose (or no longer need, whichever way you view it)
> is any company-mode integration.

Unless the UX is very close, some people will strongly prefer to stay
with the existing completion, so I guess we'd need to make it
opt-in. Unfortunately as Tomi already pointed out the configuration is
already a bit of a confusing mess.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Emacs] Using notmuch-address with EUDC, and completion-at-point
  2022-08-12 10:28     ` David Bremner
@ 2022-08-16 17:35       ` Alexander Adolf
  2022-08-18 14:57         ` David Bremner
  0 siblings, 1 reply; 7+ messages in thread
From: Alexander Adolf @ 2022-08-16 17:35 UTC (permalink / raw)
  To: David Bremner, notmuch

Hello David,

David Bremner <david@tethera.net> writes:

> [...]
>> You could do
>>
>>      (require 'eudcb-notmuch-address)
>>      (eudc-notmuch-address-set-server "localhost")
>>
>> and bind the function eudc-expand-inline to a key chord of your choice
>> in message-mode-map.
>>
>> Then you'd no longer have to tweak message-completion-alist.
>
> I stopped my investigations at the point it looked like I needed to edit
> notmuch-address.el. I guess another patch or two is needed to do notmuch
> integration. And of course we would need tests (in the notmuch test
> suite) and documentation before actually merging the functionality, but
> those can probably wait until we have a clearer idea what benefits the
> change would bring.

I agree with your assessment that the benefit in the very short term is
not too big.

If and when the proposal I made on emacs-devel, to modify how email
address completion is handled in Emacs's message.el should get accepted
& merged, then the enabled changes would be much bigger: no integration
with message.el needed (i.e. no more need to hook into
message-completion-alist), single point of interface will be EUDC, no
more integration with company needed.

From what it sound s like, it would seem to make more sense to wait for
that Emacs patch to get merged? Bundling the new code with notmuch, but
without any integration with the rest of it, effectively leaving it to
users to figure out how to make use of it wouldn't seem to make too much
sense, OTOH.

>> This assumes that eudc-expand-inline is present in Emacs 27, of course,
>> which I admittedly haven't checked.
>
> The function exists here in Emacs 27.1.
> [...]

Thanks for confirming!



Cheers,

  --alexander

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Emacs] Using notmuch-address with EUDC, and completion-at-point
  2022-08-16 17:35       ` Alexander Adolf
@ 2022-08-18 14:57         ` David Bremner
  2022-08-18 21:31           ` Alexander Adolf
  0 siblings, 1 reply; 7+ messages in thread
From: David Bremner @ 2022-08-18 14:57 UTC (permalink / raw)
  To: Alexander Adolf, notmuch

Alexander Adolf <alexander.adolf@condition-alpha.com> writes:

>
> From what it sound s like, it would seem to make more sense to wait for
> that Emacs patch to get merged? Bundling the new code with notmuch, but
> without any integration with the rest of it, effectively leaving it to
> users to figure out how to make use of it wouldn't seem to make too much
> sense, OTOH.
>

One point is that it is unlikely that notmuch will ever require the most
recent version of emacs (currently the baseline is supposedly emacs
25.1). It's fine to optionally take advantage of new features in emacs,
but we want people to be able to use notmuch-emacs without necessarily
upgrading their version of Emacs.

d

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Emacs] Using notmuch-address with EUDC, and completion-at-point
  2022-08-18 14:57         ` David Bremner
@ 2022-08-18 21:31           ` Alexander Adolf
  0 siblings, 0 replies; 7+ messages in thread
From: Alexander Adolf @ 2022-08-18 21:31 UTC (permalink / raw)
  To: David Bremner, notmuch

Hello David,

David Bremner <david@tethera.net> writes:

> [...]
> One point is that it is unlikely that notmuch will ever require the most
> recent version of emacs (currently the baseline is supposedly emacs
> 25.1). It's fine to optionally take advantage of new features in emacs,
> but we want people to be able to use notmuch-emacs without necessarily
> upgrading their version of Emacs.

I see, thanks for the clarification.

That's then one more thing to stay in my `.emacs.d/patches` folder for
the time being.


Many thanks and cheers,

  --alexander

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-08-18 21:31 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-22 14:50 [Emacs] Using notmuch-address with EUDC, and completion-at-point Alexander Adolf
2022-07-30 12:37 ` David Bremner
2022-08-02 15:26   ` Alexander Adolf
2022-08-12 10:28     ` David Bremner
2022-08-16 17:35       ` Alexander Adolf
2022-08-18 14:57         ` David Bremner
2022-08-18 21:31           ` Alexander Adolf

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.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).