如何根据当前环境能否链接外网 来判断是否执行elisp代码

  (when 能连接外网
    (shell-command (concat "git clone https://github.com/manateelazycat/color-rg.git " path-to-color-rg))
    )

能连接外网的部分写什么比较好?

ping,zsbd

(when (= (call-process "ping" nil nil nil "-c" "1" "-w" "1" "114.114.114.114") 0)
  ;; whatever
  )
1 个赞