Commit graph

79 commits

Author SHA1 Message Date
Carl Worth
3dbef312fb lib: Audit calls to notmuch_message_get_header to handle NULL return
Sebastian Spaeth reported [*] a segfault within libnotmuch when
running notmuch operations while an asyncronous offlineimap job had
removed some files from the mail store. Avoid this by handling all
cases where notmuch_message_get_header could return NULL.

[*] See message id:87d3xqti3o.fsf@SSpaeth.de on notmuch@notmuchmail.org
2010-04-24 06:50:04 -07:00
Carl Worth
7c421b87b0 lib: Simplify code to set subject from matched message.
Simply moving the code from _add_matched_message to a new
_set_subject_from_message function.
2010-04-24 06:50:04 -07:00
Carl Worth
21965718a5 Revert "thread: Simplify code for assigning the subject."
This reverts commit 36e4459a32.

With the two previous reverts, this fixes the recent message-sorting
regression, so the test suite now passes again.
2010-04-22 14:01:41 -07:00
Carl Worth
a109966080 Revert "thread: Fix sort of search when constructing threads."
This reverts commit f43990ce13.
2010-04-22 14:00:33 -07:00
Carl Worth
6a0cba4ae0 Revert "thread: Removed unsed sort argument from _thread_add_matched_message"
This reverts commit 7fb56f9dc5.
2010-04-22 14:00:17 -07:00
Carl Worth
7fb56f9dc5 thread: Removed unsed sort argument from _thread_add_matched_message
The reworked solution for naming a thread based on the subject of
oldest/newest matching message no longer needs this argument.
2010-04-21 17:05:16 -07:00
Carl Worth
f43990ce13 thread: Fix sort of search when constructing threads.
The thread-naming feature depends on the matched messages being passed
down in a precise order, (the order of the top-level search). We fix
the feature by passing that sort order down.
2010-04-21 15:52:28 -07:00
Carl Worth
36e4459a32 thread: Simplify code for assigning the subject.
We know that matched messages are always added in order, so we can
always just grab the subject from the first message. This is the same
approach that was used previously in _thread_add_message. That is, the
recent feature of renaming a thread based on the subject of the
"first" matched message is as simple as moving the subject assignment
from _thread_add_message to _thread_add_matched_message.
2010-04-21 15:06:02 -07:00
Jesse Rosenthal
4971b85641 Name thread based on matching msgs instead of first msg.
At the moment all threads are named based on the name of the first message
in the thread. However, this can cause problems if people either start
new threads by replying-all (as unfortunately, many out there do) or
change the subject of their mails to reflect a shift in a thread on a
list.

This patch names threads based on (a) matches for the query, and (b) the
search order. If the search order is oldest-first (as in the default
inbox) it chooses the oldest matching message as the subject. If the
search order is newest-first it chooses the newest one.

Reply prefixes ("Re: ", "Aw: ", "Sv: ", "Vs: ") are ignored
(case-insensitively) so a Re: won't change the subject.

Note that this adds a "sort" argument to _notmuch_thread_create and
_thread_add_matched_message, so that when constructing the thread we can
be aware of the sort order.

Signed-off-by: Jesse Rosenthal <jrosenthal@jhu.edu>
2010-04-21 14:56:53 -07:00
Carl Worth
c48dcc302c lib: search_threads: Fix nested search to handle original search of "*"
When constructing a thread, we usually run a nested query to find all
messages in the thread that match the original search string. However,
we need to have special-case handling of an original search string of
"*" now that that is a supported means of specifying all messages.

The special-case ends up bein quite simple---we do less work, (just
skipping the nested search since we know that all messages must
match). I had been wanting to write this identical code to more
efficiently handle "notmuch search thread:<foo>" which was previously
running two identical searches. So that case is now more efficient as
well.
2010-04-15 14:54:40 -07:00
Dirk Hohndel
4563f669ca fix obvious cut and paste error
the wrong variable is checked for success of an allocation

Signed-off-by: Dirk Hohndel <hohndel@infradead.org>
2010-04-06 18:55:56 -07:00
Carl Worth
b957a1b029 emacs: Fix the notmuch-search-authors-width variable.
This variable existed previously, but wasn't actually used for anything.
2010-03-31 13:32:00 -07:00
Carl Worth
4e5d2f22db 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
'move_to_previous'.
2010-03-09 09:22:29 -08:00
Bart Trojanowski
6da6566576 correct message flag enum value so that it matches the type
As per Carl's request, this patch corrects the only value defined under
the notmuch_message_flag_t enum typedef to match the name of the type.

Signed-off-by: Bart Trojanowski <bart@jukie.net>
2009-11-27 20:50:59 -08:00
Bart Trojanowski
bede40987a have _notmuch_thread_create mark which messages matched the query
When _notmuch_thread_create() is given a query string, it can return more
messages than just those matching the query.  To distinguish those that
matched the query expression, the MATCHING_SEARCH flag is set
appropriately.

Signed-off-by: Bart Trojanowski <bart@jukie.net>
2009-11-27 17:07:06 -08:00
Carl Worth
94eb9aacd4 lib/query: Drop the first and max_messages arguments from search_messages.
These only existed to support the chunky-searching hack, but that
was recently dropped anyway.
2009-11-23 20:25:13 -08:00
Ingmar Vanhassel
2ce25b93a7 Typsos 2009-11-18 03:21:36 -08:00
Carl Worth
3334865725 notmuch search: Change default search order to be newest messages first.
This is what most people want for a _search_ command. It's often
different for actually reading mail in an inbox, (where it makes more
sense to have results displayed in chronological order), but in such a
case, ther user is likely using an interface that can simply pass the
--sort=oldest-first option to "notmuch search".

Here we're also change the sort enum from NOTMUCH_SORT_DATE and
NOTMUCH_SORT_DATE_REVERSE to NOTMUCH_SORT_OLDEST_FIRST and
NOTMUCH_SORT_NEWEST_FIRST. Similarly we replace the --reverse option
to "notmuch search" with two options: --sort=oldest-first and
--sort=newest-first.

Finally, these changes are all tracked in the emacs interface, (which
has no change in its behavior).
2009-11-17 20:58:30 -08:00
Keith Packard
d025e89ac7 Fix "too many open files" bug by closing message files when done with them.
The message file header parsing code parses only enough of the file to
find the desired header fields, then it leaves the file open until the
next header parsing call or when the message is no longer in use. If a
large number of messages end up being active, this will quickly run
out of file descriptors.

Here, we add support to explicitly close the message file within a
message, (_notmuch_message_close) and call that from thread
construction code.

Signed-off-by: Keith Packard <keithp@keithp.com>

Edited-by: Carl Worth <cworth@cworth.org>:

Many portions of Keith's original patch have since been solved other
ways, (such as the code that changed the handling of the In-Reply-To
header). So the final version is clean enough that I think even Keith
would be happy to have his name on it.
2009-11-17 18:37:13 -08:00
Carl Worth
387828c435 get_in_reply_to: Implement via the database, not by opening mail file.
This reduces our reliance on open message_file objects, (so is a step
toward fixing the "too many open files" bug), but more importantly, it
means we don't load a self-referencing in-reply-to header, (since we
weed those out before adding any replyto terms to the database).
2009-11-17 17:40:19 -08:00
Carl Worth
933caf814f notmuch show: Implement proper thread ordering/nesting of messages.
We now properly analyze the in-reply-to headers to create a proper
tree representing the actual thread and present the messages in this
correct thread order. Also, there's a new "depth:" value added to the
"message{" header so that clients can format the thread as desired,
(such as by indenting replies).
2009-11-15 20:41:45 -08:00
Carl Worth
54be14098b _thread_add_messages: Remove unused variable.
I'm not sure how I let this warning go by unfixed for a while. Fix
it now.
2009-11-15 20:21:12 -08:00
Carl Worth
ed2643333c notmuch search: Fix thread dates to come only from matched messages.
We were properly sorting the threads based only on matched messages,
but we were displaying the date based on the total messages in the
thread, which led to inconsistent and very confusing results.
2009-11-12 23:10:04 -08:00
Carl Worth
f7b49d658a notmuch search: Add support for a --reverse option to reverse sort order.
Note that the difference between thread results in date order and
thread results in reverse-date order is not simply a matter of
reversing the final results. When sorting in date order, the threads
are sorted by the oldest message in the thread. When sorting in
reverse-date order, the threads are sorted by the newest message in
the thread.

This difference means that we might want an explicit option in the
interface to reverse the order, (even though the default will be to
display the inbox in date order and global searches in reverse-date
order).
2009-11-12 22:35:16 -08:00
Carl Worth
c168e24174 notmuch search: Print the number of matched/total messages for each thread.
Note that we don't print the number of *unread* messages, but instead
the number of messages that matched the search terms. This is in
keeping with our philosophy that the inbox is nothing more than a
search view. If we search for messages with an inbox tag, then that's
what we'll get a count of. (And if somebody does want to see unread
counts, then they can search for the "unread" tag.)

Getting the number of matched messages is really nice when doing
historical searches. For example in a search like:

	notmuch search tag:sent

(where the "sent" tag has been applied to all messages originating
from the user's email address)---here it's really nice to be able to
see a thread where the user just mentioned one point [1/13] vs. really
getting involved in the discussion [10/29].
2009-11-12 22:01:44 -08:00
Carl Worth
c3c0966521 notmuch search: Avoid printing duplicate author names.
We add a hash to the thread object so that we can detect author names
that have already been added to the list, and avoid adding them
redundantly. This avoids the giant chain of "bugzilla-daemon,
bugzilla-daemon, bugzilla-daemon, bugzilla-daemon, ..." author lists
that we would get otherwise, for example.
2009-11-12 21:19:42 -08:00
Carl Worth
ec6d3506db notmuch search: Print all authors contributing to a thread.
We've now expanded the notmuch_thread_create function to fire off a
secondary database query to find all the messages that belong to this
particular thread. This allows us to now have the complete authors'
list for the thread, and will also make it trivial to print accurate
message counts for threads in the future.
2009-11-12 21:09:54 -08:00
Carl Worth
2f4c587474 notmuch search: Print the names of author of matched emails.
It's important to have the names present for determining whether a
thread is worth reading or not. We may want to think about
abbreviating the list somehow if it is excessively long (or redundant
as in bugzilla-daemon, bugzilla-daemon, bugzilla-daemon, etc.).
2009-11-12 09:59:47 -08:00
Carl Worth
1465493210 libify: Move library sources down into lib directory.
A "make" invocation still works from the top-level, but not from
down inside the lib directory yet.
2009-11-09 16:24:03 -08:00
Renamed from thread.cc (Browse further)