aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/thread.cc
Commit message (Collapse)AuthorAge
* lib: Start all function names in notmuch-private.h withGravatar Charles Celerier2014-07-13
| | | | | | | | | | | | | | | | | As noted in devel/STYLE, every private library function should start with _notmuch. This patch corrects function naming that did not adhere to this style in lib/notmuch-private.h. In particular, the old function names that now begin with _notmuch are notmuch_sha1_of_file notmuch_sha1_of_string notmuch_message_file_close notmuch_message_file_get_header notmuch_message_file_open notmuch_message_get_author notmuch_message_set_author Signed-off-by: Charles Celerier <cceleri@cs.stanford.edu>
* lib: fix clang compiler warningGravatar Jani Nikula2014-01-18
| | | | | | With some combination of clang and talloc, not using the return value of talloc_steal() produces a warning. Ignore it, as talloc_steal() has no failure modes per documentation.
* lib: add NOTMUCH_EXCLUDE_FLAG to notmuch_exclude_tGravatar Mark Walters2013-06-24
| | | | | | | | | | | | | | | | | Add NOTMUCH_EXCLUDE_FLAG to notmuch_exclude_t so that it can cover all four values of search --exclude in the cli. Previously the way to avoid any message being marked excluded was to pass in an empty list of excluded tags: since we now have an explicit option we might as well honour it. The enum is in a slightly strange order as the existing FALSE/TRUE options correspond to the new NOTMUCH_EXCLUDE_FLAG/NOTMUCH_EXCLUDE_TRUE options so this means we do not need to bump the version number. Indeed, an example of this is that the cli count and show still use FALSE/TRUE and still work.
* lib: add --exclude=all optionGravatar Mark Walters2013-05-13
| | | | | | Adds a exclude all option to the lib which means that excluded messages are completely ignored (as if they had actually been deleted).
* lib: Fix name reordering to handle commas without spacesGravatar Adam Wolfe Gordon2013-03-29
| | | | | | | | Notmuch automatically re-orders names of the format "Last, First" to "First Last" when the associated email address is First.Last@example.com. But, if a name is of the format "Last,First" then notmuch will format the name as "irst Last". Handle any number of spaces after the comma, including none.
* lib: Add an iterator over all messages in a threadGravatar Austin Clements2013-02-18
| | | | | | | | Previously, getting the list of all messages in a thread required recursively traversing the thread's message hierarchy, which was both difficult and resulted in messages being out of order. This adds a public function to retrieve an iterator over all of the messages in a thread in oldest-first order.
* lib: Separate list of all messages from top-level messagesGravatar Austin Clements2013-02-18
| | | | | | | | | | | | Previously, thread.cc built up a list of all messages, then proceeded to tear it apart to transform it into a list of top-level messages. Now we simply build a new list of top-level messages. This simplifies the interface to _notmuch_message_add_reply, eliminates the pointer acrobatics from _resolve_thread_relationships, and will enable us to do things with the list of all messages in the following patches.
* lib: Clean up error handling in _notmuch_thread_createGravatar Austin Clements2013-02-18
| | | | | | | Previously, there were various opportunities for memory leaks in the error-handling paths of this function. Use a local talloc context and some reparenting to make eliminate these leaks, while keeping the control flow simple.
* lib: Add the exclude flag to notmuch_query_search_threadsGravatar Mark Walters2012-03-02
| | | | | | | | | | | Add the NOTMUCH_MESSAGE_FLAG_EXCLUDED flag to notmuch_query_search_threads. Implemented by inspecting the tags directly in _notmuch_thread_create/_thread_add_message rather than as a Xapian query for speed reasons. Note notmuch_thread_get_matched_messages now returns the number of non-excluded matching messages. This API is not totally desirable but fixing it means breaking binary compatibility so we delay that.
* Mark some structures in the library interface with visibility=default attribute.Gravatar Carl Worth2011-05-11
| | | | | | | | | | | | | As of gcc 4.6, there are new warnings from -Wattributes along the lines of: warning: ‘_notmuch_messages’ declared with greater visibility than the type of its field ‘_notmuch_messages::iterator’ [-Wattributes] To squelch these, we decorate all such containing structs with __attribute__((visibility("default"))). We take care to let only the C++ compiler see this, (since the C compiler would otherwise warn about ignored visibility attributes on types).
* Implement an internal generic string list and use it.Gravatar Austin Clements2011-03-21
| | | | | | | | | | | | This replaces the guts of the filename list and tag list, making those interfaces simple iterators over the generic string list. The directory, message filename, and tags-related code now build generic string lists and then wraps them in specific iterators. The real wins come in later patches, when we use these for even more generic functionality. As a nice side-effect, this also eliminates the annoying dependency on GList in the tag list.
* notmuch search: Clean up some memory leaks during search loop.Gravatar Carl Worth2011-01-26
| | | | | | | | | | With talloc, we were already freeing all memory by the time we exited the loop, but that didn't help with excess use of memory inside the loop, (which was mostly from tallocing some objects with the incorrect parent). Thanks to Andrew Tridgell for sitting next to me and teaching me to use talloc_report_full to find these leaks.
* Optimize thread search using matched docid sets.Gravatar Austin Clements2010-12-07
| | | | | | | | | | | | | | | | | This reduces thread search's 1+2t Xapian queries (where t is the number of matched threads) to 1+t queries and constructs exactly one notmuch_message_t for each message instead of 2 to 3. notmuch_query_search_threads eagerly fetches the docids of all messages matching the user query instead of lazily constructing message objects and fetching thread ID's from term lists. _notmuch_thread_create takes a seed docid and the set of all matched docids and uses a single Xapian query to expand this docid to its containing thread, using the matched docid set to determine which messages in the thread match the user query instead of using a second Xapian query. This reduces the amount of time required to load my inbox from 4.523 seconds to 3.025 seconds (1.5X faster).
* notmuch search: Fix to display authors in date order.Gravatar Carl Worth2010-12-07
| | | | | Previously, the authors of the thread were displayed in reverse-chronological order, which was fairly confusing.
* lib: Set thread subject at the same time as setting thread->{oldest,newest}Gravatar Carl Worth2010-12-07
| | | | | | | | | We really want to change the thread subject at the same time we set the date, (if the sort order indicates this is necessary). The previous code for setting the thread subject was sensitive on the query sort when adding matching messages. An independent bug fix is about to change that query sort order, so we remove the dependency on it here.
* lib: Eliminate some redundant includes of xapian.hGravatar Carl Worth2010-11-01
| | | | | Most files including this already include database-private.h which includes xapian.h already.
* lib: Add some missing static qualifiers.Gravatar Carl Worth2010-11-01
| | | | | | These various functions and data are all used only locally, so should be marked static. Ensuring we get these right will avoid us accidentally leaking unintended symbols through the library interface.
* Fix SEGV in _thread_cleanup_author if author ends with ', 'Gravatar Dirk Hohndel2010-04-27
| | | | | | | | | | Admittedly, an author name ending in ',' guarantees this is spam, and indeed this was triggered by a spam email, but that doesn't mean we shouldn't handle this case correctly. We now check that there is actually a component of the name (presumably the first name) after the comma in the author name. Signed-off-by: Dirk Hohndel <hohndel@infradead.org>
* lib: Re-implement moving of thread authors.Gravatar Carl Worth2010-04-27
| | | | | | | | | | | | | Just before releasing 0.3 we received reports of crashes that were bisected to the commit adding thread-author moving. Sure enough, valgrind pointed to buffer overruns in _thread_move_matched_author. Rather than trying to make sense of all the by strncpy, strchr, +1, and +2 of that code, I reimplemented thread-author ordering with a pair of hash tables and an array. Valgrind is at least happy now on the test cases it was complaining about previously.
* Simple attempt to display author names in a friendlier wayGravatar Dirk Hohndel2010-04-26
| | | | | | | | | | | | This patch only addresses the typical Outlook/Exchange case where we have "Last, First" <first.last@company.com> or "Last, First MI" <first.mi.last@company.com>. In the future we should be more fexible as to the formats we recognize, but for now we address this one as it is the Exchange default setting and therefore the most common one. Signed-off-by: Dirk Hohndel <hohndel@infradead.org>
* Reorder displayed names of thread authorsGravatar Dirk Hohndel2010-04-26
| | | | | | | | | | | | | | | | | | When displaying threads as result of a search it makes sense to list those authors first who match the search. The matching authors are separated from the non-matching ones with a '|' instead of a ',' Imagine the default "+inbox" query. Those mails in the thread that match the query are actually "new" (whatever that means). And some people seem to think that it would be much better to see those author names first. For example, imagine a long and drawn out thread that once was started by me; you have long read the older part of the thread and removed the inbox tag. Whenever a new email comes in on this thread, prior to this patch the author column in the search display will first show "Dirk Hohndel" - I think it should first show the actual author(s) of the new mail(s). Signed-off-by: Dirk Hohndel <hohndel@infradead.org>
* lib: Audit calls to notmuch_message_get_header to handle NULL returnGravatar Carl Worth2010-04-24
| | | | | | | | | 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
* lib: Simplify code to set subject from matched message.Gravatar Carl Worth2010-04-24
| | | | | Simply moving the code from _add_matched_message to a new _set_subject_from_message function.
* Revert "thread: Simplify code for assigning the subject."Gravatar Carl Worth2010-04-22
| | | | | | | This reverts commit 36e4459a328b8449b3e9d510be81a332a9b35aaa. With the two previous reverts, this fixes the recent message-sorting regression, so the test suite now passes again.
* Revert "thread: Fix sort of search when constructing threads."Gravatar Carl Worth2010-04-22
| | | | This reverts commit f43990ce134d838cdb2cdd5d0752a602e81cfdd9.
* Revert "thread: Removed unsed sort argument from _thread_add_matched_message"Gravatar Carl Worth2010-04-22
| | | | This reverts commit 7fb56f9dc5d8e66f717f5e48ecbfbc11c8190182.
* thread: Removed unsed sort argument from _thread_add_matched_messageGravatar Carl Worth2010-04-21
| | | | | The reworked solution for naming a thread based on the subject of oldest/newest matching message no longer needs this argument.
* thread: Fix sort of search when constructing threads.Gravatar Carl Worth2010-04-21
| | | | | | 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.
* thread: Simplify code for assigning the subject.Gravatar Carl Worth2010-04-21
| | | | | | | | | 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.
* Name thread based on matching msgs instead of first msg.Gravatar Jesse Rosenthal2010-04-21
| | | | | | | | | | | | | | | | | | | | | | 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>
* lib: search_threads: Fix nested search to handle original search of "*"Gravatar Carl Worth2010-04-15
| | | | | | | | | | | | | | 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.
* fix obvious cut and paste errorGravatar Dirk Hohndel2010-04-06
| | | | | | the wrong variable is checked for success of an allocation Signed-off-by: Dirk Hohndel <hohndel@infradead.org>
* emacs: Fix the notmuch-search-authors-width variable.Gravatar Carl Worth2010-03-31
| | | | This variable existed previously, but wasn't actually used for anything.
* lib: Rename iterator functions to prepare for reverse iteration.Gravatar Carl Worth2010-03-09
| | | | | | | | 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'.
* correct message flag enum value so that it matches the typeGravatar Bart Trojanowski2009-11-27
| | | | | | | 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>
* have _notmuch_thread_create mark which messages matched the queryGravatar Bart Trojanowski2009-11-27
| | | | | | | | | 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>
* lib/query: Drop the first and max_messages arguments from search_messages.Gravatar Carl Worth2009-11-23
| | | | | These only existed to support the chunky-searching hack, but that was recently dropped anyway.
* TypsosGravatar Ingmar Vanhassel2009-11-18
|
* notmuch search: Change default search order to be newest messages first.Gravatar Carl Worth2009-11-17
| | | | | | | | | | | | | | | | | 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).
* Fix "too many open files" bug by closing message files when done with them.Gravatar Keith Packard2009-11-17
| | | | | | | | | | | | | | | | | | | | | 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.
* get_in_reply_to: Implement via the database, not by opening mail file.Gravatar Carl Worth2009-11-17
| | | | | | | 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).
* notmuch show: Implement proper thread ordering/nesting of messages.Gravatar Carl Worth2009-11-15
| | | | | | | | 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).
* _thread_add_messages: Remove unused variable.Gravatar Carl Worth2009-11-15
| | | | | I'm not sure how I let this warning go by unfixed for a while. Fix it now.
* notmuch search: Fix thread dates to come only from matched messages.Gravatar Carl Worth2009-11-12
| | | | | | 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.
* notmuch search: Add support for a --reverse option to reverse sort order.Gravatar Carl Worth2009-11-12
| | | | | | | | | | | | | | 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).
* notmuch search: Print the number of matched/total messages for each thread.Gravatar Carl Worth2009-11-12
| | | | | | | | | | | | | | | | | | | 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].
* notmuch search: Avoid printing duplicate author names.Gravatar Carl Worth2009-11-12
| | | | | | | | 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.
* notmuch search: Print all authors contributing to a thread.Gravatar Carl Worth2009-11-12
| | | | | | | | 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.
* notmuch search: Print the names of author of matched emails.Gravatar Carl Worth2009-11-12
| | | | | | | 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.).
* libify: Move library sources down into lib directory.Gravatar Carl Worth2009-11-09
A "make" invocation still works from the top-level, but not from down inside the lib directory yet.