Carl Worth [Wed, 21 Oct 2009 23:03:03 +0000 (16:03 -0700)]
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.
Carl Worth [Wed, 21 Oct 2009 22:59:11 +0000 (15:59 -0700)]
Pull out a chomp_newline function from "notmuch setup"
We'll want this same thing with "notmuch restore", (and really
anything using getline).
Carl Worth [Wed, 21 Oct 2009 22:53:38 +0000 (15:53 -0700)]
Add notmuch_message_add_tag and notmuch_message_remove_tag
With these two added, we now have enough functionality in the
library to implement "notmuch restore".
Carl Worth [Wed, 21 Oct 2009 22:51:13 +0000 (15:51 -0700)]
notmuch-private.h: Move NOTMUCH_BEGIN_DECLS earlier
We actually need this before the include of xutil.h, but
it was previously stuck randomly among various system
includes. Instead, put it at the top, right after include
the notmuch.h header that defines it.
Carl Worth [Wed, 21 Oct 2009 22:46:46 +0000 (15:46 -0700)]
notmuch_query_search: Clarify the documentation.
This is where we wanted to put the note to recommend the user
call notmuch_message_destroy if the lifetime of the message
is much shorter than the lifetime of the query. (Somehow this
had ended up in the documentation of notmuch_message_get_tags
before.)
Carl Worth [Wed, 21 Oct 2009 22:45:34 +0000 (15:45 -0700)]
notmuch.h: Fix some copy-paste errors in the documentaton.
In several places we had "results" where "tags" was intended.
It actually read fine in some cases, but this is still better.
Carl Worth [Wed, 21 Oct 2009 22:42:54 +0000 (15:42 -0700)]
notmuch_message_get_message_id: Fix to cache result
Previously, this would allocate new memory with every call. That
was with talloc, of course, so there wasn't any leaking (eventually).
But since we're now calling this internally we want to be a little
less wasteful. It's easy enough to just stash the result into the
message on the first call, and then just return that on subsequent
calls.
Carl Worth [Wed, 21 Oct 2009 22:37:51 +0000 (15:37 -0700)]
database: Add new notmuch_database_find_message
With this function, and the recently added support for
notmuch_message_get_thread_ids, we now recode the find_thread_ids
function to work just the way we expect a user of the public
notmuch API to work. Not too bad really.
Carl Worth [Wed, 21 Oct 2009 22:23:08 +0000 (15:23 -0700)]
Add notmuch_message_get_thread_ids function
Along with all of the notmuch_thread_ids_t iterator functions.
Using a consistent idiom seems better here rather than returning
a comma-separated string and forcing the user to parse it.
Carl Worth [Wed, 21 Oct 2009 22:06:52 +0000 (15:06 -0700)]
Add wrappers for regcomp and regexec to xutil.c.
These will be handy for some parsing.
Carl Worth [Wed, 21 Oct 2009 21:10:00 +0000 (14:10 -0700)]
Rename NOTMUCH_MAX_TERM to NOTMUCH_TERM_MAX
Just better consistency with our naming schemes.
Carl Worth [Wed, 21 Oct 2009 21:07:40 +0000 (14:07 -0700)]
Move find_prefix function from database.cc to message.cc
It's definitely a better fit there for now, (and can likely
eventually be made static as add_term moves from database
to message as well).
Carl Worth [Wed, 21 Oct 2009 21:02:51 +0000 (14:02 -0700)]
notmuch dump: Fix to print spaces between tags.
Simple little bug here made all the tags run together.
Carl Worth [Wed, 21 Oct 2009 21:00:37 +0000 (14:00 -0700)]
Convert notmuch_database_t to start using talloc.
This will be handy as we can hang future talloc allocations off
of the datbase now.
Carl Worth [Wed, 21 Oct 2009 20:57:02 +0000 (13:57 -0700)]
Move declarations for xutil.c from notmuch-private to new xutil.h.
The motivation here is that our top-level notmuch.c main program
wants to start using these, but we don't want it to see into
notmuch-private.h, (since our main program is a test vehicle
for the "public" notmuch interface in notmuch.h).
Carl Worth [Wed, 21 Oct 2009 17:12:11 +0000 (10:12 -0700)]
notmuch dump: Fix buffer overrun in error message.
Just a little bug I noticed while editing nearby code.
Carl Worth [Wed, 21 Oct 2009 17:07:34 +0000 (10:07 -0700)]
notmuch setup: Collapse internal whitespace within message-id
I'm too lazy to see what the RFC says, but I know that having
whitespace inside a message-ID is sure to confuse things. And
besides, this makes things more compatible with sup so that
I have some hope of importing sup labels.
Carl Worth [Wed, 21 Oct 2009 07:35:56 +0000 (00:35 -0700)]
notmuch dump: Fix the sorting of results.
To properly support sorting in notmuch_query we know use an
Enquire object. We also throw in a QueryParser too, so we're
really close to being able to support arbitrary full-text
searches.
I took a look at the supported QueryParser syntax and chose
a set of flags for everything I like, (such as supporting
Boolean operators in either case ("AND" or "and"), supporting
phrase searching, supporting + and - to include/preclude terms,
and supporting a trailing * on any term as a wildcard).
Carl Worth [Wed, 21 Oct 2009 07:34:36 +0000 (00:34 -0700)]
add_message: Add a type:mail ("Kmail") term to all documents.
This gives us an easy way to specify "all mail messages" in a search
query. We simply look for this term.
Carl Worth [Wed, 21 Oct 2009 07:32:30 +0000 (00:32 -0700)]
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.
Carl Worth [Wed, 21 Oct 2009 06:13:28 +0000 (23:13 -0700)]
.gitignore: Ignore generated file Makefile.dep
Forgot to add this when I first add dependency checking to the
Makefile.
Carl Worth [Wed, 21 Oct 2009 06:12:53 +0000 (23:12 -0700)]
database: Remove two little bits of dead code.
Carl Worth [Wed, 21 Oct 2009 05:40:37 +0000 (22:40 -0700)]
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.
Carl Worth [Wed, 21 Oct 2009 05:27:56 +0000 (22:27 -0700)]
notmuch dump: Free each message as it's used.
Previously we were leaking[*] memory in that the memory footprint of
a "notmuch dump" run would continue to grow until the output was
complete, and then finally all the memory would be freed.
Now, the memory footprint is small and constant, O(1) rather than
O(n) in the number of messages.
[*] Not leaking in a valgrind sense---every byte was still carefully
being accounted for and freed eventually.
Carl Worth [Wed, 21 Oct 2009 05:24:59 +0000 (22:24 -0700)]
Add destroy functions for results, message, and tags.
None of these are strictly necessary, (everything was leak-free
without them), but notmuch_message_destroy can actually be useful
for when one query has many message results, but only one is needed
to be live at a time.
The destroy functions for results and tags are fairly gratuitous, as
there's unlikely to be any benefit from calling them. But they're all
easy to add, (all of these functions are just wrappers for talloc_free),
and we do so for consistency and completeness.
Carl Worth [Wed, 21 Oct 2009 05:08:31 +0000 (22:08 -0700)]
Rename our talloc destructor functions to _destructor.
I want to reserve the _destroy names for some public functions
I'm about to add.
Carl Worth [Wed, 21 Oct 2009 04:03:30 +0000 (21:03 -0700)]
Implement 'notmuch dump'.
This is a fairly big milestone for notmuch. It's our first command
to do anything besides building the index, so it proves we can
actually read valid results out from the index.
It also puts in place almost all of the API and infrastructure we
will need to allow searching of the database.
Finally, with this change we are now using talloc inside of notmuch
which is truly a delight to use. And now that I figured out how
to use C++ objects with talloc allocation, (it requires grotty
parts of C++ such as "placement new" and "explicit destructors"),
we are valgrind-clean for "notmuch dump", (as in "no leaks are
possible").
Carl Worth [Tue, 20 Oct 2009 22:09:51 +0000 (15:09 -0700)]
Rename private notmuch_message_t to notmuch_message_file_t
This is in preparation for a new, public notmuch_message_t.
Eventually, the public notmuch_message_t is going to grow enough
features to need to be file-backed and will likely need everything
that's now in message-file.c. So we may fold these back into one
object/implementation in the future.
Carl Worth [Tue, 20 Oct 2009 22:08:03 +0000 (15:08 -0700)]
Makefile: Add automatic dependency tracking to the Makefile.
With this, I really don't miss anything from automake.
Carl Worth [Tue, 20 Oct 2009 20:16:16 +0000 (13:16 -0700)]
notmuch: Fix setup so that accepting the default mail path works.
The recent change from GIOChannel to getline, (with a semantic
change of the newline terminator now being included in the
result that setup_command sees), broke this.
Carl Worth [Tue, 20 Oct 2009 20:07:19 +0000 (13:07 -0700)]
message: Use g_hash_table_destroy instead of g_hash_table_unref
I'm trying to chase down 3 still-reachable pointers to glib hash
tables.
This change didn't help with that, but I think destroy might be a
better semantic match for what I actually want. (It shouldn't matter
though since I never take any additional references.)
Carl Worth [Tue, 20 Oct 2009 20:05:45 +0000 (13:05 -0700)]
add_message: Fix memory leak of thread_ids GPtrArray.
We were properly feeing this memory when the thread-ids list was not
empty, but leaking it when it was.
Thanks, of course, to valgrind along with the G_SLICE=always-malloc
environment variable which makes leak checking with glib almost
bearable.
Carl Worth [Tue, 20 Oct 2009 19:49:32 +0000 (12:49 -0700)]
database.cc: Document better pieces of glib that we're using.
Carl Worth [Tue, 20 Oct 2009 19:48:14 +0000 (12:48 -0700)]
message.c: Free leaked memory in notmuch_message object
We were careful to free this memory when we finished parsing the
headers, but we missed it for the case of closing the message
without ever parsing all of the headers.
Carl Worth [Tue, 20 Oct 2009 19:47:23 +0000 (12:47 -0700)]
notmuch: Use GNU libc getline() instead of glib GIOChannel
Less reliance on glib is always nice for our memory-leak testing
efforts.
Carl Worth [Tue, 20 Oct 2009 17:14:00 +0000 (10:14 -0700)]
notmuch_database_open: Fix error message for file-not-found.
I was incorrectly using the return value of stat (-1) instead of
errno (ENOENT) to try to construct the error message here.
Also, while we're here, reword the error message to not have
"stat" in it, which in spite of what a Unix programmer will
tell you, is not actually a word.
Carl Worth [Tue, 20 Oct 2009 17:07:11 +0000 (10:07 -0700)]
Add some explanation about NOTMUCH_BASE to setup_command.
Since we allow the user to enter a custom directory, we need to
let the user know how to make this persistent. Of course, a better
answer would be to take what the user entered and shove it into
a ~/.notmuch-config file or so, but for now this will have to do.
Carl Worth [Tue, 20 Oct 2009 16:56:25 +0000 (09:56 -0700)]
notmuch_database_create/open: Fix to handle NULL as documented.
When documenting these functions I described support for a
NOTMUCH_BASE environment variable to be consulted in the case
of a NULL path. Only, I had forgotten to actually write the
code.
This code exists now, with a new, exported function:
notmuch_database_default_path
Carl Worth [Tue, 20 Oct 2009 16:52:01 +0000 (09:52 -0700)]
notmuch_message_get_header: Fix bogus return of NULL header.
A simple bug meant that the correct value was being inserted into
the hash table, but a NULL value would be returned in some cases.
(If the value was already in the hash table at the beginning of
the call the the correct value would be returned, but if the
function had to parse to reach it then it would return NULL.)
This was tripping up the recently-added code to ignore messages
with NULL From:, Subject:, and To: headers, (which is fortunate
since otherwise the broken parsing might have stayed hidden for
longer).
Carl Worth [Tue, 20 Oct 2009 06:41:31 +0000 (23:41 -0700)]
notmuch: Revamp help message a bit.
The big update here is the addition of the dump and restore commands
which are next on my list. Also, I've now come up with a syntax for
documenting the arguments of sub-commands.
Carl Worth [Tue, 20 Oct 2009 06:08:49 +0000 (23:08 -0700)]
notmuch: Ignore files that don't look like email messages.
This is helpful for things like indexes that other mail programs
may have left around. It also means we can make the initial
instructions much easier, (the user need not worry about moving
away auxiliary files from some other email program).
Carl Worth [Tue, 20 Oct 2009 05:34:59 +0000 (22:34 -0700)]
Protect definition of _GNU_SOURCE.
I was getting a duplicate definition of this from somewhere, so
getting compiler warnings without this protection.
Carl Worth [Tue, 20 Oct 2009 05:24:28 +0000 (22:24 -0700)]
Remove test programs, xapian-dump and notmuch-index-message
These were just little tests while getting comfortable with
GMime and xapian. I'll likely use pieces of these as notmuch
continues, but for now let's not distract anyone looking
at notmuch with these.
And the code will live on in the history if I need to look
at it.
Carl Worth [Tue, 20 Oct 2009 01:30:48 +0000 (18:30 -0700)]
notmuch: Reword the progress report slightly.
I noticed this style during a recent Debian install and I liked
how much less busy it is compared to what we had before, (while
still telling the user everything she might want).
Carl Worth [Mon, 19 Oct 2009 23:38:44 +0000 (16:38 -0700)]
Rework message parsing to use getline rather than mmap.
The line-based parsing can be a bit awkward when wanting to peek
ahead, (say, for folded header values), but it's so convenient
to be able to trust that a string terminator exists on every
line so it cleans up the code considerably.
Carl Worth [Mon, 19 Oct 2009 20:48:13 +0000 (13:48 -0700)]
Don't hash headers we won't end up using.
Just saving a little work here.
Carl Worth [Mon, 19 Oct 2009 20:40:56 +0000 (13:40 -0700)]
Document which pieces of glib we're still using.
Looks like we can copy in a hash-table implementation, (from cairo,
say), and then a few _ascii_ functions from glib, (we'll need to
switch a few current uses if things like isspace, etc. to locale-
independent versions as well). So not too hard to free ourselves
of glib for now, (until we add GMime back in later, of course).
Carl Worth [Mon, 19 Oct 2009 20:35:29 +0000 (13:35 -0700)]
Hook up our fancy new notmuch_parse_date function.
With all the de-glib-ification out of the way, we can now use it
to allow for date-based sorting of Xapian search results.
Carl Worth [Mon, 19 Oct 2009 20:24:12 +0000 (13:24 -0700)]
notmuch_parse_date: Handle a NULL date string gracefully.
The obvious thing to do is to treat a missing date as the beginning
of time. Also, remove a useless cast from another return of 0.
Carl Worth [Mon, 19 Oct 2009 20:21:58 +0000 (13:21 -0700)]
date.c: Rename function to notmuch_parse_date
Now completing the process of making this function "our own".
The documentation is deleted here, because we already have
the documentation we want in notmuch-private.h.
Carl Worth [Mon, 19 Oct 2009 20:19:37 +0000 (13:19 -0700)]
date.c: Add hard-coded definition of HAVE_TIMEZONE
The original code expected this to be set by running configure.
We'll just manually set it here for now. This isn't as portable
as if we were doing some compile-time examination of the current
system, but I don't need portability now.
When someone comes along that wants to port notmuch to another
system, they will already have all the #ifdefs in place and
will simply need to add the appropriate machinery to set the
defines.
Carl Worth [Mon, 19 Oct 2009 20:14:37 +0000 (13:14 -0700)]
date.c: Don't use glib's slice allocator.
This change is gratuitous. For now, notmuch is still linking
against glib, so I don't have any requirement to remove this,
(unlike the last few changes where good taste really did
require the changes).
The motivation here is two-fold:
1. I'm considering switching away from all glib-based allocation
soon so that I can more easily verify that the memory management
is solid. I want valgrind to say "no leaks are possible" not
"there is tons of memory still allocated, but probably reachable
so who knows if there are leaks or not?". And glib seems to make
that impossible.
2. I don't think there's anything performance-sensitive about the
allocation here. (In fact, if there is, then the right answer
would be to do this parsing without any allocation whatsoever.)
Carl Worth [Mon, 19 Oct 2009 20:11:57 +0000 (13:11 -0700)]
date.c: Remove occurrences of gboolean.
While this is surely one of the most innocent typedefs, it still
annoys me to have basic types like 'int' re-defined like this.
It just makes it harder to copy the code between projects, with
very little benefit in readability.
For readability, predicate functions and variables should be
obviously Boolean-natured by their actual *names*.
Carl Worth [Mon, 19 Oct 2009 20:09:19 +0000 (13:09 -0700)]
date.c: Remove all occurrences of g_return_val_if_fail
That's got to be one of the hardest macro names to read, ever,
(it's phrased with an implicit negative in the condition,
rather than something simple like "assert").
Plus, it's evil, since it's a macro with a return in it.
And finally, it's actually *longer* than just typing "if"
and "return". So what's the point of this ugly idiom?
Carl Worth [Mon, 19 Oct 2009 20:07:58 +0000 (13:07 -0700)]
date.c: Keep the comments clean.
Never know when the children might be reading over my shoulder,
for example. :-)
Carl Worth [Mon, 19 Oct 2009 20:06:55 +0000 (13:06 -0700)]
date.c: Change headers/defines t owork within notmuch.
We can't rely on any gmime-internal headers, (and fortunately we
don't need to). We also aren't burdened with any autconf machinery
so don't reference any of that.
Carl Worth [Mon, 19 Oct 2009 20:04:59 +0000 (13:04 -0700)]
date.c: Remove a bunch of undesired code.
We're only interested in the date-parsing code here.
Carl Worth [Mon, 19 Oct 2009 20:02:17 +0000 (13:02 -0700)]
date.c: Convert from LGPL-2+ to GPL-3+
As authorized by LGPL-2 term (3).
Carl Worth [Mon, 19 Oct 2009 19:57:38 +0000 (12:57 -0700)]
date.c: Add new file directly from gmime2.4-2.4.6/gmime/gmime-utils.c
We're sucking in one gmime implementation file just to get the
piece that parses an RFC 822 date, because I don't want to go
through the pain of replicating that.
Carl Worth [Mon, 19 Oct 2009 19:54:40 +0000 (12:54 -0700)]
notmuch: Switch from gmime to custom, ad-hoc parsing of headers.
Since we're currently just trying to stitch together In-Reply-To
and References headers we don't need that much sophistication.
It's when we later add full-text searching that GMime will be
useful.
So for now, even though my own code here is surely very buggy
compared to GMime it's also a lot faster. And speed is what
we're after for the initial index creation.
Carl Worth [Mon, 19 Oct 2009 19:52:46 +0000 (12:52 -0700)]
notmuch: Ignore .notmuch when counting files.
We were correctly ignoring this when adding files, but not when
doing the initial count. Clearly we need better code sharing
here.
Carl Worth [Mon, 19 Oct 2009 03:56:30 +0000 (20:56 -0700)]
notmuch: Start actually adding messages to the index.
This is the beginning of the notmuch library as well, with its
interface in notmuch.h. So far we've got create, open, close, and
add_message (all with a notmuch_database prefix).
The current add_message function has already been whittled down from
what we have in notmuch-index-message to add only references,
message-id, and thread-id to the index, (that is---just enough to do
thread-linkage but nothing for full-text searching).
The concept here is to do something quickly so that the user can get
some data into notmuch and start using it. (The most interesting stuff
is then thread-linkage and labels like inbox and unread.) We can
defer the full-text indexing of the body of the messages for later,
(such as in the background while the user is reading mail).
The initial thread-stitching step is still slower than I would like.
We may have to stop using libgmime for this step as its overhead is
not worth it for the simple case of just parsing the message-id,
references, and in-reply-to headers.
Carl Worth [Mon, 19 Oct 2009 03:49:43 +0000 (20:49 -0700)]
xapian-dump: Rewrite to generate C code as output.
This was for some time testing, (to see how fast xapian could be
if we were strictly adding documents and not doing any other IO
or computation). The answer is that xapian is quite fast, (on
the order of 1000 documents per second).
Carl Worth [Sat, 17 Oct 2009 15:26:58 +0000 (08:26 -0700)]
Start a new top-level executable: notmuch.
Of course, there's not much that this program does yet. It's got
some structure for some sub-commands that don't do anything. And
it has a main command that prints some explanatory text and then
counts all the regular files in your mail archive.
Carl Worth [Fri, 16 Oct 2009 20:42:42 +0000 (13:42 -0700)]
Fix more memory leaks.
These were more significant than the previous leak because these were
in the loop and leaking memory for every message being parsed. It
turns out that g_hash_table_new should probably be named
g_hash_table_new_and_leak_memory_please. The actually useful function
is g_hash_table_new_full which lets us pass a free function, (to free
keys when inserting duplicates into the hash table). And after all,
weeding out duplicates is the only reason we are using this hash table
in the first place.
It almost goes without saying, valgrind found these leaks.
Carl Worth [Fri, 16 Oct 2009 20:41:37 +0000 (13:41 -0700)]
Fix a one-time memory leak.
This was a single object in main outside any loops, so there was
no impact on performance or anything, but obviously we still want
to patch this.
Of course, valgrind gets the credit for seeing this.
Carl Worth [Fri, 16 Oct 2009 20:38:43 +0000 (13:38 -0700)]
Avoid reading a byte just before our allocated buffer.
When looking for a trailing ':' to introduce a quotation we peek at
the last character before a newline. But for blank lines, that's not
where we want to look. And when the first line in our buffer is a
blank line, we're underrunning our buffer. The fix is easy---just
bail early on blank lines since they have no terms anyway.
Thanks to valgrind for pointing out this error.
Carl Worth [Fri, 16 Oct 2009 20:33:39 +0000 (13:33 -0700)]
Generate random thread IDs instead of using an arbitrary Message-ID.
Previously, we used as the thread-id the message-id of the first
message in the thread that we happened to find. In fact, this is a
totally arbitrary identifier, so it might as well be random. And an
advantage of actually using a random identifier is that we now have
fixed-length thead identifiers, (and the way is open to even allow
abbreviated identifiers like git does---though we're less likely to
show these identifiers to actual users).
Carl Worth [Thu, 15 Oct 2009 16:04:31 +0000 (09:04 -0700)]
Change progress report to show "instantaneous" rate. Also print total time.
Instead of always showing the overall rate, we wait until the end
to show that. Then, on incremental updates we show the rate over the
last increment. This makes it much easier to actually watch what's
happening, (and it's easy to see the efect of xapian's internal
10,000 document flush).
Keith Packard [Thu, 15 Oct 2009 04:46:54 +0000 (21:46 -0700)]
Protect against missing message id while indexing files
Keith Packard [Thu, 15 Oct 2009 04:17:39 +0000 (21:17 -0700)]
Walk address groups and parse each address separately
Signed-off-by: Keith Packard <keithp@keithp.com>
Carl Worth [Thu, 15 Oct 2009 00:26:28 +0000 (17:26 -0700)]
Reduce the verbosity of the progress indicator.
It's fast enough that we can wait for 1000 messages before updating.
Carl Worth [Thu, 15 Oct 2009 00:25:20 +0000 (17:25 -0700)]
Add support for message-part mime parts.
We could (and probably should) reparse and index all the headers from
the embedded message, but I'm not choosing to do that now---I'm just
indexing the body of the embedded message.
Carl Worth [Thu, 15 Oct 2009 00:24:28 +0000 (17:24 -0700)]
Avoid segfault on message with no subject.
It's fun how turning a program loose on 500,000 messages will find
lots of littel corner cases.
Carl Worth [Thu, 15 Oct 2009 00:10:14 +0000 (17:10 -0700)]
Add some sort of progress indicator.
It's nice to let the user know that something is happening.
Carl Worth [Thu, 15 Oct 2009 00:09:56 +0000 (17:09 -0700)]
Avoid complaints about messages with empty mime parts.
Carl Worth [Thu, 15 Oct 2009 00:09:30 +0000 (17:09 -0700)]
Avoid complaints about empty address lists.
Carl Worth [Wed, 14 Oct 2009 23:49:26 +0000 (16:49 -0700)]
Document the little details separating the sup and notmuch indexes.
As can be seen here, there are not a lot of differences. I've verified
this by using sup-sync to import a month of mail from the sup mailing
list, and comparing the database term-by-term, value-by-value, and
data-by-data with that created by notmuch. There are no differences
other than those documented here.
Carl Worth [Wed, 14 Oct 2009 23:38:21 +0000 (16:38 -0700)]
Avoid trimming initial whitespace while looking for signatures.
I ran into a message with an indented stack trace that my indexer
was mistaking for a signature.
Carl Worth [Wed, 14 Oct 2009 23:35:03 +0000 (16:35 -0700)]
Index an attachment's filename extension as well.
I hadn't realized that sup used a special term for this. But there
you go.
Carl Worth [Wed, 14 Oct 2009 23:28:07 +0000 (16:28 -0700)]
Index the filename of any attachment.
Carl Worth [Wed, 14 Oct 2009 23:20:45 +0000 (16:20 -0700)]
[sup-compat] Don't index mime parts with content-disposition of attachment
Here's another change which I'm making for sup compatibility against
my better judgment. It seems that sup never indexes content from
mime parts with content-disposition of attachment. But these
attachments are often very indexable, (for example, the first one
I encountered was a small shell script).
So I'll have to think a bit about whether or not I want to revert
this commit. To do this properly we would really want to distinguish
between attachments that are indexable, (such as text), and those
that aren't, (such as binaries). I know the mime-type alone isn't
alwas sufficient here as even this little plaintext shell script
was attached as octet-stream.
And if we wanted to get really fancy we could run things like antiword
to generate text from non-text attachments and index their output.
Carl Worth [Wed, 14 Oct 2009 23:18:17 +0000 (16:18 -0700)]
Add label "attachment" when an attachment is seen.
Carl Worth [Wed, 14 Oct 2009 23:04:25 +0000 (16:04 -0700)]
Split thread_id value on commas before inserting into hash.
One thread_id value may have multiple thread IDs in it so we need
to separate them out before inserting into our hash.
Carl Worth [Wed, 14 Oct 2009 22:55:07 +0000 (15:55 -0700)]
Add missing null terminator before using byte-array contents as string.
Thanks to valgrind for spotting this one.
Carl Worth [Wed, 14 Oct 2009 22:33:16 +0000 (15:33 -0700)]
notmuch-index-message: Add explicit support for multipart mime.
Instead of using the recursive "foreach" method, we implement our
own recursive function. This allows us to ignore the signature
component of a multipart/signed message, (which we certainly
don't need to index).
Carl Worth [Wed, 14 Oct 2009 21:06:06 +0000 (14:06 -0700)]
[sup-compat] Don't trim trailing whitespace on line introducing quotation.
Ignoring this whitespace seems like a good idea to me, but it's
interfering with my comparisons with sup since sup doesn't do this.
This might be a commit worth dropping in the future since it exists
only for pedantic consistency with sup and not for any reason of its
own.
Carl Worth [Wed, 14 Oct 2009 21:00:10 +0000 (14:00 -0700)]
notmuch-index-message: Fix handling of thread_id terms.
We now emit one term per thread_id, rather than the comma-separated
super-term we were doing previously.
Carl Worth [Wed, 14 Oct 2009 20:46:01 +0000 (13:46 -0700)]
notmuch-index-message: Use local-part of email addres in lieu of name.
If there's no name given, take the portion of the email addres
before the '@' sign.
One step closer to matching sup's terms in the database.
Carl Worth [Wed, 14 Oct 2009 20:30:33 +0000 (13:30 -0700)]
Use gmime's own reference-parsing code.
Here's another instance where I "knew" gmime must have support for
some functionality, but not finding it, I rolled my own. Now that
I found g_mime_references_decode I'm glad to drop my ugly code.
Carl Worth [Wed, 14 Oct 2009 19:48:58 +0000 (12:48 -0700)]
notmuch-index-message: Correctly parse and index encoded mime parts.
This cleans up some old code that was very ugly, (separately opening
the mail file and seeking to the end of the headers to parse the
body). I knew gmime must have had support for transparently decoding
mime content, but I just couldn't find it previously.
Note: Multipart and MultipartSigned parts are not handled yet.
Things are quite happy now. The few differences I see with sup are:
1. sup forces email address domains to lowercase, (I don't think I care)
2. sup and notmuch disagree on ordering of multiple thread_id values
(another thing that's of no concern)
We are still doing one thing wrong when a message belongs to multiple
threads. We've got a nice comma-separated thread-value just like sup,
but then we're also putting in a comma-separated thread-term where
sup does multiple thread terms. That should be an easy fix.
Beyond that, sup and notmuch are still disagreeing on the term lists
for some messages, (I think attachment vs. inline content-disposition
is at least one piece of this). But there are likley still differences
in the heuristics for which chunks of the message body to index. I'll
be looking into this more.
Carl Worth [Wed, 14 Oct 2009 17:34:05 +0000 (10:34 -0700)]
notmuch-index-message: Lookup children for thread_id as well.
This provides the thread_id linkage for when a child message is
indexed before the parent.
Carl Worth [Wed, 14 Oct 2009 16:57:59 +0000 (09:57 -0700)]
notmuch-index-message: Use more meaningful variable names.
The abuse of the generic "value" name was getting very hard to read.
Carl Worth [Wed, 14 Oct 2009 16:54:05 +0000 (09:54 -0700)]
notmuch-index-message: Start generating correct thread_id values.
Currently we're looking up all parents (based on In-reply-to and
References header) and using the list of all thread_id values
from those as our thread_id value. We're missing one step which
sup does which is to also look up any children in the database
that have reference our message ID. So we'll need to do that next.
Carl Worth [Wed, 14 Oct 2009 15:02:27 +0000 (08:02 -0700)]
Factor out parsing of reference-header values and pickup In-reply-to.
This is in preparation for doing a couple of passes over the references,
(one to add terms to the database, and a second to find the thread_id).
We also now parse the In-reply-to header which we were missing before.
We treat it identically to the References header.
Carl Worth [Wed, 14 Oct 2009 14:24:28 +0000 (07:24 -0700)]
notmuch-index-message: Ignore more signature patterns.
Getting more sup-compatible all the time.
Carl Worth [Wed, 14 Oct 2009 04:13:23 +0000 (21:13 -0700)]
notmuch-index-message: Avoid crashing when a message has no references.
It's obviously an innocent-enough message, and the right thing is
so easy to do.
Carl Worth [Wed, 14 Oct 2009 04:11:54 +0000 (21:11 -0700)]
notmuch-index-message: Read message filenames from stdin
This allows for indexing an arbitrary number of messages with a
single invocation rather than just a single message on the command
line.
Carl Worth [Wed, 14 Oct 2009 03:42:08 +0000 (20:42 -0700)]
Move index_file out from main() into its own function.
This is a step toward having a program that will index many messages
with a single invocation.
Carl Worth [Wed, 14 Oct 2009 01:43:26 +0000 (18:43 -0700)]
notmuch-index-message: Index References as well.
We're basically matching sup now! (As long as one uses sup with my
special notmuch_index.rb file).