11 years agoUpdate documentation of notmuch_query_create
Fernando Carrijo [Sat, 5 Dec 2009 14:22:05 +0000 (12:22 -0200)]
Update documentation of notmuch_query_create

Commit cd467caf renamed notmuch_query_search to notmuch_query_search_messages.
Commit 1ba3d46f created notmuch_query_search_threads. We better keep the docs
of notmuch_query_create consistent with those changes.

Signed-off-by: Fernando Carrijo <>
Edited-by: Carl Worth to explicitly list the full name of each
function being referenced.

11 years agonotmuch show: Don't show empty headers.
Carl Worth [Tue, 9 Mar 2010 18:12:58 +0000 (10:12 -0800)]
notmuch show: Don't show empty headers.

This is a fairly old regression. There has always been code to avoid
printing empty headers (such as Cc or Bcc with no values), but it has
been broken since notmuch_message_get_header was changed to return
an empty string rather than a NULL pointer for these fields.

11 years agoTODO: Add proposal for a saved-search interface.
Carl Worth [Tue, 9 Mar 2010 18:09:40 +0000 (10:09 -0800)]
TODO: Add proposal for a saved-search interface.

Adding this to our TODO list so that it doesn't get forgotten.

11 years agoTODO: Remove many items that have been completed recently.
Carl Worth [Tue, 9 Mar 2010 18:06:37 +0000 (10:06 -0800)]
TODO: Remove many items that have been completed recently.

There's been a lot of good work done, and we've been doing a generally
poor job of noticing when some of the tasks we've completed were
already on our TODO list.

So here's a careful scan, removing all items I could find that have
already been done.

11 years agoemacs: Fix documentation of notmuch-search-remove-tag.
Carl Worth [Tue, 9 Mar 2010 17:54:53 +0000 (09:54 -0800)]
emacs: Fix documentation of notmuch-search-remove-tag.

The behavior was changed in commit 4aff2ca55bfe285ced36e9fe02c907d8b4120672
to affect all messages in the thread (and not only those matching
the current search) but the documentation was not updated (until

11 years agolib: Document what move_to_next does at the end of the list.
Carl Worth [Tue, 9 Mar 2010 17:24:45 +0000 (09:24 -0800)]
lib: Document what move_to_next does at the end of the list.

Explicitly mention that there's an invalid position after the last
item in the list.

11 years agolib: Rename iterator functions to prepare for reverse iteration.
Carl Worth [Tue, 9 Mar 2010 17:22:29 +0000 (09:22 -0800)]
lib: Rename iterator functions to prepare for reverse iteration.

We rename 'has_more' to 'valid' so that it can function whether
iterating in a forward or reverse direction. We also rename
'advance' to 'move_to_next' to setup parallel naming with
the proposed functions 'move_to_first', 'move_to_last', and

11 years agoemacs: Fix backspace to not scroll more than the previous message
Carl Worth [Tue, 9 Mar 2010 16:11:45 +0000 (08:11 -0800)]
emacs: Fix backspace to not scroll more than the previous message

The bug was occuring due to counting invisible lines, but then
scrolling past them since they are invisible.

11 years agoemacs: Unbreak notmuch-show-rewind (the function to which Backspace is bound)
Carl Worth [Tue, 9 Mar 2010 01:24:34 +0000 (17:24 -0800)]
emacs:  Unbreak notmuch-show-rewind (the function to which Backspace is bound)

Commit 095a02211e696434e5b41a85ab516b3a639f9a9b broke the backspace
key by trying to execute nil as a function, (which obviously won't
work), when it was intended as a return value. Fix this now, (and pine
for a test suite that exercises the emacs user-interface of notmuch).

11 years agoemacs: Make 'n' and 'p' navigate only open messages.
Carl Worth [Fri, 26 Feb 2010 19:30:12 +0000 (11:30 -0800)]
emacs: Make 'n' and 'p' navigate only open messages.

And add new 'N' and 'P' keybindings for navigating through messages
that are open or closed.

11 years agoemacs: Don't open unread messages by default.
Carl Worth [Fri, 26 Feb 2010 18:40:23 +0000 (10:40 -0800)]
emacs: Don't open unread messages by default.

When searching for an individual message, (by message id, say), it's
really annoying to have the entire thread open just because the thread
was archived without ever having been read.

This means that the "unread" tag is a lot less special, and it really
just exists as a mild cue for the user.

11 years agoREADME: Mention that notmuch only supports maildir or mh format.
Carl Worth [Thu, 25 Feb 2010 19:03:56 +0000 (11:03 -0800)]
README: Mention that notmuch only supports maildir or mh format.

Justin B Rye pointed out (in Debian bug #566282) that a user with mail
in mbox format can spend a lot of time investigating notmuch before
realizing that mbox is not supported. Head that off with a more
detailed mention in the README blurb.

11 years agoemacs: Avoid removing the unread tag due to internal navigation
Carl Worth [Thu, 25 Feb 2010 01:02:31 +0000 (17:02 -0800)]
emacs: Avoid removing the unread tag due to internal navigation

Sometimes the internals of the implementation navigate among messages,
(as opposed to the user explicitly requesting the next message to be
shown). In these cases we don't want to remove the unread tag from the
message navigated to.

This fixes a bug where invocation of notmuch-show-next-unread-message
would clear the unread tag from all messages in a thread.

11 years agoSimplify "unread" tag handling in emacs UI.
Jameson Rollins [Tue, 19 Jan 2010 22:54:16 +0000 (17:54 -0500)]
Simplify "unread" tag handling in emacs UI.

This patch is intended to greatly simplify the handling of the
"unread" tag in the emacs UI.  This patch adds a new function
'notmuch-show-mark-read', that removes the "unread" tag in
notmuch-show-mode.  This function is then executed as a
notmuch-show-hook, and by notmuch-show-next-message.  All of the
functions that explicitly marked messages as unread are removed or

The idea here is that the user should never have to worry about
manipulating the "unread" tag.  The tag should persist until the user
actually views a message, at which point it should be automatically
removed.  This patch simplifies the notmuch.el quite a bit, removing a
lot of somewhat redundant functions, and reducing clutter in the name
and key-mapping space.

11 years agoTODO: We should fix the --format=json option to not imply --entire-thread.
Carl Worth [Tue, 23 Feb 2010 20:51:23 +0000 (12:51 -0800)]
TODO: We should fix the --format=json option to not imply --entire-thread.

What we print and how we print it are orthogonal options, so --format
shouldn't change what messages are printed.

11 years agonotmuch search: Use "thread" rather than "id" when formatting with JSON
Carl Worth [Tue, 23 Feb 2010 20:41:59 +0000 (12:41 -0800)]
notmuch search: Use "thread" rather than "id" when formatting with JSON

The text output uses thread:<foo>, (which is a syntax directly supported
by "notmuch show"), so make the json output be "thread", "<foo>" rather
than "id", "<foo>". This should help avoid confusion of thread IDs with
message IDs, (which do use the "id" prefix in searches).

11 years agojson: Add copy of MIT license text from cJSON
Carl Worth [Tue, 23 Feb 2010 20:49:33 +0000 (12:49 -0800)]
json: Add copy of MIT license text from cJSON

When we incorporate external code, we should include its license,
(particularly when one of the terms of the license is to include it in

11 years agoAdd an "--format=(json|text)" command-line option to both notmuch-search and notmuch...
Scott Robinson [Thu, 31 Dec 2009 15:17:40 +0000 (11:17 -0400)]
Add an "--format=(json|text)" command-line option to both notmuch-search and notmuch-show.

In the case of notmuch-show, "--format=json" also implies
"--entire-thread" as the thread structure is implicit in the emitted
document tree.

As a coincidence to the implementation, multipart message ID numbers are
now incremented with each part printed. This changes the previous
semantics, which were unclear and not necessary related to the actual
ordering of the message parts.

11 years agoTODO: Rename the proposed --for option to --output
Carl Worth [Tue, 23 Feb 2010 19:27:43 +0000 (11:27 -0800)]
TODO: Rename the proposed --for option to --output

We've been using --output in IRC and on the mailing list for a while,
(someone had the good sense to point out that --for would defeat
command-line completion since it's a prefix of the proposed --format).

11 years agonotmuch.1: Use bold and indentation for the NOTMUCH_CONFIG variable.
Carl Worth [Tue, 23 Feb 2010 19:21:41 +0000 (11:21 -0800)]
notmuch.1: Use bold and indentation for the NOTMUCH_CONFIG variable.

This seems to be the standard method of formatting an environment
variable section within a man page.

11 years agoAdd ENVIRONMENT VARIABLES section to the man page
James Westby [Sat, 19 Dec 2009 13:12:15 +0000 (13:12 +0000)]
Add ENVIRONMENT VARIABLES section to the man page

Briefly describe the NOTMUCH_CONFIG variable there.

11 years agonotmuch.el: Emphasize the 'i' of 'ID' in the documentation for 'c i'.
Carl Worth [Sat, 20 Feb 2010 20:27:37 +0000 (12:27 -0800)]
notmuch.el: Emphasize the 'i' of 'ID' in the documentation for 'c i'.

We're using 'i' in the keybinding, so it helps to have a capital
'I' in the help string to empahsize the point.

11 years agoChange the stash keybinding from 'z' to 'c'. And use 'i' for message ID.
Carl Worth [Sat, 20 Feb 2010 20:23:13 +0000 (12:23 -0800)]
Change the stash keybinding from 'z' to 'c'. And use 'i' for message ID.

In spite of being implemented with the word "stash" in the function
names, the documentation (and hence help strings) for each function
already use the word "Copy" to describe the action. So 'c' is a much
more natural key-binding, (particularly since 'z' didn't map to any
real word anyway).

We also use 'i' for the message ID copying of the submap. This is
intended to align mnemonically with the "id:" prefix already used
for message IDs.

11 years agonotmuch.el: add a submap (on "z" for "ztash") to stash things.
David Bremner [Fri, 12 Feb 2010 03:01:08 +0000 (23:01 -0400)]
notmuch.el: add a submap (on "z" for "ztash") to stash things.

Provide key bindings for stuffing various RFC822 header fields and other metadata
into the emacs kill-ring as text. The bindings are as follows:

z F notmuch-show-stash-filename
z T notmuch-show-stash-tags
z c notmuch-show-stash-cc
z d notmuch-show-stash-date
z f notmuch-show-stash-from
z m notmuch-show-stash-message-id
z s notmuch-show-stash-subject
z t notmuch-show-stash-to

11 years agonotmuch.el: convert sparse keymap to a list in notmuch-substitute-one-command-key...
David Bremner [Fri, 12 Feb 2010 03:01:07 +0000 (23:01 -0400)]
notmuch.el: convert sparse keymap to a list in notmuch-substitute-one-command-key-with-prefix

The previous version would crash when a key was bound to a sparse
keymap, since apparently these are not straightforward lists.  The
usage of map-keymap is a bit obscure: it only has side-effects, no
return value.

11 years agoAdd functions notmuch-show-get-(bcc, cc, date, from, subject, to).
David Bremner [Fri, 12 Feb 2010 02:44:10 +0000 (22:44 -0400)]
Add functions notmuch-show-get-(bcc, cc, date, from, subject, to).

Return the corresponding header field for the current message as a
string.  These are thin wrappers around notmuch-show-get-header, which
means they each cause a full parse of the RFC822 header. The main idea
is to fix an api.

11 years agonotmuch-show-get-header: new function; return alist of parsed header fields.
David Bremner [Fri, 12 Feb 2010 02:34:31 +0000 (22:34 -0400)]
notmuch-show-get-header: new function; return alist of parsed header fields.

This function parses the displayed message to recover header
fields. It uses mailheader.el to do the actual header parsing, after
preprocessing to remove indentation.  It relies on the variables
notmuch-show-message-begin-regexp, notmuch-show-header-begin-regexp,
and notmuch-show-message-end-regexp.

11 years agonotmuch.el: Delete some trailing whitespace.
Carl Worth [Sat, 20 Feb 2010 20:11:31 +0000 (12:11 -0800)]
notmuch.el: Delete some trailing whitespace.

I'm not sure when this managed to creep in, but we don't want it.

11 years agonotmuch.el: Fix bug from message with ':' in the From address.
Carl Worth [Fri, 12 Feb 2010 00:19:37 +0000 (16:19 -0800)]
notmuch.el: Fix bug from message with ':' in the From address.

Eric reported that a particular thread was non-functional in the
notmuch-search mode in the emacs client. It was easy enough to trace
the bug down to a broken regular expression (using ':' instead of
';'). The bug would be triggered by a message with ':' in the
From address.

This is something I hope to add to the test suite as soon as we have
support for testing the emacs interface there.

11 years agonotmuch.el: Handle attached images via an external viewer.
Carl Worth [Wed, 10 Feb 2010 20:40:47 +0000 (12:40 -0800)]
notmuch.el: Handle attached images via an external viewer.

We temporarily override the mm-inline-media-tests variable so that the
only parts inserted into the temporary buffer (and lost) are those
parts that the user has already seen in the notmuch-show buffer.

Anything else, (such as images), will now be left to be handled via
mailcap, just like other attachment types.

11 years agonotmuch.el: Fix indentation.
Carl Worth [Wed, 10 Feb 2010 20:40:18 +0000 (12:40 -0800)]
notmuch.el: Fix indentation.

This line was indented incorrectly which can be confusing.

11 years agonotmuch.el: Avoid infinite loop marking up message with no parts.
Carl Worth [Wed, 10 Feb 2010 19:40:56 +0000 (11:40 -0800)]
notmuch.el: Avoid infinite loop marking up message with no parts.

The infinite loop was triggered by a message consisting of a single
attachment within the body, (and no "part") tags.

We need to do things in response to this bug (beyond this specific

1. Create a test suite that exercises our emacs frontend so that bugs
   like this do not come back to haunt us after we fix them once.

2. Switch from our ad-hoc regexp based search of message-part delimeters
   to known-good code for parsing a structured document, (for example,
   the outstanding JSON patches).

11 years agoReintroduce HTML inlining, with a much needed optimization
Alexander Botero-Lowry [Wed, 10 Feb 2010 01:55:21 +0000 (17:55 -0800)]
Reintroduce HTML inlining, with a much needed optimization

Now instead of requiring every single message be parsed, we now check
the Content-type in the parsed headers and only do HTML inlining if it's

11 years agoFix printf for when uint64_t != unsigned long long int
Carl Worth [Tue, 9 Feb 2010 19:09:30 +0000 (11:09 -0800)]
Fix printf for when uint64_t != unsigned long long int

Thanks to Michal Sojka <> for pointing out the
correct fix, which I verified in the freely-available WG14/N1124 draft
(from the C99 working group) which is available here:

11 years agoSwitch from random to sequential thread identifiers.
Carl Worth [Mon, 8 Feb 2010 19:33:33 +0000 (11:33 -0800)]
Switch from random to sequential thread identifiers.

The sequential identifiers have the advantage of being guaranteed to
be unique (until we overflow a 64-bit unsigned integer), and also take
up half as much space in the "notmuch search" output (16 columns
rather than 32).

This change also has the side effect of fixing a bug where notmuch
could block on /dev/random at startup (waiting for some entropy to
appear). This bug was hit hard by the test suite, (which could easily
exhaust the available entropy on common systems---resulting in large
delays of the test suite).

11 years agoTODO: Add some recently discussed items.
Carl Worth [Tue, 9 Feb 2010 19:02:18 +0000 (11:02 -0800)]
TODO: Add some recently discussed items.

These were collected either from the mailing list of from IRC
conversations. The good ideas probably aren't mine, and the mistakes
probably are.

11 years agoAllow folders with no messages to be elided from list
Keith Packard [Sun, 27 Dec 2009 00:34:18 +0000 (16:34 -0800)]
Allow folders with no messages to be elided from list

This makes it easier to see folders with messages.
Eliding empty folders is togged with the 'e' binding.

Signed-off-by: Keith Packard <>
11 years agoLook at whitespace to separate folder name from count
Keith Packard [Sun, 27 Dec 2009 00:34:17 +0000 (16:34 -0800)]
Look at whitespace to separate folder name from count

This allows folder names to contain any non-blank characters

Signed-off-by: Keith Packard <>
11 years agoAdd 'm' and ' ' bindings to notmuch-folder view
Keith Packard [Sun, 27 Dec 2009 00:34:16 +0000 (16:34 -0800)]
Add 'm' and ' ' bindings to notmuch-folder view

This allows the user to compose new mail from the folder view, and
also to use <space> to show the current folder.

Signed-off-by: Keith Packard <>
11 years agoemacs: Use font-lock-comment-face to highlight citation button
Kan-Ru Chen [Mon, 14 Dec 2009 05:41:35 +0000 (13:41 +0800)]
emacs: Use font-lock-comment-face to highlight citation button

Signed-off-by: Kan-Ru Chen <>
11 years agonotmuch.el: show some of citation even when hiding.
David Bremner [Fri, 25 Dec 2009 20:09:08 +0000 (16:09 -0400)]
notmuch.el: show some of citation even when hiding.

- rename notmuch-show-citation-lines-min to n-s-c-l-prefix
- call forward-line with the appropriate parameter to adjust
  region to be hidden.
- change citation button text so that it makes (some) sense when citation is shown

Reviewed-by: Kan-Ru Chen <>
11 years agonotmuch.el: Refactor citation markup. Variables for minimum size, button text.
David Bremner [Fri, 25 Dec 2009 20:09:07 +0000 (16:09 -0400)]
notmuch.el: Refactor citation markup. Variables for minimum size, button text.

This is a fairly intrusive rewrite.

- I pulled the common code for the signature and citation case out
  into a separate function. This is not so much shorter, but I think it
  will be easier to maintain.

- I replaced the sequence of (looking-at blah) (forward-line)  with a single
  re-search-forward per citation.

New variables

- notmuch-show-signature-button-format, notmuch-show-citation-button-format
  Allow customization of button text.

- notmuch-show-citation-lines-min
  Do not buttonize citations below the given threshold.

Reviewed-by: Kan-Ru Chen <>
11 years agonotmuch.h: Fix a couple of typos in the documentation.
Carl Worth [Sat, 6 Feb 2010 01:31:40 +0000 (17:31 -0800)]
notmuch.h: Fix a couple of typos in the documentation.

Obviously, the spell-checker isn't able to catch every mistake
I make.

11 years agonotmuch restore: Don't waste time with messages with unchanged tags.
Carl Worth [Sat, 6 Feb 2010 01:29:56 +0000 (17:29 -0800)]
notmuch restore: Don't waste time with messages with unchanged tags.

It's a simple optimization to look at a message and check that the
existing tags are actually different than the tags we are setting
before we do anything.

For my mail store this takes a "notmuch restore" that does nothing
from about 10 minutes down to 1 minute, so there's a significant
speedup here.

11 years agonotmuch-test: Add basic tests for "notmuch dump" and "notmuch restore"
Carl Worth [Sat, 6 Feb 2010 01:28:25 +0000 (17:28 -0800)]
notmuch-test: Add basic tests for "notmuch dump" and "notmuch restore"

Our test-suite coverage keeps improving, (slowly).

11 years agonotmuch-test: Fix misalignment in output.
Carl Worth [Sat, 6 Feb 2010 01:27:22 +0000 (17:27 -0800)]
notmuch-test: Fix misalignment in output.

Clean output is just so much easier to read (and validate).

11 years agonotmuch.el: Use emacs built-in forward-button and backward-button
Kan-Ru Chen [Tue, 1 Dec 2009 06:13:53 +0000 (14:13 +0800)]
notmuch.el: Use emacs built-in forward-button and backward-button

There are built-ins, so why not use them?

Signed-off-by: Kan-Ru Chen <>
11 years agoUse forward-line instead of next-line
Carl Worth [Fri, 5 Feb 2010 19:14:25 +0000 (11:14 -0800)]
Use forward-line instead of next-line

We do this all the time, but at least emacs is kind enough to remind us,
(when compiling), that next-line is only intended for interactive use,
and we should use forward-line inside of lisp code.

11 years agonotmuch.el: Add missing documentation for the new 'h' keybinding.
Carl Worth [Fri, 5 Feb 2010 19:30:35 +0000 (11:30 -0800)]
notmuch.el: Add missing documentation for the new 'h' keybinding.

Without this, our help screen displayed 'h' with no description of
what it does.

11 years agonotmuch.el: Add keybinding to toggle display of message body and headers.
Kan-Ru Chen [Tue, 1 Dec 2009 06:13:51 +0000 (14:13 +0800)]
notmuch.el: Add keybinding to toggle display of message body and headers.

I really missed this feature. Added notmuch-show-toggle-current-body and
notmuch-show-toggle-current-header and bind them to 'b' and 'h'.

Signed-off-by: Kan-Ru Chen <>
11 years agonotmuch-test: Add test to verify that uuencoded data is not indexed.
Carl Worth [Fri, 5 Feb 2010 18:24:51 +0000 (10:24 -0800)]
notmuch-test: Add test to verify that uuencoded data is not indexed.

As recently promised, no new features are being accepted to notmuch
without corresponding new tests for the test suite.

11 years agonotmuch-test: Add several tests of "notmuch search"
Carl Worth [Fri, 5 Feb 2010 18:00:04 +0000 (10:00 -0800)]
notmuch-test: Add several tests of "notmuch search"

These tests were surprisingly simple to write---not much code at all
and most of them worked the first time even with hand-prepared
versions of the expected output.

11 years agonotmuch-test: Add a new add_message function.
Carl Worth [Fri, 5 Feb 2010 01:34:48 +0000 (17:34 -0800)]
notmuch-test: Add a new add_message function.

The previous generate_message function is what's needed when testing
"notmuch new". But after that, we never want to generate a message
without also adding it to the index. So create a new add_message
function with this convenience.

11 years agoEliminate some useless gobject boilerplate.
Carl Worth [Fri, 5 Feb 2010 01:26:00 +0000 (17:26 -0800)]
Eliminate some useless gobject boilerplate.

If we had external users of this filter then they might expect some of
these macros to exist. But since this is just internal, that's just
unneeded noise.

11 years agonotmuch new: Don't index uuencoded data.
Carl Worth [Fri, 5 Feb 2010 01:08:11 +0000 (17:08 -0800)]
notmuch new: Don't index uuencoded data.

With modern MIME attachments, we're already avoiding indexing the
attachments. But for old-school uuencoded data in the mail, we have
been directly indexing the encoded data as terms, (which is not useful
at all---nobody will ever ytry to search based on the seemingly random
uuencoded data).

Additionally, indexing a modestly large uuencoded file seems to make
Xapian go insane, (consuming *lots* of memory).

We fix both problems by detecting uuencoded content and not performing
any indexing of it.

11 years agonotmuch reply: Rename the mailing_list_munged_reply_to function
Carl Worth [Thu, 4 Feb 2010 20:39:11 +0000 (12:39 -0800)]
notmuch reply: Rename the mailing_list_munged_reply_to function

This function detects whether the address in the Reply-To header
already appears in either To or Cc. So give it a name that reflects
what it does (reply_to_header_is_redundant) rather than the old name
which described one possible use of the function, (as a simple
heuristic for detecting whether a mailing list had applied reply-to

11 years agonotmuch reply: Prevent GMIME assertion complaints for empty Reply-to header.
Carl Worth [Thu, 4 Feb 2010 20:32:28 +0000 (12:32 -0800)]
notmuch reply: Prevent GMIME assertion complaints for empty Reply-to header.

Apparently, GMime doesn't want to create a valid address list object
for an empty string. That's annoying, but it's easy enough to test for
the empty string and avoid the problem.

11 years agonotmuch reply: Use strstr instead of strcasestr for portability.
Carl Worth [Thu, 4 Feb 2010 20:29:04 +0000 (12:29 -0800)]
notmuch reply: Use strstr instead of strcasestr for portability.

This change was already recommended in a comment in the original
implementation of this patch. If someone really wants to support
un-munging in the case of To: and Reply-To: having the same address
but different case, then they can provide a portable approach for

11 years agonotmuch reply: Fix the support for reply-to un-munging.
Carl Worth [Thu, 4 Feb 2010 20:27:42 +0000 (12:27 -0800)]
notmuch reply: Fix the support for reply-to un-munging.

The condition was using a reversed sense for the test of the return
value of strcasestr, (perhaps confusing it with the usage of strcmp?).

11 years agonotmuch-reply: Add missing whitespace.
Carl Worth [Thu, 4 Feb 2010 20:12:01 +0000 (12:12 -0800)]
notmuch-reply: Add missing whitespace.

Some recently-added functions were to hard for me to read without
the expected whitespace. Fix these.

11 years agonotmuch-test: Test "notmuch reply" with a reply-to-munged mail
Carl Worth [Thu, 4 Feb 2010 20:08:13 +0000 (12:08 -0800)]
notmuch-test: Test "notmuch reply" with a reply-to-munged mail

This is a test for the recently added feature where we detect that the
reply-to address already exists in the To: or Cc: header so will
already be replied to. In this case we want to include the From:
address in our reply, (where, otherwise we would use the Reply-To
address *instead* of the address in the From header).

11 years agonotmuch-reply.c: Handle munged `Reply-To' headers.
Jed Brown [Sat, 28 Nov 2009 23:19:36 +0000 (00:19 +0100)]
notmuch-reply.c: Handle munged `Reply-To' headers.

Some mailing lists engage in the evil practice of changing the Reply-To
header so that replies from all mailers go to the list by default, at
the expense of not responding to the person who actually sent the
message.  When this is detected, we reply to `From' and remove the
duplicate response to the mailing list.  Consider a reply to the
following message.

  From: Some User <>
  To: Sample users list <>
Reply-To: Sample users list <>
Prior to this patch, `notmuch reply' produces

  To: Sample users list <>,
      Sample users list <>

and after the patch,

  To: Some User <>,
      Sample users list <>

Signed-off-by: Jed Brown <>
11 years agonotmuch-reply.c: Factor adding recipients into common function
Jed Brown [Sat, 28 Nov 2009 23:19:35 +0000 (00:19 +0100)]
notmuch-reply.c: Factor adding recipients into common function

This code was already duplicated. We move it to a new, shared
add_recipients_from_message function, in preparation for more
sophisticated mailing list logic.

Signed-off-by: Jed Brown <>
11 years agonotmuch-test: Test "notmuch reply" with multiple recipients
Carl Worth [Thu, 4 Feb 2010 20:03:30 +0000 (12:03 -0800)]
notmuch-test: Test "notmuch reply" with multiple recipients

The feature tested here is that we reply to both the sender and to
others addresses on the To: line of the original message, but that we
don't reply to our own address.

11 years agonotmuch-test: Add test for "notmuch reply" with a CC header.
Carl Worth [Thu, 4 Feb 2010 19:55:57 +0000 (11:55 -0800)]
notmuch-test: Add test for "notmuch reply" with a CC header.

A simple test to help round out the set of tested features.

11 years agonotmuch-test: Add "notmuch reply" test for reply-to support.
Carl Worth [Thu, 4 Feb 2010 19:52:08 +0000 (11:52 -0800)]
notmuch-test: Add "notmuch reply" test for reply-to support.

This is the standard support of reply-to, (replying to that address
rather than the from address). It has nothing to do with the proposed
feature for extra-clever handling of a mail from a mailing-list that
has munged the reply-to header.

11 years agonotmuch-test: Test "notmuch reply" from alternate address.
Carl Worth [Thu, 4 Feb 2010 19:39:31 +0000 (11:39 -0800)]
notmuch-test: Test "notmuch reply" from alternate address.

When reply to a message addresses to an address configured in the
other_email setting in the configuration file, the reply should use
that address in the From header. Test this.

11 years agonotmuch-test: Add a basic test of "notmuch reply"
Carl Worth [Thu, 4 Feb 2010 19:33:56 +0000 (11:33 -0800)]
notmuch-test: Add a basic test of "notmuch reply"

Simply ensuring that the reply template is formatted as expected.

11 years agonotmuch-test: Eliminate sleeps to speed up test suite run
Carl Worth [Thu, 4 Feb 2010 19:31:01 +0000 (11:31 -0800)]
notmuch-test: Eliminate sleeps to speed up test suite run

We were sleeping merely to ensure that our updates to the mail store
would result in the mtime of the appropriate directories being
updated. We make the test suite run faster by not sleeping, but
instead explicitly updating the mtime of the directory to a future
time with touch.

We're careful to ensure that the time is not merely in the future
compared to the current time, but also later than any previous update
to the same directory mtime.

11 years agonotmuch-test: Allow custom headers when generating messages
Carl Worth [Thu, 4 Feb 2010 16:39:23 +0000 (08:39 -0800)]
notmuch-test: Allow custom headers when generating messages

This provides the control that future tests will need, (for example,
adding a CC field to ensure proper handling with "notmuch reply",

11 years agonotmuch-test: Use named-parameters for generate_message function
Carl Worth [Thu, 4 Feb 2010 01:24:01 +0000 (17:24 -0800)]
notmuch-test: Use named-parameters for generate_message function

This makes the test suite bash-specific, but that's not much of
an issue for me, (if somebody else would prefer some other language
then they can rewrite the test suite and maintain it).

The advantage here is that we'll now be able to easily generate
custom messages for testing operations that depend on the message
content, (such as "notmuch reply", etc.).

11 years agoAdd actual testing to notmuch-test
Carl Worth [Wed, 3 Feb 2010 00:24:53 +0000 (16:24 -0800)]
Add actual testing to notmuch-test

We verify that each command creates output exactly as expected (after
ignoring variable output such as the report of how long an operation

11 years agoAdd a very rough beginning of a test suite.
Carl Worth [Sat, 23 Jan 2010 18:36:39 +0000 (07:36 +1300)]
Add a very rough beginning of a test suite.

This notmuch-test script simply runs a few different notmuch operations,
(things that I found were useful while testing the rename-support code).

It's not useful as a test suite yet, since it doesn't actually check
the results of any operation, (the user of the suite has to know what
the results should be and must manually verify them. So there's no
integration with the build system yet, (no "make test" target).

But I didn't want to lose what I had so far, so here it is.

11 years agonotmuch.desktop: Clarify that this is the emacs interface to notmuch.
Carl Worth [Sat, 23 Jan 2010 18:28:19 +0000 (07:28 +1300)]
notmuch.desktop: Clarify that this is the emacs interface to notmuch.

And the name is notmuch not not much.

11 years agoAdd install target for notmuch.desktop file.
Jeffrey C. Ollie [Sun, 22 Nov 2009 21:17:11 +0000 (15:17 -0600)]
Add install target for notmuch.desktop file.

Add an install target that uses desktop-file-install to install the
desktop file in the appropriate location.  The location of the install
can be modified by changing the desktop_dir variable.

Signed-off-by: Jeffrey C. Ollie <>
11 years agoFix misspelling of DT_UNKNOWN.
Carl Worth [Sat, 23 Jan 2010 09:45:23 +0000 (22:45 +1300)]
Fix misspelling of DT_UNKNOWN.

How foolish of me to advertise the fact that I pushed a commit without
compiling it first...

11 years agoREADME: Tighten up the text a bit.
Carl Worth [Sat, 23 Jan 2010 06:00:25 +0000 (19:00 +1300)]
README: Tighten up the text a bit.

As Keith pointed out, (with a humorous citation from Mark Twain),
the two uses of "very" added nothing to the description. Also,
"large collection of email" was repeated uselessly.

11 years agoAdd some comments to document the recently-fixed handling of d_type.
Carl Worth [Sat, 23 Jan 2010 05:58:30 +0000 (18:58 +1300)]
Add some comments to document the recently-fixed handling of d_type.

The fix was subtle, (requiring less code than originally expected), so
it behooves us to document it well.

11 years agonotmuch new: Fix to work on filesystems returning DT_UNKNOWN
Geo Carncross [Thu, 21 Jan 2010 20:10:18 +0000 (15:10 -0500)]
notmuch new: Fix to work on filesystems returning DT_UNKNOWN

Such as reiserfs or xfs. This has been broken since the merge of
support for rename and deletion of files from the mail store.

Here's the original justification for the patch:

A review of notmuch-new.c shows three uses of ->d_type:

Near line 153, in _entries_resemble_maildir() we can simply allow for
DT_UNKNOWN. This would fail if people have MH-style folders which have
three folders called "new" "cur" and "tmp", but that seems unlikely, in
which case the "tmp" folder would simply not be scanned.

Near line 273 in add_files_recursive() we have another check. If
DT_UNKNOWN, we fall through, then add_files_recursive() does a stat
almost immediately, returning with success if the path isn't a

Thus, the fallback is already written.

Finally, near line 343, in add_files_recursive() (a long function) we
have another check. Here we can simply treat DT_UNKNOWN as DT_LNK, since
the logic for the stat() results are the same.

11 years agoInstall zsh completion file
martin f. krafft [Fri, 8 Jan 2010 22:49:34 +0000 (11:49 +1300)]
Install zsh completion file

According to the Debian zsh maintainer Clint Adams, this is the first
time that a package installs its own completer into zsh. Part of the
reason this is not usually done is because zsh does not provide a stable

We agreed to try it, given that notmuch is expected to change quite
a bit initially. If there are problems or the completer goes stable,
we'll move it into the upstream zsh repository.

Signed-off-by: martin f. krafft <>
11 years agonotmuch new: Print upgrade progress report as a percentage.
Carl Worth [Sun, 10 Jan 2010 01:38:23 +0000 (17:38 -0800)]
notmuch new: Print upgrade progress report as a percentage.

Previously we were printing a number of messages upgraded so far. The
original motivation for this was to accurately reflect the fact that
there are two passes, (so each message is processed twice and it's not
accurate to represent with a single count). But as it turns out, the
second pass takes zero time (relatively speaking) so we're still not
accounting for it.

If nothing else, the percentage-based reporting makes for a cleaner
API for the progress_notify function.

11 years agolib: Add non-content terms with a WDF value of 0.
Carl Worth [Sat, 9 Jan 2010 19:18:27 +0000 (11:18 -0800)]
lib: Add non-content terms with a WDF value of 0.

The WDF is the "within-document frequency" value for a particular
term. It's intended to provide an indication of how frequent a term is
within a document, (for use in computing relevance). Xapian's term
generator already computes WDF values when we use that, (which we do
for indexing all mail content).

We don't use the term generator when adding single terms for things
that don't actually appear in the mail document, (such as tags, the
filename, etc.). In this case, the WDF value for these terms doesn't
matter much.

But Xapian's flint backend can be more efficient with changes to terms
that don't affect the document "length". So there's a performance
advantage for manipulating tags (with the flint backend) if the WDF of
these terms is 0.

11 years agolib: Explicitly set BoolWeight when searching.
Carl Worth [Sat, 9 Jan 2010 19:16:40 +0000 (11:16 -0800)]
lib: Explicitly set BoolWeight when searching.

All notmuch searches currently sort by value (either date or message
ID) so it's just wasted effort for Xapian to compute relevance values
for each result. We now explicitly tell Xapian that we're uninterested
in the relevance values.

11 years agolib: Split the database upgrade into two phases for safer operation.
Carl Worth [Sat, 9 Jan 2010 19:13:12 +0000 (11:13 -0800)]
lib: Split the database upgrade into two phases for safer operation.

The first phase copies data from the old format to the new format
without deleting anything. This allows an old notmuch to still use the
database if the upgrade process gets interrupted. The second phase
performs the deletion (after updating the database version number). If
the second phase is interrupted, there will be some unused data in the
database, but it shouldn't cause any actual harm.

11 years agolib: Delete stale timestamp documents during database upgrade.
Carl Worth [Fri, 8 Jan 2010 17:52:25 +0000 (09:52 -0800)]
lib: Delete stale timestamp documents during database upgrade.

Once we move the timestamp to the new directory document, we don't
need the old one anymore.

11 years agonotmuch new: Don't prevent database upgrade from being interrupted.
Carl Worth [Fri, 8 Jan 2010 16:45:16 +0000 (08:45 -0800)]
notmuch new: Don't prevent database upgrade from being interrupted.

Our signal handler is designed to quickly flush out changes and then
exit. But if a database upgrade is in progress when the user
interrupts, then we just want to immediately abort. We could do
something fancy like add a return value to our progress_notify
function to allow it to tell the upgrade process to abort. But it's
actually much cleaner and robust to delay the installation of our
signal handler so that the default abort happens on SIGINT.

11 years agonotmuch new: Fix progress notification on database upgrade.
Carl Worth [Fri, 8 Jan 2010 05:24:44 +0000 (21:24 -0800)]
notmuch new: Fix progress notification on database upgrade.

This was firing continuously rather than just once per second as

11 years agonotmuch new: Automatically upgrade the database if necessary.
Carl Worth [Fri, 8 Jan 2010 02:30:32 +0000 (18:30 -0800)]
notmuch new: Automatically upgrade the database if necessary.

This takes advantage of the recently added library support to detect
if the database needs to be upgraded and then automatically performs
that upgrade, (with a nice progress report).

11 years agolib: Implement versioning in the database and provide upgrade function.
Carl Worth [Fri, 8 Jan 2010 02:26:31 +0000 (18:26 -0800)]
lib: Implement versioning in the database and provide upgrade function.

The recent support for renames in the database is our first time
(since notmuch has had more than a single user) that we have a
database format change. To support smooth upgrades we now encode a
database format version number in the Xapian metadata.

Going forward notmuch will emit a warning if used to read from a
database with a newer version than it natively supports, and will
refuse to write to a database with a newer version.

The library also provides functions to query the database format


to ask if notmuch wants a newer version than that:


and a function to actually perform that upgrade:


11 years agonotmuch new: Fix deletion support to recurse on removed directories.
Carl Worth [Fri, 8 Jan 2010 02:20:28 +0000 (18:20 -0800)]
notmuch new: Fix deletion support to recurse on removed directories.

Previously, when notmuch detected that a directory had been deleted it
was only removing files immediately in that directory. We now
correctly recurse to also remove any directories (and files, etc.)
within sub-directories, etc.

11 years agoTODO: Add a couple of ideas that came up during recent coding.
Carl Worth [Fri, 8 Jan 2010 02:17:38 +0000 (18:17 -0800)]
TODO: Add a couple of ideas that came up during recent coding.

The notmuch_query_count_messages functions duplicates a lot of code

11 years agoPrefer READ_ONLY consistently over READONLY.
Carl Worth [Thu, 7 Jan 2010 18:29:05 +0000 (10:29 -0800)]
Prefer READ_ONLY consistently over READONLY.

NOTMUCH_STATUS_READONLY_DATABASE which was ugly and confusing. Rename
the latter to NOTMUCH_STATUS_READ_ONLY_DATABASE for consistency.

11 years agolib: Consolidate checks for read-only database.
Carl Worth [Thu, 7 Jan 2010 18:19:44 +0000 (10:19 -0800)]
lib: Consolidate checks for read-only database.

Previously, many checks were deep in the library just before a cast
operation. These have now been replaced with internal errors and new
checks have instead been added at the beginning of all top-levelentry
points requiring a read-write database.

The new checks now also use a single function for checking and
printing the error message. This will give us a convenient location to
extend the check, (such as based on database version as well).

11 years agolib: Clarify internal documentation of _notmuch_database_filename_to_direntry
Carl Worth [Thu, 7 Jan 2010 17:31:58 +0000 (09:31 -0800)]
lib: Clarify internal documentation of _notmuch_database_filename_to_direntry

The original wording made it sound like this function was just doing
some string manipulation. But this function actually creates new
directory documents as a side effect. So make that explicit in its

11 years agonotmuch_message_get_filename: Support old-style filename storage.
Carl Worth [Thu, 7 Jan 2010 17:22:34 +0000 (09:22 -0800)]
notmuch_message_get_filename: Support old-style filename storage.

When a notmuch database is upgraded to the new database format, (to
support file rename and deletion), any message documents corresponding
to deleted files will not currently be upgraded. This means that a
search matching these documents will find no filenames in the expected

Go ahead and return the filename as originally stored, (rather than
aborting with an internal error), in this case.

11 years agonotmuch new: Never ask the database for any names from a new directory.
Carl Worth [Wed, 6 Jan 2010 22:35:56 +0000 (14:35 -0800)]
notmuch new: Never ask the database for any names from a new directory.

When we know that we are adding a new directory to the database, (and
we therefore are using inode rather than strcmp-based sorting of the
filenames), then we *never* want to see any names from the
database. If we get any names that could only make us inadvertently
remove files that we just added.

Since it's not obvious from the Xapian documentation whether new terms
being added as part of new documents will appear in the in-progress
all-terms iteration we are using, (and this might differ based on
Xapian backend and also might differ based on how many new directories
are added and whether a flush threshold is reached).

For all of these reasons, we play it safe and use NULL rather than a
real notmuch_filenames_t iterator in this case to avoid any problem.

11 years agolib: Treat NULL as a valid (and empty) notmuch_filenames_t iterator.
Carl Worth [Wed, 6 Jan 2010 22:35:11 +0000 (14:35 -0800)]
lib: Treat NULL as a valid (and empty) notmuch_filenames_t iterator.

This will be convenient to avoid some special-casing in higher-level

11 years agonotmuch new: Fix bug resulting in file removal on initial build of database.
Carl Worth [Wed, 6 Jan 2010 21:54:39 +0000 (13:54 -0800)]
notmuch new: Fix bug resulting in file removal on initial build of database.

The bug here was that we would see that the database did not know
anything about a directory so would get results from the filesystem in
inode rather than strcmp order.

However, we wouldn't actually ask for the list of files from the
database until after recursing into the sub-directories. So by the
time we traverse the filenames looking for deletions, the database
*does* have entries and we end up detecting erroneous deletions
because our filename list from the filesystem isn't in strcmp order.

So ask for the list of names from the database before doing any
additions to avoid this problem.

11 years agonotmuch new: Fix to detect deletions of names at the end of the list.
Carl Worth [Wed, 6 Jan 2010 21:26:47 +0000 (13:26 -0800)]
notmuch new: Fix to detect deletions of names at the end of the list.

Previously we only scanned the list of filenames in the filesystem and
detected a deletion whenever that scan skipped a name that existed in
the database. That much was fine, but we *also* need to continue
walking the list of names from the database when the filesystem list
is exhausted.

Without this, removing the last file or directory within any
particular directory would go undetected.

11 years agonotmuch new: Fix regression preventing addition of symlinked mail files.
Carl Worth [Wed, 6 Jan 2010 18:30:08 +0000 (10:30 -0800)]
notmuch new: Fix regression preventing addition of symlinked mail files.

As described in the previous commit message, we introduced multiple
symlink-based regressions in commit

Here, we fix the case of symlinks to regular files by doing an extra
stat of any DT_LNK files to determine if they do, in fact, link to
regular files.