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

From: Andrew Robbins <[email-masked]>
Date: Sun, 07 May 2017 04:40:42 -0400

Andrew Robbins <[email-masked]> writes:

> Attached are the diffs for 'NEWS', 'ChangeLog', and
> 'net-utils.el'.

Oops, attached the wrong files.  THESE are the diffs.

--- ChangeLog.2	2017-05-07 03:36:37.869464250 -0400
+++ ChangeLog.NEW	2017-05-07 03:45:59.594253035 -0400
@@ -1,3 +1,12 @@
+2017-05-07  Andrew Robbins  <[email-masked]>
+
+	* lisp/net/net-utils.el (ffap-string-at-point): Removed due to
+	'net-utils-machine-at-point' obviating this autoloaded
+	function (Bug#25426).
+	(dig-program-options): New customization variable.
+	(nslookup-host, dns-lookup-host, run-dig): Can now specify optional
+	name server argument interactively (by prefix arg) & non-interactively.
+
 2017-04-20  Nicolas Petton  <[email-masked]>
 
 	* Version 25.2 released.
--- lisp/net/net-utils.el	2017-05-07 03:36:38.553470033 -0400
+++ lisp/net/net-utils.el.NEW	2017-05-07 03:45:56.638227429 -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,15 +513,18 @@
 ;;   (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))))
-    (net-utils-run-program
+         (append nslookup-program-options (list host)
+                 (if name-server (list name-server)))))
+  (net-utils-run-program
      "Nslookup"
      (concat "** "
       (mapconcat 'identity
@@ -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")
 
--- etc/NEWS	2017-05-07 03:36:38.077466009 -0400
+++ etc/NEWS.NEW	2017-05-07 03:46:03.122283597 -0400
@@ -343,6 +343,11 @@
 ** Emacsclient has a new option -u/--suppress-output.  The option
 suppresses display of return values from the server process.
 
+** New user option 'dig-program-options' and extended functionality
+for DNS-querying functions 'nslookup-host', 'dns-lookup-host',
+and 'run-dig'.  Each function now accepts an optional name server
+argument interactively (with a prefix argument) and non-interactively.
+
 
 * Editing Changes in Emacs 26.1