Commit graph

163 commits

Author SHA1 Message Date
Carl Worth
e3046c688b Add is:<tag> as a synonym for tag:<tag> in search terms.
I like the readability of this, it provides compatibility with people
trained in this syntax by sup, and it even saves one character.
2010-03-09 16:03:58 -08:00
Scott Robinson
6ce2bf68f5 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.
2010-02-23 12:01:12 -08:00
Carl Worth
3a9c3ec9e7 notmuch new: Remove hack to ignore read-only directories in mail store.
This was really the last thing keeping the initial run of "notmuch
new" being different from all other runs. And I'm taking a fresh
look at the performance of "notmuch new" anyway, so I think we can
safely drop this optimization.
2010-01-06 10:32:05 -08:00
Carl Worth
63c503a5ac notmuch.1: Document the new --entire-thread option to "notmuch show".
This was added to "notmuch help" earlier, but not to the man page.
Add it there, and use consistent wording in both places.
2009-12-02 16:14:41 -08:00
Bart Trojanowski
d50c67d53b notmuch show: limit display to only matching messages
This patch changes the default behaviour of notmuch show to display only
messages that match the search expression.  However, --entire-thread
option is provided to display all messages in threads that matched the
search expression.

It is deemed that will be more useful for human users on the command line.
Scripts can be modified to include the --entire-thread option so that they
can display all messages once more.

Example:

$ notmuch search subject:git AND thread:23d99d0f364f93e90e15df8b42eddb5b
thread:23d99d0f364f93e90e15df8b42eddb5b      July 31 [4/12] Johan Herland; [RFCv2 00/12] Foreign VCS helper program for CVS repositories (inbox unread)

Note that in this thread 4 out of 12 messages matched.  The default show
behaviour is to show only those messages that match:

$ notmuch show subject:git AND thread:23d99d0f364f93e90e15df8b42eddb5b | grep 'message{' | wc -l
4

With the --entire-thread option the output will contain all dozen
messages:

$ notmuch show --entire-thread subject:git AND thread:23d99d0f364f93e90e15df8b42eddb5b | grep 'message{' | wc -l
12

Signed-off-by: Bart Trojanowski <bart@jukie.net>
2009-12-02 14:32:14 -08:00
Jed Brown
a2a522a758 Documentation for notmuch reply --format=(default|headers-only)
Signed-off-by: Jed Brown <jed@59A2.org>
2009-11-28 12:13:02 -08:00
Jan Janak
5a447b00ac search-tags: Add support for search-terms.
This patch adds support for search-terms to 'notmuch search-tags'. If
no search-term is provided then the command returns a list of all tags
from the database.

If the user provides one or more search-terms as arguments then the
command collects tags from matching messages only.

This could be used by functions in the Emacs mode to further limit the
list of tags offered for completion. For example, functions that remove
tags from message(s) could offer only tags present in the message(s).

Signed-off-by: Jan Janak <jan@ryngle.com>
2009-11-26 07:06:41 -08:00
Jan Janak
f8baa02335 notmuch: New command 'search-tags'.
This is a new notmuch command that can be used to search for all tags
found in the database. The resulting list is alphabetically sorted.

The primary use-case for this new command is to provide the tag
completion feature in Emacs (and other interfaces).

Signed-off-by: Jan Janak <jan@ryngle.com>
2009-11-26 07:02:48 -08:00
Carl Worth
1fd8b7866f notmuch search: Remove the chunked-searching hack.
This was a poor workaround around the fact that the existing
notmuch_threads_t object is implemented poorly. It's got a fine
iterartor-based interface, but the implementation does all of the
work up-front in _create rather than doing the work incrementally
while iterating.

So to start fixing this, first get rid of all the hacks we had working
around this. This drops the --first and --max-threads options from the
search command, (but hopefully nobody was using them
anyway---notmuch.el certainly wasn't).
2009-11-23 20:17:37 -08:00
Carl Worth
1e4f5108b5 Fix printing of literal '%' in help message.
I suppose I could have just used puts instead...
2009-11-23 18:36:14 -08:00
Carl Worth
793cbf8049 Add rudimentary date-based search.
The rudimentary aspect here is that the date ranges are specified with
UNIX timestamp values (number of seconds since 1970-01-01 UTC). One
thing that can help here is using the date program to determins
timestamps, such as:

	$(date +%s -d 2009-10-01)..$(date +%s)

Long-term, we'll probably need to do our own query parsing to be able
to support directly-specified dates and also relative expressions like
"since:'2 months ago'".
2009-11-23 17:17:08 +01:00
Keith Packard
53f8cc5651 Add 'notmuch count' command to show the count of matching messages
Getting the count of matching threads or messages is a fairly
expensive operation. Xapian provides a very efficient mechanism that
returns an approximate value, so use that for this new command.

This returns the number of matching messages, not threads, as that is
cheap to compute.

Signed-off-by: Keith Packard <keithp@keithp.com>
2009-11-23 06:33:54 +01:00
Alec Berryman
91d1d3f043 Support multiple configuration files via $NOTMUCH_CONFIG
If present, $NOTMUCH_CONFIG will be used as the configuration file
location.
2009-11-23 03:01:57 +01:00
Adrian Perez
5fdce046a1 Support for printing file paths in new command
For very large mail boxes, it is desirable to know which files are being
processed e.g. when a crash occurs to know which one was the cause. Also,
it may be interesting to have a better idea of how the operation is
progressing when processing mailboxes with big messages.

This patch adds support for printing messages as they are processed by
"notmuch new":

* The "new" command now supports a "--verbose" flag.

* When running in verbose mode, the file path of the message about to be
  processed is printed in the following format:

    current/total: /path/to/message/file

  Where "current" is the number of messages processed so far and "total" is
  the total count of files to be processed.

  The status line is erased using an ANSI sequence "\033[K" (erase current
  line from the cursor to the end of line) each time it is refreshed. This
  should not pose a problem because nearly every terminal supports it.

* The signal handler for SIGALRM and the timer are not enabled when running
  in verbose mode, because we are already printing progress with each file,
  periodical reports are not neccessary.
2009-11-23 01:07:02 +01:00
Carl Worth
fe6d3b79b0 notmuch main(): Remove stale comment.
The code this comment was referring to has since been deleted.
2009-11-18 05:22:14 -08:00
Lars Kellogg-Stedman
9d69e332fa notmuch help: Print to stdout, not to stderr.
Let usage() take a FILE * argument so that you can output to stderr in
response to usage errors, and stdout in response to an explicit
request.
2009-11-18 05:21:06 -08:00
Carl Worth
533d0f5382 notmuch help: Update documentation (following recent text from notmuch.1)
We take the recently created text from the notmuch manual page and
update the "notmuch help" command to use similar text. In particular,
we add a new "notmuch help search-terms" for documenting the search
syntax that is common to several commands.
2009-11-17 23:37:21 -08:00
Carl Worth
37bdd89870 notmuch new: Unbreak after the addition of notmuch-config.
Pull in the code from add-files.c now that notmuch_new_command is
the only user, (we no longer have notmuch_setup_command adding any
messages).
2009-11-11 19:50:15 -08:00
Carl Worth
8136e15229 notmuch: Make the command of "notmuch" walk the user through the next step.
If this is run first, it will run "notmuch setup" directly. After that
is successful, it will look for a databae and tell the user to run
"notmuch new" if the database doesn't exist yet. Finally, if the
database is present, it will provide some example "notmuch search"
commands for the user to try.
2009-11-11 17:56:59 -08:00
Carl Worth
6bd01e1b34 notmuch: Move welcome messages from "notmuch" to "notmuch setup".
It's quite possible for someone to read the documentation and run
"notmuch setup" rather than just "notmuch". In that case, we don't
want to be any less welcoming.
2009-11-11 17:33:31 -08:00
Carl Worth
305e76bc0a notmuch: Add a configuration system.
This will allow for things like the database path to be specified
without any cheesy NOTMUCH_BASE environment variable. It also will
allow "notmuch reply" to recognize the user's email address when
constructing a reply in order to do the right thing, (that is, to use
the user's address to which mail was sent as From:, and not to reply
to the user's own addresses).

With this change, the "notmuch setup" command is now strictly for
changing the configuration of notmuch. It no longer creates the
database, but instead instructs the user to call "notmuch new" to do
that.
2009-11-11 17:01:55 -08:00
Carl Worth
a9f3ad4fcb notmuch reply: Use GMime to construct the header for the reply.
The advantage here is that we actually get the necessary folding of
long headers, (particularly the References header, but also things
like Subject). This also gives us parsed recipient addresses so that
we can easily elide the sender's address(es) from the recipient list
(just as soon as we have a configured value for the recipient's
address(es)).
2009-11-11 10:54:12 -08:00
Keith Packard
357aba3ec8 notmuch reply: Add (incomplete) reply command
Reviewed-by: Carl Worth <cworth@cworth.org>

Keith wrote all the code here against notmuch before notmuch.c was
split up into multiple files. So I've pushed the code around in
various ways to match the new code structure, but have generally tried
to avoid making any changes to the behavior of the code.

I did fix one bug---a missing call to g_mime_stream_file_set_owner in
show_part which would cause "notmuch show" to go off into the weeds
when trying to show multiple messages, (since the first stream would
fclose stdout).
2009-11-10 13:32:02 -08:00
Carl Worth
50144f95ca notmuch: Break notmuch.c up into several smaller files.
Now that the client sources are alone here in their own directory,
(with all the library sources down inside the lib directory), we can
break the client up into multiple files without mixing the files up.
The hope is that these smaller files will be easier to manage and
maintain.
2009-11-10 12:03:05 -08:00
Carl Worth
59d82640dc notmuch setup: Remove a debugging print.
This was just some extra noise printed when requesting a non-default
mail directory itneractively.
2009-11-09 13:41:40 -08:00
Carl Worth
508d2d2ff7 notmuch show: Don't show the subject line twice.
I recently added a print of the subject line for use as part of a
two-line summary in the emacs client. But of course, the subject was
already being printed on the next line. So I didn't really need to add
anything, I could have just stopped hiding what was already
printed. Anyway, we now avoid printing it twice in a row.
2009-11-06 09:32:24 -08:00
Carl Worth
306e19f5dd notmuch show: Move subject from one-line summary down to its own line.
And change the display code in emacs to display the one-line summary
in inverse video.
2009-11-05 15:02:20 -08:00
Carl Worth
db81b31c56 Update notmuch man page with recently-added documentation.
It would be nice to have this documentation live in a single place,
but for now, this is what we get.
2009-11-05 10:45:40 -08:00
Carl Worth
d1b06f159c notmuch search: Document the from, to, and subject prefixes.
I've been using these for a long time, but I had neglected to document
them until now.
2009-11-05 10:33:37 -08:00
Carl Worth
494c74229b notmuch show: Fix to work with any search string rather than just a thread ID.
The more general command is more consistent, and more useful.

We also fix "notmuch search" to output copy-and-pasteable search terms
for the thread with "thread:" prepended already. Similarly, the
message-ID in the output of "notmuch show" is also now printed as a
valid search term, ("id:<message-id>" rather than "ID: <message-id>").

Naturally, the emacs code is also changed to track these changes.
2009-11-05 10:23:04 -08:00
Carl Worth
b1baaab2d5 notmuch show: Add filename to output (next to message ID).
This will allow a client using "notmuch show" to directly open the
filename and do whatever it wants with it.
2009-11-04 15:53:07 -08:00
Carl Worth
2aa6c2d9a1 notmuch show: Fix misplaced g_object_unref leading to error message.
We were inadvertently calling g_object_unref on a wild pointer leading
to the following error message:

	GLib-GObject-CRITICAL **: g_object_unref: assertion
	`G_IS_OBJECT (object)' failed

Now, why glib doesn't abort on critical errors, I'll never understand.
2009-11-04 15:01:37 -08:00
Carl Worth
aa34eb2a37 notmuch show: Remove custom "unread" hack, (printing tag in two locations).
I previously had a hack that special-cased the "unread" tag and
printed it on the same line as the message ID. But now that we are
printing all tags at the end of the one-line summary we don't need
this anymore. Get rid of it, and just read "unread" from the list of
tags just like any other tag.
2009-11-03 13:38:00 -08:00
Carl Worth
02aa1391be notmuch show: Print tags for each message.
This is in the one-line summary so should always be visible even
in our emacs client that's so eager to make things invisible.
2009-11-03 12:29:07 -08:00
Carl Worth
9c6a010674 Hide bodies of message that have already been read.
Also hide all markers.

From here, all we really need for legibility is the following:

  * Hide away citations and signatures

  * Call out the one-line summary some way, (larger font size?)

  * Add nesting for replies
2009-11-03 10:32:42 -08:00
Carl Worth
a81849b5e2 notmuch show: Switch to control character to mark sections of output
We were previously using things like "%message{" which were not
guaranteed to never appear in an email message. Using a control
character (^L or '\f' instead of '%') gives us better assurance that
our delimiter doesn't show up in an original email message.

This still isn't entirely safe since we're decoding encoded text in
the body of the email message so almost all bets are off really.
2009-11-02 21:13:19 -08:00
Carl Worth
e1f95213ae Tweak relative dates to be close to the same length.
Most all of the returned strings will now fill most of a 12-character
string, (depending on the length of the month).
2009-11-02 16:18:28 -08:00
Carl Worth
8ff934803c notmuch show: Don't print non-text MIME parts.
Additionally, print a part number for each MIME part so that the
client could (conceivably) ask for the contents of a specific
part by part number.
2009-11-02 14:33:15 -08:00
Carl Worth
d6615b554e Print "part" markers for each MIME part (with Content-type).
This can allow for the client to hide undesired MIME parts
such as text/html.
2009-11-02 13:41:04 -08:00
Carl Worth
ab317ca474 notmuch show: Use GMime to decode messages.
We now actually get text content rather than blocks of BASE64, etc.
2009-11-02 13:19:39 -08:00
Carl Worth
1a579dfe6b Add a simple manual page for notmuch.
By pulling content out of notmuch help, and also the messages
printed by "notmuch setup".
2009-11-02 07:18:31 -08:00
Carl Worth
2405b45a06 notmuch: Add a talloc context argument to each top-level command function.
I had noticed several times earlier that having a talloc context
passed in would make things more convenient. I'm not exercising
that convenience yet, but the context is there now, (and there's
one fewer item on our TODO list).
2009-10-31 16:40:47 -07:00
Carl Worth
c96021a477 Rename message_results/thread_results to messages/threads.
Shorter naming without being any less clear. A definite win.
2009-10-31 16:32:30 -07:00
Carl Worth
c37b1bdf2d notmuch: Reference help, don't print it for unknown commands.
The shorter output is much nicer for something that might end up
in an emacs mini-buffer, for example.
2009-10-31 12:08:00 -07:00
Carl Worth
a2f0445e1b Fix relative date formatting to not split one day into two formats.
We were aware of this bug when we wrote the function, (that a date
six days in the past would be treated as the "Friday" or as the
"Oct. 23" case depending on whether its time was before or after
the current time today). We thought it wouldn't be a problem, but
in practice it is. In scanning search results with this output,
the transition between formats makes it look like a day boundary,
(so it would be easy to mistakenly think "Oct. 23" is Thursday).

Fix this to avoid confusion, (still being careful to never print
"Thursday" for a date 7 days in the past when today is Thursday).
2009-10-29 17:42:21 -07:00
Carl Worth
c771eaf362 notmuch search: Add (relative) date to search output
The new function for formatting relative dates is nice enough that
we need to start using it more places. Here's one of them.
2009-10-29 17:31:07 -07:00
Carl Worth
41c7ad2c91 notmuch show: Add a one-line summary of the message before the header.
The idea here is that a client could usefully display just this one
line while optionally hiding the other header fields.
2009-10-29 17:30:56 -07:00
Carl Worth
8b93875b27 notmuch show: Trim down header list.
This is for now a non-configurable list of Subject, From, To, Cc,
Bcc, and Date.
2009-10-29 14:07:45 -07:00
Carl Worth
90a0ef4ac4 notmuch show: Add body of message as well.
This is just the raw message body for now, (so any MIME parsing will
be up to the consumer). And this will likely change in the future.
2009-10-29 09:06:53 -07:00
Carl Worth
bf78a89196 notmuch show: Initial implementation (headers only)
We're using a delimiter syntax that Keith is optimistic about
being able to easily parse in emacs. Note: We're not escaping
any occurrence of the delimiters in the message yet, so we'll
need to fix that.
2009-10-29 08:51:12 -07:00
Carl Worth
a1135f0b7e Fix add_message and get_filename to strip/re-add the database path.
We now store only a relative path inside the database so the database
is not nicely relocatable.
2009-10-28 16:51:56 -07:00
Carl Worth
fbf55bfe2f notmuch setup/new: Print progress once per second instead of after 1000 files.
With the recent addition of full-text indexing, printing only once per
1000 files just isn't often enough. The new timer-based approach will
be reliable regardless of the speed of adding message.
2009-10-28 16:09:19 -07:00
Carl Worth
b04cc33738 notmuch search: Clarify documentation of implicit Boolean operators
The original documentation of implicit AND is what we want, but
Xapian doesn't actually let us get that today. So be honest about
what the user can actually expect. And let's hope the Xapian
wizards give us the feature we want soon:

http://trac.xapian.org/ticket/402
2009-10-28 10:35:26 -07:00
Carl Worth
19ec20192c notmuch help: Review and augment all of the "notmuch help" documentation.
The big addition here is the first description of the syntax for
the query strings for "notmuch search", (and, by reference, for
"notmuch tag").
2009-10-28 01:37:57 -07:00
Carl Worth
450b054245 notmuch help: Be less verbose by default and support detailed help
Putting all of our documentation into a single help message was getting
a bit unwieldy. Now, the simple output of "notmuch help" is a reasonable
reminder and a quick reference. Then we now support a new syntax of:
"notmuch help <command>" for the more detailed help messages.

This gives us freedom to put more detailed caveats, etc. into some
sub-commands without worrying about the usage statement getting too
long.
2009-10-28 00:58:26 -07:00
Carl Worth
326f73374e Add new "notmuch tag" command for adding/removing tags.
This uses the same search functionality as "notmuch search" so
it should be quite powerful. And this global search might be
quick enough to be used for "automatic" adding of tags to new
messages.

Of course, this will all be a lot more useful when we can search
for actual text of messages and not just tags.
2009-10-27 17:15:27 -07:00
Carl Worth
b0190e59ac Merge branch to fix broken "notmuch setup" and "notmuch new"
I'm trying to stick to a habit of fixing previously-introduced bugs
on side branches off of the commit that introduced the bug. The
idea here is to make it easy to find the commits to cherry pick
if bisecting in the future lands on one of the broken commits.
2009-10-27 16:12:08 -07:00
Carl Worth
8969720108 Fix "notmuch new" (bad performance, and no committing of results).
We were incorrectly only destroying messages in the case of
successful addition to the database, and not in other cases,
(such as failure due to FILE_NOT_EMAIL).

I'm still not entirely sure why this was performing abysmally, (as in
making an operation that should take a small fraction of a second take
10 seconds), nor why it was causing the database to entirely fail to
get new results.

But fortunately, this all seems to work now.
2009-10-27 16:07:27 -07:00
Carl Worth
16003e1f8f Unbreak the "notmuch setup" command.
The recent addition of support for automatically adding tags to
new messages for "notmuch new" caused "notmuch setup" to segfault.
The fix is simple, (just need to move a destroy function to inside
a nearby if block).

Did I mention recently we need to add a test suite?
2009-10-27 12:00:58 -07:00
Carl Worth
31db02a8c1 notmuch restore: Fix to remove all tags before adding tags.
This means that the restore operation will now properly pick up the
removal of tags indicated by the tag just not being present in the
dump file.

We added a few new public functions in order to support this:

	notmuch_message_freeze
	notmuch_message_remove_all_tags
	notmuch_message_thaw
2009-10-26 22:53:39 -07:00
Carl Worth
9c4efa8487 notmuch restore: Don't bother printing tag values.
The code was just a little messy here with three parallel conditions
testing for message == NULL.
2009-10-26 22:19:08 -07:00
Carl Worth
ae0bd3f503 add_message: Add an optional parameter for getting the just-added message.
We use this to implement the addition of "inbox" and "unread" tags
for all messages added by "notmuch new".
2009-10-26 21:44:05 -07:00
Carl Worth
d07dd49aac Fix incorrect name of _notmuch_thread_get_subject.
Somehow this naming with an underscore crept in, (but only in the
private header, so notmuch.c was compiling with no prototype). Fix
to be the notmuch_thread_get_subject originally intended.
2009-10-26 20:11:58 -07:00
Carl Worth
c12823648e Add public notmuch_thread_get_subject
And use this in "notmuch search" to display subject line as well as
thread ID.
2009-10-26 17:35:31 -07:00
Carl Worth
8e96a87fff Remove all calls to g_strdup_printf
Replacing them with calls to talloc_asprintf if possible, otherwise
to asprintf (with it's painful error-handling leaving the pointer
undefined).
2009-10-26 15:17:10 -07:00
Carl Worth
94f01d9de9 Add notmuch_thread_get_tags
And augment "notmuch search" to print tag values as well as thread ID
values. This tool is almost usable now.
2009-10-26 14:46:14 -07:00
Carl Worth
3dce200788 tags: Re-implement tags iterator to avoid having C++ in the interface
We want to be able to iterate over tags stored in various ways, so
the previous TermIterator-based tags object just wasn't general
enough. The new interface is nice and simple, and involves only
C datatypes.
2009-10-26 14:02:51 -07:00
Carl Worth
46ba33b115 notmuch restore: Fix leak of FILE* object.
Apparently, I didn't copy enough of the "notmuch dump" implementation
since it didn't have a similar leak.
2009-10-26 13:36:40 -07:00
Carl Worth
1ba3d46fab Add an initial implementation of a notmuch_thread_t object.
We've now got a new notmuch_query_search_threads and a
notmuch_threads_result_t iterator. The thread object itself
doesn't do much yet, (just allows one to get the thread_id),
but that's at least enough to see that "notmuch search" is
actually doing something now, (since it has been converted
to print thread IDs instead of message IDs).

And maybe that's all we need. Getting the messages belonging
to a thread is as simple as a notmuch_query_search_messages
with a string of "thread:<thread-id>".

Though it would be convenient to add notmuch_thread_get_messages
which could use the existing notmuch_message_results_t iterator.

Now we just need an implementation of "notmuch show" and we'll
have something somewhat usable.
2009-10-25 23:12:20 -07:00
Carl Worth
cd467cafb5 Rename notmuch_query_search to notmuch_query_search_messages
Along with renaming notmuch_results_t to notmuch_message_results_t.
The new type is quite a mouthful, but I don't expect it to be
used much other than the for-loop idiom in the documentation,
(which does at least fit nicely within 80 columns).

This is all in preparation for the addition of a new
notmuch_query_search_threads of course.
2009-10-25 22:22:07 -07:00
Carl Worth
3bd4a2eaaa Add -Wswitch-enum and fix warnings.
Having to enumerate all the enum values at every switch is annoying,
but this warning actually found a bug, (missing support for
NOTMUCH_STATUS_OUT_OF_MEMORY in notmuch_status_to_string).
2009-10-25 16:03:45 -07:00
Carl Worth
c7482b4dce Add -Wmising-declarations and fix warnings.
Wow, lots of missing 'static' on internal functions.
2009-10-25 15:58:05 -07:00
Carl Worth
884ac59256 Re-enable the warning for unused parameters.
It's easy enough to squelch the warning with an __attribute__ ((unused))
and it might just catch something for us in the future.
2009-10-25 15:53:27 -07:00
Carl Worth
cc48812cb5 Add -Wextra and fix warnings.
When adding -Wextra we also add -Wno-ununsed-parameters since that
function means well enough, but is really annoying in practice.

So the warnings we fix here are basically all comparsions between
signed and unsigned values.
2009-10-25 15:52:14 -07:00
Carl Worth
7b227a6bf7 Add an INTERNAL_ERROR macro and use it for all internal errors.
We were previously just doing fprintf;exit at each point, but I
wanted to add file and line-number details to all messages, so it
makes sense to use a single macro for that.
2009-10-25 10:54:49 -07:00
Carl Worth
9f673f3cf8 notmuch dump: Eliminate extra space in error message.
Little details can make big impressions.
2009-10-25 09:20:13 -07:00
Carl Worth
a8ae2cd214 Move read-only-archive hint from "notmuch setup" to "notmuch new"
The "notmuch setup" output was getting overwhelmingly verbose.

Also, some people might not have a lot of mail, so might never need
this optimization. It's much better to move the hint to the time
when the user could actually benefit from it, (it's easy to detect
that "notmuch new" took more than 1 second, and we know if there
are any read-only directories there or not).
2009-10-25 09:14:16 -07:00
Carl Worth
144b2cbc55 Add a preliminary "notmuch search" command.
This isn't behaving at all like it's documented yet, (for example,
it's returning message IDs not thread IDs[*]). In fact, the output
code is just a copy of the body of "notmuch dump", so all you
get for now is message ID and tags.

But this should at least be enough to start exercising the query
functionality, (which is currently very buggy).

[*] I'll want to convert the databse to store thread documents
before fixing that.
2009-10-24 22:16:10 -07:00
Carl Worth
309c0e1cc5 notmuch setup/new: Propagate failure from notmuch_database_set_timestamp
With some recent testing, the timestamp was failing, (overflowing
the term limit), and reporting an error, but the top-level notmuch
command was still returning a success return value.

I think it's high time to add a test suite, (and the code base is
small enough that if we add it now it shouldn't be *too* hard to
shoot for a very high coverage percentage).
2009-10-24 22:11:38 -07:00
Carl Worth
e1e1f0cb3b Revert "Remove some unneeded initializers."
This reverts commit fb1bae0700.

These initializers were totally necessary. I clearly wasn't
thinking straight when I removed them.
2009-10-24 08:06:23 -07:00
Carl Worth
1f193675c4 Cut the enthusiasm a bit.
It gets annoying pretty quick.
2009-10-23 17:25:23 -07:00
Carl Worth
c037dc5e53 Make "notmuch new" ignore directories that are read-only.
With this, "notmuch new" is now plenty fast even with large archives
spanning many sub-directories. Document this both in "notmuch help"
and also in the output of notmuch setup.
2009-10-23 17:25:03 -07:00
Carl Worth
ef944693c3 add_files: Pull one stat out of the recrusive function.
There's no need to stat each directory both before and after each
recursive call.
2009-10-23 16:23:18 -07:00
Carl Worth
e58d85dd75 More fixing of plurals.
It definitely doesn't help that we have the same messages in both
"setup" and "new". Should combine those really.
2009-10-23 16:00:24 -07:00
Carl Worth
6cccc10bf0 More care in final status reporting.
Printing "Added 1 new messages" just looks like lack of attention
to detail, (but yes plurals can be annoying this way).
2009-10-23 15:57:39 -07:00
Carl Worth
cbb2675ec5 Print a better message than "0s" for zero seconds.
It's nice to have a tool that at least construct actual sentences.
2009-10-23 15:55:36 -07:00
Carl Worth
491ece966f Add new "notmuch new" command.
Finally, I can get new messages into my notmuch database without
having to run a complete "notmuch setup" again. This takes
advantage of the recent timestamp capabilities in the database
to avoid looking into directories that haven't changed since the
last time "notmuch new" was run.
2009-10-23 15:48:05 -07:00
Carl Worth
9577e8a105 add_files: Change to return a status value instead of void
Also change to use goto rather than early returns. And once again,
there were lots of bugs in the error cases previously.
2009-10-23 15:39:11 -07:00
Carl Worth
a7a897b883 notmuch setup: Clean up the progress printing a bit.
Get rid of a useless leading 0 on the seconds value, and make a
distinction between "files" and "messages", (we process many
files, but not all of them are recongized as messages). Finally,
add a summary line at the end saying how many unique messages
were added to the database. Since this comes right after the
total number of files, it gives the user at least a hint as
to how many messages were encountered with duplicate message IDs.
2009-10-23 15:29:06 -07:00
Carl Worth
fb1bae0700 Remove some unneeded initializers.
Some people might argue for more initializers to be "safer",
but I actually prefer to leave things this way. It saves
typing, but the real benefit is that the things that do
require initialization stand out so we know to watch them
carefully. And with valgrind, we actually get to catch
errors earlier if we *don't* initialize them. So that can
be "safer" ironically enough.
2009-10-23 14:55:50 -07:00
Carl Worth
336deb279e notmuch setup: Fix a couple of error paths.
We had early returns instead of goto statments, and sure enough,
they were leaking. Much cleaner this way.
2009-10-23 14:55:02 -07:00
Carl Worth
68a10091d6 Add notmuch_database_set_timestamp and notmuch_database_get_timestamp
These will be very helpful to implement an efficient "notmuch new"
command which imports new mail messages that have appeared.
2009-10-23 14:31:01 -07:00
Carl Worth
c9fbe6b58b notmuch restore: Print names of tags that cannot be applied
This helps the user gauge the severity of the error.

For example, when restoring my sup tags I see a bunch of tags missing
for message IDs of the form "sup-faked-...". That's not surprising
since I know that sup generates these with the md5sum of the message
header while notmuch uses the sha-1 of the entire message. But how
much will this hurt?

Well, now that I can see that most of the missing tags are just
"attachment", then I'm not concerned, (I'll be automatically creating
that tag in the future based on the message contents). But if a
missing tag is "inbox" then that's more concerning because that's data
that I can't easily regenerate outside of sup.
2009-10-23 06:08:22 -07:00
Carl Worth
302d54834d Add notmuch_status_to_string function.
Be kind and let the user print error messages, not just error
codes.
2009-10-21 16:12:53 -07:00
Carl Worth
f232f0a797 Implement "notmuch restore".
It's pretty easy to do with all the right infrastructure in place.
Now that I can get my tags from sup to notmuch, maybe I'll be able
to start reading mail again.
2009-10-21 16:03:03 -07:00
Carl Worth
f96f4fe427 Pull out a chomp_newline function from "notmuch setup"
We'll want this same thing with "notmuch restore", (and really
anything using getline).
2009-10-21 15:59:11 -07:00
Carl Worth
baf1867cc4 notmuch dump: Fix to print spaces between tags.
Simple little bug here made all the tags run together.
2009-10-21 14:02:51 -07:00
Carl Worth
0e914d9e96 notmuch dump: Fix buffer overrun in error message.
Just a little bug I noticed while editing nearby code.
2009-10-21 10:12:11 -07:00
Carl Worth
af65f52acf notmuch setup: Print a few protecting spaces after progress reports.
This is to help keep the report looking clean when a new report
is shorter than a previous reports, (say, when crossing the
boundary from over one minute remaining to less than one minute
remaining).

This used to be here, but I must have accidentally dropped it
when reformatting the progress report recently.
2009-10-21 00:32:30 -07:00
Carl Worth
6519aff957 query: Remove the magic NOTMUCH_QUERY_ALL
Using the address of a static char* was clever, but really
unnecessary. An empty string is much less magic, and even
easier to understand as the way to query everything from
the database.
2009-10-20 22:40:37 -07:00