unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#56436: [PATCH] Avoid obsolete initial-input argument in net-utils.el
@ 2022-07-07 14:41 Stefan Kangas
  2022-07-07 18:18 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 3+ messages in thread
From: Stefan Kangas @ 2022-07-07 14:41 UTC (permalink / raw)
  To: 56436

[-- Attachment #1: Type: text/plain, Size: 234 bytes --]

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?

[-- Attachment #2: 0001-Avoid-obsolete-initial-input-argument-in-net-utils.e.patch --]
[-- Type: text/x-diff, Size: 5372 bytes --]

From 653af2f26b5a5a638e45ca6e9084ba3750f02007 Mon Sep 17 00:00:00 2001
From: Stefan Kangas <stefan@marxist.se>
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 "pbreton@cs.umb.edu", 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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* bug#56436: [PATCH] Avoid obsolete initial-input argument in net-utils.el
  2022-07-07 14:41 bug#56436: [PATCH] Avoid obsolete initial-input argument in net-utils.el Stefan Kangas
@ 2022-07-07 18:18 ` Lars Ingebrigtsen
  2022-07-08  9:03   ` Stefan Kangas
  0 siblings, 1 reply; 3+ messages in thread
From: Lars Ingebrigtsen @ 2022-07-07 18:18 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: 56436

Stefan Kangas <stefan@marxist.se> writes:

> 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?

Looks good to me.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#56436: [PATCH] Avoid obsolete initial-input argument in net-utils.el
  2022-07-07 18:18 ` Lars Ingebrigtsen
@ 2022-07-08  9:03   ` Stefan Kangas
  0 siblings, 0 replies; 3+ messages in thread
From: Stefan Kangas @ 2022-07-08  9:03 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 56436-done

Lars Ingebrigtsen <larsi@gnus.org> writes:

> Looks good to me.

Thanks, pushed to master as commit 989908eee8.





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-07-08  9:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-07 14:41 bug#56436: [PATCH] Avoid obsolete initial-input argument in net-utils.el Stefan Kangas
2022-07-07 18:18 ` Lars Ingebrigtsen
2022-07-08  9:03   ` Stefan Kangas

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).