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
|
||||
;;
|
||||
;; Copyright (C) 2011-2017 Dirk-Jan C. Binnema
|
||||
;; Copyright (C) 2011-2019 Dirk-Jan C. Binnema
|
||||
|
||||
;; Author: 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
|
||||
(defconst mu4e~cookie-pre "\376"
|
||||
"Each expression we get from the backend (mu server) starts with
|
||||
a length cookie:
|
||||
<`mu4e~cookie-pre'><length-in-hex><`mu4e~cookie-post'>.")
|
||||
"Each expression starts with a length cookie:
|
||||
<`mu4e~cookie-pre'><length-in-hex><`mu4e~cookie-post'>.")
|
||||
(defconst mu4e~cookie-post "\377"
|
||||
"Each expression we get from the backend (mu server) starts with
|
||||
a length cookie:
|
||||
<`mu4e~cookie-pre'><length-in-hex><`mu4e~cookie-post'>.")
|
||||
"Each expression starts with a length cookie:
|
||||
<`mu4e~cookie-pre'><length-in-hex><`mu4e~cookie-post'>.")
|
||||
(defconst mu4e~cookie-matcher-rx
|
||||
(concat mu4e~cookie-pre "\\([[:xdigit:]]+\\)" mu4e~cookie-post)
|
||||
"Regular expression matching the length cookie.
|
||||
|
@ -56,7 +54,6 @@ Match 1 will be the length (in hex).")
|
|||
(defvar mu4e~proc-process nil
|
||||
"The mu-server process.")
|
||||
|
||||
|
||||
(defun mu4e~proc-running-p ()
|
||||
"Whether the mu process is running."
|
||||
(when (and mu4e~proc-process
|
||||
|
@ -96,16 +93,17 @@ removed."
|
|||
|
||||
|
||||
(defun mu4e~proc-filter (proc str)
|
||||
"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.
|
||||
"Filter string STR from PROC.
|
||||
This process the the 'mu server' output. It accumulates the
|
||||
strings into valid sexps by checking of the ';;eox' `end-of-sexp'
|
||||
marker, and then evaluating them.
|
||||
|
||||
The server output is as follows:
|
||||
|
||||
1. an error
|
||||
(:error 2 :message \"unknown command\")
|
||||
;; eox
|
||||
=> this will be passed to `mu4e-error-func'.
|
||||
=> passed to `mu4e-error-func'.
|
||||
|
||||
2a. a message sexp looks something like:
|
||||
\(
|
||||
|
@ -233,15 +231,15 @@ The server output is as follows:
|
|||
(setq sexp (mu4e~proc-eat-sexp-from-buf))))))
|
||||
|
||||
(defun mu4e~escape (str)
|
||||
"Escape STRING for transport -- put it in quotes, and escape
|
||||
existing quotation. In particular, backslashes and
|
||||
double-quotes."
|
||||
"Escape string STR for transport.
|
||||
Put it in quotes, and escape existing quotation. In particular,
|
||||
backslashes and double-quotes."
|
||||
(let ((esc (replace-regexp-in-string "\\\\" "\\\\\\\\" str)))
|
||||
(format "\"%s\"" (replace-regexp-in-string "\"" "\\\\\"" esc))))
|
||||
|
||||
|
||||
(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."
|
||||
(unless (mu4e~proc-running-p)
|
||||
(mu4e~proc-start))
|
||||
|
@ -288,7 +286,7 @@ Start the process if needed."
|
|||
;;(defconst mu4e-xapian-empty 19 "Error code: xapian is empty/non-existent")
|
||||
|
||||
(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)))
|
||||
(setq mu4e~proc-process nil)
|
||||
(setq mu4e~proc-buf "") ;; clear any half-received sexps
|
||||
|
@ -308,7 +306,7 @@ Start the process if needed."
|
|||
(error "Database needs upgrade; try `mu index --rebuild'"))
|
||||
((eq code 19)
|
||||
(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
|
||||
(error "Something bad happened to the mu server process")))))
|
||||
|
||||
|
@ -320,13 +318,13 @@ Start the process if needed."
|
|||
|
||||
(defun mu4e~proc-find (query threads sortfield sortdir maxnum skip-dups
|
||||
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
|
||||
is a symbol describing the field to sort by (or nil); see
|
||||
`mu4e~headers-sortfield-choices'. If SORT is `descending', sort
|
||||
Z->A, if it's `ascending', sort A->Z. MAXNUM determines the maximum
|
||||
number of results to return, or nil for 'unlimited'. If SKIP-DUPS
|
||||
is non-nil, show only one of duplicate messages (see
|
||||
Z->A, if it's `ascending', sort A->Z. MAXNUM determines the
|
||||
maximum number of results to return, or nil for 'unlimited'. If
|
||||
SKIP-DUPS is non-nil, show only one of duplicate messages (see
|
||||
`mu4e-headers-skip-duplicates'). If INCLUDE-RELATED is non-nil,
|
||||
include messages related to the messages matching the search
|
||||
query (see `mu4e-headers-include-related').
|
||||
|
@ -351,9 +349,9 @@ or an error."
|
|||
(if include-related "true" "false")))
|
||||
|
||||
(defun mu4e~proc-move (docid-or-msgid &optional maildir flags no-view)
|
||||
"Move message identified by DOCID-OR-MSGID to optional MAILDIR
|
||||
and optionally setting FLAGS. If MAILDIR is nil, message will be
|
||||
moved within the same maildir.
|
||||
"Move message identified by DOCID-OR-MSGID.
|
||||
Optionally to MAILDIR and optionally setting FLAGS. If MAILDIR is
|
||||
nil, message will be moved within the same maildir.
|
||||
|
||||
At least one of MAILDIR and FLAGS must be specified. Note that
|
||||
even when MAILDIR is nil, this is still a filesystem move, since
|
||||
|
@ -407,15 +405,20 @@ Returns either (:update ... ) or (:error ) sexp, which are handled my
|
|||
(format "noview:%s" (if no-view "true" "false")))))
|
||||
|
||||
(defun mu4e~proc-index (path my-addresses cleanup lazy-check)
|
||||
"Update the message database for filesystem PATH, which should
|
||||
point to some maildir directory structure. MY-ADDRESSES is a list
|
||||
of 'my' email addresses (see `mu4e-user-mail-address-list')."
|
||||
"Index messages on PATH with possible CLEANUP and LAZY-CHECK.
|
||||
PATH should point to some maildir directory structure.
|
||||
MY-ADDRESSES is a list of 'my' email addresses (see
|
||||
`mu4e-user-mail-address-list')."
|
||||
(let ((path (mu4e~escape path))
|
||||
(addrs (when my-addresses (mapconcat 'identity my-addresses ","))))
|
||||
(if addrs
|
||||
(mu4e~proc-send-command
|
||||
"cmd:index path:%s my-addresses:%s cleanup:%s lazy-check:%s"
|
||||
path addrs (if cleanup "true" : "false") (if lazy-check "true"))
|
||||
"cmd:index path:%s my-addresses:%s cleanup:%s lazy-check:%s contacts:%s"
|
||||
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))))
|
||||
|
||||
(defun mu4e~proc-add (path maildir)
|
||||
|
@ -441,12 +444,12 @@ e.g. '/drafts'.
|
|||
|
||||
|
||||
(defun mu4e~proc-compose (type decrypt &optional docid)
|
||||
"Start composing a message of certain TYPE (a symbol, either
|
||||
`forward', `reply', `edit', `resend' or `new', based on an
|
||||
original message (ie, replying to, forwarding, editing,
|
||||
resending) with DOCID or nil for type `new'.
|
||||
"Compose a message of TYPE, DECRYPT it and use DOCID.
|
||||
TYPE is a symbol, either `forward', `reply', `edit', `resend' or
|
||||
`new', based on an original message (ie, replying to, forwarding,
|
||||
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'."
|
||||
(unless (member type '(forward reply edit resend new))
|
||||
(mu4e-error "Unsupported compose-type %S" type))
|
||||
|
@ -462,12 +465,12 @@ The result will be delivered to the function registered as
|
|||
|
||||
(defun mu4e~proc-extract (action docid partidx decrypt
|
||||
&optional path what param)
|
||||
"Extract an attachment with index PARTIDX from message with DOCID
|
||||
and perform ACTION on it (as symbol, either `save', `open', `temp') which
|
||||
mean:
|
||||
* save: save the part to PARAM1 (a path) (non-optional for save)$
|
||||
* open: open the part with the default application registered for doing so
|
||||
* temp: save to a temporary file, then respond with
|
||||
"Perform ACTION on part with DOCID PARTIDX DECRYPT PATH WHAT PARAM.
|
||||
Use a message with DOCID and perform ACTION on it (as symbol,
|
||||
either `save', `open', `temp') which mean: * save: save the part
|
||||
to PATH (a path) (non-optional for save)$ * open: open the part
|
||||
with the default application registered for doing so * temp: save
|
||||
to a temporary file, then respond with
|
||||
(:temp <path> :what <what> :param <param>)."
|
||||
(let ((cmd
|
||||
(concat "cmd:extract "
|
||||
|
@ -488,7 +491,6 @@ mean:
|
|||
))
|
||||
(mu4e~proc-send-command "%s" cmd)))
|
||||
|
||||
|
||||
(defun mu4e~proc-ping ()
|
||||
"Sends a ping to the mu server, expecting a (:pong ...) in response."
|
||||
(mu4e~proc-send-command "cmd:ping"))
|
||||
|
@ -504,11 +506,11 @@ only contacts seen AFTER (the time_t value)."
|
|||
(or after 0)))
|
||||
|
||||
(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
|
||||
attached to the message, and return them as temp files.
|
||||
The result will be delivered to the function registered as
|
||||
`mu4e-view-func'."
|
||||
attached to the message, and return them as temp files. DECRYPT
|
||||
if necessary. The result will be delivered to the function
|
||||
registered as `mu4e-view-func'."
|
||||
(mu4e~proc-send-command
|
||||
"cmd:view %s extract-images:%s extract-encrypted:%s use-agent:true"
|
||||
(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")))
|
||||
|
||||
(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
|
||||
attached to the message, and return them as temp files. The
|
||||
result will be delivered to the function registered as
|
||||
`mu4e-view-func'."
|
||||
`mu4e-view-func'. Optionally DECRYPT."
|
||||
(mu4e~proc-send-command
|
||||
"cmd:view path:%s extract-images:%s extract-encrypted:%s use-agent:true"
|
||||
(mu4e~escape path)
|
||||
|
@ -528,12 +530,11 @@ result will be delivered to the function registered as
|
|||
(if decrypt "true" "false")))
|
||||
|
||||
(defun mu4e~proc-remove (docid)
|
||||
"Remove message identified by docid.
|
||||
The results are reporter through either (:update ... ) or (:error)
|
||||
sexp, which are handled my `mu4e-error-func', respectively."
|
||||
"Remove message with DOCID.
|
||||
The results are reporter through either (:update ... )
|
||||
or (:error) sexp, which are handled my `mu4e-error-func',
|
||||
respectively."
|
||||
(mu4e~proc-send-command "cmd:remove docid:%d" docid))
|
||||
|
||||
|
||||
(provide 'mu4e-proc)
|
||||
|
||||
;; End of mu4e-proc.el
|
||||
;;; mu4e-proc.el ends here
|
||||
|
|
Loading…
Reference in New Issue