From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Kangas Newsgroups: gmane.emacs.bugs Subject: bug#71438: [PATCH] Allow ping to receive optional arguments Date: Sun, 9 Jun 2024 05:02:51 -0700 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="17680"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 71438@debbugs.gnu.org To: TOMAS FABRIZIO ORSI , pbreton@cs.umb.edu Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Jun 09 14:41:46 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1sGHrl-0004LJ-NT for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 09 Jun 2024 14:41:45 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sGHqs-0006uw-Fw; Sun, 09 Jun 2024 08:40:50 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sGHqq-0006to-V0 for bug-gnu-emacs@gnu.org; Sun, 09 Jun 2024 08:40:48 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sGHqq-0006Ep-Mu for bug-gnu-emacs@gnu.org; Sun, 09 Jun 2024 08:40:48 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sGHr7-0008Bb-1o for bug-gnu-emacs@gnu.org; Sun, 09 Jun 2024 08:41:05 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Kangas Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 09 Jun 2024 12:41:05 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 71438 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 71438-submit@debbugs.gnu.org id=B71438.171793685131302 (code B ref 71438); Sun, 09 Jun 2024 12:41:05 +0000 Original-Received: (at 71438) by debbugs.gnu.org; 9 Jun 2024 12:40:51 +0000 Original-Received: from localhost ([127.0.0.1]:35355 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sGHqq-00088b-8j for submit@debbugs.gnu.org; Sun, 09 Jun 2024 08:40:51 -0400 Original-Received: from mail-ed1-f52.google.com ([209.85.208.52]:49400) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sGHHT-0006Vc-6m for 71438@debbugs.gnu.org; Sun, 09 Jun 2024 08:04:16 -0400 Original-Received: by mail-ed1-f52.google.com with SMTP id 4fb4d7f45d1cf-57a4d7ba501so4451281a12.2 for <71438@debbugs.gnu.org>; Sun, 09 Jun 2024 05:03:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717934573; x=1718539373; darn=debbugs.gnu.org; h=cc:to:subject:message-id:date:mime-version:references:in-reply-to :from:from:to:cc:subject:date:message-id:reply-to; bh=ZvKoLSsNvK0cboOgPouJJjJuoVUGCbe7kmFAWwGpXSs=; b=c+Kvds+s6T9pNY3OZ0wqPNkIq+w1RB2fm+8JervUj3cwox6NovaGUhGU4EpX8GCozE wWt05iLghCpwoMFG9K/fBjBQcoAQbJkAct8I8sq5BWHMuS+/U5hUUBK0BgJeZPjWlq+u kvwmnHiDoQI1gfPR3rYiMpwAsW53kg9zC0z7wDtkw0SbtBM2GHpWM99NiLh+cEO7mIBw kHTnb6FBHr8FeMOIJqiM6AOIu6PG9A0Q0lwYN8gPbfwfDm5MOn4TKcJI9Da/osi4NjbU YI/FPkrmfpUr/F8Nh9oD7ErA8UREDtL7o+yOCCydsrx58w/MKVZo5xvt/o00pnUVwfpP 3FPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717934573; x=1718539373; h=cc:to:subject:message-id:date:mime-version:references:in-reply-to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ZvKoLSsNvK0cboOgPouJJjJuoVUGCbe7kmFAWwGpXSs=; b=H9dO/t7KAEeNwuUXx8iKf9rqOSOcJEZ4zAMz72ak8r/5XpN0ZB4Vqh2D6MdaNYGbh+ loJHzUo5OGVVLdI9B/2uA1gdr2Iu76+4satjV6bSJURpOilMFBa2bPoUICj70IJ1cLI+ p6SO++orU8MNnh2igr/BJf/N1tGBRQkSt1WNP3PbKVeNqXTVnVKq28HLBSqp1hG2GRQX Oe7/OzkSuc6ADvCth80LJ1/NFPvm6wtugxOMMczTsDAvCk9312aHiPsUssk8KTBlxb2B J4dLvhx273WmyS1LBupDB6BSYc3quqL96HqPF1rm9j83Bgjv3L62neV8ILP4jjparDZS NDIA== X-Gm-Message-State: AOJu0YyauoYvkik9wXCH+4s15i8xbcIylesGQStz1o4xy33oSDeLLmur ZLrNPWZpGL7SlvxNuRkxxZo/NMU49RRHy6l2QWCNECE39VCc8IUnp/JpmhTvcmDmNOxDmBlyNeI ZuOY725QB37RKhAwMcT/UBkT2w0BEWkcY X-Google-Smtp-Source: AGHT+IGwM1qs8330McoGfDnMVU3hlj1EOQQ9GiXCEtz3joHtFBkITUEDILKiaJr++pE0JqyLUmmgN3GHeHMRzafgnt0= X-Received: by 2002:a50:aacb:0:b0:57a:3273:e646 with SMTP id 4fb4d7f45d1cf-57c50997dbdmr4464251a12.26.1717934572793; Sun, 09 Jun 2024 05:02:52 -0700 (PDT) Original-Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Sun, 9 Jun 2024 05:02:51 -0700 In-Reply-To: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:286936 Archived-At: TOMAS FABRIZIO ORSI 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 > Date: Sat, 8 Jun 2024 12:11:18 -0300 > Subject: [PATCH] ping: Added optional arguments > > Signed-off-by: Tomas Fabrizio Orsi 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.