Commit graph

107 commits

Author SHA1 Message Date
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