changeset 26041:01eac276e455

(whois-server-name): Changed to rs.internic.net (nslookup-mode): Now implemented as a derived mode. (ftp-mode): Now implemented as a derived mode. (dig): Added this function. (dig-program): Added this variable.
author Peter Breton <pbreton@attbi.com>
date Sat, 16 Oct 1999 03:15:58 +0000
parents 8500b0f62b8e
children 1eb2f529058f
files lisp/net-utils.el
diffstat 1 files changed, 97 insertions(+), 47 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/net-utils.el	Fri Oct 15 16:53:35 1999 +0000
+++ b/lisp/net-utils.el	Sat Oct 16 03:15:58 1999 +0000
@@ -3,7 +3,7 @@
 ;; Author:  Peter Breton <pbreton@cs.umb.edu>
 ;; Created: Sun Mar 16 1997
 ;; Keywords: network communications
-;; Time-stamp: <1998-06-13 06:19:01 pbreton>
+;; Time-stamp: <1999-10-15 23:14:59 pbreton>
 
 ;; This file is part of GNU Emacs.
 
@@ -176,6 +176,12 @@
   :type  'regexp
   )
 
+(defcustom dig-program  "dig"
+  "Program to query DNS information."
+  :group 'net-utils
+  :type  'string
+  )
+
 (defcustom ftp-program "ftp"
   "Progam to run to do FTP transfers."
   :group 'net-utils
@@ -226,30 +232,10 @@
 	  )))
 	 "Expressions to font-lock for nslookup.")
 
-(defvar nslookup-abbrev-table (make-abbrev-table)
-  "Abbrev table for nslookup.")
-
-(define-abbrev nslookup-abbrev-table "e"   "exit")
-(define-abbrev nslookup-abbrev-table "f"   "finger")
-(define-abbrev nslookup-abbrev-table "h"   "help")
-(define-abbrev nslookup-abbrev-table "lse" "lserver")
-(define-abbrev nslookup-abbrev-table "r"   "root")
-(define-abbrev nslookup-abbrev-table "s"   "set")
-(define-abbrev nslookup-abbrev-table "se"  "server")
-(define-abbrev nslookup-abbrev-table "v"   "viewer")
-
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; FTP goodies
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
-(defvar ftp-abbrev-table (make-abbrev-table)
-  "Abbrev table for ftp.")
-
-(define-abbrev ftp-abbrev-table "q"    "quit")
-(define-abbrev ftp-abbrev-table "g"    "get")
-(define-abbrev ftp-abbrev-table "p"    "prompt")
-(define-abbrev ftp-abbrev-table "anon" "anonymous")
-
 (defconst ftp-font-lock-keywords
   (and window-system
        (progn
@@ -257,7 +243,6 @@
 	 (list
 	  (list ftp-prompt-regexp 0 font-lock-reference-face)))))
 
-
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Utility functions
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -444,22 +429,64 @@
   (comint-run nslookup-program)
   (set-process-filter (get-buffer-process "*nslookup*")
    'net-utils-remove-ctrl-m-filter)
+  (nslookup-mode)
+  )
+
+;; Using a derived mode gives us keymaps, hooks, etc.
+(define-derived-mode 
+  nslookup-mode comint-mode "Nslookup"
+  "Major mode for interacting with the nslookup program."
   (set 
    (make-local-variable 'font-lock-defaults)
    '((nslookup-font-lock-keywords)))
-  (set 
-   (make-local-variable 'local-abbrev-table)
-   nslookup-abbrev-table)
+  (setq local-abbrev-table nslookup-mode-abbrev-table)
   (abbrev-mode t)
   (make-local-variable 'comint-prompt-regexp)
   (setq comint-prompt-regexp nslookup-prompt-regexp)
+  (make-local-variable 'comint-input-autoexpand)
+  (setq comint-input-autoexpand t)
   )
 
+(define-key nslookup-mode-map "\t" 'comint-dynamic-complete)
+
+(define-abbrev nslookup-mode-abbrev-table "e"   "exit")
+(define-abbrev nslookup-mode-abbrev-table "f"   "finger")
+(define-abbrev nslookup-mode-abbrev-table "h"   "help")
+(define-abbrev nslookup-mode-abbrev-table "lse" "lserver")
+(define-abbrev nslookup-mode-abbrev-table "q"   "exit")
+(define-abbrev nslookup-mode-abbrev-table "r"   "root")
+(define-abbrev nslookup-mode-abbrev-table "s"   "set")
+(define-abbrev nslookup-mode-abbrev-table "se"  "server")
+(define-abbrev nslookup-mode-abbrev-table "v"   "viewer")
+
+;;;###autoload
+(defun dig (host)
+  "Run dig program."
+  (interactive
+   (list
+    (progn
+      (require 'ffap)
+      (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)
+   )) 
+
 ;; This is a lot less than ange-ftp, but much simpler.
 ;;;###autoload
 (defun ftp (host)
   "Run ftp program."
-  (interactive "sFtp to Host: ")
+  (interactive 
+   (list
+    (read-from-minibuffer 
+     "Ftp to Host: " (net-utils-machine-at-point))))
   (require 'comint)
   (let ((buf (get-buffer-create (concat "*ftp [" host "]*"))))
     (set-buffer buf)
@@ -468,23 +495,40 @@
 		 (if ftp-program-options
 		     (append (list host) ftp-program-options)
 		   (list host)))
-    (set 
-     (make-local-variable 'font-lock-defaults)
-     '((ftp-font-lock-keywords)))
-
-    (make-local-variable 'comint-prompt-regexp)
-    (setq comint-prompt-regexp ftp-prompt-regexp)
-
-    ;; Already buffer local!
-    (setq comint-output-filter-functions
-	  (list 'comint-watch-for-password-prompt))
-    (set 
-     (make-local-variable 'local-abbrev-table)
-     ftp-abbrev-table)
-    (abbrev-mode t)
+    (ftp-mode)
     (switch-to-buffer-other-window buf)
     ))
 
+(define-derived-mode 
+  ftp-mode comint-mode "FTP"
+  "Major mode for interacting with the ftp program."
+
+  (set 
+   (make-local-variable 'font-lock-defaults)
+   '((ftp-font-lock-keywords)))
+  
+  (make-local-variable 'comint-prompt-regexp)
+  (setq comint-prompt-regexp ftp-prompt-regexp)
+  
+  (make-local-variable 'comint-input-autoexpand)
+  (setq comint-input-autoexpand t)
+  
+  ;; Already buffer local!
+  (setq comint-output-filter-functions
+	(list 'comint-watch-for-password-prompt))
+  
+  (setq local-abbrev-table ftp-mode-abbrev-table)
+  (abbrev-mode t)
+  )
+
+(define-abbrev ftp-mode-abbrev-table "q"    "quit")
+(define-abbrev ftp-mode-abbrev-table "g"    "get")
+(define-abbrev ftp-mode-abbrev-table "p"    "prompt")
+(define-abbrev ftp-mode-abbrev-table "anon" "anonymous")
+
+;; Occasionally useful
+(define-key ftp-mode-map "\t" 'comint-dynamic-complete)
+
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Network Connections
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -560,7 +604,7 @@
   (interactive
     (let* ((answer (read-from-minibuffer "Finger User: "
 					 (net-utils-url-at-point)))
-	   (index  (string-match "@" answer)))
+	   (index  (string-match (regexp-quote "@") answer)))
       (if index
 	  (list 
 	   (substring answer 0 index)
@@ -568,13 +612,19 @@
 	(list
 	 answer
 	 (read-from-minibuffer "At Host: " (net-utils-machine-at-point))))))
-  (run-network-program 
-   (concat "Finger [" user "@" host "]")
-   host 
-   (cdr (assoc 'finger network-connection-service-alist))
-   user))
+  (let* (
+	 (user-and-host (concat user "@" host))
+	 (process-name 
+	  (concat "Finger [" user-and-host "]"))
+	 )
+    (run-network-program 
+     process-name 
+     host 
+     (cdr (assoc 'finger network-connection-service-alist))
+     user-and-host
+     )))
 
-(defcustom whois-server-name "whois.arin.net"
+(defcustom whois-server-name "rs.internic.net"
   "Default host name for the whois service."
   :group 'net-utils
   :type  'string