mirror of https://github.com/djcb/mu.git
mu4e/server: split message / metadata
Split message and metadata, so we can use pristine (possibly pre-cached) messages. Update dependencies.
This commit is contained in:
parent
7fe1076471
commit
701ca75536
|
@ -134,7 +134,7 @@ struct Server::Private {
|
||||||
static Sexp
|
static Sexp
|
||||||
build_metadata(const QueryMatch& qmatch, unsigned docid)
|
build_metadata(const QueryMatch& qmatch, unsigned docid)
|
||||||
{
|
{
|
||||||
Sexp::List info;
|
Sexp::List mdata;
|
||||||
|
|
||||||
auto symbol_t = [] { return Sexp::make_symbol("t"); };
|
auto symbol_t = [] { return Sexp::make_symbol("t"); };
|
||||||
|
|
||||||
|
@ -167,7 +167,7 @@ build_metadata(const QueryMatch& qmatch, unsigned docid)
|
||||||
if (qmatch.has_flag(QueryMatch::Flags::ThreadSubject))
|
if (qmatch.has_flag(QueryMatch::Flags::ThreadSubject))
|
||||||
mdata.add_prop(":thread-subject", symbol_t());
|
mdata.add_prop(":thread-subject", symbol_t());
|
||||||
|
|
||||||
items.add_prop(":thread", Sexp::make_list(std::move(info)));
|
return Sexp::make_list(std::move(mdata));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* a full message-sexp consists looks something like:
|
/* a full message-sexp consists looks something like:
|
||||||
|
@ -191,6 +191,7 @@ Server::Private::build_message_sexp(MuMsg* msg,
|
||||||
|
|
||||||
return Sexp::make_list(std::move(msexp));
|
return Sexp::make_list(std::move(msexp));
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandMap
|
CommandMap
|
||||||
Server::Private::make_command_map()
|
Server::Private::make_command_map()
|
||||||
{
|
{
|
||||||
|
@ -633,7 +634,6 @@ Server::Private::output_results(const QueryResults& qres, size_t batch_size) con
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Server::Private::find_handler(const Parameters& params)
|
Server::Private::find_handler(const Parameters& params)
|
||||||
{
|
{
|
||||||
|
|
|
@ -354,8 +354,8 @@ headers."
|
||||||
;; search results)
|
;; search results)
|
||||||
;; since we still have the search results, re-use
|
;; since we still have the search results, re-use
|
||||||
;; those
|
;; those
|
||||||
(plist-put msg :thread
|
(plist-put msg :meta
|
||||||
(mu4e~headers-field-for-docid docid :thread))
|
(mu4e~headers-field-for-docid docid :meta))
|
||||||
|
|
||||||
;; first, remove the old one (otherwise, we'd have two headers with
|
;; first, remove the old one (otherwise, we'd have two headers with
|
||||||
;; the same docid...
|
;; the same docid...
|
||||||
|
@ -617,7 +617,7 @@ date. The formats used for date and time are
|
||||||
"Get the subject if it is the first one in a thread; otherwise,
|
"Get the subject if it is the first one in a thread; otherwise,
|
||||||
return the thread-prefix without the subject-text. In other words,
|
return the thread-prefix without the subject-text. In other words,
|
||||||
show the subject of a thread only once, similar to e.g. 'mutt'."
|
show the subject of a thread only once, similar to e.g. 'mutt'."
|
||||||
(let* ((tinfo (mu4e-message-field msg :thread))
|
(let* ((tinfo (mu4e-message-field msg :meta))
|
||||||
(subj (mu4e-msg-field msg :subject)))
|
(subj (mu4e-msg-field msg :subject)))
|
||||||
(concat ;; prefix subject with a thread indicator
|
(concat ;; prefix subject with a thread indicator
|
||||||
(mu4e~headers-thread-prefix tinfo)
|
(mu4e~headers-thread-prefix tinfo)
|
||||||
|
@ -645,8 +645,8 @@ found."
|
||||||
(cl-case field
|
(cl-case field
|
||||||
(:subject
|
(:subject
|
||||||
(concat ;; prefix subject with a thread indicator
|
(concat ;; prefix subject with a thread indicator
|
||||||
(mu4e~headers-thread-prefix (mu4e-message-field msg :thread))
|
(mu4e~headers-thread-prefix (mu4e-message-field msg :meta))
|
||||||
;; "["(plist-get (mu4e-message-field msg :thread) :path) "] "
|
;; "["(plist-get (mu4e-message-field msg :meta) :path) "] "
|
||||||
;; work-around: emacs' display gets really slow when lines are too long;
|
;; work-around: emacs' display gets really slow when lines are too long;
|
||||||
;; so limit subject length to 600
|
;; so limit subject length to 600
|
||||||
(truncate-string-to-width val 600)))
|
(truncate-string-to-width val 600)))
|
||||||
|
@ -1376,9 +1376,9 @@ matching messages with that mark."
|
||||||
|
|
||||||
(defun mu4e~headers-get-thread-info (msg what)
|
(defun mu4e~headers-get-thread-info (msg what)
|
||||||
"Get WHAT (a symbol, either path or thread-id) for MSG."
|
"Get WHAT (a symbol, either path or thread-id) for MSG."
|
||||||
(let* ((thread (or (mu4e-message-field msg :thread)
|
(let* ((meta (or (mu4e-message-field msg :meta)
|
||||||
(mu4e-error "No thread info found")))
|
(mu4e-error "No thread info found")))
|
||||||
(path (or (plist-get thread :path)
|
(path (or (plist-get meta :path)
|
||||||
(mu4e-error "No threadpath found"))))
|
(mu4e-error "No threadpath found"))))
|
||||||
(cl-case what
|
(cl-case what
|
||||||
(path path)
|
(path path)
|
||||||
|
|
|
@ -192,6 +192,16 @@ removed."
|
||||||
(car objcons)))))))
|
(car objcons)))))))
|
||||||
|
|
||||||
|
|
||||||
|
(defsubst mu4e--message (msgdata)
|
||||||
|
"Convert MSGDATA into a msg plist.
|
||||||
|
This receives a 'message-data' blob of the form
|
||||||
|
(:meta (...) :message (...))
|
||||||
|
and turns it into (:message :meta (...) ... ).
|
||||||
|
|
||||||
|
The former version is what the server is optimized for,
|
||||||
|
but the latter is what the header wants."
|
||||||
|
(plist-put (plist-get msgdata :message) :meta (plist-get msgdata :meta)))
|
||||||
|
|
||||||
(defun mu4e--server-filter (_proc str)
|
(defun mu4e--server-filter (_proc str)
|
||||||
"Filter string STR from PROC.
|
"Filter string STR from PROC.
|
||||||
This processes the 'mu server' output. It accumulates the
|
This processes the 'mu server' output. It accumulates the
|
||||||
|
@ -205,28 +215,27 @@ The server output is as follows:
|
||||||
;; eox
|
;; eox
|
||||||
=> passed to `mu4e-error-func'.
|
=> passed to `mu4e-error-func'.
|
||||||
|
|
||||||
2a. a message sexp looks something like:
|
2a. a header exp looks something like:
|
||||||
\(
|
(:header
|
||||||
:docid 1585
|
:meta (....)
|
||||||
:from ((\"Donald Duck\" . \"donald@example.com\"))
|
:message (
|
||||||
:to ((\"Mickey Mouse\" . \"mickey@example.com\"))
|
:docid 1585
|
||||||
:subject \"Wicked stuff\"
|
:from ((\"Donald Duck\" . \"donald@example.com\"))
|
||||||
:date (20023 26572 0)
|
:to ((\"Mickey Mouse\" . \"mickey@example.com\"))
|
||||||
:size 15165
|
:subject \"Wicked stuff\"
|
||||||
:references (\"200208121222.g7CCMdb80690@msg.id\")
|
:date (20023 26572 0)
|
||||||
:in-reply-to \"200208121222.g7CCMdb80690@msg.id\"
|
:size 15165
|
||||||
:message-id \"foobar32423847ef23@pluto.net\"
|
:references (\"200208121222.g7CCMdb80690@msg.id\")
|
||||||
:maildir: \"/archive\"
|
:in-reply-to \"200208121222.g7CCMdb80690@msg.id\"
|
||||||
:path \"/home/mickey/Maildir/inbox/cur/1312254065_3.32282.pluto,4cd5bd4e9:2,\"
|
:message-id \"foobar32423847ef23@pluto.net\"
|
||||||
:priority high
|
:maildir: \"/archive\"
|
||||||
:flags (new unread)
|
:path \"/home/mickey/Maildir/inbox/cur/1312_3.32282.pluto,4cd5bd4e9:2,\"
|
||||||
:attachments ((2 \"hello.jpg\" \"image/jpeg\") (3 \"laah.mp3\" \"audio/mp3\"))
|
:priority high
|
||||||
:body-txt \" <message body>\"
|
:flags (new unread)))
|
||||||
\)
|
|
||||||
;; eox
|
;; eox
|
||||||
=> this will be passed to `mu4e-header-func'.
|
=> this will be passed to `mu4e-header-func'.
|
||||||
|
|
||||||
2b. After the list of message sexps has been returned (see 2a.),
|
2b. After the list of headers has been returned (see 2a.),
|
||||||
we'll receive a sexp that looks like
|
we'll receive a sexp that looks like
|
||||||
(:found <n>) with n the number of messages found. The <n> will be
|
(:found <n>) with n the number of messages found. The <n> will be
|
||||||
passed to `mu4e-found-func'.
|
passed to `mu4e-found-func'.
|
||||||
|
@ -234,9 +243,11 @@ The server output is as follows:
|
||||||
3. a view looks like:
|
3. a view looks like:
|
||||||
(:view <msg-sexp>)
|
(:view <msg-sexp>)
|
||||||
=> the <msg-sexp> (see 2.) will be passed to `mu4e-view-func'.
|
=> the <msg-sexp> (see 2.) will be passed to `mu4e-view-func'.
|
||||||
|
like :header, but the :message also contains :body-txt and/or :body-html
|
||||||
|
|
||||||
4. a database update looks like:
|
4. a database update looks like:
|
||||||
(:update <msg-sexp> :move <nil-or-t>)
|
(:update <msg-sexp> :move <nil-or-t>)
|
||||||
|
like :header
|
||||||
|
|
||||||
=> the <msg-sexp> (see 2.) will be passed to
|
=> the <msg-sexp> (see 2.) will be passed to
|
||||||
`mu4e-update-func', :move tells us whether this is a move to
|
`mu4e-update-func', :move tells us whether this is a move to
|
||||||
|
@ -248,7 +259,7 @@ The server output is as follows:
|
||||||
|
|
||||||
6. a compose looks like:
|
6. a compose looks like:
|
||||||
(:compose <reply|forward|edit|new> [:original<msg-sexp>] [:include <attach>])
|
(:compose <reply|forward|edit|new> [:original<msg-sexp>] [:include <attach>])
|
||||||
`mu4e-compose-func'."
|
`mu4e-compose-func'. :original looks like :view."
|
||||||
(mu4e-log 'misc "* Received %d byte(s)" (length str))
|
(mu4e-log 'misc "* Received %d byte(s)" (length str))
|
||||||
(setq mu4e--server-buf (concat mu4e--server-buf str)) ;; update our buffer
|
(setq mu4e--server-buf (concat mu4e--server-buf str)) ;; update our buffer
|
||||||
(let ((sexp (mu4e--server-eat-sexp-from-buf)))
|
(let ((sexp (mu4e--server-eat-sexp-from-buf)))
|
||||||
|
@ -257,8 +268,8 @@ The server output is as follows:
|
||||||
(mu4e-log 'from-server "%S" sexp)
|
(mu4e-log 'from-server "%S" sexp)
|
||||||
(cond
|
(cond
|
||||||
;; a header plist can be recognized by the existence of a :date field
|
;; a header plist can be recognized by the existence of a :date field
|
||||||
((plist-get sexp :date)
|
((plist-get sexp :header)
|
||||||
(funcall mu4e-header-func sexp))
|
(funcall mu4e-header-func (mu4e--message (plist-get sexp :header))))
|
||||||
|
|
||||||
;; the found sexp, we receive after getting all the headers
|
;; the found sexp, we receive after getting all the headers
|
||||||
((plist-get sexp :found)
|
((plist-get sexp :found)
|
||||||
|
@ -266,7 +277,7 @@ The server output is as follows:
|
||||||
|
|
||||||
;; viewing a specific message
|
;; viewing a specific message
|
||||||
((plist-get sexp :view)
|
((plist-get sexp :view)
|
||||||
(funcall mu4e-view-func (plist-get sexp :view)))
|
(funcall mu4e-view-func (mu4e--message (plist-get sexp :view))))
|
||||||
|
|
||||||
;; receive an erase message
|
;; receive an erase message
|
||||||
((plist-get sexp :erase)
|
((plist-get sexp :erase)
|
||||||
|
@ -293,7 +304,7 @@ The server output is as follows:
|
||||||
;; something got moved/flags changed
|
;; something got moved/flags changed
|
||||||
((plist-get sexp :update)
|
((plist-get sexp :update)
|
||||||
(funcall mu4e-update-func
|
(funcall mu4e-update-func
|
||||||
(plist-get sexp :update)
|
(mu4e--message (plist-get sexp :update))
|
||||||
(plist-get sexp :move)
|
(plist-get sexp :move)
|
||||||
(plist-get sexp :maybe-view)))
|
(plist-get sexp :maybe-view)))
|
||||||
|
|
||||||
|
@ -305,7 +316,7 @@ The server output is as follows:
|
||||||
((plist-get sexp :compose)
|
((plist-get sexp :compose)
|
||||||
(funcall mu4e-compose-func
|
(funcall mu4e-compose-func
|
||||||
(plist-get sexp :compose)
|
(plist-get sexp :compose)
|
||||||
(plist-get sexp :original)
|
(mu4e--message (plist-get sexp :original))
|
||||||
(plist-get sexp :include)))
|
(plist-get sexp :include)))
|
||||||
|
|
||||||
;; get some info
|
;; get some info
|
||||||
|
|
Loading…
Reference in New Issue