Subject: [PATCH] Avoid obsolete initial-input argument in net-utils.el

From: Stefan Kangas <[email-masked]>
Date: Thu, 7 Jul 2022 17:41:28 +0300

Severity: wishlist

The prompting from the functions in net-utils.el is pretty bad, since it
uses the obsolete INITIAL-INPUT argument of `read-from-minibuffer'.

How about replacing it with using a proper default, as in the attached?
From 653af2f26b5a5a638e45ca6e9084ba3750f02007 Mon Sep 17 00:00:00 2001
From: Stefan Kangas <[email-masked]>
Date: Thu, 7 Jul 2022 15:58:45 +0200
Subject: [PATCH] Avoid obsolete initial-input argument in net-utils.el

* lisp/net/net-utils.el (ping, nslookup-host, dns-lookup-host)
(run-dig, ftp, smbclient, smbclient-list-shares, finger)
(network-connection-to-service): Don't use obsolete initial-input
argument.  Use 'format-prompt'.
---
 lisp/net/net-utils.el | 36 ++++++++++++++++++++----------------
 1 file changed, 20 insertions(+), 16 deletions(-)

diff --git a/lisp/net/net-utils.el b/lisp/net/net-utils.el
index ab7770e04a..a4707bb5cf 100644
--- a/lisp/net/net-utils.el
+++ b/lisp/net/net-utils.el
@@ -431,7 +431,8 @@ ping
 If your system's ping continues until interrupted, you can try setting
 `ping-program-options'."
   (interactive
-   (list (read-from-minibuffer "Ping host: " (ffap-machine-at-point))))
+   (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))
@@ -464,7 +465,8 @@ nslookup-host
 non-interactive versions of this function more suitable for use
 in Lisp code."
   (interactive
-   (list (read-from-minibuffer "Lookup host: " (ffap-machine-at-point))
+   (list (let ((default (ffap-machine-at-point)))
+           (read-string (format-prompt "Lookup host" default) nil nil default))
          (if current-prefix-arg (read-from-minibuffer "Name server: "))))
   (let ((options
          (append nslookup-program-options (list host)
@@ -576,7 +578,8 @@ dns-lookup-host
 
 This command uses `dns-lookup-program' for looking up the DNS information."
   (interactive
-   (list (read-from-minibuffer "Lookup host: " (ffap-machine-at-point))
+   (list (let ((default (ffap-machine-at-point)))
+           (read-string (format-prompt "Lookup host" default) nil nil default))
          (if current-prefix-arg (read-from-minibuffer "Name server: "))))
   (let ((options
          (append dns-lookup-program-options (list host)
@@ -600,7 +603,8 @@ run-dig
 This command uses `dig-program' for looking up the DNS information."
   (declare (obsolete dig "29.1"))
   (interactive
-   (list (read-from-minibuffer "Lookup host: " (ffap-machine-at-point))
+   (list (let ((default (ffap-machine-at-point)))
+           (read-string (format-prompt "Lookup host" default) nil nil default))
          (if current-prefix-arg (read-from-minibuffer "Name server: "))))
   (dig host nil nil nil nil name-server))
 
@@ -612,9 +616,8 @@ run-dig
 (defun ftp (host)
   "Run `ftp-program' to connect to HOST."
   (interactive
-   (list
-    (read-from-minibuffer
-     "Ftp to Host: " (ffap-machine-at-point))))
+   (list (let ((default (ffap-machine-at-point)))
+           (read-string (format-prompt "Ftp to Host" default) nil nil default))))
   (let ((buf (get-buffer-create (concat "*ftp [" host "]*"))))
     (set-buffer buf)
     (ftp-mode)
@@ -649,8 +652,8 @@ smbclient
 This command uses `smbclient-program' to connect to HOST."
   (interactive
    (list
-    (read-from-minibuffer
-     "Connect to Host: " (ffap-machine-at-point))
+    (let ((default (ffap-machine-at-point)))
+      (read-string (format-prompt "Connect to Host" default) nil nil default))
     (read-from-minibuffer "SMB Service: ")))
   (let* ((name (format "smbclient [%s\\%s]" host service))
 	 (buf (get-buffer-create (concat "*" name "*")))
@@ -668,8 +671,8 @@ smbclient-list-shares
 This command uses `smbclient-program' to connect to HOST."
   (interactive
    (list
-    (read-from-minibuffer
-     "Connect to Host: " (ffap-machine-at-point))))
+    (let ((default (ffap-machine-at-point)))
+      (read-string (format-prompt "Connect to Host" default) nil nil default))))
   (let ((buf (get-buffer-create (format "*SMB Shares on %s*" host))))
     (set-buffer buf)
     (smbclient-mode)
@@ -768,15 +771,15 @@ finger
   ;; uses a string like "[email-masked]", we won't ask for the
   ;; host name. If we don't see an "@", we'll prompt for the host.
   (interactive
-    (let* ((answer (read-from-minibuffer "Finger User: "
-                                         (ffap-url-at-point)))
+    (let* ((answer (let ((default (ffap-url-at-point)))
+                     (read-string (format-prompt "Finger User" default) nil nil default)))
 	   (index  (string-match (regexp-quote "@") answer)))
       (if index
 	  (list (substring answer 0 index)
 		(substring answer (1+ index)))
 	(list answer
-	      (read-from-minibuffer "At Host: "
-                                    (ffap-machine-at-point))))))
+              (let ((default (ffap-machine-at-point)))
+                (read-string (format-prompt "At Host" default) nil nil default))))))
   (let* ((user-and-host (concat user "@" host))
 	 (process-name (concat "Finger [" user-and-host "]"))
 	 (regexps finger-X.500-host-regexps)
@@ -909,7 +912,8 @@ network-connection-to-service
 This command uses `network-connection-service-alist', which see."
   (interactive
    (list
-    (read-from-minibuffer "Host: " (ffap-machine-at-point))
+    (let ((default (ffap-machine-at-point)))
+      (read-string (format-prompt "Host" default) nil nil default))
     (completing-read "Service: "
 		     (mapcar
                       (lambda (elt)
-- 
2.30.2