Marking as unread when moving mail to another folder

Cameron Simpson cs at cskk.id.au
Tue Feb 16 21:48:39 UTC 2021


On 16Feb2021 11:31, Sam Kuper <sampablokuper at posteo.net> wrote:
>On Thu, Jul 16, 2020 at 10:57:13AM +0200, Kai Weber wrote:
>> I have a save-hook defined to move all mail into a certain folder.
>>
>>     save-hook "~A"  +personal/Archive
>>
>> Very often I want to move the mail into the archive without opening the
>> mail at all but then the mail ends up as unread in the archive.
>>
>> I want to mark the mail as "read" when moving. How could I achieve this?
>> I guess a macro could do it? Should I get rid of the save-hook?

Does it matter if its unread in the archive? I guess to you it does.  Do 
you want to mark _everything_ in the archive as unread? Maybe it would 
be quicker with a folder-hook which matches your archive folder and 
marks everything unread as read on entry to the folder.

>This macro may do what you want.  It marks mail as "read" and moves it
>to the $record file.
>
>Note that it makes use of `<`, which is Mutt's built-in shortcut for the
>$record file.

Note: I missed this remark, thought it was a typo :-) So the OP might 
want that replaced with +personal/Archive.

>    # Unlike index mode, pager mode does not accept this macro without
>    # an initial `<exit>`. So we need two variants of this macro, one
>    # for each mode.
>    macro index  ss        "<tag-prefix-cond><enter-command>set auto_tag=yes<enter><end-cond><clear-flag>n<save-message><<Return>y<tag-prefix-cond><enter-command>set auto_tag=no<enter><end-cond><sync-mailbox>y"
>    macro pager  ss  "<exit><tag-prefix-cond><enter-command>set auto_tag=yes<enter><end-cond><clear-flag>n<save-message><<Return>y<tag-prefix-cond><enter-command>set auto_tag=no<enter><end-cond><sync-mailbox>y<display-message>"
>
>If anyone reading this knows of a better solution, please share it.

Remarks: I usually spell the pager macro like this:

    macro pager  ss  "<exit>ss"

which avoids a lot of repetition.

I rarely end macros with <sync-mailbox>, it shows things down and I like 
to only sync when intended, via the $ keystroke.

I wouldn't fiddle with auto_tag, I'd just preceed things with 
<tag-prefix>, since you seem to have made this conditional on beging 
tagged anyway. In principle, fiddling an option requires unfiddling it 
at the end of the macro with the usual cumbersome

    set $my_option=$option
    set option=whatever
    ... do stuff
    set option=$my_option

shuffle embedded in the macro.

If you set wait_key=no during the macro you can drop the "y" you have 
embedded after the save.

Cheers,
Cameron Simpson <cs at cskk.id.au>


More information about the Mutt-users mailing list