email snoozing in notmuch

Richard Lawrence richard.lawrence at berkeley.edu
Wed Dec 10 09:00:17 PST 2014


Franz Fellner <alpine.art.de at gmail.com>
writes:

> Sebastian Fischmeister wrote:
 
>> I'm thinking of how to realize the mail snoozing feature with notmuch,
>> so that certain emails won't become visible (in the search) until a
>> certain day/time (e.g., 10 days from now).
>> 
>> Using the tag as an absolute date when the mail should become visible
>> again, tags should be searchable and interpretable as dates. The search
>> would then be something like: notmuch search tag-as-date < now and
>> tag:inbox
>
> It is not neccessary to make notmuch interpret tags as date - just interpret them yourself ;)
> You can easily run your own scripts and modify tags/mails. So a simple solution might be:
> * Add "snoozed" to your notmuch exclude_tags (see config file)
> * To snooze a mail run in your mail client "tag +snoozed +snoozeby-10-days"
>   or "tag +snoozed +snoozeuntil-2015-01-09"
> * Your script (e.g. run as cronjob or after notmuch new) now 
>   - queries for "tag:snoozed"
>   - looks for snoozeuntil-* tag and parses the tag into a date. If date < now remove snooze-tags.
>   - looks for (relative) snoozeby tag and transform it into (absolute) snoozeuntil tag.
> (should be not too hard using e.g. the python or ruby bindings)

I actually do something like this.  It's not everything Sebastian was
looking for, but it's very simple, and works great for me.

I use a combination of a "pending" tag and a "byYYYYMMDD" tag.

>From cron, I run the following to refile pending mail back to the inbox
when it comes due:

#!/bin/bash
DATE_STR=$(date +'%Y%m%d')
notmuch tag +inbox -pending -by$DATE_STR -- tag:by$DATE_STR

and in Emacs, I use the following key binding to snooze mail (or in the Mutt
terminology I borrowed, `postpone' it, hence the key):

(define-key notmuch-search-mode-map "P"
  (lambda ()
    "postpone message (remove inbox tag, add pending tag and refile date)"
    (interactive)
    (let* ((date-string (format-time-string "%Y%m%d" (org-read-date nil t)))
	   (date-tag (concat "+by" date-string)))
      (notmuch-search-tag `("-inbox" "+pending" ,date-tag)))))
      
(The `org-read-date' function gives me a nice easy way to pick a date
from a calendar.  I bind "P" to the same function in
notmuch-show-mode-map, too.)

Hope that helps!

Best,
Richard



More information about the notmuch mailing list