mirror of https://github.com/djcb/mu.git
* mu4e: support setting my-addresses when indexing
This commit is contained in:
parent
39ff643e48
commit
b150f45090
|
@ -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
|
||||
|
|
|
@ -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)))))))
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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:<path>
|
||||
-> index path:<path> [my-addresses:<comma-separated-list-of-email-addresses>]
|
||||
.fi
|
||||
As a response, it will send (for each 500 messages):
|
||||
.nf
|
||||
|
|
|
@ -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:<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) {
|
||||
|
|
Loading…
Reference in New Issue