diff --git a/emacs/mu4e-proc.el b/emacs/mu4e-proc.el index b62be5cb..6493e00c 100644 --- a/emacs/mu4e-proc.el +++ b/emacs/mu4e-proc.el @@ -371,10 +371,18 @@ or (:error ) sexp, which are handled my `mu4e-update-func' and 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 -point to some maildir directory structure." - (mu4e~proc-send-command "index path:\"%s\"" path)) +point to some maildir directory structure. MY-ADDRESSES is a +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) "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 newer-than newer-than 0))) - (defun mu4e~proc-view (docid-or-msgid &optional images) "Get one particular message based on its DOCID-OR-MSGID (keyword argument). Optionally, if IMAGES is non-nil, backend will any diff --git a/emacs/mu4e-utils.el b/emacs/mu4e-utils.el index a8f305e3..74aeacc1 100644 --- a/emacs/mu4e-utils.el +++ b/emacs/mu4e-utils.el @@ -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 (when maybe-error (sit-for 5)) - (mu4e~proc-index mu4e-maildir) - (let ((buf (process-buffer proc))) - (when (buffer-live-p buf) - (kill-buffer buf)))))))) + (mu4e~proc-index mu4e-maildir mu4e-my-email-addresses) + (when (buffer-live-p buf) + (kill-buffer buf))))))) diff --git a/emacs/mu4e-vars.el b/emacs/mu4e-vars.el index e01d53d0..1b3af467 100644 --- a/emacs/mu4e-vars.el +++ b/emacs/mu4e-vars.el @@ -75,10 +75,20 @@ mu4e." :group 'mu4e :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 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" "Date format to use in the message view, in the format of @@ -139,12 +149,6 @@ restriction." :type 'integer :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 (defgroup mu4e-folders nil diff --git a/man/mu-server.1 b/man/mu-server.1 index acc85d23..fb98fbfb 100644 --- a/man/mu-server.1 +++ b/man/mu-server.1 @@ -165,10 +165,12 @@ and finally, we receive: .B index 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 --> index path: +-> index path: [my-addresses:] .fi As a response, it will send (for each 500 messages): .nf diff --git a/mu/mu-cmd-server.c b/mu/mu-cmd-server.c index fccb6741..3a7a47ea 100644 --- a/mu/mu-cmd-server.c +++ b/mu/mu-cmd-server.c @@ -895,6 +895,21 @@ index_msg_cb (MuIndexStats *stats, void *user_data) 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:, and responds with (:info * index ... ) messages while doing so (see the code) @@ -903,11 +918,13 @@ static MuError cmd_index (MuStore *store, MuQuery *query, GSList *args, GError **err) { MuIndex *index; - const char *path; + const char *path, *addresses; MuIndexStats stats, stats2; MuError rv; 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); if (!index) { @@ -915,6 +932,7 @@ cmd_index (MuStore *store, MuQuery *query, GSList *args, GError **err) return MU_OK; } + mu_index_stats_clear (&stats); rv = mu_index_run (index, path, FALSE, &stats, index_msg_cb, NULL, NULL); if (rv != MU_OK && rv != MU_STOP) {