From 1b48e69e8182bcddefddb664435b04e5f3c47ac2 Mon Sep 17 00:00:00 2001 From: JSDurand Date: Thu, 23 May 2024 17:15:53 +0800 Subject: 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. --- mail.el | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) (limited to 'mail.el') 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.") -- cgit v1.2.3-18-g5258