* add support for finding related messages to mu-find, mu4e, this does *not*

include the actual implementation though
This commit is contained in:
djcb 2012-12-25 11:58:32 +02:00
parent 3dc1e989ce
commit 58f5e39d34
7 changed files with 45 additions and 18 deletions

View File

@ -68,12 +68,13 @@ char* mu_query_version (MuQuery *store)
enum _MuQueryFlags {
MU_QUERY_FLAG_NONE = 0,
MU_QUERY_FLAG_THREADS = 1 << 0, /* <** add threading info */
MU_QUERY_FLAG_DESCENDING = 1 << 1, /* <** sort z->a */
MU_QUERY_FLAG_SKIP_UNREADABLE = 1 << 2, /* <** skip unreadable msgs */
MU_QUERY_FLAG_SKIP_DUPS = 1 << 3 /* <** skip duplicate msgs */
MU_QUERY_FLAG_THREADS = 1 << 0, /**< add threading info */
MU_QUERY_FLAG_DESCENDING = 1 << 1, /**< sort z->a */
MU_QUERY_FLAG_SKIP_UNREADABLE = 1 << 2, /**< skip unreadable msgs */
MU_QUERY_FLAG_SKIP_DUPS = 1 << 3, /**< skip duplicate msgs */
MU_QUERY_FLAG_INCLUDE_RELATED = 1 << 4 /**< include related msgs */
};
typedef enum _MuQueryFlags MuQueryFlags;
typedef enum _MuQueryFlags MuQueryFlags;
/**
* run a Xapian query; for the syntax, please refer to the mu-find

View File

@ -129,6 +129,8 @@ run_query (MuQuery *xapian, const gchar *query, MuConfig *opts, GError **err)
qflags |= MU_QUERY_FLAG_DESCENDING;
if (opts->skip_dups)
qflags |= MU_QUERY_FLAG_SKIP_DUPS;
if (opts->include_related)
qflags |= MU_QUERY_FLAG_INCLUDE_RELATED;
iter = mu_query_run (xapian, query, sortid, -1, qflags, err);
return iter;

View File

@ -874,6 +874,8 @@ get_find_params (GSList *args, MuMsgFieldId *sortfield,
*qflags |= MU_QUERY_FLAG_DESCENDING;
if (get_bool_from_args (args, "skip-dups", TRUE, NULL))
*qflags |= MU_QUERY_FLAG_SKIP_DUPS;
if (get_bool_from_args (args, "include-related", TRUE, NULL))
*qflags |= MU_QUERY_FLAG_INCLUDE_RELATED;
return MU_OK;
}

View File

@ -216,6 +216,9 @@ config_options_group_find (void)
{"skip-dups", 'u', 0, G_OPTION_ARG_NONE,
&MU_CONFIG.skip_dups,
"show only the first of messages duplicates (false)", NULL},
{"include-related", 'r', 0, G_OPTION_ARG_NONE,
&MU_CONFIG.include_related,
"include related messages in results (false)", NULL},
{"linksdir", 0, 0, G_OPTION_ARG_STRING, &MU_CONFIG.linksdir,
"output as symbolic links to a target maildir", "<dir>"},
{"clearlinks", 0, 0, G_OPTION_ARG_NONE, &MU_CONFIG.clearlinks,

View File

@ -143,6 +143,8 @@ struct _MuConfig {
* messages with the same
* msgid, show only the first
* one */
gboolean include_related; /* included related messages
* in results */
/* for find and cind */
time_t after; /* only show messages or
* adresses last seen after

View File

@ -106,6 +106,15 @@ and offlineimap."
:type 'boolean
:group 'mu4e-headers)
(defcustom mu4e-headers-include-related nil
"With this option set to non-nil, not just return the matches for
a searches, but also messages that are related (through their
references) to these messages. This can be useful e.g. to include
sent messages into message threads."
:type 'boolean
:group 'mu4e-headers)
;; marks for headers of the form; each is a cons-cell (basic . fancy)
@ -854,7 +863,8 @@ the query history stack."
mu4e~headers-sort-field
mu4e~headers-sort-direction
(unless mu4e-headers-full-search mu4e-search-results-limit)
mu4e-headers-skip-duplicates)))
mu4e-headers-skip-duplicates
mu4e-headers-include-related)))
(defun mu4e~headers-redraw-get-view-window ()
"Close all windows, redraw the headers buffer based on the value

View File

@ -317,29 +317,36 @@ In particular, backslashes and double-quotes."
(let ((esc (replace-regexp-in-string "\\\\" "\\\\\\\\" query)))
(replace-regexp-in-string "\"" "\\\\\"" esc)))
(defun mu4e~proc-find (query threads sortfield sortdir maxnum skip-dups)
(defun mu4e~proc-find (query threads sortfield sortdir maxnum skip-dups include-related)
"Start a database query for QUERY.
If THREADS is non-nil, show results in threaded fasion, SORTFIELD
is a symbol describing the field to sort by (or nil); see
`mu4e~headers-sortfield-choices'. If SORT is `descending', sort
Z->A, if it's `ascending', sort A->Z. MAXNUM determines the maximum
number of results to return, or nil for 'unlimited'. If
SKIP-DUPS is non-nil, show only one of duplicate messages.
number of results to return, or nil for 'unlimited'. If SKIP-DUPS
is non-nil, show only one of duplicate messages (see
`mu4e-headers-skip-duplicates'). If INCLUDE-RELATED is non-nil,
include messages related to the messages matching the search
query (see `mu4e-headers-include-related').
For each
result found, a function is called, depending on the kind of
result. The variables `mu4e-error-func' contain the function that
will be called for, resp., a message (header row) or an error."
(mu4e~proc-send-command
"find query:\"%s\" threads:%s sortfield:%s reverse:%s maxnum:%d skip-dups:%s"
(mu4e~proc-escape-query query)
(if threads "true" "false")
;; sortfield is e.g. ':subject'; this removes the ':'
(if (null sortfield) "nil" (substring (symbol-name sortfield) 1))
;; TODO: use ascending/descending in backend too (it's clearer than 'reverse'
(if (eq sortdir 'descending) "true" "false")
(if maxnum maxnum -1)
(if skip-dups "true" "false")))
(format
(concat
"find query:\"%s\" threads:%s sortfield:%s reverse:%s maxnum:%d "
"skip-dups:%s include-related:%s")
(mu4e~proc-escape-query query)
(if threads "true" "false")
;; sortfield is e.g. ':subject'; this removes the ':'
(if (null sortfield) "nil" (substring (symbol-name sortfield) 1))
;; TODO: use ascending/descending in backend too (it's clearer than 'reverse'
(if (eq sortdir 'descending) "true" "false")
(if maxnum maxnum -1)
(if skip-dups "true" "false")
(if include-related "true" "false"))))
(defun mu4e~proc-move (docid-or-msgid &optional maildir flags)
"Move message identified by DOCID-OR-MSGID.