I get notifications of new email when there are files in my maildir directories ~/.mail/*/Inbox/new. However, when I read a new email in mutt, files only move out of these directories when I quit mutt, or sync the mailbox. Ideally, I'd like the email to move immediately, when read. Hence I attempted to modify the default commands associated with Enter (in index), and j/k (in pager), by adding the following to ~/.mutt/muttrc.

macro index <Enter> "<display-message><sync-mailbox>" "display a message, then sync"
macro pager j "<next-undeleted><sync-mailbox>" "move to the next undeleted message, then sync"
macro pager k "<previous-undeleted><sync-mailbox>" "move to the previous undeleted message, then sync"

I confirmed that these were accepted by mutt by pressing ? for help in index/pager. j and k seem to work fine in pager mode; sync is immediately run. However, pressing Enter in index mode doesn't seem to work; there is no sync. FWIW I tried to sync manually by pressing $ after Enter, and this worked correctly, moving the files as expected.

How can I make Enter immediately sync after displaying the message?


My j and k hacks don't work perfectly either. If I search using notmuch-mutt, it creates a temporary mailbox. After opening a mail in the pager, then pressing j or k, the next email is selected, but the pager is closed, presumably because sync fails. I get the error:

Mailbox is read-only.

So my question is now the more generic title: How can I make mutt automatically sync after reading an email?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.