Re: aliasing mailing lists
On Fri, May 19, 2006 at 08:18:20AM EDT, David Woodfall wrote:
> On (20:16 18/05/06), cga2000 <cga2000@xxxxxxxxxxxxx> put forth the
> proposition:
> > On Thu, May 18, 2006 at 12:07:40PM EDT, David Woodfall wrote:
> > > On (14:58 18/05/06), David Woodfall <dave@xxxxxxxxxxxxxxx> put forth the
> > > proposition:
> > > > On (03:25 18/05/06), cga2000 <cga2000@xxxxxxxxxxxxx> put forth the
> > > > proposition:
> >
> > [..]
> > >
> > > This is more complete I think;
> > >
> > > ls -1 ~/mail/lists | grep @ |awk -F@ '{print "alias" " " $1 " " "<" $1
> > > "@" $2 ">"}' > ~/.mutt/lists
> > > ls -1 ~/mail/lists | awk '{print "mailboxes +lists/" $1}' >> ~/.mutt/lists
> > > ls -1 ~/mail/lists | awk '{print "subscribe " $1}' >> ~/.mutt/lists
> > >
> > subscribe `cd ~/mail/lists; ls`
> > mailboxes `for file in $(ls ~/mail/lists); do echo -n "+lists/$file "; done`
> >
> > .. some trial & error in the shell before I got it to work.
>
> Subscribe doesn't work for me. It needs same format as mailboxes. Try:
> subscribe `for file in $(ls ~/mail/lists); do echo -n "$file "; done`
Hmm.. how does it *not* work? What are the symptoms?
Because I played with this for a while and I have a few others that are
commented out such as:
subscribe `cd ~/mail/lists; echo $(ls)`
and more simply:
subscribe `cd ~/mail/lists; *`
but I can't remember what - if anything - was wrong with these attempts.
I'm not even sure the one that's not commented out is the one I finally
decided to use.. I'm not always sure what's best when vim tells me that
he thinks and editing session crashed and whether I want to (R)ecover,
(D)elete the recovery file.. etc. :-)
Anyway, I rather like your version - same style as the mailboxes
command so it'll make more sense a few months from now.
>
> subscribe `for file in $(ls ~/mail/lists); do echo -n "$file "; done`
>
> > I think it's the better solution because it directly adds the contents
> > of my .mutt/lists directory to the list of subscribed mailing lists and
> > to the menu.
> > >
> > > >
> > > > And in my binds file:
> > > >
> > > > macro generic \ca "!~/scripts/listalias\n:source ~/.mutt/lists\n"
> > > >
> > > > Now the mailboxes commands are sourced from my lists file too. So all I
> > > > do is
> > > > keep .procmailrc updated with new list rules and hit ^a in mutt to auto
> > > > update
> > > > the aliases and mailboxes.
> >
> > Not sure doing it on the fly is the right approach any more, though.
> > Maybe this should be done by invoking a script from the .muttrc to
> > re-create the alias file prior to sourcing it.
> >
> > Also keep in mind that mailboxes "come and go" .. ie. if you delete all
> > the messages in a given mailing list.. the corresponding mailbox
> > vanishes.. and will be recreated (in my setyp) when new messages for
> > this list are downloaded. The way I currently do it there's an outside
> > chance something will be out of sync once in a while. My way to address
> > this is that I do not delete the original message from the list
> > "Welcome to the ... mailing list.. etc."..
>
> set save_empty will keep empty mailbixes, although I tend to keep the original
> welcome message for future reference.
>
ibid. thanks for the tip, though.. I do not like the idea of mailboxes
appearing/disappearing..
> > So, if you really want something a little more robust you would probably
> > need to keep track of what lists you are subscribed to outside of mutt,
> > adding an entry when you subscribe to a mailing list and deleting it
> > when you unsubscribe.. And use this "list of subscribed lists" to
> > generate the targets of your .muttrc commands (subscribe/mailboxes) as
> > well as your alias file.
>
> If you make a mailinglists file then something like:
>
> subscribe `for entry in $(cat ~/.mutt/mailinglists); do echo -n "$entry ";
> done`
> mailboxes `for entry in $(cat ~/.mutt/mailinglists); do echo -n
> "+lists/$entry "; done`
>
> will work, although I haven't managed to get this to work for aliases:
>
> alias `for entry in $(cat ~/.mutt/mailinglists); do echo $entry | awk -F@
> '{print $1 " <"$1"@"$2">"}'; done`
>
> This refuses to work. Any ideas?
I think this won't work because you need an alias command for each
mailing list.
Assuming ~/.mutt/mailinglists contains:
list1@host1
list2@host2
the output of the `...` above is:
list1 <list1@host1> list2 <list2@host2>
.. so the final result in your .muttrc is:
alias list1 <list1@host1> list2 <list2@host2>
while what you want is:
alias list1 <list1@host1>
alias list2 <list2@host2>
Can't think of a better way to do this than using an external file and
sourcing it.. but then again I'm very new to mutt.
Let me know if you figure out something.
Thanks,
cga