On 2018-10-25 at 18:50 +0200, Martin Monperrus wrote: > Hi all, > > I don't understand the following configuration option for search > folders (https://wiki.gnome.org/Apps/Evolution/Search): > Include threads:
> Where can I find a one-sentence description of each option? Hello Martin Thanks for your question. The obvious places to find this would be on one of these locations: https://help.gnome.org/users/evolution/unstable/mail-searching.html.en https://help.gnome.org/users/evolution/unstable/mail-search-folders-add.html.en https://help.gnome.org/users/evolution/unstable/mail-search-folders-conditions.html.en But as they don't mention this piece at all, I will attempt to give my own understanding of this setting. First of all, we need to take into account that email can be grouped in threads based on the reply-to relationship.¹ For example, we have your email, this reply to you, and eg. a future email by André replying to this one, plus another of Milan replying to that one. These four emails would be in the same thread (we could call it the "Option for search folder" thread, but emails on one thread may have completely different subjects). When searching, it may be useful to have some context, not just the emails that exactly match your search (this setting is available both for advanced search and search folders). So, suppose you searched for all my emails. Which mails from that thread would show, depending on this setting? > i) None Only the emails that match the search would match, ie. just my email. > ii) All related All emails in the same thread are included. In the example thread, all the four emails would show as results, even if only this one would exactly match the From: condition you set. > iii) Replies The result includes the email that match the rest of the query, as well as all replies descendant of that email. In the example thread, it would return three emails: my message and replies by André and Milan. > iv) Replies and parents The result includes the email that match the rest of the query, as well as all parent emails and all replies descendant of that email. However, siblings and their offspring are not included. In the example thread, all four messages would be included, but if someone else also replied to your original email, that reply would not be included. > v) No reply or parent The message will only be shown if it is not replying to anyone and there is no reply to it, either. The other options only augment the result set based on the thread, but this is one a bit different, as it restricts the result to only messages that are not part of a thread. In the example thread, nothing would be returned. Best regards --- ¹ This is constructed in the In-Reply-To and References headers. Microsoft, its own header. Note: that wiki page is misformatted, it probably stopped being rendered as it used to be at a GNOME wiki update and nobody noticed. I can work on fixing it, but my user (ÁngelGonzález) lacks write rights there, so someone would need to give it edit rights (I'm quite sure that someone had already marked it as "not a bot" a long time ago, but apparently it got lost). Implementation details: ----------------------- These GUI options map to the _filter_threading_t enum defined on src/e-util/e-filter-rule.h /* threading, if the context supports it */ enum _filter_threading_t { E_FILTER_THREAD_NONE, /* don't add any thread matching */ E_FILTER_THREAD_ALL, /* add all possible threads */ E_FILTER_THREAD_REPLIES, /* add only replies */ E_FILTER_THREAD_REPLIES_PARENTS, /* replies plus parents */ E_FILTER_THREAD_SINGLE /* messages with no replies or parents */ }; which themselves map to the match-threads options "all", "replies", "replies_parents" and "single" in the internal language. Finally translated in evolution-data-server src/camel/camel-folder-search.c to ids 0 to 4 and applied accordingly (see function folder_search_match_threads) I am attaching a small patch that adds some comments to folder_search_match_threads. Kind regards
diff --git a/src/camel/camel-folder-search.c b/src/camel/camel-folder-search.c index e240caa..f6f908c 100644 --- a/src/camel/camel-folder-search.c +++ b/src/camel/camel-folder-search.c @@ -1046,6 +1046,7 @@ folder_search_match_threads (CamelSExp *sexp, g_free (error_msg); } + /* no thread matching, the earlier result is already complete */ if (type == 0) return r; @@ -1065,11 +1066,14 @@ folder_search_match_threads (CamelSExp *sexp, } results = g_hash_table_new (g_str_hash, g_str_equal); + /* iterate every message matching the rest of the search terms */ for (i = 0; i < r->value.ptrarray->len && !g_cancellable_is_cancelled (search->priv->cancellable); i++) { CamelFolderThreadNode *node, *scan; - if (type != 4) + if (type != 4) { + /* the matched message itself will always be part of the returned result unless in "(match-thread single)" mode */ g_hash_table_insert (results, g_ptr_array_index (r->value.ptrarray, i), GINT_TO_POINTER (1)); + } node = g_hash_table_lookup (p->threads_hash, (gchar *) g_ptr_array_index (r->value.ptrarray, i)); if (node == NULL) /* this shouldn't happen but why cry over spilt milk */ @@ -1080,14 +1084,14 @@ folder_search_match_threads (CamelSExp *sexp, if (node->child == NULL && node->parent == NULL) g_hash_table_insert (results, (gchar *) camel_message_info_get_uid (node->message), GINT_TO_POINTER (1)); } else { - if (type == 3) { + if (type == 3) { /* add the parents of the matched message */ scan = node; /* coverity[check_after_deref] */ while (scan && scan->parent) { scan = scan->parent; g_hash_table_insert (results, (gchar *) camel_message_info_get_uid (scan->message), GINT_TO_POINTER (1)); } - } else if (type == 1) { + } else if (type == 1) { /* get the thread root message, we will add all the descendants below */ while (node != NULL && node->parent) node = node->parent; }
_______________________________________________ evolution-list mailing list evolution-list@gnome.org To change your list options or unsubscribe, visit ... https://mail.gnome.org/mailman/listinfo/evolution-list