1 [[!img notmuch-logo.png alt="Notmuch logo" class="left"]]
2 # Frequently Asked Questions
4 See also [[Less Frequently Asked Questions|lfaq]].
8 ## How come this query matches mails in folder:2013? `notmuch search --output=files folder:inbox`
10 You have duplicates of a message (or messages) in both folders.
12 Notmuch searches are message based. Multiple files may be associated
13 with the same message (i.e. the files have identical Message-ID). A
14 `folder:` search will match the folder of any of the files. The
15 `--output=files` option outputs all the files of all matching messages.
17 ## How come my query does not list all the emails on the file system?
19 You may have emails that have some of the [exclude
20 tags](https://notmuchmail.org/doc/latest/man1/notmuch-search.html#cmdoption-search-exclude)
22 Notmuch can be configured to exclude some tags while searching. You
23 can list excluded tags with
25 $ notmuch config get search.exclude_tags
28 To verify this is the reason of the discrepancy, add the excluded tags
29 explicitly to your query. If the problematic query is
31 $ notmuch search --output=files -- folder:inbox
35 $ notmuch search --output=files -- folder:inbox tag:deleted
37 You can also temporarily turn of the excluded tags feature with `--exclude`.
39 $ notmuch search --output=files --exclude=false -- folder:inbox
41 ## Shouldn't notmuch support inline PGP?
43 [Why it might not be a good idea](https://dkg.fifthhorseman.net/notes/inline-pgp-harmful/)
45 ## How do I delete messages
49 ## How do I configure the citation line when replying in Emacs?
51 (setq message-citation-line-format "On %a, %d %b %Y, %f wrote:")
52 (setq message-citation-line-function 'message-insert-formatted-citation-line)
54 See help for `message-citation-line-format` for details.
56 ## What are sexp queries?
58 For the syntax of sexp queries, see [the manual
59 page](https://notmuchmail.org/doc/latest/man7/notmuch-sexp-queries.html).
61 To see if your version of notmuch supports them, run
63 $ notmuch config get built_with.sexp_queries
65 ## How do I search for messages that have no tags?
67 To do this directly, you need a recent notmuch compiled with sexp
68 queries (see above). You can then run
70 $ notmuch search --query=sexp --output=messages '(not (tag *))'
72 The same style of query should work for any prefix, even user defined
73 prefixes like `List` (see below).
75 Otherwise, it's possible to accomplish this using two searches in shell. First,
76 you need to query all tags in the database, and transform the result into a
77 query that matches messages that have none of those tags:
79 $ notmuch search --output=tags \* | sed 's/^/not tag:/;2~1s/^/and /'
81 Next, use that to query the messages:
83 $ notmuch search $(notmuch search --output=tags \* | \
84 sed 's/^/not tag:/;2~1s/^/and /')
86 ## How do I search for punctuation, specific special characters, or regexp?
88 Please see the [notmuch-search-terms manual
89 page](https://notmuchmail.org/doc/latest/man7/notmuch-search-terms.html) first.
91 The main thing to understand is that Xapian, and therefore Notmuch, searches are
92 closer to natural language searches than regular expression
93 searches. Punctuation is mostly ignored.
95 The boolean prefix searches (see Boolean and Probabilistic Prefixes in the man
96 page), such as tag: or path: searches, need an exact match.
99 fields](https://notmuchmail.org/doc/latest/man7/notmuch-search-terms.html#search-prefixes)
100 it is possible to use regex searches (although these are often
101 noticeably slower than native Xapian queries). The limited set of
102 fields is a quirk of implementation which requires a Xapian "value
103 slot" in the database schema. Adding regex support for more fields to
104 would require of adding more value slots to the schema. The
105 performance impact of that needs to be experimentally evaluated, and
106 assuming it is not too bad, some database upgrade code would need to
109 ## How do I search for folders or paths with spaces?
111 The spaces in the names must be escaped. For example if you use bash or zsh,
112 you can search for messages with tag `foo` in folder `INBOX/folder with spaces`
115 $ notmuch search tag:foo 'folder:"INBOX/folder with spaces"'
117 ## How do I search for the `List-Id:` header?
119 See `index.header.<prefix>` in `notmuch-config(1)` for details. TLD;R:
121 notmuch config set index.header.List List-Id
123 ## Can I use notmuch with grsec?
125 Sure! It works out of the box. If you have TPE enabled (trusted path execution),
126 make sure the user is executing the script belongs to the
127 `kernel.grsecurity.tpe_gid` (in debian this is grsec-tpe).
128 This is required in order to run the `pre-new` and `post-new` hooks.
130 ## Can I tag threads?
132 No. Tagging is message based.
134 It is possible, however, to make tags propagate to all messages in a thread
135 using a little bit of scripting in the [post-new
136 hook](https://notmuchmail.org/doc/latest/man5/notmuch-hooks.html). For example, to add the muted tag to all
137 messages in threads that have at least one message with the muted tag:
140 for tag in "$THREAD_TAGS"; do
141 notmuch tag +$tag thread:{tag:$tag}
144 You can add other tags to `THREAD_TAGS` as needed. Note that this is
145 one way only; you need to explicitly remove the tag from all the
146 messages in a thread to stop it from propagating again. See
147 [notmuch-search-terms](https://notmuchmail.org/doc/latest/man7/notmuch-search-terms.html)
148 for discussion of `thread:{}` queries.
151 ## How can I extract a git patchset for an email thread?
154 [notmuch-extract-patch](https://github.com/aaptel/notmuch-extract-patch). See
155 also notmuch-extract-patch in
156 [mailscripts](https://git.spwhitton.name/mailscripts/).