Merge pull request #285 from thierryvolpiatto/master
* mu4e: allow stopping update process (SIGINT)
This commit is contained in:
@ -47,6 +47,7 @@
|
|||||||
|
|
||||||
;;
|
;;
|
||||||
(define-key map "U" 'mu4e-update-mail-and-index)
|
(define-key map "U" 'mu4e-update-mail-and-index)
|
||||||
|
(define-key map "S" 'mu4e-interrupt-update-mail)
|
||||||
(define-key map (kbd "C-S-u") 'mu4e-update-mail-and-index)
|
(define-key map (kbd "C-S-u") 'mu4e-update-mail-and-index)
|
||||||
|
|
||||||
|
|
||||||
@ -134,7 +135,8 @@ clicked."
|
|||||||
|
|
||||||
(mu4e~main-action-str "\t* [U]pdate email & database\n"
|
(mu4e~main-action-str "\t* [U]pdate email & database\n"
|
||||||
'mu4e-update-mail-show-window)
|
'mu4e-update-mail-show-window)
|
||||||
|
(mu4e~main-action-str "\t* [S]top update email\n"
|
||||||
|
'mu4e-interrupt-update-mail)
|
||||||
;; show the queue functions if `smtpmail-queue-dir' is defined
|
;; show the queue functions if `smtpmail-queue-dir' is defined
|
||||||
(if (file-directory-p smtpmail-queue-dir)
|
(if (file-directory-p smtpmail-queue-dir)
|
||||||
(concat
|
(concat
|
||||||
|
|||||||
@ -797,6 +797,8 @@ The messages are inserted into the process buffer."
|
|||||||
;; - needs to check for errors
|
;; - needs to check for errors
|
||||||
;; - (optionally) pop-up a window
|
;; - (optionally) pop-up a window
|
||||||
;; - (optionally) check password requests
|
;; - (optionally) check password requests
|
||||||
|
(defvar mu4e~update-buffer-name nil
|
||||||
|
"Internal, store the name of the buffer process when updating.")
|
||||||
(defun mu4e-update-mail-and-index (run-in-background)
|
(defun mu4e-update-mail-and-index (run-in-background)
|
||||||
"Get a new mail by running `mu4e-get-mail-command'. If
|
"Get a new mail by running `mu4e-get-mail-command'. If
|
||||||
run-in-background is non-nil (or called with prefix-argument), run
|
run-in-background is non-nil (or called with prefix-argument), run
|
||||||
@ -804,20 +806,16 @@ in the background; otherwise, pop up a window."
|
|||||||
(interactive "P")
|
(interactive "P")
|
||||||
(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"))
|
||||||
(let* ((buf (unless run-in-background
|
(let* ((process-connection-type t)
|
||||||
(get-buffer-create mu4e~update-name)))
|
|
||||||
(win (and buf (split-window (selected-window)
|
|
||||||
(- (window-height (selected-window)) 8))))
|
|
||||||
(process-connection-type t)
|
|
||||||
(proc (start-process-shell-command
|
(proc (start-process-shell-command
|
||||||
mu4e~update-name buf mu4e-get-mail-command)))
|
"mu4e-update" mu4e~update-name
|
||||||
|
mu4e-get-mail-command))
|
||||||
|
(buf (process-buffer proc)))
|
||||||
|
(setq mu4e~update-buffer-name (buffer-name buf))
|
||||||
|
(when (not run-in-background)
|
||||||
|
(pop-to-buffer buf)
|
||||||
|
(special-mode))
|
||||||
(mu4e-index-message "Retrieving mail...")
|
(mu4e-index-message "Retrieving mail...")
|
||||||
(when (window-live-p win)
|
|
||||||
(with-selected-window win
|
|
||||||
(switch-to-buffer buf)
|
|
||||||
(set-window-dedicated-p win t)
|
|
||||||
(erase-buffer)
|
|
||||||
(insert "\n"))) ;; FIXME -- needed so output starts
|
|
||||||
(set-process-sentinel proc
|
(set-process-sentinel proc
|
||||||
(lambda (proc msg)
|
(lambda (proc msg)
|
||||||
(let* ((status (process-status proc))
|
(let* ((status (process-status proc))
|
||||||
@ -831,11 +829,19 @@ in the background; otherwise, pop up a window."
|
|||||||
;; there may be an error, give the user up to 5 seconds to check
|
;; there may be an error, give the user up to 5 seconds to check
|
||||||
(when maybe-error (sit-for 5))
|
(when maybe-error (sit-for 5))
|
||||||
(mu4e-update-index)
|
(mu4e-update-index)
|
||||||
(when (buffer-live-p buf) (kill-buffer buf)))))
|
(when (buffer-live-p buf)
|
||||||
|
(with-selected-window (get-buffer-window buf) (quit-window t))))))
|
||||||
;; if we're running in the foreground, handle password requests
|
;; if we're running in the foreground, handle password requests
|
||||||
(unless run-in-background
|
(unless run-in-background
|
||||||
(process-put proc 'x-interactive (not run-in-background))
|
(process-put proc 'x-interactive (not run-in-background))
|
||||||
(set-process-filter proc 'mu4e~get-mail-process-filter))))
|
(set-process-filter proc 'mu4e~get-mail-process-filter))))
|
||||||
|
|
||||||
|
(defun mu4e~interrupt-update-mail ()
|
||||||
|
"Stop the update process by sending SIGINT to it."
|
||||||
|
(interactive)
|
||||||
|
(interrupt-process (get-buffer-process
|
||||||
|
(get-buffer mu4e~update-buffer-name)) t))
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user