* mu4e: support setting my-addresses when indexing

This commit is contained in:
djcb 2012-06-19 17:59:35 +03:00
parent 39ff643e48
commit b150f45090
5 changed files with 49 additions and 19 deletions

View File

@ -371,10 +371,18 @@ or (:error ) sexp, which are handled my `mu4e-update-func' and
idparam (or flagstr "") (or path "")))) idparam (or flagstr "") (or path ""))))
(defun mu4e~proc-index (path)
(defun mu4e~proc-index (path my-addresses)
"Update the message database for filesystem PATH, which should "Update the message database for filesystem PATH, which should
point to some maildir directory structure." point to some maildir directory structure. MY-ADDRESSES is a
(mu4e~proc-send-command "index path:\"%s\"" path)) list of my email addresses (see e.g. `mu4e-my-email-addresses')."
(let ((addrs
(when my-addresses
(mapconcat 'identity my-addresses ","))))
(if addrs
(mu4e~proc-send-command "index path:\"%s\" my-addresses:%s"
path addrs)
(mu4e~proc-send-command "index path:\"%s\"" path))))
(defun mu4e~proc-add (path maildir) (defun mu4e~proc-add (path maildir)
"Add the message at PATH to the database, with MAILDIR set to the "Add the message at PATH to the database, with MAILDIR set to the
@ -448,7 +456,6 @@ contacts seen after NEWER-THAN (the time_t value)."
(if only-personal "true" "false") (if only-personal "true" "false")
(if newer-than newer-than 0))) (if newer-than newer-than 0)))
(defun mu4e~proc-view (docid-or-msgid &optional images) (defun mu4e~proc-view (docid-or-msgid &optional images)
"Get one particular message based on its DOCID-OR-MSGID (keyword "Get one particular message based on its DOCID-OR-MSGID (keyword
argument). Optionally, if IMAGES is non-nil, backend will any argument). Optionally, if IMAGES is non-nil, backend will any

View File

@ -677,10 +677,9 @@ processing takes part in the background, unless buf is non-nil."
;; there may be an error, give the user up to 5 seconds to check ;; there may be an error, give the user up to 5 seconds to check
(when maybe-error (when maybe-error
(sit-for 5)) (sit-for 5))
(mu4e~proc-index mu4e-maildir) (mu4e~proc-index mu4e-maildir mu4e-my-email-addresses)
(let ((buf (process-buffer proc))) (when (buffer-live-p buf)
(when (buffer-live-p buf) (kill-buffer buf)))))))
(kill-buffer buf))))))))

View File

@ -75,10 +75,20 @@ mu4e."
:group 'mu4e :group 'mu4e
:safe 'stringp) :safe 'stringp)
(defvar mu4e-user-mail-address-regexp "$^" (defcustom mu4e-user-mail-address-regexp "$^"
"Regular expression matching the user's mail address(es). This is "Regular expression matching the user's mail address(es). This is
used to distinguish ourselves from others, e.g. when replying and used to distinguish ourselves from others, e.g. when replying and
in :from-or-to headers. By default, match nothing.") in :from-or-to headers. By default, match nothing."
:type 'string
:group 'mu4e
:safe 'stringp)
(defcustom mu4e-my-email-addresses `(,user-mail-address)
"List of e-mail addresses to consider 'my email addresses',
ie. addresses whose presence in an email imply that it is a
personal message. This is used when indexing messages."
:type '(string)
:group 'mu4e)
(defvar mu4e-date-format-long "%c" (defvar mu4e-date-format-long "%c"
"Date format to use in the message view, in the format of "Date format to use in the message view, in the format of
@ -139,12 +149,6 @@ restriction."
:type 'integer :type 'integer
:group 'mu4e-compose) :group 'mu4e-compose)
(defcustom mu4e-compose-my-email-addresses `(,user-mail-address)
"List of e-mail addresses to consider 'my email addresses',
ie. addresses whose presence in an email imply that it is a
personal message."
:type '(string)
:group 'mu4e-compose)
;; Folders ;; Folders
(defgroup mu4e-folders nil (defgroup mu4e-folders nil

View File

@ -165,10 +165,12 @@ and finally, we receive:
.B index .B index
Using the \fBindex\fR command, we can (re)index the database, similar to what Using the \fBindex\fR command, we can (re)index the database, similar to what
\fBmu find\fR does. \fBmu find\fR does. The \fBmy-addresses\fR parameter (optionally)
registers 'my' email addresses; see the documentation for
\fBmu_store_set_my_addresses\fR.
.nf .nf
-> index path:<path> -> index path:<path> [my-addresses:<comma-separated-list-of-email-addresses>]
.fi .fi
As a response, it will send (for each 500 messages): As a response, it will send (for each 500 messages):
.nf .nf

View File

@ -895,6 +895,21 @@ index_msg_cb (MuIndexStats *stats, void *user_data)
return MU_OK; return MU_OK;
} }
static void
set_my_addresses (MuStore *store, char *addrstr)
{
char **my_addresses;
if (!addrstr)
return;
my_addresses = g_strsplit (addrstr,"," -1);
mu_store_set_my_addresses (store, my_addresses);
g_strfreev (my_addresses);
}
/* /*
* 'index' (re)indexs maildir at path:<path>, and responds with (:info * 'index' (re)indexs maildir at path:<path>, and responds with (:info
* index ... ) messages while doing so (see the code) * index ... ) messages while doing so (see the code)
@ -903,11 +918,13 @@ static MuError
cmd_index (MuStore *store, MuQuery *query, GSList *args, GError **err) cmd_index (MuStore *store, MuQuery *query, GSList *args, GError **err)
{ {
MuIndex *index; MuIndex *index;
const char *path; const char *path, *addresses;
MuIndexStats stats, stats2; MuIndexStats stats, stats2;
MuError rv; MuError rv;
GET_STRING_OR_ERROR_RETURN (args, "path", &path, err); GET_STRING_OR_ERROR_RETURN (args, "path", &path, err);
set_my_addresses (store,
get_string_from_args (args, "my-addresses", TRUE, NULL));
index = mu_index_new (store, err); index = mu_index_new (store, err);
if (!index) { if (!index) {
@ -915,6 +932,7 @@ cmd_index (MuStore *store, MuQuery *query, GSList *args, GError **err)
return MU_OK; return MU_OK;
} }
mu_index_stats_clear (&stats); mu_index_stats_clear (&stats);
rv = mu_index_run (index, path, FALSE, &stats, index_msg_cb, NULL, NULL); rv = mu_index_run (index, path, FALSE, &stats, index_msg_cb, NULL, NULL);
if (rv != MU_OK && rv != MU_STOP) { if (rv != MU_OK && rv != MU_STOP) {