I have several folders defined in Mutt:
mailboxes "~/Mail/inbox" mailboxes "~/Mail/sent" mailboxes "~/Mail/archive"
I can save (move) a message to archive, by pressing s and then ? to see a list of folders, and then I can choose archive from the list.
Since I always want only to save to archive I would like to have a macro, so that pressing s automatically saves selected message to archive, without asking me.
Can somebody please help?
EDIT:
I now have following macro, to save messages to my “archive” folder:
macro index,pager S "<tag-prefix><save-message>=archive<enter> :set delete=yes<enter><sync-mailbox>:set delete=no<enter>"
the problem is, the messages stay in index marked as deleted. They are not “synced” immediately. Second, the <enter> at the end acts as <display-message>, so that when I press S, I end up in the pager of the current message.
In a similar way, I am trying to implement the trash folder in mutt. The following is taken from the Mutt MacroSamples
set maildir_trash=yes set wait_key=no folder-hook . 'bind index q quit' folder-hook inbox 'macro index q ":unset maildir_trash;push "T~D\n<tag-prefix-cond>m=trash\n<end-cond><quit>"n"'
but this does not work either. Insted mutt asks me:
Append messages to etmaildir_trash;push"T~Dn<tag-prefix-cond>m=trashn<end-cond><quit>"/maildir_trash;push"T~Dn<tag-prefix-cond>m=trashn<end-co ([yes]/no):
what ever I press, nothing happens
(the folders trash/{cur,new,tmp} do exist)
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
tagged mails:
macro index S ":set confirmappend=no delete=yesn<tag-prefix-cond><save-message>=archiven<sync-mailbox>:set confirmappend=yes delete=ask-yesn"
current only:
macro index A ":set confirmappend=no delete=yesn<save-message>=archiven<sync-mailbox>:set confirmappend=yes delete=ask-yesn"
edit
macro index S ":set confirmappend=no delete=yesn<tag-prefix><save-message>=archiven<sync-mailbox>:set confirmappend=yes delete=ask-yesn"
My fault, using tag-prefix instead of tag-prefix-cond, will apply the macro to tagged messages if present, else to the current selected.
Method 2
The mutt guide has an example macro for your use case:
macro index <tag-prefix-cond><save-message>=foo<enter> “Save tagged messages (if any) to =foo”
You could implement it in your case like so:
macro index,pager A "<save-message>=Mail/archive<enter>" "mark message as Archived"
Hitting Shifta in either the index or pager view would save the message to your archive maildir.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0