]> git.cworth.org Git - notmuch-wiki/blob - faq.mdwn
update exclude faq entry
[notmuch-wiki] / faq.mdwn
1 [[!img notmuch-logo.png alt="Notmuch logo" class="left"]]
2 # Frequently Asked Questions
3
4 [[!toc levels=2]]
5
6 ## How come this query matches mails in folder:2013? `notmuch search --output=files folder:inbox`
7
8 You have duplicates of a message (or messages) in both folders.
9
10 Notmuch searches are message based. Multiple files may be associated
11 with the same message (i.e. the files have identical Message-ID). A
12 `folder:` search will match the folder of any of the files. The
13 `--output=files` option outputs all the files of all matching messages.
14
15 ## How come my query does not list all the emails on the file system?
16
17 You may have emails that have some of the [exclude
18 tags](https://notmuchmail.org/doc/latest/man1/notmuch-search.html#cmdoption-search-exclude)
19
20 Notmuch can be configured to exclude some tags while searching. You
21 can list excluded tags with
22
23     $ notmuch config get search.exclude_tags
24     deleted
25
26 To verify this is the reason of the discrepancy, add the excluded tags
27 explicitly to your query. If the problematic query is
28
29     $ notmuch search --output=files -- folder:inbox
30
31 Try
32
33     $ notmuch search --output=files -- folder:inbox tag:deleted
34
35 You can also temporarily turn of the excluded tags feature with `--exclude`.
36
37     $ notmuch search --output=files --exclude=false -- folder:inbox
38
39 ## Shouldn't notmuch support inline PGP?
40
41 [Why it might not be a good idea](https://dkg.fifthhorseman.net/notes/inline-pgp-harmful/)
42
43 ## How do I delete messages
44
45 See [[excluding]].
46
47 ## How do I configure the citation line when replying in Emacs?
48
49         (setq message-citation-line-format "On %a, %d %b %Y, %f wrote:")
50         (setq message-citation-line-function 'message-insert-formatted-citation-line)
51
52 See help for `message-citation-line-format` for details.
53
54 ## What are sexp queries?
55
56 For the syntax of sexp queries, see [the manual
57 page](https://notmuchmail.org/doc/latest/man7/notmuch-sexp-queries.html).
58
59 To see if your version of notmuch supports them, run
60
61         $ notmuch config get built_with.sexp_queries
62
63 ## How do I search for messages that have no tags?
64
65 To do this directly, you need a recent notmuch compiled with sexp
66 queries (see above). You can then run
67
68         $ notmuch search --query=sexp --output=messages '(not (tag *))'
69
70 The same style of query should work for any prefix, even user defined
71 prefixes like `List` (see below).
72
73 Otherwise, it's possible to accomplish this using two searches in shell. First,
74 you need to query all tags in the database, and transform the result into a
75 query that matches messages that have none of those tags:
76
77         $ notmuch search --output=tags \* | sed 's/^/not tag:/;2~1s/^/and /'
78
79 Next, use that to query the messages:
80
81         $ notmuch search $(notmuch search --output=tags \* | \
82                 sed 's/^/not tag:/;2~1s/^/and /')
83
84 ## How do I search for punctuation, specific special characters, or regexp?
85
86 Please see the [notmuch-search-terms manual
87 page](https://notmuchmail.org/doc/latest/man7/notmuch-search-terms.html) first.
88
89 The main thing to understand is that Xapian, and therefore Notmuch, searches are
90 closer to natural language searches than regular expression
91 searches. Punctuation is mostly ignored.
92
93 The boolean prefix searches (see Boolean and Probabilistic Prefixes in the man
94 page), such as tag: or path: searches, need an exact match.
95
96 For [specific
97 fields](https://notmuchmail.org/doc/latest/man7/notmuch-search-terms.html#search-prefixes)
98 it is possible to use regex searches (although these are often
99 noticeably slower than native Xapian queries). The limited set of
100 fields is a quirk of implementation which requires a Xapian "value
101 slot" in the database schema. Adding regex support for more fields to
102 would require of adding more value slots to the schema. The
103 performance impact of that needs to be experimentally evaluated, and
104 assuming it is not too bad, some database upgrade code would need to
105 be written.
106
107 ## How do I search for folders or paths with spaces?
108
109 The spaces in the names must be escaped. For example if you use bash or zsh,
110 you can search for messages with tag `foo` in folder `INBOX/folder with spaces`
111 with this query:
112
113         $ notmuch search tag:foo 'folder:"INBOX/folder with spaces"'
114
115 ## How do I search for the `List-Id:` header?
116
117 See `index.header.<prefix>` in `notmuch-config(1)` for details. TLD;R:
118
119     notmuch config set index.header.List List-Id
120
121 ## Can I use notmuch with grsec?
122
123 Sure! It works out of the box. If you have TPE enabled (trusted path execution),
124 make sure the user is executing the script belongs to the
125 `kernel.grsecurity.tpe_gid` (in debian this is grsec-tpe).
126 This is required in order to run the `pre-new` and `post-new` hooks.
127
128 ## Can I tag threads?
129
130 No. Tagging is message based.
131
132 It is possible, however, to make tags propagate to all messages in a thread
133 using a little bit of scripting in the [post-new
134 hook](https://notmuchmail.org/doc/latest/man5/notmuch-hooks.html). For example, to add the muted tag to all
135 messages in threads that have at least one message with the muted tag:
136
137         THREAD_TAGS="muted"
138         for tag in "$THREAD_TAGS"; do
139                 notmuch tag +$tag thread:{tag:$tag}
140         done
141
142 You can add other tags to `THREAD_TAGS` as needed. Note that this is
143 one way only; you need to explicitly remove the tag from all the
144 messages in a thread to stop it from propagating again. See
145 [notmuch-search-terms](https://notmuchmail.org/doc/latest/man7/notmuch-search-terms.html)
146 for discussion of `thread:{}` queries.
147
148
149 ## How can I extract a git patchset for an email thread?
150
151 See
152 [notmuch-extract-patch](https://github.com/aaptel/notmuch-extract-patch). See
153 also notmuch-extract-patch in
154 [mailscripts](https://git.spwhitton.name/mailscripts/).
155
156 ## T150-tagging.sh is failing with Xapian 1.4.6
157
158 This is (probably) a bug in this point release of Xapian, should be
159 fixed in 1.4.7.  Try reverting Xapian commit
160 `093999529acc2f86900d91fed0c7f7af301ab94a`, e.g. with the following
161 patch.
162
163
164     index 80e578b85..a47f14a68 100644
165     --- a/xapian-core/backends/glass/glass_postlist.cc
166     +++ b/xapian-core/backends/glass/glass_postlist.cc
167     @@ -759,7 +759,7 @@ GlassPostList::open_nearby_postlist(const std::string & term_,
168          (void)need_pos;
169          if (term_.empty())
170             RETURN(NULL);
171     -    if (!this_db.get() || this_db->postlist_table.is_modified())
172     +    if (!this_db.get() || this_db->postlist_table.is_writable())
173             RETURN(NULL);
174          RETURN(new GlassPostList(this_db, term_, cursor->clone()));
175      }
176