From def754ac4c1bb310925f1b419376c718c2cb13fa Mon Sep 17 00:00:00 2001 From: JSDurand Date: Tue, 21 May 2024 21:37:30 +0800 Subject: basic: Add a function to test internet connection. --- basic.el | 9 +++++++++ 1 file changed, 9 insertions(+) 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) -- cgit v1.2.3-18-g5258