From 67261b614d6740f84455aaf9989286e9c0ae0d55 Mon Sep 17 00:00:00 2001 From: djcb Date: Sun, 25 Mar 2012 13:25:55 +0300 Subject: [PATCH] * implement the :erase message from the backend to properly clean up the header buffer When we're doing a search while the results of a previous search are still coming in from the backend, this way we can tell the frontend that this is the right time to clear the buffer (previously, sometimes the results would be mixed). --- emacs/mu4e-proc.el | 13 +++++++++++-- man/mu-server.1 | 6 ++++++ src/mu-cmd-server.c | 6 ++++++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/emacs/mu4e-proc.el b/emacs/mu4e-proc.el index df083c2d..e030659f 100644 --- a/emacs/mu4e-proc.el +++ b/emacs/mu4e-proc.el @@ -62,6 +62,11 @@ server process; the function is passed a msg plist as argument. See after the headers have returns, to report on the number of matches. See `mu4e-proc-filter' for the format.") +(defvar mu4e-proc-erase-func 'mu4e-default-handler + "*internal* A function called for when we received an :erase sexp +after the headers have returns, to clear the current headers +buffer. See `mu4e-proc-filter' for the format.") + (defvar mu4e-proc-compose-func 'mu4e-default-handler "*internal* A function called for each message returned from the server process that is used as basis for composing a new @@ -256,10 +261,14 @@ updated as well, with all processed sexp data removed." ((plist-get sexp :found) (funcall mu4e-proc-found-func (plist-get sexp :found))) - ;; viewin a specific message + ;; viewing a specific message ((plist-get sexp :view) (funcall mu4e-proc-view-func (plist-get sexp :view))) + ;; receive an erase message + ((plist-get sexp :erase) + (funcall mu4e-proc-erase-func)) + ;; receive a pong message ((plist-get sexp :pong) (funcall mu4e-proc-pong-func @@ -433,7 +442,7 @@ be delivered to the function registered as `mu4e-proc-message-func'." The result will be delivered to the function registered as `mu4e-proc-compose-func'." (unless (member compose-type '(forward reply edit)) - (error "Unsupported compose-type")) + (error "Unsupported compose-type %S" compose-type)) (mu4e-proc-send-command "compose %s %d" (symbol-name compose-type) docid)) diff --git a/man/mu-server.1 b/man/mu-server.1 index b81e5f74..5d2c5b1c 100644 --- a/man/mu-server.1 +++ b/man/mu-server.1 @@ -51,6 +51,12 @@ Using the \fBfind\fR command we can search for messages. .nf -> find "" .fi +First, this will return an 'erase'-sexp, to clear the buffer from possible +results from a previous query. +.nf +<- (:erase t) +.fi + This will return a series of 0 up to s-expression corresponding to each message found (with a negative number for meaning 'unlimited'). The information for each message does not contain the message body; the \fBview\fR diff --git a/src/mu-cmd-server.c b/src/mu-cmd-server.c index 63f2b33a..2715d25a 100644 --- a/src/mu-cmd-server.c +++ b/src/mu-cmd-server.c @@ -376,6 +376,12 @@ cmd_find (MuStore *store, MuQuery *query, GSList *args, GError **err) return server_error (err, MU_ERROR_INTERNAL, "couldn't get iterator"); + /* before sending new results, send an 'erase' message, so the + * frontend knows it should erase the headers buffer. this + * will ensure that the output of two finds quickly will not + * be mixed. */ + send_expr ("(:erase t)"); + /* return results + the number of results found */ send_expr ("(:found %u)\n", output_found_sexps (iter, maxnum)); mu_msg_iter_destroy (iter);