GNU bug report logs - #71438
[PATCH] Allow ping to receive optional arguments

Previous Next

Package: emacs;

Reported by: TOMAS FABRIZIO ORSI <torsi <at> fi.uba.ar>

Date: Sat, 8 Jun 2024 15:58:04 UTC

Severity: normal

Tags: patch

Fixed in version 30.1

Done: Stefan Kangas <stefankangas <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Stefan Kangas <stefankangas <at> gmail.com>
To: TOMAS FABRIZIO ORSI <torsi <at> fi.uba.ar>, Eli Zaretskii <eliz <at> gnu.org>
Cc: pbreton <at> cs.umb.edu, 71438 <at> debbugs.gnu.org
Subject: bug#71438: [PATCH] Allow ping to receive optional arguments
Date: Sun, 16 Jun 2024 18:14:59 -0700
TOMAS FABRIZIO ORSI <torsi <at> fi.uba.ar> writes:

> Did you have the chance to look at the patch?
> The patch did not have the changes to changelog because I was
> unsure if there were going to be any additional comments regarding
> the e-lisp code.
> Should I send a patch with the changelog modified?

Sorry for the late reply.

I think this patch (to be applied on top of yours) might provide a
slighly better experience.  I also made an attempt at improving the
docstring.  What do you think?

diff --git a/lisp/net/net-utils.el b/lisp/net/net-utils.el
index c37d9976cf2..8fb417da241 100644
--- a/lisp/net/net-utils.el
+++ b/lisp/net/net-utils.el
@@ -425,24 +425,30 @@ traceroute
      options)))

 ;;;###autoload
-(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'."
+(defun ping (host &optional flags)
+  "Ping HOST using `ping-program'.
+
+The user option `ping-program-options' is passed as flags to
+`ping-program'.  With a \\[universal-argument] prefix arg, prompt the
+user for the flags to pass.
+
+When called from Lisp, the optional argument FLAGS, if non-nil, is a
+list of strings that will be passed as flags for the `ping-program'.  If
+FLAGS is nil, `ping-program-options' will be used.
+
+If your system's ping continues until interrupted, you can try using a
+prefix argument or setting `ping-program-options'."
   (interactive
    (list (let ((default (ffap-machine-at-point)))
            (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) " "))))
+         (when current-prefix-arg
+           (split-string
+            (read-string (format-prompt "Ping options" ping-program-options)
+                         nil nil ping-program-options)))))
   (let ((full-command
-	 (if (or (equal options (list "")) (not options))
+	 (if (or (equal flags (list "")) (not flags))
 	     (append ping-program-options (list host))
-	     (append options (list host)))))
+	     (append flags (list host)))))
     (net-utils-run-program
      (concat "Ping" " " host)
      (concat "** Ping ** " ping-program " ** " host)




This bug report was last modified 1 year and 47 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.