From 40030845d3691480f4b75f8a65ab84f345508465 Mon Sep 17 00:00:00 2001 From: Tomas Fabrizio Orsi Date: Sat, 8 Jun 2024 12:11:18 -0300 Subject: [PATCH] ping: Added optional arguments --- lisp/net/net-utils.el | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/lisp/net/net-utils.el b/lisp/net/net-utils.el index 83842cd..c37d997 100644 --- a/lisp/net/net-utils.el +++ b/lisp/net/net-utils.el @@ -425,22 +425,29 @@ This variable is only used if the variable options))) ;;;###autoload -(defun ping (host) +(defun ping (host &optional options) "Ping HOST. +Optional argument OPTIONS sets which options will be passed to `ping-program' +With a \\[universal-argument] prefix arg, prompt the user for OPTIONS. +If called interactively with no prefix arg, then `ping-program-options' +will be used. +If OPTIONS is not set, then `ping-program-options' will be used. If your system's ping continues until interrupted, you can try setting `ping-program-options'." (interactive (list (let ((default (ffap-machine-at-point))) - (read-string (format-prompt "Ping host" default) nil nil default)))) - (let ((options - (if ping-program-options + (read-string (format-prompt "Ping host" default) nil nil default)) + (if current-prefix-arg (split-string (read-string + (format-prompt "Ping options (RET for defaults)" nil) nil nil nil) " ")))) + (let ((full-command + (if (or (equal options (list "")) (not options)) (append ping-program-options (list host)) - (list host)))) + (append options (list host))))) (net-utils-run-program (concat "Ping" " " host) (concat "** Ping ** " ping-program " ** " host) ping-program - options))) + full-command))) ;;;###autoload (defun nslookup-host (host &optional name-server) -- 2.44.2