mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2024-11-21 06:55:39 +00:00
Allow giving "ping" flags with C-u M-x ping
* lisp/net/net-utils.el (ping): With a prefix argument, prompt the user for flags to pass to the "ping" command. (Bug#71438) * etc/NEWS: Document the above change. Copyright-paperwork-exempt: yes
This commit is contained in:
parent
a6296fda5e
commit
72f2b01e31
5
etc/NEWS
5
etc/NEWS
@ -1961,6 +1961,11 @@ The following new XML schemas are now supported:
|
||||
|
||||
** color.el now supports the Oklab color representation.
|
||||
|
||||
---
|
||||
** 'M-x ping' can now give "ping" additional flags.
|
||||
Typing 'C-u M-x ping' prompts first for the host, and then for the flags
|
||||
to give to "ping".
|
||||
|
||||
|
||||
* New Modes and Packages in Emacs 30.1
|
||||
|
||||
|
@ -425,22 +425,35 @@ This variable is only used if the variable
|
||||
options)))
|
||||
|
||||
;;;###autoload
|
||||
(defun ping (host)
|
||||
"Ping HOST.
|
||||
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))))
|
||||
(let ((options
|
||||
(if ping-program-options
|
||||
(read-string (format-prompt "Ping host" default) nil nil default))
|
||||
(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 flags (list "")) (not flags))
|
||||
(append ping-program-options (list host))
|
||||
(list host))))
|
||||
(append flags (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)
|
||||
|
Loading…
Reference in New Issue
Block a user