]> git.cworth.org Git - notmuch-wiki/blob - initial_tagging.mdwn
initial_tagging: document tagging of read mails
[notmuch-wiki] / initial_tagging.mdwn
1 [[!img notmuch-logo.png alt="Notmuch logo" class="left"]]
2 # Approaches to initial tagging of messages
3
4 This page collects scripts and strategies for organizing mail using
5 notmuch and doing automated initial tagging.
6
7 The `[new]` config section allows you to control which tags new messages
8 receive. By default, `notmuch config` will use the tags *inbox* and *unread*.
9
10 If `maildir.synchronize_flags` is true (which is the default), Maildir flags 
11 have precedence over the initial tags. Thus an already read mail gets its 
12 initial *unread* tag correctly removed.
13
14 ## The *new* tag approach
15
16 Here's another very general and ad-hoc approach to initial message tagging, 
17 which sets all new messages to get the *new* tag:
18
19     [new]
20     tags=new;
21
22 After running `notmuch new`, all new messages will be marked *new*.
23 You can then do various tag post-processing by just acting on messages
24 with that tag.  For instance, a post-processing script might do the
25 following:
26
27     # immediately archive all messages from "me"
28     notmuch tag -new -- tag:new and from:me@example.com
29
30     # delete all messages from a spammer:
31     notmuch tag +deleted -- tag:new and from:spam@spam.com
32
33     # tag all message from notmuch mailing list
34     notmuch tag +notmuch -- tag:new and to:notmuch@notmuchmail.org
35
36     # finally, retag all "new" messages "inbox" and "unread"
37     notmuch tag +inbox +unread -new -- tag:new
38
39 Note that the command above will mark a new but already-read mail as unread.
40
41 Since the post-processing is only acting on a few messages, it is
42 generally extremely fast.
43
44 You can use the `post-new` hook, which is automatically run after `notmuch new`,
45 to do post-processing. See `man notmuch-hooks` for details on hooks.
46
47
48 ## Other solutions
49
50 * [Carl Worth's approach to tagging](http://notmuchmail.org/pipermail/notmuch/2010/001691.html). It
51   is email id:87r5o8stbj.fsf@yoom.home.cworth.org in the notmuch
52   mailing list archives.
53
54
55 * [One user's setup](http://notmuchmail.org/pipermail/notmuch/2010/001690.html)
56   (id:87hbp5j9dv.fsf@hackervisions.org), which includes using the
57   inbox tag as a "new mail" flag.
58
59 * [Another user's setup](http://notmuchmail.org/pipermail/notmuch/2011/003976.html)
60   (id:"87tyfu3k5a.fsf@gmail.com"), which uses a dedicated tag for
61   marking new mail, which is then sorted with a python script using
62   Bogofilter for spam detection.  This is generally a great deal
63   faster than a shell-scripted approach.  This approach introduces a
64   workflow built around a "watch" tag. Here, the user is only
65   presented with threads as they are started. At this point the user
66   can choose to watch the thread, in which case future messages will
67   be tagged with "inbox", or ignore it. This provides an excellent
68   means for dealing with a large flux of messages with a low
69   signal-to-noise.
70
71 * [afew](https://github.com/teythoon/afew) is an initial tagging
72   solution that should work out of the box for most basic tagging
73   needs (mailinglist handling, killed thread handling, autoarchiving
74   of sent mails) and has some fancy features (e.g. mail classification
75   using bayesian filters).
76
77 ## Notmuch MDA -- `notmuch-insert`
78
79 The [[notmuch insert command|manpages/notmuch-insert-1]] is a tool for
80 delivering emails to maildir, indexing them to the Notmuch database, and tagging
81 them as desired.