aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Breton1999-10-16 03:15:58 +0000
committerPeter Breton1999-10-16 03:15:58 +0000
commit552a813228d56a74d2f7b649f8fbc3defb290f8e (patch)
tree83eb553d44bcf756ed8a951c2f783c38b97d19aa
parent1416c7ffb542477723bdbc644731ad61331105df (diff)
downloademacs-552a813228d56a74d2f7b649f8fbc3defb290f8e.tar.gz
emacs-552a813228d56a74d2f7b649f8fbc3defb290f8e.zip
(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.
-rw-r--r--lisp/net-utils.el144
1 files changed, 97 insertions, 47 deletions
diff --git a/lisp/net-utils.el b/lisp/net-utils.el
index 08aab61f6c8..6eabcb7c20c 100644
--- a/lisp/net-utils.el
+++ b/lisp/net-utils.el
@@ -3,7 +3,7 @@
3;; Author: Peter Breton <pbreton@cs.umb.edu> 3;; Author: Peter Breton <pbreton@cs.umb.edu>
4;; Created: Sun Mar 16 1997 4;; Created: Sun Mar 16 1997
5;; Keywords: network communications 5;; Keywords: network communications
6;; Time-stamp: <1998-06-13 06:19:01 pbreton> 6;; Time-stamp: <1999-10-15 23:14:59 pbreton>
7 7
8;; This file is part of GNU Emacs. 8;; This file is part of GNU Emacs.
9 9
@@ -176,6 +176,12 @@ These options can be used to limit how many ICMP packets are emitted."
176 :type 'regexp 176 :type 'regexp
177 ) 177 )
178 178
179(defcustom dig-program "dig"
180 "Program to query DNS information."
181 :group 'net-utils
182 :type 'string
183 )
184
179(defcustom ftp-program "ftp" 185(defcustom ftp-program "ftp"
180 "Progam to run to do FTP transfers." 186 "Progam to run to do FTP transfers."
181 :group 'net-utils 187 :group 'net-utils
@@ -226,30 +232,10 @@ These options can be used to limit how many ICMP packets are emitted."
226 ))) 232 )))
227 "Expressions to font-lock for nslookup.") 233 "Expressions to font-lock for nslookup.")
228 234
229(defvar nslookup-abbrev-table (make-abbrev-table)
230 "Abbrev table for nslookup.")
231
232(define-abbrev nslookup-abbrev-table "e" "exit")
233(define-abbrev nslookup-abbrev-table "f" "finger")
234(define-abbrev nslookup-abbrev-table "h" "help")
235(define-abbrev nslookup-abbrev-table "lse" "lserver")
236(define-abbrev nslookup-abbrev-table "r" "root")
237(define-abbrev nslookup-abbrev-table "s" "set")
238(define-abbrev nslookup-abbrev-table "se" "server")
239(define-abbrev nslookup-abbrev-table "v" "viewer")
240
241;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 235;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
242;; FTP goodies 236;; FTP goodies
243;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 237;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
244 238
245(defvar ftp-abbrev-table (make-abbrev-table)
246 "Abbrev table for ftp.")
247
248(define-abbrev ftp-abbrev-table "q" "quit")
249(define-abbrev ftp-abbrev-table "g" "get")
250(define-abbrev ftp-abbrev-table "p" "prompt")
251(define-abbrev ftp-abbrev-table "anon" "anonymous")
252
253(defconst ftp-font-lock-keywords 239(defconst ftp-font-lock-keywords
254 (and window-system 240 (and window-system
255 (progn 241 (progn
@@ -257,7 +243,6 @@ These options can be used to limit how many ICMP packets are emitted."
257 (list 243 (list
258 (list ftp-prompt-regexp 0 font-lock-reference-face))))) 244 (list ftp-prompt-regexp 0 font-lock-reference-face)))))
259 245
260
261;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 246;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
262;; Utility functions 247;; Utility functions
263;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 248;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -444,22 +429,64 @@ If your system's ping continues until interrupted, you can try setting
444 (comint-run nslookup-program) 429 (comint-run nslookup-program)
445 (set-process-filter (get-buffer-process "*nslookup*") 430 (set-process-filter (get-buffer-process "*nslookup*")
446 'net-utils-remove-ctrl-m-filter) 431 'net-utils-remove-ctrl-m-filter)
432 (nslookup-mode)
433 )
434
435;; Using a derived mode gives us keymaps, hooks, etc.
436(define-derived-mode
437 nslookup-mode comint-mode "Nslookup"
438 "Major mode for interacting with the nslookup program."
447 (set 439 (set
448 (make-local-variable 'font-lock-defaults) 440 (make-local-variable 'font-lock-defaults)
449 '((nslookup-font-lock-keywords))) 441 '((nslookup-font-lock-keywords)))
450 (set 442 (setq local-abbrev-table nslookup-mode-abbrev-table)
451 (make-local-variable 'local-abbrev-table)
452 nslookup-abbrev-table)
453 (abbrev-mode t) 443 (abbrev-mode t)
454 (make-local-variable 'comint-prompt-regexp) 444 (make-local-variable 'comint-prompt-regexp)
455 (setq comint-prompt-regexp nslookup-prompt-regexp) 445 (setq comint-prompt-regexp nslookup-prompt-regexp)
446 (make-local-variable 'comint-input-autoexpand)
447 (setq comint-input-autoexpand t)
456 ) 448 )
457 449
450(define-key nslookup-mode-map "\t" 'comint-dynamic-complete)
451
452(define-abbrev nslookup-mode-abbrev-table "e" "exit")
453(define-abbrev nslookup-mode-abbrev-table "f" "finger")
454(define-abbrev nslookup-mode-abbrev-table "h" "help")
455(define-abbrev nslookup-mode-abbrev-table "lse" "lserver")
456(define-abbrev nslookup-mode-abbrev-table "q" "exit")
457(define-abbrev nslookup-mode-abbrev-table "r" "root")
458(define-abbrev nslookup-mode-abbrev-table "s" "set")
459(define-abbrev nslookup-mode-abbrev-table "se" "server")
460(define-abbrev nslookup-mode-abbrev-table "v" "viewer")
461
462;;;###autoload
463(defun dig (host)
464 "Run dig program."
465 (interactive
466 (list
467 (progn
468 (require 'ffap)
469 (read-from-minibuffer
470 "Lookup host: "
471 (or (ffap-string-at-point 'machine) "")))))
472 (net-utils-run-program
473 "Dig"
474 (concat "** "
475 (mapconcat 'identity
476 (list "Dig" host dig-program)
477 " ** "))
478 dig-program
479 (list host)
480 ))
481
458;; This is a lot less than ange-ftp, but much simpler. 482;; This is a lot less than ange-ftp, but much simpler.
459;;;###autoload 483;;;###autoload
460(defun ftp (host) 484(defun ftp (host)
461 "Run ftp program." 485 "Run ftp program."
462 (interactive "sFtp to Host: ") 486 (interactive
487 (list
488 (read-from-minibuffer
489 "Ftp to Host: " (net-utils-machine-at-point))))
463 (require 'comint) 490 (require 'comint)
464 (let ((buf (get-buffer-create (concat "*ftp [" host "]*")))) 491 (let ((buf (get-buffer-create (concat "*ftp [" host "]*"))))
465 (set-buffer buf) 492 (set-buffer buf)
@@ -468,23 +495,40 @@ If your system's ping continues until interrupted, you can try setting
468 (if ftp-program-options 495 (if ftp-program-options
469 (append (list host) ftp-program-options) 496 (append (list host) ftp-program-options)
470 (list host))) 497 (list host)))
471 (set 498 (ftp-mode)
472 (make-local-variable 'font-lock-defaults)
473 '((ftp-font-lock-keywords)))
474
475 (make-local-variable 'comint-prompt-regexp)
476 (setq comint-prompt-regexp ftp-prompt-regexp)
477
478 ;; Already buffer local!
479 (setq comint-output-filter-functions
480 (list 'comint-watch-for-password-prompt))
481 (set
482 (make-local-variable 'local-abbrev-table)
483 ftp-abbrev-table)
484 (abbrev-mode t)
485 (switch-to-buffer-other-window buf) 499 (switch-to-buffer-other-window buf)
486 )) 500 ))
487 501
502(define-derived-mode
503 ftp-mode comint-mode "FTP"
504 "Major mode for interacting with the ftp program."
505
506 (set
507 (make-local-variable 'font-lock-defaults)
508 '((ftp-font-lock-keywords)))
509
510 (make-local-variable 'comint-prompt-regexp)
511 (setq comint-prompt-regexp ftp-prompt-regexp)
512
513 (make-local-variable 'comint-input-autoexpand)
514 (setq comint-input-autoexpand t)
515
516 ;; Already buffer local!
517 (setq comint-output-filter-functions
518 (list 'comint-watch-for-password-prompt))
519
520 (setq local-abbrev-table ftp-mode-abbrev-table)
521 (abbrev-mode t)
522 )
523
524(define-abbrev ftp-mode-abbrev-table "q" "quit")
525(define-abbrev ftp-mode-abbrev-table "g" "get")
526(define-abbrev ftp-mode-abbrev-table "p" "prompt")
527(define-abbrev ftp-mode-abbrev-table "anon" "anonymous")
528
529;; Occasionally useful
530(define-key ftp-mode-map "\t" 'comint-dynamic-complete)
531
488;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 532;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
489;; Network Connections 533;; Network Connections
490;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 534;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -560,7 +604,7 @@ This list in not complete.")
560 (interactive 604 (interactive
561 (let* ((answer (read-from-minibuffer "Finger User: " 605 (let* ((answer (read-from-minibuffer "Finger User: "
562 (net-utils-url-at-point))) 606 (net-utils-url-at-point)))
563 (index (string-match "@" answer))) 607 (index (string-match (regexp-quote "@") answer)))
564 (if index 608 (if index
565 (list 609 (list
566 (substring answer 0 index) 610 (substring answer 0 index)
@@ -568,13 +612,19 @@ This list in not complete.")
568 (list 612 (list
569 answer 613 answer
570 (read-from-minibuffer "At Host: " (net-utils-machine-at-point)))))) 614 (read-from-minibuffer "At Host: " (net-utils-machine-at-point))))))
571 (run-network-program 615 (let* (
572 (concat "Finger [" user "@" host "]") 616 (user-and-host (concat user "@" host))
573 host 617 (process-name
574 (cdr (assoc 'finger network-connection-service-alist)) 618 (concat "Finger [" user-and-host "]"))
575 user)) 619 )
620 (run-network-program
621 process-name
622 host
623 (cdr (assoc 'finger network-connection-service-alist))
624 user-and-host
625 )))
576 626
577(defcustom whois-server-name "whois.arin.net" 627(defcustom whois-server-name "rs.internic.net"
578 "Default host name for the whois service." 628 "Default host name for the whois service."
579 :group 'net-utils 629 :group 'net-utils
580 :type 'string 630 :type 'string