summaryrefslogtreecommitdiff
path: root/lisp/net/dig.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/net/dig.el')
-rw-r--r--lisp/net/dig.el39
1 files changed, 27 insertions, 12 deletions
diff --git a/lisp/net/dig.el b/lisp/net/dig.el
index f7f1500454a..d4fad0c61fd 100644
--- a/lisp/net/dig.el
+++ b/lisp/net/dig.el
@@ -44,6 +44,11 @@
"Name of dig (domain information groper) binary."
:type 'file)
+(defcustom dig-program-options nil
+ "Options for the dig program."
+ :type '(repeat string)
+ :version "26.1")
+
(defcustom dig-dns-server nil
"DNS server to query.
If nil, use system defaults."
@@ -59,8 +64,8 @@ If nil, use system defaults."
:type 'sexp)
(defun dig-invoke (domain &optional
- query-type query-class query-option
- dig-option server)
+ query-type query-class query-option
+ dig-option server)
"Call dig with given arguments and return buffer containing output.
DOMAIN is a string with a DNS domain. QUERY-TYPE is an optional
string with a DNS type. QUERY-CLASS is an optional string with a DNS
@@ -79,7 +84,8 @@ and is a commonly available debugging tool."
(push domain cmdline)
(if server (push (concat "@" server) cmdline)
(if dig-dns-server (push (concat "@" dig-dns-server) cmdline)))
- (apply #'call-process dig-program nil buf nil cmdline)
+ (apply #'call-process dig-program nil buf nil
+ (append dig-program-options cmdline))
buf))
(defun dig-extract-rr (domain &optional type class)
@@ -117,11 +123,9 @@ Buffer should contain output generated by `dig-invoke'."
(setq str (replace-match "" nil nil str)))
str))
-(defvar dig-mode-map
- (let ((map (make-sparse-keymap)))
- (define-key map "g" nil)
- (define-key map "q" #'dig-exit)
- map))
+(defvar-keymap dig-mode-map
+ "g" nil
+ "q" #'dig-exit)
(define-derived-mode dig-mode special-mode "Dig"
"Major mode for displaying dig output."
@@ -132,7 +136,7 @@ Buffer should contain output generated by `dig-invoke'."
(defun dig-exit ()
"Quit dig output buffer."
- (interactive)
+ (interactive nil dig-mode)
(quit-window t))
;;;###autoload
@@ -140,12 +144,23 @@ Buffer should contain output generated by `dig-invoke'."
query-type query-class query-option dig-option server)
"Query addresses of a DOMAIN using dig.
See `dig-invoke' for an explanation for the parameters.
-When called interactively, DOMAIN is prompted for. If given a prefix,
-also prompt for the QUERY-TYPE parameter."
+When called interactively, DOMAIN is prompted for.
+
+If given a \\[universal-argument] prefix, also prompt \
+for the QUERY-TYPE parameter.
+
+If given a \\[universal-argument] \\[universal-argument] \
+prefix, also prompt for the SERVER parameter."
(interactive
- (list (read-string "Host: ")
+ (list (let ((default (ffap-machine-at-point)))
+ (read-string (format-prompt "Host" default) nil nil default))
(and current-prefix-arg
(read-string "Query type: "))))
+ (when (and (numberp (car current-prefix-arg))
+ (>= (car current-prefix-arg) 16))
+ (let ((serv (read-from-minibuffer "Name server: ")))
+ (when (not (equal serv ""))
+ (setq server serv))))
(pop-to-buffer-same-window
(dig-invoke domain query-type query-class query-option dig-option server))
(goto-char (point-min))