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>, pbreton@cs.umb.edu
Cc: 71438@debbugs.gnu.org
Subject: bug#71438: [PATCH] Allow ping to receive optional arguments
Date: Sun, 9 Jun 2024 05:02:51 -0700	[thread overview]
Message-ID: <CADwFkmkCPEgqK3Fb498zpQUhAwA9Cc4s8NnUQH6Scp2cQOqoEQ@mail.gmail.com> (raw)
In-Reply-To: <CAHTSwYhnSiTG20hmG-95B00fsNcb+GMoee5TyAuRxgfebUxRSg@mail.gmail.com>

TOMAS FABRIZIO ORSI <torsi@fi.uba.ar> writes:

> Hi! This small patch makes it so that the "ping" interactive
> function can receive optional arguments.
> This allows the caller to change its argument every time. If no
> arguments are passed, the default variable will be used.
>
> Prior to this (if I am not mistaken), one had to change the
> variable each time.
>
> I would love to get some feedback! Thanks in advance.
>
> Version: GNU Emacs 29.3 (build 1, x86_64-pc-linux-gnu,
> GTK+ Version 3.24.41, cairo version 1.18.0) of 2024-05-18
>
> PS: This is my first time sending an email to the emacs
> mailing list. I CC'd  bug-gnu-emacs@gnu.org because it
> was the address that the CONTRIBUTE file stated one
> should send patches to. I apologize in advance if I made
> a mistake.

Thanks for your contribution to Emacs!

This is the right list to send your patch to.

> From de527784bb1f6e60a65291e5ab798328fd18c8e0 Mon Sep 17 00:00:00 2001
> From: Tomas Fabrizio Orsi <torsi@fi.uba.ar>
> Date: Sat, 8 Jun 2024 12:11:18 -0300
> Subject: [PATCH] ping: Added optional arguments
>
> Signed-off-by: Tomas Fabrizio Orsi <torsi@fi.uba.ar>

Consider adding a ChangeLog entry to the commit message, see CONTRIBUTE.

Note that we don't usually use "Signed-off-by" trailers so that can
probably be removed as redundant.

Does this deserve to be announced in NEWS?

> ---
>  lisp/net/net-utils.el | 21 ++++++++++++---------
>  1 file changed, 12 insertions(+), 9 deletions(-)
>
> diff --git a/lisp/net/net-utils.el b/lisp/net/net-utils.el
> index 83842cd..6f69326 100644
> --- a/lisp/net/net-utils.el
> +++ b/lisp/net/net-utils.el
> @@ -78,7 +78,7 @@
>
>  ;; On GNU/Linux and Irix, the system's ping program seems to send packets
>  ;; indefinitely unless told otherwise
> -(defcustom ping-program-options
> +(defcustom ping-program-default-options
>    (and (eq system-type 'gnu/linux)
>         (list "-c" "4"))
>    "Options for the ping program.

This needs an `define-obsolete-variable-alias'.

> @@ -425,22 +425,25 @@ 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'
> +If OPTIONS is not set, then `ping-program-default-options' will be used.
>  If your system's ping continues until interrupted, you can try setting
> -`ping-program-options'."
> +`ping-program-default-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
> -	     (append ping-program-options (list host))
> -	   (list host))))
> +           (read-string (format-prompt "Ping host" default) nil nil default))
> +         (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-default-options (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

There is an extra RET before you can ping, so the change is
backwards-incompatible.  I rarely if ever use `M-x ping`, so I can't
give a very informed opinion here, but:

- Perhaps we should make it prompt for options only with a prefix
  command?

- Or an option that reverts back to the old behaviour (or enables the
  new)?

- Or is the new behaviour simply more useful and should be enabled
  unconditionally?  At the very least, this needs some kind of
  rationale.

Let's see if anyone else has any thoughts here.





  parent reply	other threads:[~2024-06-09 12:02 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 [this message]
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
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=CADwFkmkCPEgqK3Fb498zpQUhAwA9Cc4s8NnUQH6Scp2cQOqoEQ@mail.gmail.com \
    --to=stefankangas@gmail.com \
    --cc=71438@debbugs.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.