Subject: Re: bug#25426: [PATCH] 26.1; Revised patch for bug#25426

From: Andrew Robbins <[email-masked]>
Date: Sun, 07 May 2017 16:27:44 -0400

[email-masked] writes:

> Andrew Robbins <[email-masked]> writes:
>
>>    (let ((options
>> -	 (if nslookup-program-options
>> -	     (append nslookup-program-options (list host))
>> -	   (list host))))
>> -    (net-utils-run-program
>> +         (append nslookup-program-options (list host)
>> +                 (if name-server (list name-server)))))
>> +  (net-utils-run-program
>>       "Nslookup"
>>       (concat "** "
>>        (mapconcat 'identity
>
> The indentation on (net-utils-run-program...) seems to have got messed
> up.  Otherwise looks good to me.

Ah, good catch.  Here's the final diff if there aren't any other
modifications that need to be made:

--- lisp/net/net-utils.el	2017-05-07 03:57:44.080371619 -0400
+++ lisp/net/net-utils.el.NEW	2017-05-07 16:05:46.601658191 -0400
@@ -199,6 +199,12 @@
   :group 'net-utils
   :type  'string)
 
+(defcustom dig-program-options nil
+  "Options for the dig program."
+  :group 'net-utils
+  :type '(repeat string)
+  :version "26.1")
+
 (defcustom ftp-program "ftp"
   "Program to run to do FTP transfers."
   :group 'net-utils
@@ -507,14 +513,17 @@
 ;;   (delete-matching-lines filter))
 
 ;;;###autoload
-(defun nslookup-host (host)
-  "Lookup the DNS information for HOST."
+(defun nslookup-host (host &optional name-server)
+  "Look up the DNS information for HOST (name or IP address).
+Optional argument NAME-SERVER says which server to use for
+DNS resolution.
+Interactively, prompt for NAME-SERVER if invoked with prefix argument."
   (interactive
-   (list (read-from-minibuffer "Lookup host: " (net-utils-machine-at-point))))
+   (list (read-from-minibuffer "Lookup host: " (net-utils-machine-at-point))
+         (if current-prefix-arg (read-from-minibuffer "Name server: "))))
   (let ((options
-	 (if nslookup-program-options
-	     (append nslookup-program-options (list host))
-	   (list host))))
+         (append nslookup-program-options (list host)
+                 (if name-server (list name-server)))))
     (net-utils-run-program
      "Nslookup"
      (concat "** "
@@ -551,14 +560,17 @@
   (setq comint-input-autoexpand t))
 
 ;;;###autoload
-(defun dns-lookup-host (host)
-  "Lookup the DNS information for HOST (name or IP address)."
+(defun dns-lookup-host (host &optional name-server)
+  "Look up the DNS information for HOST (name or IP address).
+Optional argument NAME-SERVER says which server to use for
+DNS resolution.
+Interactively, prompt for NAME-SERVER if invoked with prefix argument."
   (interactive
-   (list (read-from-minibuffer "Lookup host: " (net-utils-machine-at-point))))
+   (list (read-from-minibuffer "Lookup host: " (net-utils-machine-at-point))
+         (if current-prefix-arg (read-from-minibuffer "Name server: "))))
   (let ((options
-	 (if dns-lookup-program-options
-	     (append dns-lookup-program-options (list host))
-	   (list host))))
+         (append dns-lookup-program-options (list host)
+                 (if name-server (list name-server)))))
     (net-utils-run-program
      (concat "DNS Lookup [" host "]")
      (concat "** "
@@ -568,15 +580,18 @@
      dns-lookup-program
      options)))
 
-(autoload 'ffap-string-at-point "ffap")
-
 ;;;###autoload
-(defun run-dig (host)
-  "Run dig program."
+(defun run-dig (host &optional name-server)
+  "Look up the DNS information for HOST (name or IP address).
+Optional argument NAME-SERVER says which server to use for
+DNS resolution.
+Interactively, prompt for NAME-SERVER if invoked with prefix argument."
   (interactive
-   (list
-    (read-from-minibuffer "Lookup host: "
-                          (or (ffap-string-at-point 'machine) ""))))
+   (list (read-from-minibuffer "Lookup host: " (net-utils-machine-at-point))
+         (if current-prefix-arg (read-from-minibuffer "Name server: "))))
+  (let ((options
+         (append dig-program-options (list host)
+                 (if name-server (list (concat "@" name-server))))))
   (net-utils-run-program
    "Dig"
    (concat "** "
@@ -584,7 +599,7 @@
 		      (list "Dig" host dig-program)
 		      " ** "))
    dig-program
-   (list host)))
+   options)))
 
 (autoload 'comint-exec "comint")