mu4e address autocomplete during compose needs to make context-sensitive selections

19 views
Skip to first unread message

Johan Pretorius

unread,
May 25, 2022, 11:42:25 AM5/25/22
to mu-discuss

When composing an email in mu4e, I make heavy use of autocompletion in the To: and Cc: lines.

Sometimes I have both a personal and work email address for the person I'm communicating with.

I'd like the autocompletion to select the appropriate email address - I guess the easiest way to do so, would be to base it on the context I have selected.

For example, if I am sending email from al...@work.com to Bob, I'd like the mail to go to b...@bobsjob.com. Whereas if I'm sending email from al...@gmail.com, I'd like the mail to go to b...@home.com

Since I already have al...@work.com and al...@gmail.com configured in mu4e contexts, it seems that what is needed is to make autocompletion respect the context.

What do I need to do, to make mu4e email address autocompletion respect the context?

Regards,
Johan

Tassilo Horn

unread,
May 25, 2022, 3:19:54 PM5/25/22
to mu-di...@googlegroups.com, Johan Pretorius
Johan Pretorius <jpret...@polymorph.co.za> writes:

Hi Johan,

> I'd like the autocompletion to select the appropriate email address -
> I guess the easiest way to do so, would be to base it on the context I
> have selected.
>
> For example, if I am sending email from al...@work.com to Bob, I'd
> like the mail to go to b...@bobsjob.com. Whereas if I'm sending email
> from al...@gmail.com, I'd like the mail to go to b...@home.com
>
> Since I already have al...@work.com and al...@gmail.com configured in
> mu4e contexts, it seems that what is needed is to make autocompletion
> respect the context.
>
> What do I need to do, to make mu4e email address autocompletion
> respect the context?

Technically, I think you could define an :around advice for
mu4e~compose-complete-handler which would let-bind mu4e--contacts-set
(or mu4e--contacts-hash if you're using a released mu4e version) to
either only personal or work emails.

The actual challenge is how you would do that classification. I mean,
the addresses offered for completion by mu4e--contacts-set are the
thousands of contacts you've ever communicated with. You'd need to
classify them somehow which might only be feasible if you could find a
pattern, e.g., at work you only communicate with contacts @foo.com and
@bar.com and a handful of others you can easily enumerate.

Another idea would be to compile the list of suitable receivers in terms
of a search from:al...@work.com and then collecting all To/Cc values
from the result. However, that will probably be too slow to do with
mu4e. Maybe it's doable by shelling out, e.g.,

mu find --fields="t, c" from:ts...@gnu.org | tr , '\n' | \
sed -e 's/^[[:space:]]//' | sort | uniq

compiles a list of all To: and Cc: values I've used when sending mail
with this address.

Bye,
Tassilo

Johan Pretorius

unread,
May 26, 2022, 3:33:38 AM5/26/22
to Tassilo Horn, mu-di...@googlegroups.com
Hi Tassilo,

I like your idea of compiling a list based on which from: address I've used to communicate with the addresses in the To: and CC: fields.

Thanks!
-Johan

Reply all
Reply to author
Forward
0 new messages