On Thu, Feb 07, 2013 at 08:44:34AM +0000, David Woodfall wrote:
> On Thu, Feb 07, 2013 at 08:01:21AM +0000, James Griffin 
> <jmz.grif...@kode5.net> put forth the proposition:
> >--> David Woodfall <d...@dawoodfall.net> [2013-02-06 21:59:48 +0000]:
> No it works fine now. Just trying out a couple of shell scripts
> similar to Andre's, but much simpler:
> 
> mailboxes.sh:
> ##########################
> #!/bin/sh
> 
> set -e
> MAILDIR="/home/david/mail"
> HOSTNAME="blackswan"
> 
> for f in $(find $MAILDIR -name "*," -o -name "*$HOSTNAME" | cut -d'/' -f5 | \
>    sort -u | sed 's/^\.//')
> do
>    if [ "$f" == "new" ] || [ "$f" == "cur" ]; then
>        f="INBOX"
>    fi
>    echo -n " +"$f
> done
> 
> echo ########################
> 
> It seems to be working fine but for some reason I'm unable to bind it to a 
> macro in browser:
> 
> macro browser z "|~/.mutt/mailboxes.sh\n"
> 
> This just tells me that key is unbound, and I've tried it elsewhere like
> index, which works, but I'd rather have it in browser where I'm actually
> looking at the mailboxes.

Well, not quite obvious at first, but easy to understand: Your script
generates just a list of mailbox names, e.g. "+foo +bar +baz". That output
is usable by feeding it into a mailboxes-command. e.g. "mailboxes 
`mailboxes.sh`".
And that command in turn you can bind to a macro.: "macro browser z "mailboxes 
`mailboxes.sh`"

But: that macro will be generated while parsing the config, so it will execute
"mailboxes +foo +bar +baz" when it is called. So you need to source that
out into a seperate file, that than in turn is sourced by the macron on
demand. So you essentially end up with a state that I already had: commit
17cb8a4ff0a455073fba19fdb95871b73ddf480e in my mutt-repo. At that time I
was still using the 1st version of my mailboxes-script, but it got
unmanageable as some of my folders grew too big. So the runtime of the
script ended up being 30-60s, depending on the speed of my NFS-server
serving the Maildir.

So I reimplemented it using perl (because I wanted to do perl anyway some
day) and build it to be completely optimized. The issue I diagnosed with
the old version was that it ran through all directories and file to find
unread mails, but that takes too long. In the perl-version I stop at the
first occurance of an unread mail or don't even check the cur-directory if
already the new-directory has contents. And I also avoid going into cur,
new or tmp directories if it should print all anyway.

But it is up to you what way you want to go.

Have fun,
Andre

-- 
Andre Klärner

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to