Mutt: mark as read and delete

emailmutttrash

I discard some messages without reading them. After deleting said messages, however, I am soon alerted to the presence of unread mail in my trash can.

Is there a way to either:

  • disable the alert (set beep_new) when a new message is found in the trash can; or
  • simultaneously mark a message as read and delete it?

I imagine the former could be implemented with a trash folder hook and the latter could be implemented using a macro. However, in the case of the latter, after marking a message (Wn) or entire thread (^R) as read, the selected entry may or may not change, depending on the position of the message in the folder.

One must then use a conditional to determine how to restore the selection by use of the entry navigation commands. After restoring the selection, the message can be deleted. According to the official documentation, the configuration files do not support conditionals, so a macro-based solution might involve piping through a shell script.

Perhaps there is a simpler solution to this problem that I have overlooked?

Best Answer

To simultaneously mark a message as read and delete it you can use the set resolve=no before the command to avoid jumping to the next message. This avoid having to check condition and such. Your cursor will stay in place after the ation is done.

For example, I uses the following to mark as read before moving a message to an archive maildir:

macro index,pager a ":set confirmappend=no delete=yes resolve=no\n<clear-flag>N<tag-prefix><save-message>=archive\n:set confirmappend=yes delete=ask-yes resolve=yes\n<next-undeleted>"

This will:

  • Set some value before the action, including resolve=no to avoid jumping to the next message
  • Clear the unread flag: <clear-flag>N
  • Save the message into my archive: <tag-prefix><save-message>=archive
  • Set value back to what they should be, including resolve
  • Jump to the next undeleted message: <next-undeleted>

So to mark as read and delete, something like this should work:

macro index,pager d ":set confirmappend=no delete=yes resolve=no\n<clear-flag>N<tag-prefix><delete-message>:set confirmappend=yes delete=ask-yes resolve=yes\n<next-undeleted>"
Related Question