mutt: mark as read and delete

5,570

Solution 1

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>"

Solution 2

If you are enabling the option imap_check_subscribed, then all IMAP subscribed folders are automatically added to the list of mailboxes.

The command unmailboxes can be used to remove a mailbox from the list of mailboxes. So you can add the following in the .muttrc file:

push ":unmailboxes +[Gmail]/Trash<enter>"

We can't use directly the unmailboxes command because imap_check_subscribed will retrieve and add the list of mailboxes after reading the config file (.muttrc), thus we need to push it.

Solution 3

The obvious way is to simply not include "trash can" in the list of mailboxes that mutt checks for new mail.

i.e. don't add the trashcan folder to mailboxes.

e.g. if you generate the mailboxes list with something like:

mailboxes \
  /var/spool/mail/username \
  `find ~/Mail -type f | xargs`

then add grep -v trashcan | just before the xargs, like so:

`find ~/Mail -type f | grep -v trashcan | xargs`
Share:
5,570

Related videos on Youtube

user001
Author by

user001

Updated on September 18, 2022

Comments

  • user001
    user001 almost 2 years

    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?

  • Alessio
    Alessio almost 12 years
    probably one of your addon patches, most likely the trash patch. I also use mutt with an imaps:// mailbox and it doesn't do what you described - I don't even get an imap Trash folder unless I specificall add one. mutt's imap support has some annoyances but that's not one of them.
  • ppr
    ppr over 6 years
    why the confirmappend ?
  • Mayeu
    Mayeu over 6 years
    This part dependend of your configuration. The idea is that by default confirmappend is set to yes in mutt. Setting it to no will prevent mutt to ask confirmation when appending the message in an existing mailbox, but then at the end of the command I restore the default behaviour. If your configuration is set to no at all time, then this is not needed.
  • ppr
    ppr over 6 years
    Ok thanks for the explanation. Another question: in my case, the two macro are only working for the index (not for the pager despite the "pager" presence). It is the case for you too?
  • Sebastian Stark
    Sebastian Stark about 5 years
    In case if IMAP simply unsubscribing from the Trash folder is enough.