Abbreviation for commonly used group of addresses

20 views
Skip to first unread message

Eduardo Mercovich

unread,
Apr 14, 2016, 10:59:57 AM4/14/16
to mu-discuss
Message-ID: <87ega9s...@gmail.com>
User-agent: mu4e 0.9.17; emacs 24.5.1
it: a few addresses that are commonly used together, for example, a
Dear all.

I have (probably you too) a common use case and like to share how you do
small team that is temporary and thus has no mailing list or similar
arranging.

So you have these 4 to 7 people that are usually mailed together. Even
if each is only a couple keys (because of helm used with addresses) it
becomes repetitive and not efficient at all.

How do you define an abbreviation for those so you can mail all with a
couple keys? I'm trying abbrev-mode (wich is an all around great tool)
but maybe mu4e native mechanism would be good too...

Thank you for sharing your thoughts and current solutions. :)

Best.


--
eduardo mercovich

Donde se cruzan tus talentos
con las necesidades del mundo,
ahí está tu vocación.

Alex Bennée

unread,
Sep 20, 2022, 2:42:58 PM9/20/22
to mu-di...@googlegroups.com, Eduardo Mercovich

Eduardo Mercovich <eduardo....@gmail.com> writes:

> Message-ID: <87ega9s...@gmail.com>
> User-agent: mu4e 0.9.17; emacs 24.5.1
> it: a few addresses that are commonly used together, for example, a
> Dear all.
>
> I have (probably you too) a common use case and like to share how you do
> small team that is temporary and thus has no mailing list or similar
> arranging.

I too would like to have this sort of thing. As a bonus driven by org
mode (because that is a good place to keep a table of interested
parties).

> So you have these 4 to 7 people that are usually mailed together. Even
> if each is only a couple keys (because of helm used with addresses) it
> becomes repetitive and not efficient at all.
>
> How do you define an abbreviation for those so you can mail all with a
> couple keys? I'm trying abbrev-mode (wich is an all around great tool)
> but maybe mu4e native mechanism would be good too...
>
> Thank you for sharing your thoughts and current solutions. :)

The only two ways I can think is either:

a) hacking your aliases into mu4e--contacts-set (ugly "private" hash table)
b) installing an additional function to completion-at-point-functions

although I wonder how it would expand. Ideally you want the completion
function to search on a group name (e.g. "People into Foo") but expand
into a set of pretty "Name" <person@email>, ... expansions.

>
> Best.
>
>
> --
> eduardo mercovich
>
> Donde se cruzan tus talentos
> con las necesidades del mundo,
> ahí está tu vocación.


--
Alex Bennée

Tim Cross

unread,
Sep 20, 2022, 7:29:40 PM9/20/22
to mu-di...@googlegroups.com
There are 3 solutions I can think of, one of which you already have.

1. Use ~/.mailrc. This one is built into message-mode (which mu4e uses
to compose messages). All you need to do is ensure
message-mail-alias-type is set to abbrev (which I think is the defualt)
and your ready to go. Just define your aliases in ~/.mailrc e.g

alias team1 "John Smith <jsm...@example.com>, Ronald McDonald
<big...@fat.com>"

and then type the alias name i.e. team1 and hit tab to have it
completed.

The benefit of this approach is that mu4e contacts still works. The
drawback is there is no integration with other systems, like google
contacts, giving mobile device integration etc.

2. Use org-contacts. Setting this up is fairly straight-forward and
org-contacts is available on GNU ELPA (and MELPA I think). With this
approach, you would use a GROUP property to define different groups of
contacts. While this requires a little more manual intervention, it
would be possible to write some additional emacs lisp functions to get
exactly the behaviour you want. One advantage of this approach is that
you can set things up to have your contacts synced with other systems,
such as google contacts, making your contacts available on mobile
devices. One nice thing about it is that all your contacts are just
plain text and therefore can also be manipulated easily using various tools.

3. Use BBDB. This is a very powerful contact management database system
which has been around for decades. I used it over 20 years ago and it
was great. Extremely powerful. There is some information about
integrating with bbdb in the mu4e manual. Downside is that it can be
complicated and your contact information is in a bbdb specific database
(well really just a lisp data structure in a file).

I've used all of the above approaches in the past. Currently, I have
been using the ~/.mailrc approach because it is easy and because some
other mail clients wil also use it. However, I was using and plan to
return to using org-contacts (just haven't got around to reconfiguring
after a major system and emacs overhaul!).

Alex Bennée

unread,
Sep 21, 2022, 5:18:48 AM9/21/22
to mu-di...@googlegroups.com, Tim Cross
Hmm I already have a .mailrc for git-send-email aliases but they don't
seem to expand. Does it work through the same completion-at-point
expansion mechanism?

> 2. Use org-contacts. Setting this up is fairly straight-forward and
> org-contacts is available on GNU ELPA (and MELPA I think). With this
> approach, you would use a GROUP property to define different groups of
> contacts. While this requires a little more manual intervention, it
> would be possible to write some additional emacs lisp functions to get
> exactly the behaviour you want. One advantage of this approach is that
> you can set things up to have your contacts synced with other systems,
> such as google contacts, making your contacts available on mobile
> devices. One nice thing about it is that all your contacts are just
> plain text and therefore can also be manipulated easily using various
> tools.

I shall have a play.

> 3. Use BBDB. This is a very powerful contact management database system
> which has been around for decades. I used it over 20 years ago and it
> was great. Extremely powerful. There is some information about
> integrating with bbdb in the mu4e manual. Downside is that it can be
> complicated and your contact information is in a bbdb specific database
> (well really just a lisp data structure in a file).
>
> I've used all of the above approaches in the past. Currently, I have
> been using the ~/.mailrc approach because it is easy and because some
> other mail clients wil also use it. However, I was using and plan to
> return to using org-contacts (just haven't got around to reconfiguring
> after a major system and emacs overhaul!).

The perennial problem of a long time emacs users ;-)

--
Alex Bennée

Tim Cross

unread,
Sep 21, 2022, 6:53:10 AM9/21/22
to Alex Bennée, mu-di...@googlegroups.com
Not sure if it is the same mechanism or not. From a user perspective, it
works the same as the mu4e contacts for me - I type the alias name in
the To, Cc or Bcc field and hit tab and the alias is replaced by the
string associated with the alias iin the .mailrc file.

I've done nothing 'special' to get htis to work apart from ensuring the
variable message-mail-alias-type is set correctly. I'm running mu4e from
git HEAD.

Eduardo Mercovich

unread,
Sep 22, 2022, 10:45:17 AM9/22/22
to Alex Bennée, mu-di...@googlegroups.com
Hello everyone.

>> I have (probably you too) a common use case and like to share how you
>> do small team that is temporary and thus has no mailing list or
>> similar arranging. [...] So you have these 4 to 7 people that are
>> usually mailed together. Even if each is only a couple keys (because
>> of helm used with addresses) it becomes repetitive and not efficient
>> at all.

>> How do you define an abbreviation for those so you can mail all with a
>> couple keys? I'm trying abbrev-mode (wich is an all around great tool)
>> but maybe mu4e native mechanism would be good too...

> The only two ways I can think is either:
> a) hacking your aliases into mu4e--contacts-set (ugly "private" hash table)
> b) installing an additional function to completion-at-point-functions

I did it with .mailrc (including pretty names) and it works without
touching anything else. :)

Best...


--
Eduardo Mercovich

Donde se cruzan tus talentos
con las necesidades del mundo,
ahí está tu vocación.
(Anónimo)

Alex Bennée

unread,
Sep 22, 2022, 11:36:31 AM9/22/22
to Eduardo Mercovich, mu-di...@googlegroups.com

Eduardo Mercovich <eduardo....@gmail.com> writes:

> Hello everyone.
>
>>> I have (probably you too) a common use case and like to share how you
>>> do small team that is temporary and thus has no mailing list or
>>> similar arranging. [...] So you have these 4 to 7 people that are
>>> usually mailed together. Even if each is only a couple keys (because
>>> of helm used with addresses) it becomes repetitive and not efficient
>>> at all.
>
>>> How do you define an abbreviation for those so you can mail all with a
>>> couple keys? I'm trying abbrev-mode (wich is an all around great tool)
>>> but maybe mu4e native mechanism would be good too...
>
>> The only two ways I can think is either:
>> a) hacking your aliases into mu4e--contacts-set (ugly "private" hash table)
>> b) installing an additional function to completion-at-point-functions
>
> I did it with .mailrc (including pretty names) and it works without
> touching anything else. :)

Hmm I can get it to work with C-x ' (expand-abbrev) but the usual tab
calls message-tab which despite the doc string seems to ignore
message-completion-alist due to completion-at-point failing the expansion.

(defun message-tab ()
"Complete names according to `message-completion-alist'.
Execute function specified by `message-tab-body-function' when
not in those headers. If that variable is nil, indent with the
regular text mode tabbing command."
(interactive nil message-mode)
(cond
((let ((completion-fail-discreetly t))
(completion-at-point))
;; Completion was performed; nothing else to do.
nil)
(message-tab-body-function (funcall message-tab-body-function))
(t (funcall (or (lookup-key text-mode-map "\t")
(lookup-key global-map "\t")
'indent-relative)))))

Looking at completion-at-point-functions:

Value in #<buffer *draft*>
(mu4e~compose-complete-contact
message-completion-function
t)

and manually calling (funcall (message-completion-function)) works so I
can only assume mu4e~compose-complete-contact stopped the rest of the
functions being called despite failing the expansion itself.

>
> Best... -- Eduardo Mercovich Donde se cruzan tus talentos con las
> necesidades del mundo, ahí está tu vocación. (Anónimo)


--
Alex Bennée

Eduardo Mercovich

unread,
Sep 22, 2022, 1:11:25 PM9/22/22
to Alex Bennée, mu-di...@googlegroups.com
Hi Alex.

[...]

>>>> How do you define an abbreviation for those so you can mail all with a
>>>> couple keys? I'm trying abbrev-mode (wich is an all around great tool)
>>>> but maybe mu4e native mechanism would be good too...
>>
>>> The only two ways I can think is either:
>>> a) hacking your aliases into mu4e--contacts-set (ugly "private" hash table)
>>> b) installing an additional function to completion-at-point-functions
>>
>> I did it with .mailrc (including pretty names) and it works without
>> touching anything else. :)

> Hmm I can get it to work with C-x ' (expand-abbrev) but the usual tab
> calls message-tab which despite the doc string seems to ignore
> message-completion-alist due to completion-at-point failing the expansion.

I use just tab for all aliases expansion, there is not even search since
it's not needed because I make them really short.

But I'm still using an older mu4e version, if that could be an issue...

Tim Cross

unread,
Sep 22, 2022, 6:55:54 PM9/22/22
to mu-di...@googlegroups.com
I'm using the latest mu development versions (HEAD of git repo) and it
works fine. No additional configuration was required - I just started
adding aliases to my mailrc file. Also running Emacs from git pulled
about 5 days ago (29.0.50).

It is most likely due to something else in your Emacs configuration (for
example company, helm, ivy, evil, spacemacs, doom emacs etc).

I would start by just running Emacs with only your mu4e setup and see if
it works. If it does, then you know it is something else you have
added/installed. If it still doesn't work, you know it is either
something in Emacs or your mu4e installation or the entry in your mailrc
file is incorrectly formatted.

My suspicion is it will be some other completions framework you have
installed. I"m only using vertico, embark and corfu. I also use
evil-mode and I run within a GUI, not a terminal (actually, I use emacs
--deamon and a simple script with uses emacsclient to pop open a frame
with mu4e when I want to deal with email).

BTW I find chemacs2 a really useful tool for switching between different
Emacs configuration profiles. See https://github.com/plexus/chemacs2
With this library, I have a number of different Emacs configurations
which make debugging very simple. For example, I have a nearly vanilla
profile where I can just add one thing, such as mu4e, and test it in a
fairly vanilla environment. Switching between environments is as easy as

emacs --with-profile vanilla

Reply all
Reply to author
Forward
0 new messages