On 22Jul2015 11:35, Peter P. <peterpar...@fastmail.com> wrote:
I have bound the 'd' key to move mails to a trash folder, and 'D' to
move an entire thread to a trash folder:

folder-hook . 'macro index,pager d "<save-message>=INBOX.Trash \r"
folder-hook . 'macro index,pager D 
"<tag-thread><tag-prefix><save-message>=INBOX.Trash \r"

Minor remark: I bind ^D (ctrl-D) to delete thread; "D" is already bound to delete pattern.

This doesn't prevent me from accidentally moving these messages twice,
eg when the first mails in a thread are deleted using 'd' (and are
marked deleted accordingly) with a subsequent use of 'D' the entire
thread, including the messages that got deleted already, gets saved to
the trash folder again, causing duplicates.

Is there a way to execute above scripts only on messages and threads
whose status is not 'deleted'?

I would do 3 things:

- leave the first macro alone; it is hard to point at a deleted message (mutt tends to skip the the next undeleted message), so personally if I were on a deleted message and pressed "d" I'd want it to just do it

- look at the $delete_untag setting, which clears the tag on a message if you delete it

- modify the second macro, eg (untested):

 macro index,pager D 
"<tag-thread><untag-pattern>~D<enter><tag-prefix><save-message>=INBOX.Trash<enter>"

That should tag the thread, untag any deleted messages, then move.

Actually, I would extend that macro to flush any existing tags as I presume you don't want to delete "the thread plus anything else that happened to be tagged". So:

 macro index,pager D 
"<untag-pattern>~T<enter><tag-thread><untag-pattern>~D<enter><tag-prefix><save-message>=INBOX.Trash<enter>"

Another note is I split my macro like this into two, thus:

 macro index D 
"<untag-pattern>~T<enter><tag-thread><untag-pattern>~D<enter><tag-prefix><save-message>=INBOX.Trash<enter>"
 macro pager D qD

i.e. inside the pager the macro just exits to the index and then runs delete thread.

Again, I recommend using ^D instead of D for this macro. Your call, obviously.

Cheers,
Cameron Simpson <c...@zip.com.au>

In article <323c4db9.6...@ss1.csd.sc.edu>, lhart...@ss1.csd.sc.edu wrote:
| It still is true that the best touring bike is the one that you are
| riding right now.  Anything can be used for touring.  As long as you
| can travel, you are touring.
I beleive such true and profound statements are NOT allowed to be posted
in this newsgroup, and are also against the charter.  You've been warned.
       - Randy Davis DoD #0013 <ra...@agames.com> in rec.moto

Reply via email to