Debian Codegraph @

docs/configuration.rst

raw
1 Configuration
2 =============
3
4 Configuration File
5 ------------------
6
7 Customization of tag filters takes place in afew's config file in
8 `~/.config/afew/config`.
9
10 NotMuch Config
11 --------------
12
13 afew tries to adapt to the new tag that notmuch sets on new email, but has
14 mostly been developed and used against the **new** tag. To use that,
15 make sure that `~/.notmuch-config` contains:
16
17 .. code-block:: ini
18
19 [new]
20 tags=new
21
22 afew reads the notmuch database location from notmuch config. When no database
23 path is set in notmuch config, afew uses the `MAILDIR` environment variable
24 when set, or `$HOME/mail` as a fallback, like notmuch CLI does. If a relative
25 path is provided, afew prepends `$HOME/` to the path in the same manner as
26 notmuch, which was introduced in version 0.28 of notmuch.
27
28 Filter Configuration
29 --------------------
30
31 You can modify filters, and define your own versions of the base Filter that
32 allow you to tag messages in a similar way to the `notmuch tag` command, using
33 the config file. The default config file is:
34
35 .. code-block:: ini
36
37 [SpamFilter]
38 [KillThreadsFilter]
39 [ListMailsFilter]
40 [ArchiveSentMailsFilter]
41 sent_tag = ''
42 [InboxFilter]
43
44 See the :doc:`filters` page for the details of those filters and the custom
45 arguments they accept.
46
47 You can add filters based on the base filter as well. These can be customised
48 by specifying settings beneath them. The standard settings, which apply to all
49 filters, are:
50
51 message
52 text that will be displayed while running this filter if the verbosity is high
53 enough.
54
55 query
56 the query to use against the messages, specified in standard notmuch format.
57 Note that you don't need to specify the **new** tag - afew will add that when
58 run with the `--new` flag.
59
60 tags
61 the tags to add or remove for messages that match the query. Tags to add are
62 preceded by a **+** and tags to remove are preceded by a **-**. Multiple tags
63 are separated by semicolons.
64
65 tags_blacklist
66 if the message has one of these tags, don't add `tags` to it. Tags are
67 separated by semicolons.
68
69 So to add the **deer** tag to any message to or from `[email protected]` you
70 could do:
71
72 .. code-block:: ini
73
74 [Filter.1]
75 query = '[email protected]'
76 tags = +deer
77 message = Wild animals ahoy
78
79 You can also (in combination with the InboxFilter) have email skip the Inbox
80 by removing the new tag before you get to the InboxFilter:
81
82 .. code-block:: ini
83
84 [Filter.2]
85 query = from'[email protected]'
86 tags = -new;+boss
87 message = Message from above
88
89 Full Sample Config
90 ------------------
91
92 Showing some sample configs is the easiest way to understand. The
93 `notmuch initial tagging page`_ shows a sample config:
94
95 .. _notmuch initial tagging page: http://notmuchmail.org/initial_tagging/
96
97 .. code-block:: sh
98
99 # immediately archive all messages from "me"
100 notmuch tag -new -- tag:new and from:[email protected]
101
102 # delete all messages from a spammer:
103 notmuch tag +deleted -- tag:new and from:[email protected]
104
105 # tag all message from notmuch mailing list
106 notmuch tag +notmuch -- tag:new and to:[email protected]
107
108 # finally, retag all "new" messages "inbox" and "unread"
109 notmuch tag +inbox +unread -new -- tag:new
110
111 The (roughly) equivalent set up in afew would be:
112
113 .. code-block:: ini
114
115 [ArchiveSentMailsFilter]
116
117 [Filter.1]
118 message = Delete all messages from spammer
119 query = from:[email protected]
120 tags = +deleted;-new
121
122 [Filter.2]
123 message = Tag all messages from the notmuch mailing list
124 query = to:[email protected]
125 tags = +notmuch
126
127 [InboxFilter]
128
129 Not that the queries do not generally include `tag:new` because this is implied when afew
130 is run with the `--new` flag.
131
132 The differences between them is that
133
134 * the ArchiveSentMailsFilter will add tags specified by `sent_tag` option
135 (default `''` means add no tags. You may want to set it to `sent`), as well as
136 archiving the email. And it will not archive email that has been sent to one
137 of your own addresses.
138 * the InboxFilter does not add the **unread** tag. But most mail clients will
139 manage the unread status directly in maildir.
140
141 More Filter Examples
142 --------------------
143
144 Here are a few more example filters from github dotfiles:
145
146 .. code-block:: ini
147
148 [Filter.1]
149 query = '[email protected]'
150 tags = +sicsa
151 message = sicsa
152
153 [Filter.2]
154 query = 'from:[email protected] OR from:GT Silber OR from:[email protected]'
155 tags = +soc;+foo
156 message = foosoc
157
158 [Filter.3]
159 query = 'folder:gmail/G+'
160 tags = +G+
161 message = gmail spam
162
163 # skip inbox
164 [Filter.6]
165 query = 'to:[email protected] AND (subject:emacs OR subject:elisp OR "(defun" OR "(setq" OR PATCH)'
166 tags = -new
167 message = notmuch emacs stuff
168
169 # Assuming the following workflow: all messages for projects or releases should be tagged
170 # as "project/A", "project/B" respectively "release/1.0.1" or "release/1.2.0".
171 #
172 # In most cases replies to messages retain their context: the project, the release(s), ..
173 #
174 # The following config will propagate all project/... or release/... tags from a thread
175 # to all new messages.
176
177 [PropagateTagsByRegexInThreadFilter.1]
178 propagate_tags = project/.*
179 # do not tag spam
180 filter = not is:spam
181
182 [PropagateTagsByRegexInThreadFilter.2]
183 propagate_tags = release/.*