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

Re: auto-move mails



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Thursday, July 24 at 02:16 PM, quoth Ravi Uday:
> In mutt 1.5.17 is there a way we can setup a rule where if the 
> number of emails touches 150 move the first 50 to a specified folder 
> ? We can then map this rule witha key too ?

Well, it's no so much a "rule" as it is a trigger. For example, you 
could use a folder-hook. If you want to do things based on the 
*number* of messages, then you're going to have to play some creative 
games. I can't think of a way to get it to trigger only when there are 
150 messages, but I *can* think of a way to make sure that there are 
only the most-recent 100 messages.

Since the concept of "most-recent" relies on the sorting order, we're 
going to use a combination of changing the sorting order and the ~m 
matching pattern. For example, we can use a hook that will:

     1. Save the current sort order
     2. Sort the messages so that the most-recent come first
     3. Tag all messages after the 100th message
     4. Save all tagged messages into a specified folder
     5. Restore the original sort order

Such as this:

     folder-hook . '<enter-command>set my_savedsort=$sort<enter>\
     <enter-command>set sort=reverse-date-received<enter>\
     <tag-pattern>~m 101-<enter>\
     <tag-prefix-cond><save-message>=foo<enter>\
     <sync-mailbox>\
     <enter-command>set sort=$my_savedsort<enter>'

You can, of course, bind that macro to a key instead of a hook if you 
prefer.

~Kyle
- -- 
No man should escape our universities without knowing how little he 
knows.
                                               -- J. Robert Oppenheimer
-----BEGIN PGP SIGNATURE-----
Comment: Thank you for using encryption!

iEYEARECAAYFAkiJ3FcACgkQBkIOoMqOI14w0gCcDs/FOoTBR3KlFG1mmUvQyJEP
vf8AoJeV9B2vwfbtxsScIyIi0LU0Gr78
=umeY
-----END PGP SIGNATURE-----