* mu4e: use the new server protocol
This commit is contained in:
@ -314,11 +314,11 @@ The results are reporter through either (:update ... ) or (:error)
|
|||||||
sexp, which are handled my `mu4e-error-func', respectively."
|
sexp, which are handled my `mu4e-error-func', respectively."
|
||||||
(mu4e~proc-send-command "remove docid:%d" docid))
|
(mu4e~proc-send-command "remove docid:%d" docid))
|
||||||
|
|
||||||
(defun mu4e~proc-escape (query)
|
(defun mu4e~proc-escape (str)
|
||||||
"Escape the query QUERY for transport.
|
"Escape STRING for transport -- put it in quotes, and escape existing quotation.
|
||||||
In particular, backslashes and double-quotes."
|
In particular, backslashes and double-quotes."
|
||||||
(let ((esc (replace-regexp-in-string "\\\\" "\\\\\\\\" query)))
|
(let ((esc (replace-regexp-in-string "\\\\" "\\\\\\\\" str)))
|
||||||
(replace-regexp-in-string "\"" "\\\\\"" esc)))
|
(format "\"%s\"" (replace-regexp-in-string "\"" "\\\\\"" esc))))
|
||||||
|
|
||||||
(defun mu4e~proc-find (query threads sortfield sortdir maxnum skip-dups include-related)
|
(defun mu4e~proc-find (query threads sortfield sortdir maxnum skip-dups include-related)
|
||||||
"Start a database query for QUERY.
|
"Start a database query for QUERY.
|
||||||
@ -338,7 +338,7 @@ result. The variables `mu4e-error-func' contain the function that
|
|||||||
will be called for, resp., a message (header row) or an error."
|
will be called for, resp., a message (header row) or an error."
|
||||||
(mu4e~proc-send-command
|
(mu4e~proc-send-command
|
||||||
(concat
|
(concat
|
||||||
"find query:\"%s\" threads:%s sortfield:%s reverse:%s maxnum:%d "
|
"cmd:find query:%s threads:%s sortfield:%s reverse:%s maxnum:%d "
|
||||||
"skip-dups:%s include-related:%s")
|
"skip-dups:%s include-related:%s")
|
||||||
(mu4e~proc-escape query)
|
(mu4e~proc-escape query)
|
||||||
(if threads "true" "false")
|
(if threads "true" "false")
|
||||||
@ -390,8 +390,8 @@ or (:error ) sexp, which are handled my `mu4e-update-func' and
|
|||||||
(if (stringp flags) flags (mu4e-flags-to-string flags)))))
|
(if (stringp flags) flags (mu4e-flags-to-string flags)))))
|
||||||
(path
|
(path
|
||||||
(when maildir
|
(when maildir
|
||||||
(format " maildir:\"%s\"" (mu4e~proc-escape maildir)))))
|
(format " maildir:%s" (mu4e~proc-escape maildir)))))
|
||||||
(mu4e~proc-send-command "move %s %s %s"
|
(mu4e~proc-send-command "cmd:move %s %s %s"
|
||||||
idparam (or flagstr "") (or path ""))))
|
idparam (or flagstr "") (or path ""))))
|
||||||
|
|
||||||
(defun mu4e~proc-index (path my-addresses)
|
(defun mu4e~proc-index (path my-addresses)
|
||||||
@ -401,15 +401,15 @@ of 'my' email addresses (see `mu4e-user-mail-address-list')."
|
|||||||
(let ((path (mu4e~proc-escape path))
|
(let ((path (mu4e~proc-escape path))
|
||||||
(addrs (when my-addresses (mapconcat 'identity my-addresses ","))))
|
(addrs (when my-addresses (mapconcat 'identity my-addresses ","))))
|
||||||
(if addrs
|
(if addrs
|
||||||
(mu4e~proc-send-command "index path:\"%s\" my-addresses:%s" path addrs)
|
(mu4e~proc-send-command "cmd:index path:%s my-addresses:%s" path addrs)
|
||||||
(mu4e~proc-send-command "index path:\"%s\"" path))))
|
(mu4e~proc-send-command "cmd:index path:%s" path))))
|
||||||
|
|
||||||
(defun mu4e~proc-add (path maildir)
|
(defun mu4e~proc-add (path maildir)
|
||||||
"Add the message at PATH to the database.
|
"Add the message at PATH to the database.
|
||||||
With MAILDIR set to the maildir this message resides in,
|
With MAILDIR set to the maildir this message resides in,
|
||||||
e.g. '/drafts'; if this works, we will receive (:info add :path
|
e.g. '/drafts'; if this works, we will receive (:info add :path
|
||||||
<path> :docid <docid>) as well as (:update <msg-sexp>)."
|
<path> :docid <docid>) as well as (:update <msg-sexp>)."
|
||||||
(mu4e~proc-send-command "add path:\"%s\" maildir:\"%s\""
|
(mu4e~proc-send-command "cmd:add path:%s maildir:%s"
|
||||||
(mu4e~proc-escape path) (mu4e~proc-escape maildir)))
|
(mu4e~proc-escape path) (mu4e~proc-escape maildir)))
|
||||||
|
|
||||||
(defun mu4e~proc-sent (path maildir)
|
(defun mu4e~proc-sent (path maildir)
|
||||||
@ -419,7 +419,7 @@ e.g. '/drafts'.
|
|||||||
|
|
||||||
if this works, we will receive (:info add :path <path> :docid
|
if this works, we will receive (:info add :path <path> :docid
|
||||||
<docid> :fcc <path>)."
|
<docid> :fcc <path>)."
|
||||||
(mu4e~proc-send-command "sent path:\"%s\" maildir:\"%s\""
|
(mu4e~proc-send-command "cmd:sent path:%s maildir:%s"
|
||||||
(mu4e~proc-escape path) (mu4e~proc-escape maildir)))
|
(mu4e~proc-escape path) (mu4e~proc-escape maildir)))
|
||||||
|
|
||||||
|
|
||||||
@ -435,12 +435,12 @@ The result will be delivered to the function registered as
|
|||||||
(mu4e-error "Unsupported compose-type %S" type))
|
(mu4e-error "Unsupported compose-type %S" type))
|
||||||
(unless (eq (null docid) (eq type 'new))
|
(unless (eq (null docid) (eq type 'new))
|
||||||
(mu4e-error "`new' implies docid not-nil, and vice-versa"))
|
(mu4e-error "`new' implies docid not-nil, and vice-versa"))
|
||||||
(mu4e~proc-send-command "compose type:%s docid:%d"
|
(mu4e~proc-send-command "cmd:compose type:%s docid:%d"
|
||||||
(symbol-name type) docid))
|
(symbol-name type) docid))
|
||||||
|
|
||||||
(defun mu4e~proc-mkdir (path)
|
(defun mu4e~proc-mkdir (path)
|
||||||
"Create a new maildir-directory at filesystem PATH."
|
"Create a new maildir-directory at filesystem PATH."
|
||||||
(mu4e~proc-send-command "mkdir path:\"%s\"" path))
|
(mu4e~proc-send-command "cmd:mkdir path:%s" (mu4e~proc-escape path)))
|
||||||
|
|
||||||
(defun mu4e~proc-extract (action docid partidx &optional path what param)
|
(defun mu4e~proc-extract (action docid partidx &optional path what param)
|
||||||
"Extract an attachment with index PARTIDX from message with DOCID
|
"Extract an attachment with index PARTIDX from message with DOCID
|
||||||
@ -451,16 +451,16 @@ mean:
|
|||||||
* temp: save to a temporary file, then respond with
|
* temp: save to a temporary file, then respond with
|
||||||
(:temp <path> :what <what> :param <param>)."
|
(:temp <path> :what <what> :param <param>)."
|
||||||
(let ((cmd
|
(let ((cmd
|
||||||
(concat "extract "
|
(concat "cmd:extract "
|
||||||
(case action
|
(case action
|
||||||
(save
|
(save
|
||||||
(format "action:save docid:%d index:%d path:\"%s\""
|
(format "action:save docid:%d index:%d path:%s"
|
||||||
docid partidx path))
|
docid partidx (mu4e~proc-escape path)))
|
||||||
(open (format "action:open docid:%d index:%d" docid partidx))
|
(open (format "action:open docid:%d index:%d" docid partidx))
|
||||||
(temp
|
(temp
|
||||||
(format "action:temp docid:%d index:%d what:%s%s"
|
(format "action:temp docid:%d index:%d what:%s%s"
|
||||||
docid partidx what
|
docid partidx what
|
||||||
(if param (format " param:\"%s\"" param) "")))
|
(if param (format " param:%s" (mu4e~proc-escape param)) "")))
|
||||||
(otherwise (mu4e-error "Unsupported action %S" action))))))
|
(otherwise (mu4e-error "Unsupported action %S" action))))))
|
||||||
(mu4e~proc-send-command "%s" cmd)))
|
(mu4e~proc-send-command "%s" cmd)))
|
||||||
|
|
||||||
@ -475,7 +475,7 @@ A (:contacts (<list>)) is expected in response. If PERSONAL is
|
|||||||
non-nil, only get personal contacts, if AFTER is non-nil, get
|
non-nil, only get personal contacts, if AFTER is non-nil, get
|
||||||
only contacts seen AFTER (the time_t value)."
|
only contacts seen AFTER (the time_t value)."
|
||||||
(mu4e~proc-send-command
|
(mu4e~proc-send-command
|
||||||
"contacts personal:%s after:%d"
|
"cmd:contacts personal:%s after:%d"
|
||||||
(if personal "true" "false")
|
(if personal "true" "false")
|
||||||
(or after 0)))
|
(or after 0)))
|
||||||
|
|
||||||
@ -486,7 +486,7 @@ attached to the message, and return them as temp files.
|
|||||||
The result will be delivered to the function registered as
|
The result will be delivered to the function registered as
|
||||||
`mu4e-message-func'."
|
`mu4e-message-func'."
|
||||||
(mu4e~proc-send-command
|
(mu4e~proc-send-command
|
||||||
"view %s extract-images:%s extract-encrypted:%s use-agent:true"
|
"cmd:view %s extract-images:%s extract-encrypted:%s use-agent:true"
|
||||||
(mu4e--docid-msgid-param docid-or-msgid)
|
(mu4e--docid-msgid-param docid-or-msgid)
|
||||||
(if images "true" "false")
|
(if images "true" "false")
|
||||||
(if decrypt "true" "false")))
|
(if decrypt "true" "false")))
|
||||||
@ -498,8 +498,8 @@ attached to the message, and return them as temp files. The
|
|||||||
result will be delivered to the function registered as
|
result will be delivered to the function registered as
|
||||||
`mu4e-message-func'."
|
`mu4e-message-func'."
|
||||||
(mu4e~proc-send-command
|
(mu4e~proc-send-command
|
||||||
"view path:\"%s\" extract-images:%s extract-encrypted:%s use-agent:true"
|
"cmd:view path:%s extract-images:%s extract-encrypted:%s use-agent:true"
|
||||||
(shell-quote-argument path)
|
(mu4e~proc-escape path)
|
||||||
(if images "true" "false")
|
(if images "true" "false")
|
||||||
(if decrypt "true" "false")))
|
(if decrypt "true" "false")))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user