mirror of https://github.com/djcb/mu.git
Don't raise 'Update process is already running' error
Only issue a message. Refactor a bit. This is for the use-case where the time to update is longer than the period between updates -- e.g. you return from suspension/hibernation and an old update process is still running.
This commit is contained in:
parent
85716b7990
commit
ada193c8fd
|
@ -850,23 +850,15 @@ frame to display buffer BUF."
|
||||||
(if (window-live-p win)
|
(if (window-live-p win)
|
||||||
(with-selected-window win (kill-buffer-and-window))
|
(with-selected-window win (kill-buffer-and-window))
|
||||||
(when (buffer-live-p buf) (kill-buffer buf)))))
|
(when (buffer-live-p buf) (kill-buffer buf)))))
|
||||||
|
|
||||||
;; complicated function, as it:
|
;; complicated function, as it:
|
||||||
;; - 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
|
||||||
(defun mu4e-update-mail-and-index (run-in-background)
|
(defun mu4e~update-mail-and-index-real (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),
|
||||||
in the background; otherwise, pop up a window."
|
run in the background; otherwise, pop up a window."
|
||||||
(interactive "P")
|
|
||||||
(when (and (buffer-live-p mu4e~update-buffer)
|
|
||||||
(process-live-p (get-buffer-process mu4e~update-buffer)))
|
|
||||||
(mu4e-error "Update process is already running"))
|
|
||||||
(run-hooks 'mu4e-update-pre-hook)
|
|
||||||
(unless mu4e-get-mail-command
|
|
||||||
(mu4e-error "`mu4e-get-mail-command' is not defined"))
|
|
||||||
|
|
||||||
(let* ((process-connection-type t)
|
(let* ((process-connection-type t)
|
||||||
(proc (start-process-shell-command
|
(proc (start-process-shell-command
|
||||||
"mu4e-update" " *mu4e-update*"
|
"mu4e-update" " *mu4e-update*"
|
||||||
|
@ -892,6 +884,20 @@ in the background; otherwise, pop up a window."
|
||||||
(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-update-mail-and-index (run-in-background)
|
||||||
|
"Get a new mail by running `mu4e-get-mail-command'. If
|
||||||
|
run-in-background is non-nil (or called with prefix-argument), run
|
||||||
|
in the background; otherwise, pop up a window."
|
||||||
|
(interactive "P")
|
||||||
|
(unless mu4e-get-mail-command
|
||||||
|
(mu4e-error "`mu4e-get-mail-command' is not defined"))
|
||||||
|
(if (and (buffer-live-p mu4e~update-buffer)
|
||||||
|
(process-live-p (get-buffer-process mu4e~update-buffer)))
|
||||||
|
(mu4e-message "Update process is already running")
|
||||||
|
(progn
|
||||||
|
(run-hooks 'mu4e-update-pre-hook)
|
||||||
|
(mu4e~update-mail-and-index-real run-in-background))))
|
||||||
|
|
||||||
(defun mu4e-interrupt-update-mail ()
|
(defun mu4e-interrupt-update-mail ()
|
||||||
"Stop the update process by sending SIGINT to it."
|
"Stop the update process by sending SIGINT to it."
|
||||||
(interactive)
|
(interactive)
|
||||||
|
|
Loading…
Reference in New Issue