Mercurial > emacs
comparison lisp/net-utils.el @ 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 | 1d78cd7c460d |
children | 9b2b851efc39 |
comparison
equal
deleted
inserted
replaced
26040:8500b0f62b8e | 26041:01eac276e455 |
---|---|
1 ;;; net-utils.el --- Network functions | 1 ;;; net-utils.el --- Network functions |
2 | 2 |
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 |
10 ;; GNU Emacs is free software; you can redistribute it and/or modify | 10 ;; GNU Emacs is free software; you can redistribute it and/or modify |
11 ;; it under the terms of the GNU General Public License as published by | 11 ;; it under the terms of the GNU General Public License as published by |
172 | 172 |
173 (defcustom nslookup-prompt-regexp "^> " | 173 (defcustom nslookup-prompt-regexp "^> " |
174 "Regexp to match the nslookup prompt." | 174 "Regexp to match the nslookup prompt." |
175 :group 'net-utils | 175 :group 'net-utils |
176 :type 'regexp | 176 :type 'regexp |
177 ) | |
178 | |
179 (defcustom dig-program "dig" | |
180 "Program to query DNS information." | |
181 :group 'net-utils | |
182 :type 'string | |
177 ) | 183 ) |
178 | 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 |
224 ) | 230 ) |
225 0 font-lock-variable-name-face) | 231 0 font-lock-variable-name-face) |
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 | |
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 | 238 |
253 (defconst ftp-font-lock-keywords | 239 (defconst ftp-font-lock-keywords |
254 (and window-system | 240 (and window-system |
255 (progn | 241 (progn |
256 (require 'font-lock) | 242 (require 'font-lock) |
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 | |
260 | 245 |
261 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 246 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
262 ;; Utility functions | 247 ;; Utility functions |
263 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 248 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
264 | 249 |
442 (interactive) | 427 (interactive) |
443 (require 'comint) | 428 (require 'comint) |
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) |
456 ) | 446 (make-local-variable 'comint-input-autoexpand) |
447 (setq comint-input-autoexpand t) | |
448 ) | |
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 )) | |
457 | 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) |
466 (comint-mode) | 493 (comint-mode) |
467 (comint-exec buf (concat "ftp-" host) ftp-program nil | 494 (comint-exec buf (concat "ftp-" host) ftp-program nil |
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 )) |
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) | |
487 | 531 |
488 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 532 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
489 ;; Network Connections | 533 ;; Network Connections |
490 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 534 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
491 | 535 |
558 ;; uses a string like "pbreton@cs.umb.edu", we won't ask for the | 602 ;; uses a string like "pbreton@cs.umb.edu", we won't ask for the |
559 ;; host name. If we don't see an "@", we'll prompt for the host. | 603 ;; host name. If we don't see an "@", we'll prompt for the host. |
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) |
567 (substring answer (1+ index))) | 611 (substring answer (1+ index))) |
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 ) |
576 | 620 (run-network-program |
577 (defcustom whois-server-name "whois.arin.net" | 621 process-name |
622 host | |
623 (cdr (assoc 'finger network-connection-service-alist)) | |
624 user-and-host | |
625 ))) | |
626 | |
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 |
581 ) | 631 ) |
582 | 632 |