Gnus development mailing list
 help / color / mirror / Atom feed
* In-buffer completion of EBDB mail addresses with corfu
@ 2023-10-18 20:24 Arash Esbati
  2023-10-19  4:14 ` Eric Abrahamsen
  0 siblings, 1 reply; 8+ messages in thread
From: Arash Esbati @ 2023-10-18 20:24 UTC (permalink / raw)
  To: ding

Hi all,

almost a year ago, I asked here about using corfu for in-buffer
completion of mail addresses in BBDB database.  I got that working
somehow, bug now I switched to EBDB (soley because it has a manual ;-)
and now I have the same problem: Does anybody has a working solution how
to get in-buffer completion working in Message mode?  In a *unsent mail*
buffer, I want:

  To: <Point-here-hit-TAB offers mail addresses with corfu>

It seems EBDB works in general; if I go to the "To: " header and do

  M-x edbd-complete-mail RET

I get a *Completions* buffer where I can choose from.

After this question[1], there was also a bug report #59314[2] that EUDC
has some issues with header completion, but it seems there was no real
solution?

This is with EBDB v0.8.18 installed from ELPA and Emacs 30 from master
(98748aa6e6) and zero customization for EBDB.  The value of
`completion-at-point-functions' is:

  completion-at-point-functions is a variable defined in ‘minibuffer.el’.

  Its value is (message-completion-function t)
  Local in buffer *unsent mail*; global value is 
  (tags-completion-at-point-function cape-file)

TIA.  Best, Arash

Footnotes:
[1]  Message-ID: <87r0y42vnh.fsf@a16n.net>

[2]  https://debbugs.gnu.org/cgi/bugreport.cgi?bug=59314



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

* Re: In-buffer completion of EBDB mail addresses with corfu
  2023-10-18 20:24 In-buffer completion of EBDB mail addresses with corfu Arash Esbati
@ 2023-10-19  4:14 ` Eric Abrahamsen
  2023-10-19  7:14   ` Arash Esbati
  0 siblings, 1 reply; 8+ messages in thread
From: Eric Abrahamsen @ 2023-10-19  4:14 UTC (permalink / raw)
  To: ding

Arash Esbati <arash@gnu.org> writes:

> Hi all,
>
> almost a year ago, I asked here about using corfu for in-buffer
> completion of mail addresses in BBDB database.  I got that working
> somehow, bug now I switched to EBDB (soley because it has a manual ;-)

:)

I believe there are more advantages, but yes this is the primary one.

> and now I have the same problem: Does anybody has a working solution how
> to get in-buffer completion working in Message mode?  In a *unsent mail*
> buffer, I want:
>
>   To: <Point-here-hit-TAB offers mail addresses with corfu>
>
> It seems EBDB works in general; if I go to the "To: " header and do
>
>   M-x edbd-complete-mail RET
>
> I get a *Completions* buffer where I can choose from.

Address completion in message-mode is messy. There are a couple of
different places where EBDB can insinuate itself into the completion
mechanism: the one that happens by default shadows `message-expand-name'
with `ebdb-complete-mail', which runs its own live-search completion
function, you've seen that above.

The other option is to set (the variable) `ebdb-complete-mail' to the
symbol 'capf. This will put a pre-defined list of "name <email>" strings
into the completion-at-point-functions hook. Then TAB should offer those
strings for completion, using corfu.

The search is less powerful because it doesn't use a dynamic lookup, but
it should still be fine to use.

Let me know how that works!



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

* Re: In-buffer completion of EBDB mail addresses with corfu
  2023-10-19  4:14 ` Eric Abrahamsen
@ 2023-10-19  7:14   ` Arash Esbati
  2023-10-19 14:29     ` Eric Abrahamsen
  0 siblings, 1 reply; 8+ messages in thread
From: Arash Esbati @ 2023-10-19  7:14 UTC (permalink / raw)
  To: Eric Abrahamsen; +Cc: ding

Eric Abrahamsen <eric@ericabrahamsen.net> writes:

> The other option is to set (the variable) `ebdb-complete-mail' to the
> symbol 'capf. This will put a pre-defined list of "name <email>" strings
> into the completion-at-point-functions hook. Then TAB should offer those
> strings for completion, using corfu.
>
> The search is less powerful because it doesn't use a dynamic lookup, but
> it should still be fine to use.
>
> Let me know how that works!

Thanks for your response.  I added

  (setq ebdb-complete-mail 'capf)

to my .gnus, but I think this is not enough.  IIUC, I need:

  (setq ebdb-complete-mail 'capf)
  (require 'ebdb-message)

Then this is the value of `completion-at-point-functions' in this
buffer:

  completion-at-point-functions is a variable defined in ‘minibuffer.el’.

  Its value is
  (ebdb-mail-dwim-completion-at-point-function
   message-completion-function t)

Now I hit 'C-c C-f C-t' and enter ', TAB' after your "name <email>" and
get some space added with "No match" in the echo area.  So it doesn't
seem to work.  Or am I missing something?

And while we're at it: I suggest to autoload the functions
`ebdb-insinuate-message', `ebdb-insinuate-mail' and
`ebdb-message-auto-update' and let users add things like:

  (add-hook 'message-mode-hook #'ebdb-insinuate-message)
  (add-hook 'message-send-hook #'ebdb-message-auto-update)

  (add-hook 'mail-setup-hook #'ebdb-insinuate-mail)
  (add-hook 'mail-send-hook #'ebdb-message-auto-update)

to their init file, depending on what they're using.

Best, Arash


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

* Re: In-buffer completion of EBDB mail addresses with corfu
  2023-10-19  7:14   ` Arash Esbati
@ 2023-10-19 14:29     ` Eric Abrahamsen
  2023-10-20  6:41       ` Arash Esbati
  0 siblings, 1 reply; 8+ messages in thread
From: Eric Abrahamsen @ 2023-10-19 14:29 UTC (permalink / raw)
  To: Arash Esbati; +Cc: ding

Arash Esbati <arash@gnu.org> writes:

> Eric Abrahamsen <eric@ericabrahamsen.net> writes:
>
>> The other option is to set (the variable) `ebdb-complete-mail' to the
>> symbol 'capf. This will put a pre-defined list of "name <email>" strings
>> into the completion-at-point-functions hook. Then TAB should offer those
>> strings for completion, using corfu.
>>
>> The search is less powerful because it doesn't use a dynamic lookup, but
>> it should still be fine to use.
>>
>> Let me know how that works!
>
> Thanks for your response.  I added
>
>   (setq ebdb-complete-mail 'capf)
>
> to my .gnus, but I think this is not enough.  IIUC, I need:
>
>   (setq ebdb-complete-mail 'capf)
>   (require 'ebdb-message)
>
> Then this is the value of `completion-at-point-functions' in this
> buffer:
>
>   completion-at-point-functions is a variable defined in ‘minibuffer.el’.
>
>   Its value is
>   (ebdb-mail-dwim-completion-at-point-function
>    message-completion-function t)
>
> Now I hit 'C-c C-f C-t' and enter ', TAB' after your "name <email>" and
> get some space added with "No match" in the echo area.  So it doesn't
> seem to work.  Or am I missing something?

I'm not completely clear what you're doing here -- you enter a full name
and email, then a comma, then TAB? EBDB will only look back as far as
the nearest comma for completion. In this case it will send in a blank
string, which should offer all emails in your EBDB database for
completion. Have you created any records? Are there strings in
`ebdb-dwim-completion-cache'?

> And while we're at it: I suggest to autoload the functions
> `ebdb-insinuate-message', `ebdb-insinuate-mail' and
> `ebdb-message-auto-update' and let users add things like:
>
>   (add-hook 'message-mode-hook #'ebdb-insinuate-message)
>   (add-hook 'message-send-hook #'ebdb-message-auto-update)
>
>   (add-hook 'mail-setup-hook #'ebdb-insinuate-mail)
>   (add-hook 'mail-send-hook #'ebdb-message-auto-update)
>
> to their init file, depending on what they're using.

That's not a bad idea. Having them `require' libraries to activate
behavior isn't very Emacsy. That would be a pretty annoying change for
existing users, though...


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

* Re: In-buffer completion of EBDB mail addresses with corfu
  2023-10-19 14:29     ` Eric Abrahamsen
@ 2023-10-20  6:41       ` Arash Esbati
  2023-10-20 15:08         ` Eric Abrahamsen
  0 siblings, 1 reply; 8+ messages in thread
From: Arash Esbati @ 2023-10-20  6:41 UTC (permalink / raw)
  To: Eric Abrahamsen; +Cc: ding

Eric Abrahamsen <eric@ericabrahamsen.net> writes:

> I'm not completely clear what you're doing here -- you enter a full name
> and email, then a comma, then TAB? EBDB will only look back as far as
> the nearest comma for completion. In this case it will send in a blank
> string, which should offer all emails in your EBDB database for
> completion. 

I think we can skip this (see below).

> Have you created any records?

Yes.

> Are there strings in `ebdb-dwim-completion-cache'?

Thanks, this is it.  It was nil.  If I do `M-x ebdb RET RET' to see my
records and then hit 'q', `ebdb-dwim-completion-cache' seems to get
populated and then hitting TAB in the header in Message mode offers
in-buffer completion.  Is there a way to automate the setting of
`ebdb-dwim-completion-cache'?

> That's not a bad idea. Having them `require' libraries to activate
> behavior isn't very Emacsy.

Agreed.  And that was the reason I made that suggestion.

> That would be a pretty annoying change for existing users, though...

Are these two approaches mutually exclusive?  Users who want to
`require' it can still do it, and others can load the package lazily if
the autoload cookies are added.  Or am I missing something?

Best, Arash


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

* Re: In-buffer completion of EBDB mail addresses with corfu
  2023-10-20  6:41       ` Arash Esbati
@ 2023-10-20 15:08         ` Eric Abrahamsen
  2023-10-21  9:09           ` Arash Esbati
  0 siblings, 1 reply; 8+ messages in thread
From: Eric Abrahamsen @ 2023-10-20 15:08 UTC (permalink / raw)
  To: ding

Arash Esbati <arash@gnu.org> writes:

> Eric Abrahamsen <eric@ericabrahamsen.net> writes:
>
>> I'm not completely clear what you're doing here -- you enter a full name
>> and email, then a comma, then TAB? EBDB will only look back as far as
>> the nearest comma for completion. In this case it will send in a blank
>> string, which should offer all emails in your EBDB database for
>> completion. 
>
> I think we can skip this (see below).
>
>> Have you created any records?
>
> Yes.
>
>> Are there strings in `ebdb-dwim-completion-cache'?
>
> Thanks, this is it.  It was nil.  If I do `M-x ebdb RET RET' to see my
> records and then hit 'q', `ebdb-dwim-completion-cache' seems to get
> populated and then hitting TAB in the header in Message mode offers
> in-buffer completion.  Is there a way to automate the setting of
> `ebdb-dwim-completion-cache'?

There are "is EBDB loaded" guards around every entrypoint I could think
of, except this! Luckily that's not hard to fix.

>> That's not a bad idea. Having them `require' libraries to activate
>> behavior isn't very Emacsy.
>
> Agreed.  And that was the reason I made that suggestion.
>
>> That would be a pretty annoying change for existing users, though...
>
> Are these two approaches mutually exclusive?  Users who want to
> `require' it can still do it, and others can load the package lazily if
> the autoload cookies are added.  Or am I missing something?

Yes, I suppose you're right. `add-hook' is idempotent, so no harm done
if that ends up getting called twice. And the "insinuate" functions are
a fine place to make sure that `ebdb-load' is called.

I don't think there should be anything complicated about that, I'll play
with it and release a new version soon.

Thanks!
Eric



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

* Re: In-buffer completion of EBDB mail addresses with corfu
  2023-10-20 15:08         ` Eric Abrahamsen
@ 2023-10-21  9:09           ` Arash Esbati
  2023-10-21 18:32             ` Eric Abrahamsen
  0 siblings, 1 reply; 8+ messages in thread
From: Arash Esbati @ 2023-10-21  9:09 UTC (permalink / raw)
  To: Eric Abrahamsen; +Cc: ding

Eric Abrahamsen <eric@ericabrahamsen.net> writes:

> Yes, I suppose you're right. `add-hook' is idempotent, so no harm done
> if that ends up getting called twice. And the "insinuate" functions are
> a fine place to make sure that `ebdb-load' is called.

That would be great.  I now have this setup in my .gnus and it works:

  (setq ebdb-complete-mail 'capf)
  (require 'ebdb-message)
  (add-hook 'message-mode-hook #'ebdb-load)

> I don't think there should be anything complicated about that, I'll play
> with it and release a new version soon.

Looking forward to that.  And please don't forget to update the manual
;-)

Best, Arash


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

* Re: In-buffer completion of EBDB mail addresses with corfu
  2023-10-21  9:09           ` Arash Esbati
@ 2023-10-21 18:32             ` Eric Abrahamsen
  0 siblings, 0 replies; 8+ messages in thread
From: Eric Abrahamsen @ 2023-10-21 18:32 UTC (permalink / raw)
  To: ding

Arash Esbati <arash@gnu.org> writes:

> Eric Abrahamsen <eric@ericabrahamsen.net> writes:
>
>> Yes, I suppose you're right. `add-hook' is idempotent, so no harm done
>> if that ends up getting called twice. And the "insinuate" functions are
>> a fine place to make sure that `ebdb-load' is called.
>
> That would be great.  I now have this setup in my .gnus and it works:
>
>   (setq ebdb-complete-mail 'capf)
>   (require 'ebdb-message)
>   (add-hook 'message-mode-hook #'ebdb-load)
>
>> I don't think there should be anything complicated about that, I'll play
>> with it and release a new version soon.
>
> Looking forward to that.  And please don't forget to update the manual
> ;-)

Of course :)



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

end of thread, other threads:[~2023-10-21 18:33 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-18 20:24 In-buffer completion of EBDB mail addresses with corfu Arash Esbati
2023-10-19  4:14 ` Eric Abrahamsen
2023-10-19  7:14   ` Arash Esbati
2023-10-19 14:29     ` Eric Abrahamsen
2023-10-20  6:41       ` Arash Esbati
2023-10-20 15:08         ` Eric Abrahamsen
2023-10-21  9:09           ` Arash Esbati
2023-10-21 18:32             ` Eric Abrahamsen

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 NNTP newsgroup(s).