El Tuesday, 13 de September del 2016 a les 23:30, Erik Christiansen va escriure:

On 13.09.16 12:08, mimosinnet wrote:
When the members of the group CoordsM change, I have to change the

Is there a way I can use the definition of the "Address Groups"
(http://www.mutt.org/doc/manual/#addrgroup) to be able to define an
alias (http://www.mutt.org/doc/manual/#alias).

I've not tried to make the group and group_alias names the same, to ease
the task of e.g. an awk script synthesising the group's alias from the
"alias -group" lines. Leaving it as is, I figure one would need a
linking comment line, e.g.:

# group_alias CoordsMaster CoordsM

placed _before_ the first alias line using either name.

Then a script something like:

Waw! Erik! Thanks a lot!
I have been playing with your idea and written a script in perl6:


This script:
- Creates the same alias that has been defined by the -group option
- It can be used with multiple definitions of -group



(P.S.: I am sorry I have hijack the thread ಥ_ಥ )


gawk '
$2 ~ /group_alias/   { alias_groups[$4] = $3 ; group_aliases[$3] = $4 }

$1 ~ /alias/ && $2 ~ /-group/   {
  if ($3 in alias_groups)
  {  i = alias_groups[$3]
     alias_lists[i] = alias_lists[i] ", " $4

$1 ~ /alias/ && $2 !~ /-group/ {
  if ($2 in group_aliases) printf("%s %s %s\n",$1,$2,substr(alias_lists[$2],3))
  else print

  { print }      # Print all lines not rewritten.

' ~/.muttrc > /tmp/muttrc

does the trick for me. To use:

$ muttalgrp                      # Or whatever it should be called.
$ diff ~/.muttrc /tmp/muttrc     # Check shows one line updated, here.
$ mv /tmp/muttrc ~/.muttrc       # You could back-up the old one first.

1) This was quickly cobbled together to see what it'd take to do the job.
  It has only been lightly tested.
2) It catches the required alias lines, and those without -group, but
  not present in group_aliases, but there might be some .muttrc idiom
  which isn't covered.
3) It ought to work for multiple groups in the .muttrc, but it's only been
  tested on one.
4) It doesn't suit my use-case, where not every member of the group
is allowed to be in the group alias, as the group included in replies
  is a subset of the receipt group. That could perhaps be fiddled with
  either multiple groups or group aliases.

Linux User: #463211
41:25:16N (41.421110) 2:11:28E (2.188333)

Reply via email to