all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Andrew Robbins <contact@andrewrobbins.info>
To: 25426@debbugs.gnu.org
Subject: bug#25426: [PATCH] in net-utils.el several DNS query functions now take optional name server argument; also, `dig-program-options' added
Date: Thu, 12 Jan 2017 09:03:02 -0500	[thread overview]
Message-ID: <878tqgs7e1.fsf@andrewrobbins.info> (raw)

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

- In a git-clone'd "lisp/net/net-utils.el" I modified several
interactive DNS-querying functions (nslookup-host,
dns-lookup-host, run-dig) to allow specifying a particular name
server to use where before you couldn't. This is possible
non-interactively as well as interactively with a prefix argument.

- Also, a new variable `dig-program-options' is defined to allow
users to set options for use with `run-dig'. This is in line with
the current `nslookup-program-options' and
`dns-lookup-program-options' and is necessary for the new
definition of `run-dig' to function.

- The `run-dig' function no longer needs the auto-loaded
`ffap-string-at-point' function, removing one dependency on
ffap.el 

For all users, and especially those unaware of the changes, there
should be no discernible difference in functionality when used
exactly as before.

My changelog and diff are attached.

[-- Attachment #2: changelog_net-utils --]
[-- Type: application/octet-stream, Size: 382 bytes --]

2017-01-12  Andrew Robbins  <contact@andrewrobbins.info>

	* lisp/net/net-utils.el (ffap-string-at-point): Removed due to
	'net-utils-machine-at-point' obviating this autoloaded function.
	(dig-program-options): New customization variable.
	(nslookup-host, dns-lookup-host, run-dig): Can now specify optional
	name server argument interactively (by prefix arg) & noninteractively.


[-- Attachment #3: diff_net-utils --]
[-- Type: application/octet-stream, Size: 4393 bytes --]

--- OLD_net-utils.el	2017-01-12 04:08:40.094886747 -0500
+++ NEW_net-utils.el	2017-01-12 06:30:05.055334267 -0500
@@ -199,6 +199,11 @@
   :group 'net-utils
   :type  'string)
 
+(defcustom dig-program-options nil
+  "Options for the dig program."
+  :group 'net-utils
+  :type '(repeat string))
+
 (defcustom ftp-program "ftp"
   "Program to run to do FTP transfers."
   :group 'net-utils
@@ -507,20 +512,27 @@
 ;;   (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).
+When called interactively, DNS resolver NAME-SERVER may be specified
+by passing the function a prefix argument."
   (interactive
-   (list (read-from-minibuffer "Lookup host: " (net-utils-machine-at-point))))
+   (if current-prefix-arg
+       (list
+        (read-from-minibuffer "Look up host: " (net-utils-machine-at-point))
+        (read-from-minibuffer "Name server: "))
+     (list
+      (read-from-minibuffer "Look up host: " (net-utils-machine-at-point)))))
   (let ((options
-	 (if nslookup-program-options
-	     (append nslookup-program-options (list host))
-	   (list host))))
+	 (if name-server
+	     (append nslookup-program-options (list host name-server))
+	   (append nslookup-program-options (list host)))))
     (net-utils-run-program
      "Nslookup"
      (concat "** "
-      (mapconcat 'identity
-		(list "Nslookup" host nslookup-program)
-		" ** "))
+	     (mapconcat 'identity
+		        (list "Nslookup" host nslookup-program)
+		        " ** "))
      nslookup-program
      options)))
 
@@ -551,40 +563,58 @@
   (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).
+When called interactively, DNS resolver NAME-SERVER may be specified
+by passing the function a prefix argument."
   (interactive
-   (list (read-from-minibuffer "Lookup host: " (net-utils-machine-at-point))))
+   (if current-prefix-arg
+       (list
+        (read-from-minibuffer "Look up host: " (net-utils-machine-at-point))
+        (read-from-minibuffer "Name server: "))
+     (list
+      (read-from-minibuffer "Look up host: " (net-utils-machine-at-point)))))
   (let ((options
-	 (if dns-lookup-program-options
-	     (append dns-lookup-program-options (list host))
-	   (list host))))
+	 (if name-server
+	     (append dns-lookup-program-options (list host name-server))
+	   (append dns-lookup-program-options (list host)))))
     (net-utils-run-program
      (concat "DNS Lookup [" host "]")
      (concat "** "
-      (mapconcat 'identity
-		(list "DNS Lookup" host dns-lookup-program)
-		" ** "))
+	     (mapconcat 'identity
+		        (list "DNS Lookup" host dns-lookup-program)
+		        " ** "))
      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).
+When called interactively, DNS resolver NAME-SERVER may be specified
+by passing the function a prefix argument."
   (interactive
-   (list
-    (read-from-minibuffer "Lookup host: "
-                          (or (ffap-string-at-point 'machine) ""))))
-  (net-utils-run-program
-   "Dig"
-   (concat "** "
-	   (mapconcat 'identity
-		      (list "Dig" host dig-program)
-		      " ** "))
-   dig-program
-   (list host)))
+   (if current-prefix-arg
+       (list
+        (read-from-minibuffer "Look up host: " (net-utils-machine-at-point))
+        (read-from-minibuffer "Name server: "))
+     (list
+      (read-from-minibuffer "Look up host: " (net-utils-machine-at-point)))))
+  (let* ((server
+	  (if (and name-server (equal "dig" dig-program))
+	      (concat "@" name-server)
+	    name-server))
+	 (options
+	  (if server
+	      (append dig-program-options (list host server))
+	    (append dig-program-options (list host)))))
+    (net-utils-run-program
+     "Dig"
+     (concat "** "
+	     (mapconcat 'identity
+		        (list "Dig" host dig-program)
+		        " ** "))
+     dig-program
+     options)))
 
 (autoload 'comint-exec "comint")
 

             reply	other threads:[~2017-01-12 14:03 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-12 14:03 Andrew Robbins [this message]
2017-02-14  3:15 ` bug#25426: Copyright Assignment Andrew Robbins
2017-02-14 16:23   ` Eli Zaretskii
2017-05-06  2:40 ` bug#25426: Copyright Assignment Completed Andrew Robbins
2017-05-06  7:16   ` Eli Zaretskii
2017-05-06  7:50     ` Eli Zaretskii
2017-05-06 11:05       ` Andrew Robbins
2017-05-06 12:04 ` bug#25426: [PATCH] in net-utils.el several DNS query functions now take optional name server argument; also, `dig-program-options' added npostavs
2017-05-07  8:02   ` Andrew Robbins
2017-05-07  8:36 ` bug#25426: [PATCH] 26.1; Revised patch for bug#25426 Andrew Robbins
2017-05-07  8:40   ` Andrew Robbins
2017-05-07 14:10     ` npostavs
2017-05-07 20:27       ` Andrew Robbins
2017-05-12  8:37         ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=878tqgs7e1.fsf@andrewrobbins.info \
    --to=contact@andrewrobbins.info \
    --cc=25426@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.