mu/emacs/mu4e-proc.el

469 lines
17 KiB
EmacsLisp
Raw Normal View History

;;; mu4e-proc.el -- part of mu4e, the mu mail user agent
2011-09-12 19:52:32 +02:00
;;
;; Copyright (C) 2011-2012 Dirk-Jan C. Binnema
2011-09-12 19:52:32 +02:00
;; Author: Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
;; Maintainer: Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
;; This file is not part of GNU Emacs.
;;
;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;;; Code:
(eval-when-compile (require 'cl))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; internal vars
2011-12-13 08:07:38 +01:00
(defvar mu4e-mu-proc nil
2011-09-12 19:52:32 +02:00
"*internal* The mu-server process")
2011-12-13 08:07:38 +01:00
(defvar mu4e-proc-error-func 'mu4e-default-handler
2011-09-12 19:52:32 +02:00
"*internal* A function called for each error returned from the
server process; the function is passed an error plist as
2011-12-13 08:07:38 +01:00
argument. See `mu4e-proc-filter' for the format.")
2011-09-12 19:52:32 +02:00
2011-12-13 08:07:38 +01:00
(defvar mu4e-proc-update-func 'mu4e-default-handler
"*internal* A function called for each :update sexp returned from
the server process; the function is passed a msg sexp as
2011-12-13 08:07:38 +01:00
argument. See `mu4e-proc-filter' for the format.")
2011-12-13 08:07:38 +01:00
(defvar mu4e-proc-remove-func 'mu4e-default-handler
"*internal* A function called for each :remove sexp returned from
the server process, when some message has been deleted. The
function is passed the docid of the removed message.")
(defvar mu4e-proc-sent-func 'mu4e-default-handler
"*internal* A function called for each :sent sexp returned from
the server process, when some message has been sent. The
function is passed the docid and the draft-path of the sent message.")
2011-12-13 08:07:38 +01:00
(defvar mu4e-proc-view-func 'mu4e-default-handler
"*internal* A function called for each single message sexp
returned from the server process. The function is passed a message
2011-12-13 08:07:38 +01:00
sexp as argument. See `mu4e-proc-filter' for the
format.")
2011-12-13 08:07:38 +01:00
(defvar mu4e-proc-header-func 'mu4e-default-handler
"*internal* A function called for each message returned from the
server process; the function is passed a msg plist as argument. See
2011-12-13 08:07:38 +01:00
`mu4e-proc-filter' for the format.")
2011-09-12 19:52:32 +02:00
2011-12-13 08:07:38 +01:00
(defvar mu4e-proc-found-func 'mu4e-default-handler
"*internal* A function called for when we received a :found sexp
after the headers have returns, to report on the number of
2011-12-13 08:07:38 +01:00
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.")
2011-12-13 08:07:38 +01:00
(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
message (ie., either a reply or a forward); the function is passed
2011-12-13 08:07:38 +01:00
msg and a symbol (either reply or forward). See `mu4e-proc-filter'
for the format of <msg-plist>.")
2011-09-12 19:52:32 +02:00
2011-12-13 08:07:38 +01:00
(defvar mu4e-proc-info-func 'mu4e-default-handler
"*internal* A function called for each (:info type ....) sexp
received from the server process.")
2011-09-12 19:52:32 +02:00
2011-12-13 08:07:38 +01:00
(defvar mu4e-proc-pong-func 'mu4e-default-handler
"*internal* A function called for each (:pong type ....) sexp
received from the server process.")
2011-09-30 07:37:47 +02:00
2011-12-13 08:07:38 +01:00
(defvar mu4e-buf nil
2011-09-12 19:52:32 +02:00
"*internal* Buffer for results data.")
2011-12-13 08:07:38 +01:00
(defvar mu4e-path-docid-map
2011-09-19 23:20:59 +02:00
(make-hash-table :size 32 :rehash-size 2 :test 'equal :weakness nil)
2011-09-18 22:57:46 +02:00
"*internal* hash we use to keep a path=>docid mapping for message
we added ourselves (ie., draft messages), so we can e.g. move them
to the sent folder using their docid")
2011-12-13 08:07:38 +01:00
(defun mu4e-proc-info-handler (info)
"Handler function for (:info ...) sexps received from the server
process."
(let ((type (plist-get info :info)))
(cond
2011-09-18 22:57:46 +02:00
((eq type 'add)
;; update our path=>docid map; we use this when composing messages to
;; add draft messages to the db, so when we're sending them, we can move
2011-12-13 08:07:38 +01:00
;; to the sent folder using the `mu4e-proc-move'.
(puthash (plist-get info :path) (plist-get info :docid) mu4e-path-docid-map))
2011-09-30 07:37:47 +02:00
((eq type 'version)
(setq
2011-12-13 08:07:38 +01:00
mu4e-version (plist-get info :version)
mu4e-doccount (plist-get-info :doccount)))
((eq type 'index)
(if (eq (plist-get info :status) 'running)
(message (format "Indexing... processed %d, updated %d"
(plist-get info :processed) (plist-get info :updated)))
(message
(format "Indexing completed; processed %d, updated %d, cleaned-up %d"
(plist-get info :processed) (plist-get info :updated)
2011-09-19 23:20:59 +02:00
(plist-get info :cleaned-up)))))
((plist-get info :message) (message "%s" (plist-get info :message))))))
2011-12-13 08:07:38 +01:00
(defun mu4e-default-handler (&rest args)
"Dummy handler function."
(error "Not handled: %S" args))
2011-12-26 11:17:28 +01:00
(defconst mu4e-server-name "*mu4e-server*"
2011-09-30 07:37:47 +02:00
"*internal* Name of the server process, buffer.")
2011-12-13 08:07:38 +01:00
(defun mu4e-start-proc ()
2011-09-12 19:52:32 +02:00
"Start the mu server process."
;; TODO: add version check
2011-12-13 08:07:38 +01:00
(unless (file-executable-p mu4e-mu-binary)
(error (format "`mu4e-mu-binary' (%S) not found" mu4e-mu-binary)))
2011-09-12 19:52:32 +02:00
(let* ((process-connection-type nil) ;; use a pipe
(args '("server"))
2011-12-13 08:07:38 +01:00
(args (append args (when mu4e-mu-home
(list (concat "--muhome=" mu4e-mu-home))))))
(setq mu4e-buf "")
(setq mu4e-mu-proc (apply 'start-process
mu4e-server-name mu4e-server-name
mu4e-mu-binary args))
;; register a function for (:info ...) sexps
2011-12-13 08:07:38 +01:00
(setq mu4e-proc-info-func 'mu4e-proc-info-handler)
(when mu4e-mu-proc
2011-12-23 18:09:03 +01:00
(set-process-query-on-exit-flag mu4e-mu-proc nil)
2011-12-13 08:07:38 +01:00
(set-process-coding-system mu4e-mu-proc 'binary 'utf-8-unix)
(set-process-filter mu4e-mu-proc 'mu4e-proc-filter)
(set-process-sentinel mu4e-mu-proc 'mu4e-proc-sentinel))))
2011-09-12 19:52:32 +02:00
2011-12-13 08:07:38 +01:00
(defun mu4e-kill-proc ()
2011-09-12 19:52:32 +02:00
"Kill the mu server process."
2011-12-13 08:07:38 +01:00
(let* ((buf (get-buffer mu4e-server-name))
(proc (and buf (get-buffer-process buf))))
2011-11-05 09:26:24 +01:00
(when proc
2011-09-30 07:37:47 +02:00
(let ((delete-exited-processes t))
2011-10-10 07:38:14 +02:00
;; the mu server signal handler will make it quit after 'quit'
2011-12-13 08:07:38 +01:00
(mu4e-proc-send-command "quit"))
2011-11-05 09:26:24 +01:00
;; try sending SIGINT (C-c) to process, so it can exit gracefully
(ignore-errors
2011-11-05 09:26:24 +01:00
(signal-process proc 'SIGINT))))
(setq
2011-12-13 08:07:38 +01:00
mu4e-mu-proc nil
mu4e-buf nil))
2011-09-12 19:52:32 +02:00
2011-12-13 08:07:38 +01:00
(defun mu4e-proc-is-running ()
(and mu4e-mu-proc (eq (process-status mu4e-mu-proc) 'run)))
2011-09-12 19:52:32 +02:00
2011-12-13 08:07:38 +01:00
(defun mu4e-proc-eat-sexp-from-buf ()
"'Eat' the next s-expression from `mu4e-buf'. `mu4e-buf gets its
contents from the mu-servers in the following form:
\376<len-of-sexp>\376<sexp>
2011-12-13 08:07:38 +01:00
Function returns this sexp, or nil if there was none. `mu4e-buf' is
updated as well, with all processed sexp data removed."
2011-12-13 08:07:38 +01:00
(when mu4e-buf
2011-11-05 09:26:24 +01:00
;; TODO: maybe try a non-regexp solution?
2011-12-13 08:07:38 +01:00
(let* ((b (string-match "\376\\([0-9]+\\)\376" mu4e-buf))
2011-09-30 07:37:47 +02:00
(sexp-len
2011-12-13 08:07:38 +01:00
(when b (string-to-number (match-string 1 mu4e-buf)))))
;; does mu4e-buf contain the full sexp?
(when (and b (>= (length mu4e-buf) (+ sexp-len (match-end 0))))
2011-09-30 07:37:47 +02:00
;; clear-up start
2011-12-13 08:07:38 +01:00
(setq mu4e-buf (substring mu4e-buf (match-end 0)))
2011-10-26 21:00:08 +02:00
;; note: we read the input in binary mode -- here, we take the part that
;; is the sexp, and convert that to utf-8, before we interpret it.
(let ((objcons
2011-11-05 09:26:24 +01:00
(ignore-errors ;; note: this may fail if we killed the process
;; in the middle
(read-from-string
2011-12-13 08:07:38 +01:00
(decode-coding-string (substring mu4e-buf 0 sexp-len) 'utf-8)))))
2011-11-05 09:26:24 +01:00
(when objcons
2011-12-13 08:07:38 +01:00
(setq mu4e-buf (substring mu4e-buf sexp-len))
2011-11-05 09:26:24 +01:00
(car objcons)))))))
2011-09-12 19:52:32 +02:00
2011-12-13 08:07:38 +01:00
(defun mu4e-proc-filter (proc str)
2011-09-12 19:52:32 +02:00
"A process-filter for the 'mu server' output; it accumulates the
strings into valid sexps by checking of the ';;eox' end-of-sexp
marker, and then evaluating them.
2011-09-12 19:52:32 +02:00
The server output is as follows:
2011-09-12 19:52:32 +02:00
1. an error
(:error 2 :error-message \"unknown command\")
;; eox
2011-12-13 08:07:38 +01:00
=> this will be passed to `mu4e-proc-error-func'.
2011-09-12 19:52:32 +02:00
2a. a message sexp looks something like:
2011-09-12 19:52:32 +02:00
\(
:docid 1585
:from ((\"Donald Duck\" . \"donald@example.com\"))
:to ((\"Mickey Mouse\" . \"mickey@example.com\"))
:subject \"Wicked stuff\"
:date (20023 26572 0)
:size 15165
:references (\"200208121222.g7CCMdb80690@msg.id\")
:in-reply-to \"200208121222.g7CCMdb80690@msg.id\"
:message-id \"foobar32423847ef23@pluto.net\"
:maildir: \"/archive\"
:path \"/home/mickey/Maildir/inbox/cur/1312254065_3.32282.pluto,4cd5bd4e9:2,\"
:priority high
:flags (new unread)
:attachments ((2 \"hello.jpg\" \"image/jpeg\") (3 \"laah.mp3\" \"audio/mp3\"))
:body-txt \" <message body>\"
\)
;; eox
2011-12-13 08:07:38 +01:00
=> this will be passed to `mu4e-proc-header-func'.
2b. After the list of message sexps has been returned (see 2a.),
we'll receive a sexp that looks like
(:found <n>) with n the number of messages found. The <n> will be
2011-12-13 08:07:38 +01:00
passed to `mu4e-proc-found-func'.
3. a view looks like:
(:view <msg-sexp>)
2011-12-13 08:07:38 +01:00
=> the <msg-sexp> (see 2.) will be passed to `mu4e-proc-view-func'.
4. a database update looks like:
(:update <msg-sexp> :move <nil-or-t>)
=> the <msg-sexp> (see 2.) will be passed to
2011-12-13 08:07:38 +01:00
`mu4e-proc-update-func', :move tells us whether this is a move to
another maildir, or merely a flag change.
5. a remove looks like:
(:remove <docid>)
2011-12-13 08:07:38 +01:00
=> the docid will be passed to `mu4e-proc-remove-func'
6. a compose looks like:
(:compose <msg-sexp> :action <reply|forward>) => the <msg-sexp>
and either 'reply or 'forward will be passed
2011-12-13 08:07:38 +01:00
`mu4e-proc-compose-func'."
(mu4e-proc-log "* Received %d byte(s)" (length str))
(setq mu4e-buf (concat mu4e-buf str)) ;; update our buffer
(let ((sexp (mu4e-proc-eat-sexp-from-buf)))
(while sexp
2011-12-13 08:07:38 +01:00
(mu4e-proc-log "<- %S" sexp)
(cond
2011-09-18 22:57:46 +02:00
;; a header plist can be recognized by the existence of a :date field
((plist-get sexp :date)
2011-12-13 08:07:38 +01:00
(funcall mu4e-proc-header-func sexp))
;; the found sexp, we receive after getting all the headers
((plist-get sexp :found)
2011-12-13 08:07:38 +01:00
(funcall mu4e-proc-found-func (plist-get sexp :found)))
;; viewing a specific message
((plist-get sexp :view)
2011-12-13 08:07:38 +01:00
(funcall mu4e-proc-view-func (plist-get sexp :view)))
2011-09-22 20:01:35 +02:00
;; receive an erase message
((plist-get sexp :erase)
(funcall mu4e-proc-erase-func))
;; receive a :sent message
((plist-get sexp :sent)
(funcall mu4e-proc-sent-func
(plist-get sexp :docid)
(plist-get sexp :path)))
;; receive a pong message
((plist-get sexp :pong)
2011-12-13 08:07:38 +01:00
(funcall mu4e-proc-pong-func
(plist-get sexp :version) (plist-get sexp :doccount)))
2011-09-22 20:01:35 +02:00
;; something got moved/flags changed
((plist-get sexp :update)
2011-12-13 08:07:38 +01:00
(funcall mu4e-proc-update-func
(plist-get sexp :update) (plist-get sexp :move)))
2011-09-22 20:01:35 +02:00
;; a message got removed
((plist-get sexp :remove)
2011-12-13 08:07:38 +01:00
(funcall mu4e-proc-remove-func (plist-get sexp :remove)))
2011-09-22 20:01:35 +02:00
;; start composing a new message
((plist-get sexp :compose-type)
2011-12-13 08:07:38 +01:00
(funcall mu4e-proc-compose-func
2011-10-02 20:35:03 +02:00
(plist-get sexp :compose-type)
(plist-get sexp :original)
(plist-get sexp :include)))
2011-09-22 20:01:35 +02:00
;; get some info
((plist-get sexp :info)
2011-12-13 08:07:38 +01:00
(funcall mu4e-proc-info-func sexp))
2011-09-22 20:01:35 +02:00
;; receive an error
((plist-get sexp :error)
2011-12-13 08:07:38 +01:00
(funcall mu4e-proc-error-func sexp))
(t (message "Unexpected data from server [%S]" sexp)))
2011-12-13 08:07:38 +01:00
(setq sexp (mu4e-proc-eat-sexp-from-buf)))))
2012-01-07 13:26:34 +01:00
;; error codes are defined in src/mu-util.h
;;(defconst mu4e-xapian-empty 19 "Error code: xapian is empty/non-existent")
2011-12-13 08:07:38 +01:00
(defun mu4e-proc-sentinel (proc msg)
"Function that will be called when the mu-server process
terminates."
(let ((status (process-status proc)) (code (process-exit-status proc)))
2011-12-13 08:07:38 +01:00
(setq mu4e-mu-proc nil)
(setq mu4e-buf "") ;; clear any half-received sexps
(cond
((eq status 'signal)
(cond
2011-09-30 07:37:47 +02:00
((eq code 9) (message nil))
;;(message "the mu server process has been stopped"))
(t (message (format "mu server process received signal %d" code)))))
((eq status 'exit)
(cond
2011-11-05 09:26:24 +01:00
((eq code 0)
(message nil)) ;; don't do anything
2011-09-20 22:59:20 +02:00
((eq code 11)
(message "Database is locked by another process"))
((eq code 19)
2012-01-07 13:26:34 +01:00
(message "Database is empty or non-existent; try indexing some messages"))
(t (message (format "mu server process ended with exit code %d" code)))))
(t
2012-01-07 13:26:34 +01:00
(message "Something bad happened to the mu server process")))))
2011-09-12 19:52:32 +02:00
2011-12-13 08:07:38 +01:00
(defconst mu4e-proc-log-buffer-name "*mu4e-log*"
"*internal* Name of the logging buffer.")
2011-09-12 19:52:32 +02:00
2011-12-13 08:07:38 +01:00
(defun mu4e-proc-log (frm &rest args)
"Write something in the *mu4e-log* buffer - mainly useful for debugging."
(when mu4e-debug
(with-current-buffer (get-buffer-create mu4e-proc-log-buffer-name)
2011-09-18 22:57:46 +02:00
(goto-char (point-max))
(insert (apply 'format (concat (format-time-string "%Y-%m-%d %T "
(current-time)) frm "\n") args)))))
2011-09-12 19:52:32 +02:00
2011-12-13 08:07:38 +01:00
(defun mu4e-proc-send-command (frm &rest args)
"Send as command to the mu server process; start the process if needed."
2011-12-13 08:07:38 +01:00
(unless (mu4e-proc-is-running)
(mu4e-start-proc))
(let ((cmd (apply 'format frm args)))
2011-12-13 08:07:38 +01:00
(mu4e-proc-log (concat "-> " cmd))
(process-send-string mu4e-mu-proc (concat cmd "\n"))))
2011-09-12 19:52:32 +02:00
2011-12-13 08:07:38 +01:00
(defun mu4e-proc-remove-msg (docid)
2011-09-12 19:52:32 +02:00
"Remove message identified by DOCID. The results are reporter
through either (:update ... ) or (:error ) sexp, which are handled
2011-12-13 08:07:38 +01:00
my `mu4e-proc-update-func' and `mu4e-proc-error-func', respectively."
(mu4e-proc-send-command "remove %d" docid))
2011-09-12 19:52:32 +02:00
2011-12-13 08:07:38 +01:00
(defun mu4e-proc-find (expr &optional maxnum)
"Start a database query for EXPR, getting up to MAXNUM
results (or -1 for unlimited). For each result found, a function is
called, depending on the kind of result. The variables
2011-12-13 08:07:38 +01:00
`mu4e-proc-header-func' and `mu4e-proc-error-func' contain the function
2011-09-12 19:52:32 +02:00
that will be called for, resp., a message (header row) or an
error."
2011-12-13 08:07:38 +01:00
(mu4e-proc-send-command "find \"%s\" %d"
expr (if maxnum maxnum -1)))
2011-09-12 19:52:32 +02:00
2011-12-13 08:07:38 +01:00
(defun mu4e-proc-move-msg (docid targetmdir &optional flags)
"Move message identified by DOCID to TARGETMDIR, optionally
setting FLAGS in the process.
2011-09-12 19:52:32 +02:00
TARGETDIR must be a maildir, that is, the part _without_ cur/ or
new/ or the root-maildir-prefix. E.g. \"/archive\". This directory
must already exist.
2011-09-12 19:52:32 +02:00
The FLAGS parameter can have the following forms:
1. a list of flags such as '(passed replied seen)
2. a string containing the one-char versions of the flags, e.g. \"PRS\"
3. a delta-string specifying the changes with +/- and the one-char flags,
e.g. \"+S-N\" to set Seen and remove New.
The flags are any of `deleted', `flagged', `new', `passed', `replied' `seen' or
`trashed', or the corresponding \"DFNPRST\" as defined in [1]. See
2011-12-13 08:07:38 +01:00
`mu4e-string-to-flags' and `mu4e-flags-to-string'.
2011-09-12 19:52:32 +02:00
The server reports the results for the operation through
2011-12-13 08:07:38 +01:00
`mu4e-proc-update-func'.
2011-09-12 19:52:32 +02:00
The results are reported through either (:update ... )
2011-12-13 08:07:38 +01:00
or (:error ) sexp, which are handled my `mu4e-proc-update-func' and
`mu4e-proc-error-func', respectively."
2011-09-12 19:52:32 +02:00
(let
2011-12-13 08:07:38 +01:00
((flagstr (if (stringp flags) flags (mu4e-flags-to-string flags)))
(fullpath (concat mu4e-maildir targetmdir)))
(unless (and (file-directory-p fullpath) (file-writable-p fullpath))
(error "Not a writable directory: %s" fullpath))
2011-09-19 23:20:59 +02:00
;; note, we send the maildir, *not* the full path
2011-12-13 08:07:38 +01:00
(mu4e-proc-send-command "move %d \"%s\" %s" docid
targetmdir flagstr)))
2011-09-12 19:52:32 +02:00
2011-12-13 08:07:38 +01:00
(defun mu4e-proc-flag (docid-or-msgid flags)
2011-10-02 20:35:03 +02:00
"Set FLAGS for the message identified by either DOCID-OR-MSGID."
2011-12-13 08:07:38 +01:00
(let ((flagstr (if (stringp flags) flags (mu4e-flags-to-string flags))))
(mu4e-proc-send-command "flag %S %s" docid-or-msgid flagstr)))
2011-09-12 19:52:32 +02:00
2011-12-13 08:07:38 +01:00
(defun mu4e-proc-index (maildir)
2011-09-18 22:57:46 +02:00
"Update the message database for MAILDIR."
2011-12-13 08:07:38 +01:00
(mu4e-proc-send-command "index \"%s\"" maildir))
2011-09-18 22:57:46 +02:00
2011-12-13 08:07:38 +01:00
(defun mu4e-proc-add (path maildir)
2011-09-19 23:20:59 +02:00
"Add the message at PATH to the database, with MAILDIR
set to e.g. '/drafts'; if this works, we will receive (:info :path
<path> :docid <docid>)."
2011-12-13 08:07:38 +01:00
(mu4e-proc-send-command "add \"%s\" \"%s\"" path maildir))
2011-09-19 23:20:59 +02:00
(defun mu4e-proc-mkdir (maildir)
"Update the message database for MAILDIR."
(mu4e-proc-send-command "mkdir \"%s\"" maildir))
2011-12-13 08:07:38 +01:00
(defun mu4e-proc-save (docid partidx path)
2011-09-19 23:20:59 +02:00
"Save attachment PARTIDX from message with DOCID to PATH."
2011-12-13 08:07:38 +01:00
(mu4e-proc-send-command "save %d %d \"%s\"" docid partidx path))
2011-09-19 23:20:59 +02:00
2011-12-13 08:07:38 +01:00
(defun mu4e-proc-open (docid partidx)
2011-09-19 23:20:59 +02:00
"Open attachment PARTIDX from message with DOCID."
2011-12-13 08:07:38 +01:00
(mu4e-proc-send-command "open %d %d" docid partidx))
2011-09-12 19:52:32 +02:00
2011-12-13 08:07:38 +01:00
(defun mu4e-proc-ping ()
"Sends a ping to the mu server, expecting a (:pong ...) in
response."
2011-12-13 08:07:38 +01:00
(mu4e-proc-send-command "ping"))
(defun mu4e-proc-sent (draftpath maildir)
"Tell the mu server that message DRAFTPATH has been send and its MAILDIR,
expecting a (:sent <docid> :path <draftpath>) in response."
(mu4e-proc-send-command "sent %s %s" draftpath maildir))
(defun mu4e-proc-view-msg (docid-or-msgid)
"Get one particular message based on its DOCID-OR-MSGID. The result will
2011-12-13 08:07:38 +01:00
be delivered to the function registered as `mu4e-proc-message-func'."
(if (stringp docid-or-msgid)
(mu4e-proc-send-command "view %s" docid-or-msgid)
(mu4e-proc-send-command "view %d" docid-or-msgid)))
2011-12-13 08:07:38 +01:00
(defun mu4e-proc-compose (compose-type docid)
2011-09-30 07:37:47 +02:00
"Start composing a message with DOCID and COMPOSE-TYPE (a symbol,
2011-10-02 20:35:03 +02:00
either `forward', `reply' or `edit'.
The result will be delivered to the function registered as
2011-12-13 08:07:38 +01:00
`mu4e-proc-compose-func'."
2011-10-02 20:35:03 +02:00
(unless (member compose-type '(forward reply edit))
(error "Unsupported compose-type %S" compose-type))
2011-12-13 08:07:38 +01:00
(mu4e-proc-send-command "compose %s %d" (symbol-name compose-type) docid))
2011-09-12 19:52:32 +02:00
2011-09-22 20:01:35 +02:00
2011-12-13 08:07:38 +01:00
(provide 'mu4e-proc)
;; End of mu4e-proc.el