* mua updates
This commit is contained in:
@ -83,12 +83,53 @@ maildir"
|
||||
(chosen (ido-completing-read prompt showfolders)))
|
||||
(concat (if fullpath mua/maildir "") chosen)))
|
||||
|
||||
(defun mua/mu-run (&rest args)
|
||||
"Run 'mu' synchronously with ARGS as command-line argument;,
|
||||
where <exit-code> is the exit code of the program, or 1 if the
|
||||
process was killed. <str> contains whatever the command wrote on
|
||||
standard output/error, or nil if there was none or in case of
|
||||
error. Basically, `mua/mu-run' is like `shell-command-to-string',
|
||||
but with better possibilities for error handling"
|
||||
(let* ((rv)
|
||||
(str (with-output-to-string
|
||||
(with-current-buffer standard-output ;; but we also get stderr...
|
||||
(setq rv (apply 'call-process mua/mu-binary nil t nil
|
||||
args))))))
|
||||
`(,(if (numberp rv) rv 1) . ,str)))
|
||||
|
||||
(defun mua/mu-binary-version ()
|
||||
"Get the version of the mu binary."
|
||||
(let ((cmd (concat mua/mu-binary
|
||||
" --version | head -1 | sed 's/.*version //'")))
|
||||
(substring (shell-command-to-string cmd) 0 -1)))
|
||||
"Get the version string of the mu binary, or nil if we failed
|
||||
to get it"
|
||||
(let ((rv (mua/mu-run "--version")))
|
||||
(if (and (= (car rv) 0) (string-match "version \\(.*\\)$" (cdr rv)))
|
||||
(match-string 1 (cdr rv))
|
||||
(mua/warn "Failed to get version string"))))
|
||||
|
||||
(defun mua/mu-mv (src target &optional flags))
|
||||
|
||||
(defun mua/mu-add (src target &optional flags))
|
||||
|
||||
(defun mua/mu-remove (path)
|
||||
"Remove message at PATH from the database"
|
||||
|
||||
|
||||
)
|
||||
|
||||
(defun mua/mu-mv (src target &optional flags))
|
||||
|
||||
|
||||
(defun mua/mu-view-sexp (path)
|
||||
"Return a string with an s-expression representing the message
|
||||
at PATH; the format is described in `mua/msg-from-string', and
|
||||
that function converts the string into a Lisp object (plist)"
|
||||
(if (not (file-readable-p path))
|
||||
(mua/warn "Path is note a readable file")
|
||||
(let* ((rv (mua/mu-run "view" "--format=sexp" path))
|
||||
(code (car rv)) (str (cdr rv)))
|
||||
(if (= code 0)
|
||||
str
|
||||
(mua/warn "mu view failed (%d): %s"
|
||||
code (if str str "error"))))))
|
||||
|
||||
|
||||
(provide 'mua-common)
|
||||
|
||||
@ -67,21 +67,6 @@ database -- at least not in a usable way."
|
||||
(error "Failed to parse message")))
|
||||
|
||||
|
||||
(defun mua/msg-from-path (path)
|
||||
"Get the an s-expression (plist) describing the e-mail message
|
||||
at path, or nil if it failed. This functions uses 'mu view' to
|
||||
obtain the s-expression. For the format, see `mua/msg-from-string'"
|
||||
(if (not (file-readable-p path))
|
||||
(progn
|
||||
(mua/warn "Message is not readable")
|
||||
(mua/log "not readable: %s" path))
|
||||
(condition-case nil
|
||||
(progn (let* ((cmd (concat mua/mu-binary " view --format=sexp " path))
|
||||
(str (shell-command-to-string cmd)))
|
||||
(mua/msg-from-string str)))
|
||||
(error "Failed to read/parse message %s" path))))
|
||||
|
||||
|
||||
(defun mua/msg-body-txt-or-html (msg)
|
||||
"Get :body-txt, or if not available, :body-html converted to
|
||||
text, using `html2text'."
|
||||
|
||||
@ -53,18 +53,16 @@ we quit from this view. Also, if PARENTBUF is a find buffer (ie.,
|
||||
has mu-headers-mode as its major mode), this allows various
|
||||
commands (navigation, marking etc.) to be applied to this
|
||||
buffer."
|
||||
(let* ((msg (mua/msg-from-path path))
|
||||
(buf (get-buffer-create mua/view-buffer-name))
|
||||
(str (mua/view-message msg)))
|
||||
(when (and msg str)
|
||||
|
||||
(switch-to-buffer buf)
|
||||
(let* ((sexp (mua/mu-view-sexp path))
|
||||
(msg (and sexp (mua/msg-from-string sexp))))
|
||||
(when msg
|
||||
(switch-to-buffer (get-buffer-create mua/view-buffer-name))
|
||||
(let ((inhibit-read-only t))
|
||||
(erase-buffer)
|
||||
(insert str))
|
||||
(insert (mua/view-message msg)))
|
||||
|
||||
(mua/view-mode)
|
||||
|
||||
|
||||
(setq ;; these are buffer-local
|
||||
mua/hdrs-buffer headersbuf
|
||||
mua/parent-buffer headersbuf)
|
||||
|
||||
@ -66,9 +66,6 @@ quitted, it switches back to its parent buffer")
|
||||
(setq mua/working-folders
|
||||
'("/archive" "/bulkarchive" "/todo"))
|
||||
|
||||
|
||||
|
||||
|
||||
(setq mua/header-fields
|
||||
'( (:date . 25)
|
||||
(:flags . 6)
|
||||
|
||||
Reference in New Issue
Block a user