summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJSDurand <mmemmew@gmail.com>2024-05-21 21:37:30 +0800
committerJSDurand <mmemmew@gmail.com>2024-05-21 21:37:30 +0800
commitdef754ac4c1bb310925f1b419376c718c2cb13fa (patch)
treea57096f6b1661e62cb63d5141288e2ee7891a6b3
parentc409b9089945737c27a28ca6719dbd45e8a4ac16 (diff)
basic: Add a function to test internet connection.
-rw-r--r--basic.el9
1 files changed, 9 insertions, 0 deletions
diff --git a/basic.el b/basic.el
index 03a075e..6e1d7fd 100644
--- a/basic.el
+++ b/basic.el
@@ -657,6 +657,15 @@ The remaining CONFIGS are evaluated after the package is loaded."
(require ,package-name)
,@configs))
+;;; Test internet connection
+
+(defun durand-internet-on (&optional host)
+ "Test if the internet connection is working.
+If HOST is non-nil, ping HOST, otherwise ping Google."
+ (interactive nil)
+ (setq host (cond (host) ("www.google.com")))
+ (= 0 (call-process "ping" nil nil nil "-c" "1" "-W" "1" host)))
+
;;; Go to parent in the file name completion map
(defun durand-delete-goto-parent-dir (n &optional kill-flag)