<<< Date Index >>>     <<< Thread Index >>>

Re: aliasing mailing lists



On Wed, May 17, 2006 at 09:59:52PM EDT, Cameron Simpson wrote:
> On 17May2006 16:05, cga2000 <cga2000@xxxxxxxxxxxxx> wrote:
> | Is there any way I can make mutt even more effective by aliasing
> | mailing lists on the fly? Same as using the default 'a' for private
> | parties.
> | 
> | The messages from the mailing lists in my setup have headers like:
> | 
> | 'From: the OP'
> | 'To:   the mailing list'
> | 
> | So it obviously won't work with the 'a' command.
> | 
> | Has anyone concocted a simple strategy that would save me the trouble
> | of entering all these mailing lists I am subscribed to in my alias file?
> 
> Well, it's not quite what you want, but I have a script I use for a
> similar purpose. I have a cross referencing system in my inbound and
> outbound mail filing that copies messages to special xref-foo folders
> based on addresses in the headers. So I have a frequent need to add new
> messages to the cross references, and have bound "A" to this task.

..precisely the key I had in mind..
> 
> The macro looks like this:
> 
>   <pipe-message>grabaliases -<enter><copy-message>+spool-refile<enter>
> 
> You are interested in doing the first part, somewhat modified.
> 
> Grabaliases is here:
> 
>   http://www.cskk.ezoshosting.com/cs/css/bin/grabaliases
> 
> It gets the addresses from the headers, inserts them in my xref tabel and
> fires up an editor. What you probably want to do is get the addresses
> from the To: line, append them to your list subscription file as mutt
> subscribe commands (which you should keep separate for this purpose,
> and just "source" it from your main muttrc), then run up an editor to
> tidy up.

I did not give enough detail. My situation is rather more simple because
I already have a procmail set of rules that selects messages from
mailing lists and automatically copies them to an mbox in ~/mail/lists
whose name is the full name of the mailing list.

ie.

$ ls -1 ~/mail/lists

bug-bash@xxxxxxx
debian-laptop@xxxxxxxxxxxxxxxx
debian-printing@xxxxxxxxxxxxxxxx
debian-user@xxxxxxxxxxxxxxxx
...

And naturally, my .muttrc has the subscribe commands to define as a
mailing list each file in the mail/lists directory.

So, in order to generate a typo-free alias file for my mailing lists
I wrote a one-line script that pipes the above through awk like so:

ls -1 ~/mail/lists | grep @ |awk -F@ '{print "alias" " " $1 " " "<" $1 "@" $2 
">"}' 

.. and when I need to update my mailing-lists alias file, I just edit
the current file, open a new line, and type the name of the script,
"!!sh" and this generates the list of aliases. After a quick
verification, I delete the lines that correspond to the previous
version of the list's alias file, save the new contents and bounce mutt.

Quite ugly but it probably takes longer to explain than actually do it.

After reading the above I think I will add a '> ~/.mutt/mlist' to
redirect awk to overwrite the alias file. I could then bind the 'A' key
to a macro that executes the script and sources the new alias file.

Not very robust by the look of it but it should work?
> 
> For that purpose maybe you might like this script:
> 
>   http://www.cskk.ezoshosting.com/cs/css/bin/grabaddrs-all
> 
> which pulls all the addresses from all the address-like headers; cut
> it back to grab just from To: (and maybe CC:). Then turn them into
> subscribe lines with some awk, append to file, and edit. So a short
> script like this:
> 
>   #!/bin/sh
>   grabaddrs-tocc | awk '{print "subscribe", $1}' >>your-subscriptions.txt
>   ${EDITOR:-vi} your-subscriptions.txt </dev/tty >/dev/tty 2>&1
> 
> where "grabaddrs-tocc" is the cut back "grabaddrs-all" script.
> Then your macro would be something like:
> 
>   <pipe-message>grab-mlist -<enter>
> 
> where "grab-mlist" is the short shell script above.

I need to play with this and see what I would gain by switching to this
strategy.
> 
> Note that grabaddrs-all is not a complete RFC822 address parser; it
> just does ok with the command address renderings seen.  There are legal
> addresses it won't recognise, but those seem to be very rare.
> 
That, I would probably never have noticed. :-)

> Cheers,

Thanks. Very interesting scripts, though I must say not easy to follow
with my elementary knowledge of bash scripting.

Thanks,

cga