mirror of https://github.com/djcb/mu.git
mu4e: mu4e-proc: Fix flymake warnings, whitespace
This commit is contained in:
parent
4b52ddc1cb
commit
0437edc982
|
@ -1,6 +1,6 @@
|
||||||
;; mu4e-proc.el -- part of mu4e, the mu mail user agent
|
;; mu4e-proc.el -- part of mu4e, the mu mail user agent
|
||||||
;;
|
;;
|
||||||
;; Copyright (C) 2011-2017 Dirk-Jan C. Binnema
|
;; Copyright (C) 2011-2019 Dirk-Jan C. Binnema
|
||||||
|
|
||||||
;; Author: Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
;; Author: Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
||||||
;; Maintainer: Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
;; Maintainer: Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
||||||
|
@ -37,13 +37,11 @@
|
||||||
|
|
||||||
;; dealing with the length cookie that precedes expressions
|
;; dealing with the length cookie that precedes expressions
|
||||||
(defconst mu4e~cookie-pre "\376"
|
(defconst mu4e~cookie-pre "\376"
|
||||||
"Each expression we get from the backend (mu server) starts with
|
"Each expression starts with a length cookie:
|
||||||
a length cookie:
|
<`mu4e~cookie-pre'><length-in-hex><`mu4e~cookie-post'>.")
|
||||||
<`mu4e~cookie-pre'><length-in-hex><`mu4e~cookie-post'>.")
|
|
||||||
(defconst mu4e~cookie-post "\377"
|
(defconst mu4e~cookie-post "\377"
|
||||||
"Each expression we get from the backend (mu server) starts with
|
"Each expression starts with a length cookie:
|
||||||
a length cookie:
|
<`mu4e~cookie-pre'><length-in-hex><`mu4e~cookie-post'>.")
|
||||||
<`mu4e~cookie-pre'><length-in-hex><`mu4e~cookie-post'>.")
|
|
||||||
(defconst mu4e~cookie-matcher-rx
|
(defconst mu4e~cookie-matcher-rx
|
||||||
(concat mu4e~cookie-pre "\\([[:xdigit:]]+\\)" mu4e~cookie-post)
|
(concat mu4e~cookie-pre "\\([[:xdigit:]]+\\)" mu4e~cookie-post)
|
||||||
"Regular expression matching the length cookie.
|
"Regular expression matching the length cookie.
|
||||||
|
@ -56,12 +54,11 @@ Match 1 will be the length (in hex).")
|
||||||
(defvar mu4e~proc-process nil
|
(defvar mu4e~proc-process nil
|
||||||
"The mu-server process.")
|
"The mu-server process.")
|
||||||
|
|
||||||
|
|
||||||
(defun mu4e~proc-running-p ()
|
(defun mu4e~proc-running-p ()
|
||||||
"Whether the mu process is running."
|
"Whether the mu process is running."
|
||||||
(when (and mu4e~proc-process
|
(when (and mu4e~proc-process
|
||||||
(memq (process-status mu4e~proc-process)
|
(memq (process-status mu4e~proc-process)
|
||||||
'(run open listen connect stop)))
|
'(run open listen connect stop)))
|
||||||
t))
|
t))
|
||||||
|
|
||||||
(defsubst mu4e~proc-eat-sexp-from-buf ()
|
(defsubst mu4e~proc-eat-sexp-from-buf ()
|
||||||
|
@ -76,36 +73,37 @@ removed."
|
||||||
;; mu4e~cookie-matcher-rx:
|
;; mu4e~cookie-matcher-rx:
|
||||||
;; (concat mu4e~cookie-pre "\\([[:xdigit:]]+\\)]" mu4e~cookie-post)
|
;; (concat mu4e~cookie-pre "\\([[:xdigit:]]+\\)]" mu4e~cookie-post)
|
||||||
(let ((b (string-match mu4e~cookie-matcher-rx mu4e~proc-buf))
|
(let ((b (string-match mu4e~cookie-matcher-rx mu4e~proc-buf))
|
||||||
(sexp-len) (objcons))
|
(sexp-len) (objcons))
|
||||||
(when b
|
(when b
|
||||||
(setq sexp-len (string-to-number (match-string 1 mu4e~proc-buf) 16))
|
(setq sexp-len (string-to-number (match-string 1 mu4e~proc-buf) 16))
|
||||||
;; does mu4e~proc-buf contain the full sexp?
|
;; does mu4e~proc-buf contain the full sexp?
|
||||||
(when (>= (length mu4e~proc-buf) (+ sexp-len (match-end 0)))
|
(when (>= (length mu4e~proc-buf) (+ sexp-len (match-end 0)))
|
||||||
;; clear-up start
|
;; clear-up start
|
||||||
(setq mu4e~proc-buf (substring mu4e~proc-buf (match-end 0)))
|
(setq mu4e~proc-buf (substring mu4e~proc-buf (match-end 0)))
|
||||||
;; note: we read the input in binary mode -- here, we take the part
|
;; 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
|
;; that is the sexp, and convert that to utf-8, before we interpret
|
||||||
;; it.
|
;; it.
|
||||||
(setq objcons (read-from-string
|
(setq objcons (read-from-string
|
||||||
(decode-coding-string
|
(decode-coding-string
|
||||||
(substring mu4e~proc-buf 0 sexp-len)
|
(substring mu4e~proc-buf 0 sexp-len)
|
||||||
'utf-8 t)))
|
'utf-8 t)))
|
||||||
(when objcons
|
(when objcons
|
||||||
(setq mu4e~proc-buf (substring mu4e~proc-buf sexp-len))
|
(setq mu4e~proc-buf (substring mu4e~proc-buf sexp-len))
|
||||||
(car objcons)))))))
|
(car objcons)))))))
|
||||||
|
|
||||||
|
|
||||||
(defun mu4e~proc-filter (proc str)
|
(defun mu4e~proc-filter (proc str)
|
||||||
"A process-filter for the 'mu server' output.
|
"Filter string STR from PROC.
|
||||||
It accumulates the strings into valid sexps by checking of the
|
This process the the 'mu server' output. It accumulates the
|
||||||
';;eox' end-of-sexp marker, and then evaluating them.
|
strings into valid sexps by checking of the ';;eox' `end-of-sexp'
|
||||||
|
marker, and then evaluating them.
|
||||||
|
|
||||||
The server output is as follows:
|
The server output is as follows:
|
||||||
|
|
||||||
1. an error
|
1. an error
|
||||||
(:error 2 :message \"unknown command\")
|
(:error 2 :message \"unknown command\")
|
||||||
;; eox
|
;; eox
|
||||||
=> this will be passed to `mu4e-error-func'.
|
=> passed to `mu4e-error-func'.
|
||||||
|
|
||||||
2a. a message sexp looks something like:
|
2a. a message sexp looks something like:
|
||||||
\(
|
\(
|
||||||
|
@ -156,92 +154,92 @@ The server output is as follows:
|
||||||
(let ((sexp (mu4e~proc-eat-sexp-from-buf)))
|
(let ((sexp (mu4e~proc-eat-sexp-from-buf)))
|
||||||
(with-local-quit
|
(with-local-quit
|
||||||
(while sexp
|
(while sexp
|
||||||
(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 :date)
|
||||||
(funcall mu4e-header-func sexp))
|
(funcall mu4e-header-func sexp))
|
||||||
|
|
||||||
;; 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)
|
||||||
(funcall mu4e-found-func (plist-get sexp :found)))
|
(funcall mu4e-found-func (plist-get sexp :found)))
|
||||||
|
|
||||||
;; 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 (plist-get sexp :view)))
|
||||||
|
|
||||||
;; receive an erase message
|
;; receive an erase message
|
||||||
((plist-get sexp :erase)
|
((plist-get sexp :erase)
|
||||||
(funcall mu4e-erase-func))
|
(funcall mu4e-erase-func))
|
||||||
|
|
||||||
;; receive a :sent message
|
;; receive a :sent message
|
||||||
((plist-get sexp :sent)
|
((plist-get sexp :sent)
|
||||||
(funcall mu4e-sent-func
|
(funcall mu4e-sent-func
|
||||||
(plist-get sexp :docid)
|
(plist-get sexp :docid)
|
||||||
(plist-get sexp :path)))
|
(plist-get sexp :path)))
|
||||||
|
|
||||||
;; received a pong message
|
;; received a pong message
|
||||||
((plist-get sexp :pong)
|
((plist-get sexp :pong)
|
||||||
(funcall mu4e-pong-func
|
(funcall mu4e-pong-func
|
||||||
(plist-get sexp :props)))
|
(plist-get sexp :props)))
|
||||||
|
|
||||||
;; received a contacts message
|
;; received a contacts message
|
||||||
;; note: we use 'member', to match (:contacts nil)
|
;; note: we use 'member', to match (:contacts nil)
|
||||||
((plist-member sexp :contacts)
|
((plist-member sexp :contacts)
|
||||||
(funcall mu4e-contacts-func
|
(funcall mu4e-contacts-func
|
||||||
(plist-get sexp :contacts)))
|
(plist-get sexp :contacts)))
|
||||||
|
|
||||||
;; 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)
|
(plist-get sexp :update)
|
||||||
(plist-get sexp :move)
|
(plist-get sexp :move)
|
||||||
(plist-get sexp :maybe-view)))
|
(plist-get sexp :maybe-view)))
|
||||||
|
|
||||||
;; a message got removed
|
;; a message got removed
|
||||||
((plist-get sexp :remove)
|
((plist-get sexp :remove)
|
||||||
(funcall mu4e-remove-func (plist-get sexp :remove)))
|
(funcall mu4e-remove-func (plist-get sexp :remove)))
|
||||||
|
|
||||||
;; start composing a new message
|
;; start composing a new message
|
||||||
((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)
|
(plist-get sexp :original)
|
||||||
(plist-get sexp :include)))
|
(plist-get sexp :include)))
|
||||||
|
|
||||||
;; do something with a temporary file
|
;; do something with a temporary file
|
||||||
((plist-get sexp :temp)
|
((plist-get sexp :temp)
|
||||||
(funcall mu4e-temp-func
|
(funcall mu4e-temp-func
|
||||||
(plist-get sexp :temp) ;; name of the temp file
|
(plist-get sexp :temp) ;; name of the temp file
|
||||||
(plist-get sexp :what) ;; what to do with it
|
(plist-get sexp :what) ;; what to do with it
|
||||||
;; (pipe|emacs|open-with...)
|
;; (pipe|emacs|open-with...)
|
||||||
(plist-get sexp :docid) ;; docid of the message
|
(plist-get sexp :docid) ;; docid of the message
|
||||||
(plist-get sexp :param)));; parameter for the action
|
(plist-get sexp :param)));; parameter for the action
|
||||||
|
|
||||||
;; get some info
|
;; get some info
|
||||||
((plist-get sexp :info)
|
((plist-get sexp :info)
|
||||||
(funcall mu4e-info-func sexp))
|
(funcall mu4e-info-func sexp))
|
||||||
|
|
||||||
;; receive an error
|
;; receive an error
|
||||||
((plist-get sexp :error)
|
((plist-get sexp :error)
|
||||||
(funcall mu4e-error-func
|
(funcall mu4e-error-func
|
||||||
(plist-get sexp :error)
|
(plist-get sexp :error)
|
||||||
(plist-get sexp :message)))
|
(plist-get sexp :message)))
|
||||||
|
|
||||||
(t (mu4e-message "Unexpected data from server [%S]" sexp)))
|
(t (mu4e-message "Unexpected data from server [%S]" sexp)))
|
||||||
|
|
||||||
(setq sexp (mu4e~proc-eat-sexp-from-buf))))))
|
(setq sexp (mu4e~proc-eat-sexp-from-buf))))))
|
||||||
|
|
||||||
(defun mu4e~escape (str)
|
(defun mu4e~escape (str)
|
||||||
"Escape STRING for transport -- put it in quotes, and escape
|
"Escape string STR for transport.
|
||||||
existing quotation. In particular, backslashes and
|
Put it in quotes, and escape existing quotation. In particular,
|
||||||
double-quotes."
|
backslashes and double-quotes."
|
||||||
(let ((esc (replace-regexp-in-string "\\\\" "\\\\\\\\" str)))
|
(let ((esc (replace-regexp-in-string "\\\\" "\\\\\\\\" str)))
|
||||||
(format "\"%s\"" (replace-regexp-in-string "\"" "\\\\\"" esc))))
|
(format "\"%s\"" (replace-regexp-in-string "\"" "\\\\\"" esc))))
|
||||||
|
|
||||||
|
|
||||||
(defun mu4e~proc-send-command (frm &rest args)
|
(defun mu4e~proc-send-command (frm &rest args)
|
||||||
"Send as command to the mu server process.
|
"Send string from FRM and ARGS to the mu server process.
|
||||||
Start the process if needed."
|
Start the process if needed."
|
||||||
(unless (mu4e~proc-running-p)
|
(unless (mu4e~proc-running-p)
|
||||||
(mu4e~proc-start))
|
(mu4e~proc-start))
|
||||||
|
@ -254,13 +252,13 @@ Start the process if needed."
|
||||||
(unless (file-executable-p mu4e-mu-binary)
|
(unless (file-executable-p mu4e-mu-binary)
|
||||||
(mu4e-error (format "`mu4e-mu-binary' (%S) not found" mu4e-mu-binary)))
|
(mu4e-error (format "`mu4e-mu-binary' (%S) not found" mu4e-mu-binary)))
|
||||||
(let* ((process-connection-type nil) ;; use a pipe
|
(let* ((process-connection-type nil) ;; use a pipe
|
||||||
(args '("server"))
|
(args '("server"))
|
||||||
(args (append args (when mu4e-mu-home
|
(args (append args (when mu4e-mu-home
|
||||||
(list (concat "--muhome=" mu4e-mu-home))))))
|
(list (concat "--muhome=" mu4e-mu-home))))))
|
||||||
(setq mu4e~proc-buf "")
|
(setq mu4e~proc-buf "")
|
||||||
(setq mu4e~proc-process (apply 'start-process
|
(setq mu4e~proc-process (apply 'start-process
|
||||||
mu4e~proc-name mu4e~proc-name
|
mu4e~proc-name mu4e~proc-name
|
||||||
mu4e-mu-binary args))
|
mu4e-mu-binary args))
|
||||||
;; register a function for (:info ...) sexps
|
;; register a function for (:info ...) sexps
|
||||||
(unless mu4e~proc-process
|
(unless mu4e~proc-process
|
||||||
(mu4e-error "Failed to start the mu4e backend"))
|
(mu4e-error "Failed to start the mu4e backend"))
|
||||||
|
@ -272,14 +270,14 @@ Start the process if needed."
|
||||||
(defun mu4e~proc-kill ()
|
(defun mu4e~proc-kill ()
|
||||||
"Kill the mu server process."
|
"Kill the mu server process."
|
||||||
(let* ((buf (get-buffer mu4e~proc-name))
|
(let* ((buf (get-buffer mu4e~proc-name))
|
||||||
(proc (and (buffer-live-p buf) (get-buffer-process buf))))
|
(proc (and (buffer-live-p buf) (get-buffer-process buf))))
|
||||||
(when proc
|
(when proc
|
||||||
(let ((delete-exited-processes t))
|
(let ((delete-exited-processes t))
|
||||||
;; the mu server signal handler will make it quit after 'quit'
|
;; the mu server signal handler will make it quit after 'quit'
|
||||||
(mu4e~proc-send-command "cmd:quit"))
|
(mu4e~proc-send-command "cmd:quit"))
|
||||||
;; try sending SIGINT (C-c) to process, so it can exit gracefully
|
;; try sending SIGINT (C-c) to process, so it can exit gracefully
|
||||||
(ignore-errors
|
(ignore-errors
|
||||||
(signal-process proc 'SIGINT))))
|
(signal-process proc 'SIGINT))))
|
||||||
(setq
|
(setq
|
||||||
mu4e~proc-process nil
|
mu4e~proc-process nil
|
||||||
mu4e~proc-buf nil))
|
mu4e~proc-buf nil))
|
||||||
|
@ -288,29 +286,29 @@ Start the process if needed."
|
||||||
;;(defconst mu4e-xapian-empty 19 "Error code: xapian is empty/non-existent")
|
;;(defconst mu4e-xapian-empty 19 "Error code: xapian is empty/non-existent")
|
||||||
|
|
||||||
(defun mu4e~proc-sentinel (proc msg)
|
(defun mu4e~proc-sentinel (proc msg)
|
||||||
"Function that will be called when the mu-server process terminates."
|
"Function called when the server process PROC terminates with MSG."
|
||||||
(let ((status (process-status proc)) (code (process-exit-status proc)))
|
(let ((status (process-status proc)) (code (process-exit-status proc)))
|
||||||
(setq mu4e~proc-process nil)
|
(setq mu4e~proc-process nil)
|
||||||
(setq mu4e~proc-buf "") ;; clear any half-received sexps
|
(setq mu4e~proc-buf "") ;; clear any half-received sexps
|
||||||
(cond
|
(cond
|
||||||
((eq status 'signal)
|
((eq status 'signal)
|
||||||
(cond
|
(cond
|
||||||
((or(eq code 9) (eq code 2)) (message nil))
|
((or(eq code 9) (eq code 2)) (message nil))
|
||||||
;;(message "the mu server process has been stopped"))
|
;;(message "the mu server process has been stopped"))
|
||||||
(t (error (format "mu server process received signal %d" code)))))
|
(t (error (format "mu server process received signal %d" code)))))
|
||||||
((eq status 'exit)
|
((eq status 'exit)
|
||||||
(cond
|
(cond
|
||||||
((eq code 0)
|
((eq code 0)
|
||||||
(message nil)) ;; don't do anything
|
(message nil)) ;; don't do anything
|
||||||
((eq code 11)
|
((eq code 11)
|
||||||
(error "Database is locked by another process"))
|
(error "Database is locked by another process"))
|
||||||
((eq code 15)
|
((eq code 15)
|
||||||
(error "Database needs upgrade; try `mu index --rebuild'"))
|
(error "Database needs upgrade; try `mu index --rebuild'"))
|
||||||
((eq code 19)
|
((eq code 19)
|
||||||
(error "Database empty; try indexing some messages"))
|
(error "Database empty; try indexing some messages"))
|
||||||
(t (error "mu server process ended with exit code %d" code))))
|
(t (error "Mu server process ended with exit code %d" code))))
|
||||||
(t
|
(t
|
||||||
(error "Something bad happened to the mu server process")))))
|
(error "Something bad happened to the mu server process")))))
|
||||||
|
|
||||||
(defun mu4e~docid-msgid-param (docid-or-msgid)
|
(defun mu4e~docid-msgid-param (docid-or-msgid)
|
||||||
"Construct a backend parameter based on DOCID-OR-MSGID."
|
"Construct a backend parameter based on DOCID-OR-MSGID."
|
||||||
|
@ -319,15 +317,15 @@ Start the process if needed."
|
||||||
(format "docid:%d" docid-or-msgid)))
|
(format "docid:%d" docid-or-msgid)))
|
||||||
|
|
||||||
(defun mu4e~proc-find (query threads sortfield sortdir maxnum skip-dups
|
(defun mu4e~proc-find (query threads sortfield sortdir maxnum skip-dups
|
||||||
include-related)
|
include-related)
|
||||||
"Start a database query for QUERY.
|
"Run QUERY with THREADS SORTFIELD SORTDIR MAXNUM SKIP-DUPS INCLUDE-RELATED.
|
||||||
If THREADS is non-nil, show results in threaded fasion, SORTFIELD
|
If THREADS is non-nil, show results in threaded fasion, SORTFIELD
|
||||||
is a symbol describing the field to sort by (or nil); see
|
is a symbol describing the field to sort by (or nil); see
|
||||||
`mu4e~headers-sortfield-choices'. If SORT is `descending', sort
|
`mu4e~headers-sortfield-choices'. If SORT is `descending', sort
|
||||||
Z->A, if it's `ascending', sort A->Z. MAXNUM determines the maximum
|
Z->A, if it's `ascending', sort A->Z. MAXNUM determines the
|
||||||
number of results to return, or nil for 'unlimited'. If SKIP-DUPS
|
maximum number of results to return, or nil for 'unlimited'. If
|
||||||
is non-nil, show only one of duplicate messages (see
|
SKIP-DUPS is non-nil, show only one of duplicate messages (see
|
||||||
`mu4e-headers-skip-duplicates'). If INCLUDE-RELATED is non-nil,
|
`mu4e-headers-skip-duplicates'). If INCLUDE-RELATED is non-nil,
|
||||||
include messages related to the messages matching the search
|
include messages related to the messages matching the search
|
||||||
query (see `mu4e-headers-include-related').
|
query (see `mu4e-headers-include-related').
|
||||||
|
|
||||||
|
@ -351,9 +349,9 @@ or an error."
|
||||||
(if include-related "true" "false")))
|
(if include-related "true" "false")))
|
||||||
|
|
||||||
(defun mu4e~proc-move (docid-or-msgid &optional maildir flags no-view)
|
(defun mu4e~proc-move (docid-or-msgid &optional maildir flags no-view)
|
||||||
"Move message identified by DOCID-OR-MSGID to optional MAILDIR
|
"Move message identified by DOCID-OR-MSGID.
|
||||||
and optionally setting FLAGS. If MAILDIR is nil, message will be
|
Optionally to MAILDIR and optionally setting FLAGS. If MAILDIR is
|
||||||
moved within the same maildir.
|
nil, message will be moved within the same maildir.
|
||||||
|
|
||||||
At least one of MAILDIR and FLAGS must be specified. Note that
|
At least one of MAILDIR and FLAGS must be specified. Note that
|
||||||
even when MAILDIR is nil, this is still a filesystem move, since
|
even when MAILDIR is nil, this is still a filesystem move, since
|
||||||
|
@ -386,19 +384,19 @@ Returns either (:update ... ) or (:error ) sexp, which are handled my
|
||||||
(unless (or maildir flags)
|
(unless (or maildir flags)
|
||||||
(mu4e-error "At least one of maildir and flags must be specified"))
|
(mu4e-error "At least one of maildir and flags must be specified"))
|
||||||
(unless (or (not maildir)
|
(unless (or (not maildir)
|
||||||
(file-exists-p (concat mu4e-maildir "/" maildir "/")))
|
(file-exists-p (concat mu4e-maildir "/" maildir "/")))
|
||||||
(mu4e-error "Target dir does not exist"))
|
(mu4e-error "Target dir does not exist"))
|
||||||
(let* ((idparam (mu4e~docid-msgid-param docid-or-msgid))
|
(let* ((idparam (mu4e~docid-msgid-param docid-or-msgid))
|
||||||
(flagstr
|
(flagstr
|
||||||
(when flags
|
(when flags
|
||||||
(concat " flags:"
|
(concat " flags:"
|
||||||
(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~escape maildir))))
|
(format " maildir:%s" (mu4e~escape maildir))))
|
||||||
(rename
|
(rename
|
||||||
(if (and maildir mu4e-change-filenames-when-moving)
|
(if (and maildir mu4e-change-filenames-when-moving)
|
||||||
"true" "false")))
|
"true" "false")))
|
||||||
(mu4e~proc-send-command "cmd:move %s %s %s %s %s"
|
(mu4e~proc-send-command "cmd:move %s %s %s %s %s"
|
||||||
idparam
|
idparam
|
||||||
(or flagstr "")
|
(or flagstr "")
|
||||||
|
@ -407,15 +405,20 @@ Returns either (:update ... ) or (:error ) sexp, which are handled my
|
||||||
(format "noview:%s" (if no-view "true" "false")))))
|
(format "noview:%s" (if no-view "true" "false")))))
|
||||||
|
|
||||||
(defun mu4e~proc-index (path my-addresses cleanup lazy-check)
|
(defun mu4e~proc-index (path my-addresses cleanup lazy-check)
|
||||||
"Update the message database for filesystem PATH, which should
|
"Index messages on PATH with possible CLEANUP and LAZY-CHECK.
|
||||||
point to some maildir directory structure. MY-ADDRESSES is a list
|
PATH should point to some maildir directory structure.
|
||||||
of 'my' email addresses (see `mu4e-user-mail-address-list')."
|
MY-ADDRESSES is a list of 'my' email addresses (see
|
||||||
|
`mu4e-user-mail-address-list')."
|
||||||
(let ((path (mu4e~escape path))
|
(let ((path (mu4e~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
|
(mu4e~proc-send-command
|
||||||
"cmd:index path:%s my-addresses:%s cleanup:%s lazy-check:%s"
|
"cmd:index path:%s my-addresses:%s cleanup:%s lazy-check:%s contacts:%s"
|
||||||
path addrs (if cleanup "true" : "false") (if lazy-check "true"))
|
path
|
||||||
|
addrs
|
||||||
|
(if cleanup "true" : "false")
|
||||||
|
(if lazy-check "true")
|
||||||
|
(if mu4e-compose-complete-addresses "true"))
|
||||||
(mu4e~proc-send-command "cmd: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)
|
||||||
|
@ -441,12 +444,12 @@ e.g. '/drafts'.
|
||||||
|
|
||||||
|
|
||||||
(defun mu4e~proc-compose (type decrypt &optional docid)
|
(defun mu4e~proc-compose (type decrypt &optional docid)
|
||||||
"Start composing a message of certain TYPE (a symbol, either
|
"Compose a message of TYPE, DECRYPT it and use DOCID.
|
||||||
`forward', `reply', `edit', `resend' or `new', based on an
|
TYPE is a symbol, either `forward', `reply', `edit', `resend' or
|
||||||
original message (ie, replying to, forwarding, editing,
|
`new', based on an original message (ie, replying to, forwarding,
|
||||||
resending) with DOCID or nil for type `new'.
|
editing, resending) with DOCID or nil for type `new'.
|
||||||
|
|
||||||
The result will be delivered to the function registered as
|
The result is delivered to the function registered as
|
||||||
`mu4e-compose-func'."
|
`mu4e-compose-func'."
|
||||||
(unless (member type '(forward reply edit resend new))
|
(unless (member type '(forward reply edit resend new))
|
||||||
(mu4e-error "Unsupported compose-type %S" type))
|
(mu4e-error "Unsupported compose-type %S" type))
|
||||||
|
@ -461,34 +464,33 @@ The result will be delivered to the function registered as
|
||||||
(mu4e~proc-send-command "cmd:mkdir path:%s" (mu4e~escape path)))
|
(mu4e~proc-send-command "cmd:mkdir path:%s" (mu4e~escape path)))
|
||||||
|
|
||||||
(defun mu4e~proc-extract (action docid partidx decrypt
|
(defun mu4e~proc-extract (action docid partidx decrypt
|
||||||
&optional path what param)
|
&optional path what param)
|
||||||
"Extract an attachment with index PARTIDX from message with DOCID
|
"Perform ACTION on part with DOCID PARTIDX DECRYPT PATH WHAT PARAM.
|
||||||
and perform ACTION on it (as symbol, either `save', `open', `temp') which
|
Use a message with DOCID and perform ACTION on it (as symbol,
|
||||||
mean:
|
either `save', `open', `temp') which mean: * save: save the part
|
||||||
* save: save the part to PARAM1 (a path) (non-optional for save)$
|
to PATH (a path) (non-optional for save)$ * open: open the part
|
||||||
* open: open the part with the default application registered for doing so
|
with the default application registered for doing so * temp: save
|
||||||
* temp: save to a temporary file, then respond with
|
to a temporary file, then respond with
|
||||||
(:temp <path> :what <what> :param <param>)."
|
(:temp <path> :what <what> :param <param>)."
|
||||||
(let ((cmd
|
(let ((cmd
|
||||||
(concat "cmd:extract "
|
(concat "cmd:extract "
|
||||||
(cl-case action
|
(cl-case action
|
||||||
(save
|
(save
|
||||||
(format "action:save docid:%d index:%d path:%s extract-encrypted:%s use-agent:true"
|
(format "action:save docid:%d index:%d path:%s extract-encrypted:%s use-agent:true"
|
||||||
docid partidx (mu4e~escape path) (if decrypt "true" "false")))
|
docid partidx (mu4e~escape path) (if decrypt "true" "false")))
|
||||||
(open (format "action:open docid:%d index:%d extract-encrypted:%s use-agent:true"
|
(open (format "action:open docid:%d index:%d extract-encrypted:%s use-agent:true"
|
||||||
docid partidx (if decrypt "true" "false")))
|
docid partidx (if decrypt "true" "false")))
|
||||||
(temp
|
(temp
|
||||||
(format "action:temp docid:%d index:%d what:%s%s extract-encrypted:%s use-agent:true"
|
(format "action:temp docid:%d index:%d what:%s%s extract-encrypted:%s use-agent:true"
|
||||||
docid partidx what
|
docid partidx what
|
||||||
(if param
|
(if param
|
||||||
(if (stringp param)
|
(if (stringp param)
|
||||||
(format " param:%s" (mu4e~escape param))
|
(format " param:%s" (mu4e~escape param))
|
||||||
(format " param:%S" param)) "") (if decrypt "true" "false")))
|
(format " param:%S" param)) "") (if decrypt "true" "false")))
|
||||||
(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)))
|
||||||
|
|
||||||
|
|
||||||
(defun mu4e~proc-ping ()
|
(defun mu4e~proc-ping ()
|
||||||
"Sends a ping to the mu server, expecting a (:pong ...) in response."
|
"Sends a ping to the mu server, expecting a (:pong ...) in response."
|
||||||
(mu4e~proc-send-command "cmd:ping"))
|
(mu4e~proc-send-command "cmd:ping"))
|
||||||
|
@ -504,11 +506,11 @@ only contacts seen AFTER (the time_t value)."
|
||||||
(or after 0)))
|
(or after 0)))
|
||||||
|
|
||||||
(defun mu4e~proc-view (docid-or-msgid &optional images decrypt)
|
(defun mu4e~proc-view (docid-or-msgid &optional images decrypt)
|
||||||
"Get one particular message based on its DOCID-OR-MSGID.
|
"Get a message DOCID-OR-MSGID.
|
||||||
Optionally, if IMAGES is non-nil, backend will any images
|
Optionally, if IMAGES is non-nil, backend will any images
|
||||||
attached to the message, and return them as temp files.
|
attached to the message, and return them as temp files. DECRYPT
|
||||||
The result will be delivered to the function registered as
|
if necessary. The result will be delivered to the function
|
||||||
`mu4e-view-func'."
|
registered as `mu4e-view-func'."
|
||||||
(mu4e~proc-send-command
|
(mu4e~proc-send-command
|
||||||
"cmd: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)
|
||||||
|
@ -516,11 +518,11 @@ The result will be delivered to the function registered as
|
||||||
(if decrypt "true" "false")))
|
(if decrypt "true" "false")))
|
||||||
|
|
||||||
(defun mu4e~proc-view-path (path &optional images decrypt)
|
(defun mu4e~proc-view-path (path &optional images decrypt)
|
||||||
"View message at PATH (keyword argument).
|
"View message at PATH..
|
||||||
Optionally, if IMAGES is non-nil, backend will any images
|
Optionally, if IMAGES is non-nil, backend will any images
|
||||||
attached to the message, and return them as temp files. The
|
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-view-func'."
|
`mu4e-view-func'. Optionally DECRYPT."
|
||||||
(mu4e~proc-send-command
|
(mu4e~proc-send-command
|
||||||
"cmd: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"
|
||||||
(mu4e~escape path)
|
(mu4e~escape path)
|
||||||
|
@ -528,12 +530,11 @@ result will be delivered to the function registered as
|
||||||
(if decrypt "true" "false")))
|
(if decrypt "true" "false")))
|
||||||
|
|
||||||
(defun mu4e~proc-remove (docid)
|
(defun mu4e~proc-remove (docid)
|
||||||
"Remove message identified by docid.
|
"Remove message with DOCID.
|
||||||
The results are reporter through either (:update ... ) or (:error)
|
The results are reporter through either (:update ... )
|
||||||
sexp, which are handled my `mu4e-error-func', respectively."
|
or (:error) sexp, which are handled my `mu4e-error-func',
|
||||||
|
respectively."
|
||||||
(mu4e~proc-send-command "cmd:remove docid:%d" docid))
|
(mu4e~proc-send-command "cmd:remove docid:%d" docid))
|
||||||
|
|
||||||
|
|
||||||
(provide 'mu4e-proc)
|
(provide 'mu4e-proc)
|
||||||
|
;;; mu4e-proc.el ends here
|
||||||
;; End of mu4e-proc.el
|
|
||||||
|
|
Loading…
Reference in New Issue