Macro to mark as "read" and then archive

Sam Kuper sampablokuper at posteo.net
Tue Jul 28 17:06:43 UTC 2020


Dear Mutt nuts,

I wanted a Mutt macro that met the following desiderata:

1.  Allows the user to choose, at each invocation, whether to apply the
    macro:

    - to only the current message (by simply running the macro); or
      instead
  
    - to currently-tagged messages (by pressing the tag-prefix key,
      which by default is `;`, before running the macro).

2.  Marks those message(s) as "read".  IIUC, in Mutt this amounts to
    marking those message(s) as not "new" and not "old".

3.  Moves ("saves") those message(s) to my `$record` mailbox (which, in
    Mutt, can be referenced with the mailbox shortcut `<`).

4.  Syncs the current mailbox.


I think I succeeded, but it took me a few attempts.  I am posting this
to the list in case it is useful for others.


# Attempt 1

Criteria satisfied:  1: yes, 2: no, 3: yes, 4: yes.

    macro index,pager  ss  "<save-message><<Return>y<sync-mailbox>y"

Note: a "first draft" effort.


# Attempt 2

Criteria satisfied:  1: partly, 2: yes, 3: partly, 4: yes.

    macro index,pager  ss "<clear-flag>n<save-message><<Return>y<sync-mailbox>y"

Note: works fine on single messages, but if used on multiple tagged
messages, then after it removes the "new" (and "old") flags from all the
tagged messages as desired, it then archives ("saves") only the
*current* message instead of all tagged messages.  The reason for this
is mentioned here:
https://gitlab.com/muttmua/mutt/-/wikis/MuttGuide/Macros#special-usage-applying-to-several-tagged-entries


# Attempt 3

Criteria satisfied:  1: yes, 2: yes, 3: yes, 4: yes.

    macro index,pager  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"

Note: I think this works as intended.  (At least, as long as it is all
on one line in the .muttrc. I haven't yet learned how to split macros
across multiple lines.)  Maybe it is useful to you.  If you find a bug
in this macro, please let me know so that I can fix it.


Thank you to all Mutt's developers and maintainers for creating such a
powerful MUA.

Sam

-- 
A: When it messes up the order in which people normally read text.
Q: When is top-posting a bad thing?

()  ASCII ribbon campaign. Please avoid HTML emails & proprietary
/\  file formats. (Why? See e.g. https://v.gd/jrmGbS ). Thank you.


More information about the Mutt-users mailing list