2013/10/13: Mark an email thread as read, forever

Sometimes on mailing lists, there are threads that go on forever and I'm not at all interested in. While mutt provides, with the read-thread command (by default bound to C-r), a way to mark all mails of a thread as read, this does not include the mails that certainly will come the next days and weeks. In a sense, one would need read-thread to be called over and over again.

In fact, this is literally what a cronjob is doing for me (since over two years). In a drop directory, I store the information about which threads to be marked as read in a simple format: one file (with name starting with A-) per thread to be read, first line folder, second line the message ID of one mail in the thread. From that, autoread.pl first composes a custom .muttrc in which there is a push statement for the sequence of actions of going through all these folders, searching the respective mail by message ID, and marking the thread as read; then autoread.pl calls mutt, with that custom .muttrc as configuration file (via the -F option). The autoread.pl program is run via cron in a screen to provide a tty.

Of course, emails arriving between two invocations of the cron job are only marked as read at the next invocation of the cron job. However, this marking as read happens just before the synchronisation action of my forward mail synchronisation. So, on the machines where I usually read my email, i.e., my desktop and my laptop, I do not have problems with no-yet read mails in these threads.

The description of the threads gets into the drop directory in the (for me) usual way. My .muttrc contains the following line.


macro index,pager "<esc>R" "|/home/aehlig/conf/mutt-thread-read.pl $my_folder<enter>" "Mark thread read forever"

The mentioned mutt-thread-read.pl script extracts the message id and adds the request to a batch file. That batch file at a suitable moment gets unbatched (unbatch-autoread) and dropped via uux (uucp-thread-read-aehlig).