Re: Equivalent to 'limit' for index?

2013-02-07 Thread James Griffin
-- David Woodfall d...@dawoodfall.net [2013-02-06 21:59:48 +]:

 Is there a way of 1) Doing a 'limit' in the index, which shows only
 folders with new mail, or 2) A file-mask that I can use to do the
 same?
 
 Man page and google didn't find anything, and I tried making a macro
 for limit for the index but it didn't work.
 
 Thanks

I see Andre has provided some of his own scripts and, they do look
interesting; I'll take a look too if that's ok.

But the index view is just that. It displays messages and info about
them for that mailbox; so no, you couldn't use the limit function for
showing mailboxes with new mail other than the buffy-list function.

In my default folder-hook I have this (borrowed from Rado's config which
is listed on the wiki under config tricks):

folder-hook . \
... ;\
macro index tab buffy-list ;\
... ;\
'

[then I list my other folder-hooks underneath]

and at the bottom of the file

folder-hook . 'push tab'

What that does is to list all the folders at the bottom of the index
view with new mail in the buffy-list each time I change to a new folder.
I also have buffy-list bound to tab as well so if I want to check the
buffy-list again when in the index view I just press tab.

Are you still having problems getting mutt to tell you what mailboxes
have new mail in them?

Jamie

-- 
Primary Key: 4096R/1D31DC38 2011-12-03
Key Fingerprint: A4B9 E875 A18C 6E11 F46D  B788 BEE6 1251 1D31 DC38


Re: Equivalent to 'limit' for index?

2013-02-07 Thread David Woodfall

On Thu, Feb 07, 2013 at 08:01:21AM +, James Griffin jmz.grif...@kode5.net 
put forth the proposition:

-- David Woodfall d...@dawoodfall.net [2013-02-06 21:59:48 +]:


Is there a way of 1) Doing a 'limit' in the index, which shows only
folders with new mail, or 2) A file-mask that I can use to do the
same?

Man page and google didn't find anything, and I tried making a macro
for limit for the index but it didn't work.

Thanks


I see Andre has provided some of his own scripts and, they do look
interesting; I'll take a look too if that's ok.

But the index view is just that. It displays messages and info about
them for that mailbox; so no, you couldn't use the limit function for
showing mailboxes with new mail other than the buffy-list function.

In my default folder-hook I have this (borrowed from Rado's config which
is listed on the wiki under config tricks):

folder-hook . \
... ;\
macro index tab buffy-list ;\
... ;\
'

[then I list my other folder-hooks underneath]

and at the bottom of the file

folder-hook . 'push tab'

What that does is to list all the folders at the bottom of the index
view with new mail in the buffy-list each time I change to a new folder.
I also have buffy-list bound to tab as well so if I want to check the
buffy-list again when in the index view I just press tab.

Are you still having problems getting mutt to tell you what mailboxes
have new mail in them?


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.



Re: Equivalent to 'limit' for index?

2013-02-07 Thread James Griffin
-- David Woodfall d...@dawoodfall.net [2013-02-07 08:44:34 +]:

 On Thu, Feb 07, 2013 at 08:01:21AM +, James Griffin 
 jmz.grif...@kode5.net put forth the proposition:
 -- David Woodfall d...@dawoodfall.net [2013-02-06 21:59:48 +]:
 
 Is there a way of 1) Doing a 'limit' in the index, which shows only
 folders with new mail, or 2) A file-mask that I can use to do the
 same?
 
 Man page and google didn't find anything, and I tried making a macro
 for limit for the index but it didn't work.
 
 Thanks
 
 I see Andre has provided some of his own scripts and, they do look
 interesting; I'll take a look too if that's ok.
 
 But the index view is just that. It displays messages and info about
 them for that mailbox; so no, you couldn't use the limit function for
 showing mailboxes with new mail other than the buffy-list function.
 
 In my default folder-hook I have this (borrowed from Rado's config which
 is listed on the wiki under config tricks):
 
  folder-hook . \
  ... ;\
  macro index tab buffy-list ;\
  ... ;\
  '
 
  [then I list my other folder-hooks underneath]
 
 and at the bottom of the file
 
  folder-hook . 'push tab'
 
 What that does is to list all the folders at the bottom of the index
 view with new mail in the buffy-list each time I change to a new folder.
 I also have buffy-list bound to tab as well so if I want to check the
 buffy-list again when in the index view I just press tab.
 
 Are you still having problems getting mutt to tell you what mailboxes
 have new mail in them?
 
 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.

What do you mean by in a browser ? Do you you mean the folder view?

-- 
Primary Key: 4096R/1D31DC38 2011-12-03
Key Fingerprint: A4B9 E875 A18C 6E11 F46D  B788 BEE6 1251 1D31 DC38


Re: Equivalent to 'limit' for index?

2013-02-07 Thread David Woodfall

On Thu, Feb 07, 2013 at 09:33:00AM +, James Griffin jmz.grif...@kode5.net 
put forth the proposition:

-- David Woodfall d...@dawoodfall.net [2013-02-07 08:44:34 +]:


On Thu, Feb 07, 2013 at 08:01:21AM +, James Griffin jmz.grif...@kode5.net 
put forth the proposition:
-- David Woodfall d...@dawoodfall.net [2013-02-06 21:59:48 +]:

Is there a way of 1) Doing a 'limit' in the index, which shows only
folders with new mail, or 2) A file-mask that I can use to do the
same?

Man page and google didn't find anything, and I tried making a macro
for limit for the index but it didn't work.

Thanks

I see Andre has provided some of his own scripts and, they do look
interesting; I'll take a look too if that's ok.

But the index view is just that. It displays messages and info about
them for that mailbox; so no, you couldn't use the limit function for
showing mailboxes with new mail other than the buffy-list function.

In my default folder-hook I have this (borrowed from Rado's config which
is listed on the wiki under config tricks):

folder-hook . \
... ;\
macro index tab buffy-list ;\
... ;\
'

[then I list my other folder-hooks underneath]

and at the bottom of the file

folder-hook . 'push tab'

What that does is to list all the folders at the bottom of the index
view with new mail in the buffy-list each time I change to a new folder.
I also have buffy-list bound to tab as well so if I want to check the
buffy-list again when in the index view I just press tab.

Are you still having problems getting mutt to tell you what mailboxes
have new mail in them?

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.


What do you mean by in a browser ? Do you you mean the folder view?


Yes, when I use the toggle-mailboxes command and it lists all the imap
folders.

I've seen plenty of macros for browser online, but it just seems to
get ignored here. Maybe they are outdated.


Re: Equivalent to 'limit' for index?

2013-02-07 Thread David Woodfall

On Thu, Feb 07, 2013 at 09:40:43AM +, David Woodfall d...@dawoodfall.net 
put forth the proposition:

On Thu, Feb 07, 2013 at 09:33:00AM +, James Griffin jmz.grif...@kode5.net 
put forth the proposition:

-- David Woodfall d...@dawoodfall.net [2013-02-07 08:44:34 +]:


On Thu, Feb 07, 2013 at 08:01:21AM +, James Griffin jmz.grif...@kode5.net 
put forth the proposition:

-- David Woodfall d...@dawoodfall.net [2013-02-06 21:59:48 +]:


Is there a way of 1) Doing a 'limit' in the index, which shows only
folders with new mail, or 2) A file-mask that I can use to do the
same?

Man page and google didn't find anything, and I tried making a macro
for limit for the index but it didn't work.

Thanks


I see Andre has provided some of his own scripts and, they do look
interesting; I'll take a look too if that's ok.

But the index view is just that. It displays messages and info about
them for that mailbox; so no, you couldn't use the limit function for
showing mailboxes with new mail other than the buffy-list function.

In my default folder-hook I have this (borrowed from Rado's config which
is listed on the wiki under config tricks):

folder-hook . \
... ;\
macro index tab buffy-list ;\
... ;\
'

[then I list my other folder-hooks underneath]

and at the bottom of the file

folder-hook . 'push tab'

What that does is to list all the folders at the bottom of the index
view with new mail in the buffy-list each time I change to a new folder.
I also have buffy-list bound to tab as well so if I want to check the
buffy-list again when in the index view I just press tab.

Are you still having problems getting mutt to tell you what mailboxes
have new mail in them?


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.


What do you mean by in a browser ? Do you you mean the folder view?


Yes, when I use the toggle-mailboxes command and it lists all the imap
folders.

I've seen plenty of macros for browser online, but it just seems to
get ignored here. Maybe they are outdated.


Well, I got it working by using 'macro generic' instead, then adding a
couple of toggle-mailboxes at the end:

macro generic Z :source 
~/.mutt/sourceallboxes\ntoggle-mailboxestoggle-mailboxes
macro generic z :source 
~/.mutt/sourceboxes\ntoggle-mailboxestoggle-mailboxes

If anyone is interested the scripts below:



sourceboxes:
unmailboxes *
mailboxes `~/.mutt/mailboxes.sh`
subscribe `~/.mutt/subscribed.sh`

sourceallboxes:
unmailboxes *
mailboxes `~/.mutt/allmailboxes.sh`
subscribe `~/.mutt/allsubscribed.sh`

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

allmailboxes.sh:
#!/bin/sh

set -e
MAILDIR=/home/david/mail
HOSTNAME=blackswan

for f in $(find $MAILDIR -name new | cut -d'/' -f5 | sed 's/^\.//')
do
   if [ $f == new ]; then
   f=INBOX
   fi
   echo -n  +$f
done

subscribed.sh:
#!/bin/sh

set -e
MAILDIR=/home/david/mail
HOSTNAME=blackswan

for f in $(find $MAILDIR -name *, -o -name *$HOSTNAME | grep \.lists\. \
   | cut -d'/' -f5 | sort -u | sed 's/^\.//')
do
   echo -n $f 
done

allsubscribed.sh:
#!/bin/sh

set -e
MAILDIR=/home/david/mail
HOSTNAME=blackswan

for f in $(find $MAILDIR -name .lists.* \
   | cut -d'/' -f5 | sort -u | sed 's/^\.//')
do  
   if [ -n $f ]; then

   echo -n $f 
   fi
done

##

Seems to work fine for me, although I'm guessing a bit at how 
individual email files are named when new. For instance, some

end in my hostname and some end in a ','.

--
When all you have is a Swiss Army Knife, every problem looks like email.
   -- Peter da Silva


Re: Equivalent to 'limit' for index?

2013-02-07 Thread Andre Klärner
On Thu, Feb 07, 2013 at 08:44:34AM +, David Woodfall wrote:
 On Thu, Feb 07, 2013 at 08:01:21AM +, James Griffin 
 jmz.grif...@kode5.net put forth the proposition:
 -- David Woodfall d...@dawoodfall.net [2013-02-06 21:59:48 +]:
 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


smime.p7s
Description: S/MIME cryptographic signature


Re: Equivalent to 'limit' for index?

2013-02-07 Thread David Woodfall

On Thu, Feb 07, 2013 at 10:47:57AM +0100, Andre Klärner kan...@ak-online.be 
put forth the proposition:

On Thu, Feb 07, 2013 at 08:44:34AM +, David Woodfall wrote:

On Thu, Feb 07, 2013 at 08:01:21AM +, James Griffin jmz.grif...@kode5.net 
put forth the proposition:
-- David Woodfall d...@dawoodfall.net [2013-02-06 21:59:48 +]:
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.


Yes, my first effort was much too slow, but piping from find takes  a
second to output the list.

I've also taken out the subscribed part and just subscribe to all when
mutt loads.

Thanks for the info on macros. I didn't know they were generated like
that.


Re: Equivalent to 'limit' for index?

2013-02-07 Thread Andre Klärner
Hi David,

On Thu, Feb 07, 2013 at 09:55:55AM +, David Woodfall wrote:
 Seems to work fine for me, although I'm guessing a bit at how
 individual email files are named when new. For instance, some
 end in my hostname and some end in a ','.

well, those ending in your hostname are probaply in the new/ part of the
maildir. While they are moved to cur/ by the MUA they get renames and
appended with the :2,PRSTDF field, which is a delimiter, the version of
the stuff behind, another delimiter and the flags. All is explained in
detail here: http://cr.yp.to/proto/maildir.html
That is also one new thing in my mailboxes.pl: It tries to parse it as
near to the spec as possible.

Regards, Andre

-- 
Andre Klärner


smime.p7s
Description: S/MIME cryptographic signature


Re: Equivalent to 'limit' for index?

2013-02-07 Thread David Woodfall

On Thu, Feb 07, 2013 at 02:23:03PM +0100, Andre Klärner kan...@ak-online.be 
put forth the proposition:

Hi David,

On Thu, Feb 07, 2013 at 09:55:55AM +, David Woodfall wrote:

Seems to work fine for me, although I'm guessing a bit at how
individual email files are named when new. For instance, some
end in my hostname and some end in a ','.


well, those ending in your hostname are probaply in the new/ part of the
maildir. While they are moved to cur/ by the MUA they get renames and
appended with the :2,PRSTDF field, which is a delimiter, the version of
the stuff behind, another delimiter and the flags. All is explained in
detail here: http://cr.yp.to/proto/maildir.html
That is also one new thing in my mailboxes.pl: It tries to parse it as
near to the spec as possible.


Thanks, that's useful info.


Re: Equivalent to 'limit' for index?

2013-02-06 Thread Andre Klärner
Hi David,

On Wed, Feb 06, 2013 at 09:59:48PM +, David Woodfall wrote:
 1) Doing a 'limit' in the index, which shows only folders with new mail, 

I also asked this a while ago, and no, it isn't.

 2) A file-mask that I can use to do the same?

Yes, that one actually exists. In guess it is m in the default key
bindings. Check the help screen while you are in the index. But I guess
there is no way to abuse this for listing folders with new mails.

But I had similiar problems, and figured that it would be best to generate
the mailboxes in the config by a script that delivers either all mailboxes
or just the ones with new mail. You can check it out in my git-repo:
http://git.ak-online.be/?p=kandre/mutt.git;a=tree;f=.mutt;h=f45a42e9df1b58be7a18ae387b40825dc2815bec;hb=refs/heads/master

You need mailboxes.pl, mailboxes.pl.sh and the snippets that call it from
muttrc.

Regards, Andre

-- 
Andre Klärner


smime.p7s
Description: S/MIME cryptographic signature


Re: Equivalent to 'limit' for index?

2013-02-06 Thread David Woodfall

On Thu, Feb 07, 2013 at 06:43:08AM +0100, Andre Klärner kan...@ak-online.be 
put forth the proposition:

Hi David,

On Wed, Feb 06, 2013 at 09:59:48PM +, David Woodfall wrote:

1) Doing a 'limit' in the index, which shows only folders with new mail,


I also asked this a while ago, and no, it isn't.


2) A file-mask that I can use to do the same?


Yes, that one actually exists. In guess it is m in the default key
bindings. Check the help screen while you are in the index. But I guess
there is no way to abuse this for listing folders with new mails.

But I had similiar problems, and figured that it would be best to generate
the mailboxes in the config by a script that delivers either all mailboxes
or just the ones with new mail. You can check it out in my git-repo:
http://git.ak-online.be/?p=kandre/mutt.git;a=tree;f=.mutt;h=f45a42e9df1b58be7a18ae387b40825dc2815bec;hb=refs/heads/master

You need mailboxes.pl, mailboxes.pl.sh and the snippets that call it from
muttrc.

Regards, Andre

--
Andre Klärner


Thanks. That looks interesting.