all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Kangas <stefankangas@gmail.com>
To: TOMAS FABRIZIO ORSI <torsi@fi.uba.ar>, Eli Zaretskii <eliz@gnu.org>
Cc: pbreton@cs.umb.edu, 71438@debbugs.gnu.org
Subject: bug#71438: [PATCH] Allow ping to receive optional arguments
Date: Sun, 16 Jun 2024 18:14:59 -0700	[thread overview]
Message-ID: <CADwFkmmmCh6FUxaVM84=V5zLk3=Og8bCMDJydBC14p4_c46_Cw@mail.gmail.com> (raw)
In-Reply-To: <CAHTSwYiapiSLJusFoMqdGnYb-CBUgHx5-3Miw2j+KpgbGJGYnQ@mail.gmail.com>

TOMAS FABRIZIO ORSI <torsi@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)





  reply	other threads:[~2024-06-17  1:14 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-08 15:28 bug#71438: [PATCH] Allow ping to receive optional arguments TOMAS FABRIZIO ORSI
2024-06-08 18:48 ` Peter Breton via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-06-08 18:57   ` TOMAS FABRIZIO ORSI
2024-06-09 12:02 ` Stefan Kangas
2024-06-09 13:47   ` Eli Zaretskii
2024-06-09 15:03     ` TOMAS FABRIZIO ORSI
2024-06-09 15:21       ` Eli Zaretskii
2024-06-09 15:38       ` Stefan Kangas
2024-06-09 15:48         ` TOMAS FABRIZIO ORSI
2024-06-16 21:46           ` TOMAS FABRIZIO ORSI
2024-06-17  1:14             ` Stefan Kangas [this message]
2024-06-17  2:03               ` TOMAS FABRIZIO ORSI
2024-06-17  6:19                 ` Stefan Kangas
2024-06-19  2:17                   ` TOMAS FABRIZIO ORSI
2024-06-20 18:45                     ` Stefan Kangas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CADwFkmmmCh6FUxaVM84=V5zLk3=Og8bCMDJydBC14p4_c46_Cw@mail.gmail.com' \
    --to=stefankangas@gmail.com \
    --cc=71438@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=pbreton@cs.umb.edu \
    --cc=torsi@fi.uba.ar \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.