* mu4e: mu4e-proc: capture sexp evaluation in (ignore-errors ...)

This commit is contained in:
djcb
2012-09-28 17:11:58 +03:00
parent 7a82bb562d
commit e11e83e2a4

View File

@ -106,26 +106,27 @@ mu-servers in the following form:
Function returns this sexp, or nil if there was Function returns this sexp, or nil if there was
none. `mu4e~proc-buf' is updated as well, with all processed sexp none. `mu4e~proc-buf' is updated as well, with all processed sexp
data removed." data removed."
;; mu4e~cookie-matcher-rx: (ignore-errors ;; the server may die in the middle...
;; (concat mu4e~cookie-pre "\\([[:xdigit:]]+\\)]" mu4e~cookie-post) ;; mu4e~cookie-matcher-rx:
(let ((b (string-match mu4e~cookie-matcher-rx mu4e~proc-buf)) ;; (concat mu4e~cookie-pre "\\([[:xdigit:]]+\\)]" mu4e~cookie-post)
(sexp-len) (objcons)) (let ((b (string-match mu4e~cookie-matcher-rx mu4e~proc-buf))
(when b (sexp-len) (objcons))
(setq sexp-len (string-to-number (match-string 1 mu4e~proc-buf) 16)) (when b
;; does mu4e~proc-buf contain the full sexp? (setq sexp-len (string-to-number (match-string 1 mu4e~proc-buf) 16))
(when (>= (length mu4e~proc-buf) (+ sexp-len (match-end 0))) ;; does mu4e~proc-buf contain the full sexp?
;; clear-up start (when (>= (length mu4e~proc-buf) (+ sexp-len (match-end 0)))
(setq mu4e~proc-buf (substring mu4e~proc-buf (match-end 0))) ;; clear-up start
;; note: we read the input in binary mode -- here, we take the part (setq mu4e~proc-buf (substring mu4e~proc-buf (match-end 0)))
;; that is the sexp, and convert that to utf-8, before we interpret ;; note: we read the input in binary mode -- here, we take the part
;; it. ;; that is the sexp, and convert that to utf-8, before we interpret
(setq objcons (read-from-string ;; it.
(decode-coding-string (setq objcons (read-from-string
(substring mu4e~proc-buf 0 sexp-len) (decode-coding-string
'utf-8 t))) (substring mu4e~proc-buf 0 sexp-len)
(when objcons 'utf-8 t)))
(setq mu4e~proc-buf (substring mu4e~proc-buf sexp-len)) (when objcons
(car objcons)))))) (setq mu4e~proc-buf (substring mu4e~proc-buf sexp-len))
(car objcons)))))))
(defsubst mu4e~proc-filter (proc str) (defsubst mu4e~proc-filter (proc str)