summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJSDurand <mmemmew@gmail.com>2024-05-23 17:15:53 +0800
committerJSDurand <mmemmew@gmail.com>2024-05-23 17:15:53 +0800
commit1b48e69e8182bcddefddb664435b04e5f3c47ac2 (patch)
tree8b7b1f8392963b654afc3aa898547561bab45525
parent888b80d129c4d43b63e8bbe32272b00273f4dbb5 (diff)
mail: Notify when there is no internet connection.
* mail.el (durand-mail-update): When there is no internet connection and the command tries to launch a new connection, inform the user about the lack of internet connection, so that the user can take some action as needed.
-rw-r--r--mail.el38
1 files changed, 21 insertions, 17 deletions
diff --git a/mail.el b/mail.el
index 4ecddfa..93290c5 100644
--- a/mail.el
+++ b/mail.el
@@ -306,23 +306,27 @@ If FOREGROUND-P is `0', do not fetch mails, but just run
(= arg 0))
0)
((null arg))))))
- (cond
- ((and (numberp foreground-p)
- (= foreground-p 0))
- (run-hooks 'durand-mail-update-hook))
- ((and (not (get-process "durand-mail-update"))
- (durand-internet-on))
- (make-process
- :name "durand-mail-update"
- :command durand-mail-update-command
- :filter (cond (foreground-p #'durand-mail-update-filter))
- :sentinel (cond (foreground-p #'durand-mail-update-sentinel))
- :buffer (cond
- (foreground-p
- (let ((buffer
- (get-buffer-create durand-mail-update-buffer)))
- (buffer-disable-undo buffer)
- buffer)))))))
+ (let ((process-found (get-process "durand-mail-update"))
+ (internet-on (durand-internet-on)))
+ (cond
+ ((and (numberp foreground-p)
+ (= foreground-p 0))
+ (run-hooks 'durand-mail-update-hook))
+ ((and (not process-found) internet-on)
+ (make-process
+ :name "durand-mail-update"
+ :command durand-mail-update-command
+ :filter (cond (foreground-p #'durand-mail-update-filter))
+ :sentinel (cond (foreground-p #'durand-mail-update-sentinel))
+ :buffer (cond
+ (foreground-p
+ (let ((buffer
+ (get-buffer-create
+ durand-mail-update-buffer)))
+ (buffer-disable-undo buffer)
+ buffer)))))
+ ((not (or process-found internet-on))
+ (message "There is no internet connection.")))))
(defvar durand-mail-update-timer nil
"A timer to automatically update mail in the background.")