mu4e-utils: Only ask for pwd if the update process is called interactively.

Adds a new optional parameter INTERACTIVE to `mu4e-update-mail' which
is passed as a process property (`process-put') to the filter
function.

Signed-off-by: Rüdiger Sonderfeld <ruediger@c-plusplus.de>
This commit is contained in:
Rüdiger Sonderfeld
2012-08-27 13:42:30 +02:00
parent b116c64fb8
commit 0897246cf6

View File

@ -560,7 +560,7 @@ split-window."
(switch-to-buffer buf) (switch-to-buffer buf)
(set-window-dedicated-p win t) (set-window-dedicated-p win t)
(erase-buffer) (erase-buffer)
(insert "\n") ;; FIXME -- needed so output starts (insert "\n") ;; FIXME -- needed so output starts
(mu4e-update-mail buf t)))) (mu4e-update-mail buf t))))
@ -698,17 +698,22 @@ into the process buffer."
(set-buffer (process-buffer proc)) (set-buffer (process-buffer proc))
(let ((inhibit-read-only t)) (let ((inhibit-read-only t))
;; Check whether process asks for a password and query user ;; Check whether process asks for a password and query user
(when (string-match mu4e~get-mail-password-regexp msg)
(if (process-get proc 'x-interactive) (if (process-get proc 'x-interactive)
(process-send-string proc (concat (process-send-string proc (concat
(read-passwd mu4e~get-mail-ask-password) (read-passwd mu4e~get-mail-ask-password)
"\n"))
;; TODO kill process?
(error "Get-mail process requires a password but was not called interactively"))) (error "Get-mail process requires a password but was not called interactively")))
(insert msg)))) (insert msg))))
(defun mu4e-update-mail (&optional buf interactive) (defun mu4e-update-mail (&optional buf interactive)
"Update mail (retrieve using `mu4e-get-mail-command' and update "Update mail (retrieve using `mu4e-get-mail-command' and update
the database afterwards), with output going to BUF if not nil, or the database afterwards), with output going to BUF if not nil, or
discarded if nil. After retrieving mail, update the database. Note, discarded if nil. After retrieving mail, update the database. Note,
function is asynchronous, returns (almost) immediately, and all the function is asynchronous, returns (almost) immediately, and all the
processing takes part in the background, unless buf is non-nil.
If INTERACTIVE is not nil then the user might be asked for a
password." password."
(unless mu4e-get-mail-command (unless mu4e-get-mail-command
(mu4e-error "`mu4e-get-mail-command' is not defined")) (mu4e-error "`mu4e-get-mail-command' is not defined"))
@ -731,6 +736,7 @@ processing takes part in the background, unless buf is non-nil."
(sit-for 5)) (sit-for 5))
(mu4e~proc-index mu4e-maildir mu4e-my-email-addresses) (mu4e~proc-index mu4e-maildir mu4e-my-email-addresses)
(when (buffer-live-p buf) (when (buffer-live-p buf)
(kill-buffer buf)))))
(process-put proc 'x-interactive interactive) (process-put proc 'x-interactive interactive)
(set-process-filter proc 'mu4e~process-filter))) (set-process-filter proc 'mu4e~process-filter)))