aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Robbins2017-05-12 11:19:46 +0300
committerEli Zaretskii2017-05-12 11:19:46 +0300
commita1b69815147b67f4ff7730d0b97b526c8eda2935 (patch)
tree1f01290857091a95adf2b69633c039fe6b1d38aa
parentd9592104c8aa93a9b92a05c410a546f0abd8d0b5 (diff)
downloademacs-a1b69815147b67f4ff7730d0b97b526c8eda2935.tar.gz
emacs-a1b69815147b67f4ff7730d0b97b526c8eda2935.zip
Extend DNS lookup commands to allow specifying the name server
* 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) and non-interactively. * etc/NEWS: Mention the extension of DNS lookup commands.
-rw-r--r--etc/NEWS6
-rw-r--r--lisp/net/net-utils.el63
2 files changed, 48 insertions, 21 deletions
diff --git a/etc/NEWS b/etc/NEWS
index 3b830c93424..9be6ee0f3f7 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -338,6 +338,12 @@ want to reverse the direction of the scroll, customize
338** Emacsclient has a new option -u/--suppress-output. The option 338** Emacsclient has a new option -u/--suppress-output. The option
339suppresses display of return values from the server process. 339suppresses display of return values from the server process.
340 340
341---
342** New user option 'dig-program-options' and extended functionality
343for DNS-querying functions 'nslookup-host', 'dns-lookup-host',
344and 'run-dig'. Each function now accepts an optional name server
345argument interactively (with a prefix argument) and non-interactively.
346
341 347
342* Editing Changes in Emacs 26.1 348* Editing Changes in Emacs 26.1
343 349
diff --git a/lisp/net/net-utils.el b/lisp/net/net-utils.el
index 06b67dcc4f4..6b38462ff3e 100644
--- a/lisp/net/net-utils.el
+++ b/lisp/net/net-utils.el
@@ -199,6 +199,12 @@ This variable is only used if the variable
199 :group 'net-utils 199 :group 'net-utils
200 :type 'string) 200 :type 'string)
201 201
202(defcustom dig-program-options nil
203 "Options for the dig program."
204 :group 'net-utils
205 :type '(repeat string)
206 :version "26.1")
207
202(defcustom ftp-program "ftp" 208(defcustom ftp-program "ftp"
203 "Program to run to do FTP transfers." 209 "Program to run to do FTP transfers."
204 :group 'net-utils 210 :group 'net-utils
@@ -507,14 +513,19 @@ If your system's ping continues until interrupted, you can try setting
507;; (delete-matching-lines filter)) 513;; (delete-matching-lines filter))
508 514
509;;;###autoload 515;;;###autoload
510(defun nslookup-host (host) 516(defun nslookup-host (host &optional name-server)
511 "Lookup the DNS information for HOST." 517 "Look up the DNS information for HOST (name or IP address).
518Optional argument NAME-SERVER says which server to use for
519DNS resolution.
520Interactively, prompt for NAME-SERVER if invoked with prefix argument.
521
522This command uses `nslookup-program' for looking up the DNS information."
512 (interactive 523 (interactive
513 (list (read-from-minibuffer "Lookup host: " (net-utils-machine-at-point)))) 524 (list (read-from-minibuffer "Lookup host: " (net-utils-machine-at-point))
525 (if current-prefix-arg (read-from-minibuffer "Name server: "))))
514 (let ((options 526 (let ((options
515 (if nslookup-program-options 527 (append nslookup-program-options (list host)
516 (append nslookup-program-options (list host)) 528 (if name-server (list name-server)))))
517 (list host))))
518 (net-utils-run-program 529 (net-utils-run-program
519 "Nslookup" 530 "Nslookup"
520 (concat "** " 531 (concat "** "
@@ -551,14 +562,19 @@ If your system's ping continues until interrupted, you can try setting
551 (setq comint-input-autoexpand t)) 562 (setq comint-input-autoexpand t))
552 563
553;;;###autoload 564;;;###autoload
554(defun dns-lookup-host (host) 565(defun dns-lookup-host (host &optional name-server)
555 "Lookup the DNS information for HOST (name or IP address)." 566 "Look up the DNS information for HOST (name or IP address).
567Optional argument NAME-SERVER says which server to use for
568DNS resolution.
569Interactively, prompt for NAME-SERVER if invoked with prefix argument.
570
571This command uses `dns-lookup-program' for looking up the DNS information."
556 (interactive 572 (interactive
557 (list (read-from-minibuffer "Lookup host: " (net-utils-machine-at-point)))) 573 (list (read-from-minibuffer "Lookup host: " (net-utils-machine-at-point))
574 (if current-prefix-arg (read-from-minibuffer "Name server: "))))
558 (let ((options 575 (let ((options
559 (if dns-lookup-program-options 576 (append dns-lookup-program-options (list host)
560 (append dns-lookup-program-options (list host)) 577 (if name-server (list name-server)))))
561 (list host))))
562 (net-utils-run-program 578 (net-utils-run-program
563 (concat "DNS Lookup [" host "]") 579 (concat "DNS Lookup [" host "]")
564 (concat "** " 580 (concat "** "
@@ -568,15 +584,20 @@ If your system's ping continues until interrupted, you can try setting
568 dns-lookup-program 584 dns-lookup-program
569 options))) 585 options)))
570 586
571(autoload 'ffap-string-at-point "ffap")
572
573;;;###autoload 587;;;###autoload
574(defun run-dig (host) 588(defun run-dig (host &optional name-server)
575 "Run dig program." 589 "Look up DNS information for HOST (name or IP address).
590Optional argument NAME-SERVER says which server to use for
591DNS resolution.
592Interactively, prompt for NAME-SERVER if invoked with prefix argument.
593
594This command uses `dig-program' for looking up the DNS information."
576 (interactive 595 (interactive
577 (list 596 (list (read-from-minibuffer "Lookup host: " (net-utils-machine-at-point))
578 (read-from-minibuffer "Lookup host: " 597 (if current-prefix-arg (read-from-minibuffer "Name server: "))))
579 (or (ffap-string-at-point 'machine) "")))) 598 (let ((options
599 (append dig-program-options (list host)
600 (if name-server (list (concat "@" name-server))))))
580 (net-utils-run-program 601 (net-utils-run-program
581 "Dig" 602 "Dig"
582 (concat "** " 603 (concat "** "
@@ -584,14 +605,14 @@ If your system's ping continues until interrupted, you can try setting
584 (list "Dig" host dig-program) 605 (list "Dig" host dig-program)
585 " ** ")) 606 " ** "))
586 dig-program 607 dig-program
587 (list host))) 608 options)))
588 609
589(autoload 'comint-exec "comint") 610(autoload 'comint-exec "comint")
590 611
591;; This is a lot less than ange-ftp, but much simpler. 612;; This is a lot less than ange-ftp, but much simpler.
592;;;###autoload 613;;;###autoload
593(defun ftp (host) 614(defun ftp (host)
594 "Run ftp program." 615 "Run `ftp program."
595 (interactive 616 (interactive
596 (list 617 (list
597 (read-from-minibuffer 618 (read-from-minibuffer