File: configuration.rst

package info (click to toggle)
afew 3.0.1-8
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 660 kB
  • sloc: python: 1,484; makefile: 10; sh: 6
file content (183 lines) | stat: -rw-r--r-- 5,407 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
Configuration
=============

Configuration File
------------------

Customization of tag filters takes place in afew's config file in
`~/.config/afew/config`.

NotMuch Config
--------------

afew tries to adapt to the new tag that notmuch sets on new email, but has
mostly been developed and used against the **new** tag.  To use that,
make sure that `~/.notmuch-config` contains:

.. code-block:: ini

    [new]
    tags=new

afew reads the notmuch database location from notmuch config. When no database
path is set in notmuch config, afew uses the `MAILDIR` environment variable
when set, or `$HOME/mail` as a fallback, like notmuch CLI does. If a relative
path is provided, afew prepends `$HOME/` to the path in the same manner as
notmuch, which was introduced in version 0.28 of notmuch.

Filter Configuration
--------------------

You can modify filters, and define your own versions of the base Filter that
allow you to tag messages in a similar way to the `notmuch tag` command, using
the config file.  The default config file is:

.. code-block:: ini

    [SpamFilter]
    [KillThreadsFilter]
    [ListMailsFilter]
    [ArchiveSentMailsFilter]
    sent_tag = ''
    [InboxFilter]

See the :doc:`filters` page for the details of those filters and the custom
arguments they accept.

You can add filters based on the base filter as well.  These can be customised
by specifying settings beneath them.  The standard settings, which apply to all
filters, are:

message
  text that will be displayed while running this filter if the verbosity is high
  enough.

query
  the query to use against the messages, specified in standard notmuch format.
  Note that you don't need to specify the **new** tag - afew will add that when
  run with the `--new` flag.

tags
  the tags to add or remove for messages that match the query. Tags to add are
  preceded by a **+** and tags to remove are preceded by a **-**.  Multiple tags
  are separated by semicolons.

tags_blacklist
  if the message has one of these tags, don't add `tags` to it. Tags are
  separated by semicolons.

So to add the **deer** tag to any message to or from `antelope@deer.com` you
could do:

.. code-block:: ini

    [Filter.1]
    query = 'antelope@deer.com'
    tags = +deer
    message = Wild animals ahoy

You can also (in combination with the InboxFilter) have email skip the Inbox
by removing the new tag before you get to the InboxFilter:

.. code-block:: ini

    [Filter.2]
    query = from'pointyheaded@boss.com'
    tags = -new;+boss
    message = Message from above

Full Sample Config
------------------

Showing some sample configs is the easiest way to understand.  The
`notmuch initial tagging page`_ shows a sample config:

.. _notmuch initial tagging page: http://notmuchmail.org/initial_tagging/

.. code-block:: sh

    # immediately archive all messages from "me"
    notmuch tag -new -- tag:new and from:me@example.com

    # delete all messages from a spammer:
    notmuch tag +deleted -- tag:new and from:spam@spam.com

    # tag all message from notmuch mailing list
    notmuch tag +notmuch -- tag:new and to:notmuch@notmuchmail.org

    # finally, retag all "new" messages "inbox" and "unread"
    notmuch tag +inbox +unread -new -- tag:new

The (roughly) equivalent set up in afew would be:

.. code-block:: ini

    [ArchiveSentMailsFilter]

    [Filter.1]
    message = Delete all messages from spammer
    query = from:spam@spam.com
    tags = +deleted;-new

    [Filter.2]
    message = Tag all messages from the notmuch mailing list
    query = to:notmuch@notmuchmail.org
    tags = +notmuch

    [InboxFilter]

Not that the queries do not generally include `tag:new` because this is implied when afew
is run with the `--new` flag.

The differences between them is that

* the ArchiveSentMailsFilter will add tags specified by `sent_tag` option
  (default `''` means add no tags. You may want to set it to `sent`), as well as
  archiving the email. And it will not archive email that has been sent to one
  of your own addresses.
* the InboxFilter does not add the **unread** tag.  But most mail clients will
  manage the unread status directly in maildir.

More Filter Examples
--------------------

Here are a few more example filters from github dotfiles:

.. code-block:: ini

    [Filter.1]
    query = 'sicsa-students@sicsa.ac.uk'
    tags = +sicsa
    message = sicsa

    [Filter.2]
    query = 'from:foosoc.ed@gmail.com OR from:GT Silber OR from:lizzie.brough@eusa.ed.ac.uk'
    tags = +soc;+foo
    message = foosoc

    [Filter.3]
    query = 'folder:gmail/G+'
    tags = +G+
    message = gmail spam

    # skip inbox
    [Filter.6]
    query = 'to:notmuch@notmuchmail.org AND (subject:emacs OR subject:elisp OR "(defun" OR "(setq" OR PATCH)'
    tags = -new
    message = notmuch emacs stuff

    # Assuming the following workflow: all messages for projects or releases should be tagged
    # as "project/A", "project/B" respectively "release/1.0.1" or "release/1.2.0".
    #
    # In most cases replies to messages retain their context: the project, the release(s), ..
    #
    # The following config will propagate all project/... or release/... tags from a thread
    # to all new messages.

    [PropagateTagsByRegexInThreadFilter.1]
    propagate_tags = project/.*
    # do not tag spam
    filter = not is:spam

    [PropagateTagsByRegexInThreadFilter.2]
    propagate_tags = release/.*