Mercurial > emacs
annotate lisp/net/net-utils.el @ 42811:cf0c0ef57504
*** empty log message ***
| author | Jason Rumney <jasonr@gnu.org> |
|---|---|
| date | Thu, 17 Jan 2002 19:29:24 +0000 |
| parents | c4fdc37d21f5 |
| children | 33ca9e7e717a d7ddb3e565de |
| rev | line source |
|---|---|
|
38436
b174db545cfd
Some fixes to follow coding conventions.
Pavel Jan?k <Pavel@Janik.cz>
parents:
36225
diff
changeset
|
1 ;;; net-utils.el --- network functions |
| 28210 | 2 |
| 36225 | 3 ;; Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc. |
| 4 | |
| 28210 | 5 ;; Author: Peter Breton <pbreton@cs.umb.edu> |
| 6 ;; Created: Sun Mar 16 1997 | |
|
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Jan?k <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
7 ;; Keywords: network comm |
| 28210 | 8 |
| 9 ;; This file is part of GNU Emacs. | |
| 10 | |
| 11 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
| 12 ;; it under the terms of the GNU General Public License as published by | |
| 13 ;; the Free Software Foundation; either version 2, or (at your option) | |
| 14 ;; any later version. | |
| 15 | |
| 16 ;; GNU Emacs is distributed in the hope that it will be useful, | |
| 17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 19 ;; GNU General Public License for more details. | |
| 20 | |
| 21 ;; You should have received a copy of the GNU General Public License | |
| 22 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
| 23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
| 24 ;; Boston, MA 02111-1307, USA. | |
| 25 | |
| 26 ;;; Commentary: | |
|
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Jan?k <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
27 |
| 28210 | 28 ;; |
| 29 ;; There are three main areas of functionality: | |
|
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
30 ;; |
| 28210 | 31 ;; * Wrap common network utility programs (ping, traceroute, netstat, |
| 32 ;; nslookup, arp, route). Note that these wrappers are of the diagnostic | |
| 33 ;; functions of these programs only. | |
|
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
34 ;; |
| 28210 | 35 ;; * Implement some very basic protocols in Emacs Lisp (finger and whois) |
|
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
36 ;; |
| 28210 | 37 ;; * Support connections to HOST/PORT, generally for debugging and the like. |
| 38 ;; In other words, for doing much the same thing as "telnet HOST PORT", and | |
| 39 ;; then typing commands. | |
| 40 ;; | |
| 41 ;; PATHS | |
| 42 ;; | |
| 43 ;; On some systems, some of these programs are not in normal user path, | |
|
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
44 ;; but rather in /sbin, /usr/sbin, and so on. |
| 28210 | 45 |
| 46 | |
| 47 ;;; Code: | |
| 48 (eval-when-compile | |
| 49 (require 'comint)) | |
| 50 | |
| 51 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
| 52 ;; Customization Variables | |
| 53 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
| 54 | |
| 55 (defgroup net-utils nil | |
| 56 "Network utility functions." | |
| 57 :prefix "net-utils-" | |
| 58 :group 'comm | |
|
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Jan?k <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
59 :version "20.3") |
| 28210 | 60 |
|
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
61 (defcustom net-utils-remove-ctl-m |
| 28210 | 62 (member system-type (list 'windows-nt 'msdos)) |
| 63 "If non-nil, remove control-Ms from output." | |
| 64 :group 'net-utils | |
|
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Jan?k <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
65 :type 'boolean) |
| 28210 | 66 |
|
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
67 (defcustom traceroute-program |
|
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
68 (if (eq system-type 'windows-nt) |
| 28210 | 69 "tracert" |
| 70 "traceroute") | |
| 71 "Program to trace network hops to a destination." | |
| 72 :group 'net-utils | |
|
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Jan?k <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
73 :type 'string) |
| 28210 | 74 |
| 75 (defcustom traceroute-program-options nil | |
| 76 "Options for the traceroute program." | |
| 77 :group 'net-utils | |
|
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Jan?k <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
78 :type '(repeat string)) |
| 28210 | 79 |
| 80 (defcustom ping-program "ping" | |
| 81 "Program to send network test packets to a host." | |
| 82 :group 'net-utils | |
|
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Jan?k <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
83 :type 'string) |
| 28210 | 84 |
|
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Jan?k <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
85 ;; On GNU/Linux and Irix, the system's ping program seems to send packets |
| 28210 | 86 ;; indefinitely unless told otherwise |
|
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
87 (defcustom ping-program-options |
| 28210 | 88 (and (memq system-type (list 'linux 'gnu/linux 'irix)) |
| 89 (list "-c" "4")) | |
| 90 "Options for the ping program. | |
| 91 These options can be used to limit how many ICMP packets are emitted." | |
| 92 :group 'net-utils | |
|
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Jan?k <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
93 :type '(repeat string)) |
| 28210 | 94 |
|
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
95 (defcustom ipconfig-program |
| 28210 | 96 (if (eq system-type 'windows-nt) |
| 97 "ipconfig" | |
| 98 "ifconfig") | |
| 99 "Program to print network configuration information." | |
| 100 :group 'net-utils | |
|
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Jan?k <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
101 :type 'string) |
| 28210 | 102 |
| 103 (defcustom ipconfig-program-options | |
|
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Jan?k <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
104 (list |
|
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Jan?k <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
105 (if (eq system-type 'windows-nt) |
|
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Jan?k <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
106 "/all" "-a")) |
| 28210 | 107 "Options for ipconfig-program." |
| 108 :group 'net-utils | |
|
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Jan?k <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
109 :type '(repeat string)) |
| 28210 | 110 |
| 111 (defcustom netstat-program "netstat" | |
| 112 "Program to print network statistics." | |
| 113 :group 'net-utils | |
|
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Jan?k <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
114 :type 'string) |
| 28210 | 115 |
|
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
116 (defcustom netstat-program-options |
| 28210 | 117 (list "-a") |
| 118 "Options for netstat-program." | |
| 119 :group 'net-utils | |
|
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Jan?k <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
120 :type '(repeat string)) |
| 28210 | 121 |
| 122 (defcustom arp-program "arp" | |
| 123 "Program to print IP to address translation tables." | |
| 124 :group 'net-utils | |
|
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Jan?k <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
125 :type 'string) |
| 28210 | 126 |
|
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
127 (defcustom arp-program-options |
| 28210 | 128 (list "-a") |
| 129 "Options for arp-program." | |
| 130 :group 'net-utils | |
|
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Jan?k <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
131 :type '(repeat string)) |
| 28210 | 132 |
|
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
133 (defcustom route-program |
| 28210 | 134 (if (eq system-type 'windows-nt) |
| 135 "route" | |
| 136 "netstat") | |
| 137 "Program to print routing tables." | |
| 138 :group 'net-utils | |
|
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Jan?k <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
139 :type 'string) |
| 28210 | 140 |
|
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
141 (defcustom route-program-options |
| 28210 | 142 (if (eq system-type 'windows-nt) |
| 143 (list "print") | |
| 144 (list "-r")) | |
| 145 "Options for route-program." | |
| 146 :group 'net-utils | |
|
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Jan?k <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
147 :type '(repeat string)) |
| 28210 | 148 |
| 149 (defcustom nslookup-program "nslookup" | |
| 150 "Program to interactively query DNS information." | |
| 151 :group 'net-utils | |
|
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Jan?k <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
152 :type 'string) |
| 28210 | 153 |
| 154 (defcustom nslookup-program-options nil | |
| 155 "List of options to pass to the nslookup program." | |
| 156 :group 'net-utils | |
|
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Jan?k <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
157 :type '(repeat string)) |
| 28210 | 158 |
| 159 (defcustom nslookup-prompt-regexp "^> " | |
|
32197
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
160 "Regexp to match the nslookup prompt. |
|
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
161 |
|
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
162 This variable is only used if the variable |
|
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
163 `comint-use-prompt-regexp-instead-of-fields' is non-nil." |
| 28210 | 164 :group 'net-utils |
|
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Jan?k <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
165 :type 'regexp) |
| 28210 | 166 |
| 167 (defcustom dig-program "dig" | |
| 168 "Program to query DNS information." | |
| 169 :group 'net-utils | |
|
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Jan?k <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
170 :type 'string) |
| 28210 | 171 |
| 172 (defcustom ftp-program "ftp" | |
| 173 "Progam to run to do FTP transfers." | |
| 174 :group 'net-utils | |
|
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Jan?k <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
175 :type 'string) |
| 28210 | 176 |
| 177 (defcustom ftp-program-options nil | |
| 178 "List of options to pass to the FTP program." | |
| 179 :group 'net-utils | |
|
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Jan?k <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
180 :type '(repeat string)) |
| 28210 | 181 |
| 182 (defcustom ftp-prompt-regexp "^ftp>" | |
|
32197
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
183 "Regexp which matches the FTP program's prompt. |
|
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
184 |
|
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
185 This variable is only used if the variable |
|
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
186 `comint-use-prompt-regexp-instead-of-fields' is non-nil." |
| 28210 | 187 :group 'net-utils |
|
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Jan?k <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
188 :type 'regexp) |
| 28210 | 189 |
| 190 (defcustom smbclient-program "smbclient" | |
| 191 "Smbclient program." | |
| 192 :group 'net-utils | |
|
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Jan?k <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
193 :type 'string) |
| 28210 | 194 |
| 195 (defcustom smbclient-program-options nil | |
| 196 "List of options to pass to the smbclient program." | |
| 197 :group 'net-utils | |
|
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Jan?k <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
198 :type '(repeat string)) |
| 28210 | 199 |
| 200 (defcustom smbclient-prompt-regexp "^smb: \>" | |
|
32197
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
201 "Regexp which matches the smbclient program's prompt. |
|
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
202 |
|
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
203 This variable is only used if the variable |
|
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
204 `comint-use-prompt-regexp-instead-of-fields' is non-nil." |
| 28210 | 205 :group 'net-utils |
|
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Jan?k <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
206 :type 'regexp) |
| 28210 | 207 |
|
28419
fed834403704
network-connection-mode is derived from comint-mode
Peter Breton <pbreton@attbi.com>
parents:
28210
diff
changeset
|
208 ;; Internal variables |
|
fed834403704
network-connection-mode is derived from comint-mode
Peter Breton <pbreton@attbi.com>
parents:
28210
diff
changeset
|
209 (defvar network-connection-service nil) |
|
fed834403704
network-connection-mode is derived from comint-mode
Peter Breton <pbreton@attbi.com>
parents:
28210
diff
changeset
|
210 (defvar network-connection-host nil) |
|
fed834403704
network-connection-mode is derived from comint-mode
Peter Breton <pbreton@attbi.com>
parents:
28210
diff
changeset
|
211 |
| 28210 | 212 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 213 ;; Nslookup goodies | |
| 214 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
| 215 | |
| 216 (defconst nslookup-font-lock-keywords | |
|
32158
b048135b76bc
(nslookup-font-lock-keywords, ftp-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
32123
diff
changeset
|
217 (progn |
|
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Jan?k <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
218 (defvar font-lock-type-face) |
|
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Jan?k <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
219 (defvar font-lock-keyword-face) |
|
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Jan?k <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
220 (defvar font-lock-variable-name-face) |
|
32158
b048135b76bc
(nslookup-font-lock-keywords, ftp-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
32123
diff
changeset
|
221 (require 'font-lock) |
|
b048135b76bc
(nslookup-font-lock-keywords, ftp-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
32123
diff
changeset
|
222 (list |
|
b048135b76bc
(nslookup-font-lock-keywords, ftp-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
32123
diff
changeset
|
223 (list "^[A-Za-z0-9 _]+:" 0 font-lock-type-face) |
|
b048135b76bc
(nslookup-font-lock-keywords, ftp-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
32123
diff
changeset
|
224 (list "\\<\\(SOA\\|NS\\|MX\\|A\\|CNAME\\)\\>" |
|
b048135b76bc
(nslookup-font-lock-keywords, ftp-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
32123
diff
changeset
|
225 1 font-lock-keyword-face) |
|
b048135b76bc
(nslookup-font-lock-keywords, ftp-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
32123
diff
changeset
|
226 ;; Dotted quads |
|
b048135b76bc
(nslookup-font-lock-keywords, ftp-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
32123
diff
changeset
|
227 (list |
|
b048135b76bc
(nslookup-font-lock-keywords, ftp-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
32123
diff
changeset
|
228 (mapconcat 'identity |
|
b048135b76bc
(nslookup-font-lock-keywords, ftp-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
32123
diff
changeset
|
229 (make-list 4 "[0-9]+") |
|
b048135b76bc
(nslookup-font-lock-keywords, ftp-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
32123
diff
changeset
|
230 "\\.") |
|
b048135b76bc
(nslookup-font-lock-keywords, ftp-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
32123
diff
changeset
|
231 0 font-lock-variable-name-face) |
|
b048135b76bc
(nslookup-font-lock-keywords, ftp-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
32123
diff
changeset
|
232 ;; Host names |
|
b048135b76bc
(nslookup-font-lock-keywords, ftp-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
32123
diff
changeset
|
233 (list |
|
b048135b76bc
(nslookup-font-lock-keywords, ftp-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
32123
diff
changeset
|
234 (let ((host-expression "[-A-Za-z0-9]+")) |
|
b048135b76bc
(nslookup-font-lock-keywords, ftp-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
32123
diff
changeset
|
235 (concat |
|
b048135b76bc
(nslookup-font-lock-keywords, ftp-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
32123
diff
changeset
|
236 (mapconcat 'identity |
|
b048135b76bc
(nslookup-font-lock-keywords, ftp-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
32123
diff
changeset
|
237 (make-list 2 host-expression) |
|
b048135b76bc
(nslookup-font-lock-keywords, ftp-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
32123
diff
changeset
|
238 "\\.") |
|
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Jan?k <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
239 "\\(\\." host-expression "\\)*")) |
|
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Jan?k <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
240 0 font-lock-variable-name-face))) |
|
32158
b048135b76bc
(nslookup-font-lock-keywords, ftp-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
32123
diff
changeset
|
241 "Expressions to font-lock for nslookup.") |
| 28210 | 242 |
| 243 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
| 244 ;; Utility functions | |
| 245 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
| 246 | |
| 247 ;; Simplified versions of some at-point functions from ffap.el. | |
| 248 ;; It's not worth loading all of ffap just for these. | |
| 249 (defun net-utils-machine-at-point () | |
| 250 (let ((pt (point))) | |
| 251 (buffer-substring-no-properties | |
| 252 (save-excursion | |
| 253 (skip-chars-backward "-a-zA-Z0-9.") | |
| 254 (point)) | |
| 255 (save-excursion | |
| 256 (skip-chars-forward "-a-zA-Z0-9.") | |
| 257 (skip-chars-backward "." pt) | |
| 258 (point))))) | |
| 259 | |
| 260 (defun net-utils-url-at-point () | |
| 261 (let ((pt (point))) | |
| 262 (buffer-substring-no-properties | |
| 263 (save-excursion | |
| 264 (skip-chars-backward "--:=&?$+@-Z_a-z~#,%") | |
| 265 (skip-chars-forward "^A-Za-z0-9" pt) | |
| 266 (point)) | |
| 267 (save-excursion | |
| 268 (skip-chars-forward "--:=&?$+@-Z_a-z~#,%") | |
| 269 (skip-chars-backward ":;.,!?" pt) | |
| 270 (point))))) | |
| 271 | |
| 272 | |
| 273 (defun net-utils-remove-ctrl-m-filter (process output-string) | |
| 274 "Remove trailing control Ms." | |
| 275 (let ((old-buffer (current-buffer)) | |
| 276 (filtered-string output-string)) | |
| 277 (unwind-protect | |
| 278 (let ((moving)) | |
| 279 (set-buffer (process-buffer process)) | |
| 280 (setq moving (= (point) (process-mark process))) | |
|
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
281 |
| 28210 | 282 (while (string-match "\r" filtered-string) |
| 283 (setq filtered-string | |
| 284 (replace-match "" nil nil filtered-string))) | |
| 285 | |
| 286 (save-excursion | |
| 287 ;; Insert the text, moving the process-marker. | |
| 288 (goto-char (process-mark process)) | |
| 289 (insert filtered-string) | |
| 290 (set-marker (process-mark process) (point))) | |
| 291 (if moving (goto-char (process-mark process)))) | |
| 292 (set-buffer old-buffer)))) | |
|
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
293 |
| 28210 | 294 (defmacro net-utils-run-program (name header program &rest args) |
| 295 "Run a network information program." | |
| 296 ` (let ((buf (get-buffer-create (concat "*" ,name "*")))) | |
| 297 (set-buffer buf) | |
| 298 (erase-buffer) | |
| 299 (insert ,header "\n") | |
|
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
300 (set-process-filter |
| 28210 | 301 (apply 'start-process ,name buf ,program ,@args) |
| 302 'net-utils-remove-ctrl-m-filter) | |
|
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
303 (display-buffer buf) |
|
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
304 buf)) |
| 28210 | 305 |
| 306 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
| 307 ;; Wrappers for external network programs | |
| 308 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
| 309 | |
| 310 ;;;###autoload | |
| 311 (defun traceroute (target) | |
| 312 "Run traceroute program for TARGET." | |
| 313 (interactive "sTarget: ") | |
|
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
314 (let ((options |
| 28210 | 315 (if traceroute-program-options |
| 316 (append traceroute-program-options (list target)) | |
| 317 (list target)))) | |
| 318 (net-utils-run-program | |
| 319 (concat "Traceroute" " " target) | |
| 320 (concat "** Traceroute ** " traceroute-program " ** " target) | |
| 321 traceroute-program | |
|
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Jan?k <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
322 options))) |
| 28210 | 323 |
| 324 ;;;###autoload | |
| 325 (defun ping (host) | |
| 326 "Ping HOST. | |
|
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
327 If your system's ping continues until interrupted, you can try setting |
| 28210 | 328 `ping-program-options'." |
|
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
329 (interactive |
| 28210 | 330 (list (read-from-minibuffer "Ping host: " (net-utils-machine-at-point)))) |
|
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
331 (let ((options |
| 28210 | 332 (if ping-program-options |
| 333 (append ping-program-options (list host)) | |
| 334 (list host)))) | |
| 335 (net-utils-run-program | |
| 336 (concat "Ping" " " host) | |
| 337 (concat "** Ping ** " ping-program " ** " host) | |
| 338 ping-program | |
|
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Jan?k <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
339 options))) |
| 28210 | 340 |
| 341 ;;;###autoload | |
| 342 (defun ipconfig () | |
| 343 "Run ipconfig program." | |
| 344 (interactive) | |
| 345 (net-utils-run-program | |
| 346 "Ipconfig" | |
| 347 (concat "** Ipconfig ** " ipconfig-program " ** ") | |
| 348 ipconfig-program | |
|
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Jan?k <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
349 ipconfig-program-options)) |
| 28210 | 350 |
| 351 ;; This is the normal name on most Unixes. | |
| 352 ;;;###autoload | |
|
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
353 (defalias 'ifconfig 'ipconfig) |
| 28210 | 354 |
| 355 ;;;###autoload | |
| 356 (defun netstat () | |
| 357 "Run netstat program." | |
| 358 (interactive) | |
| 359 (net-utils-run-program | |
| 360 "Netstat" | |
| 361 (concat "** Netstat ** " netstat-program " ** ") | |
| 362 netstat-program | |
|
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Jan?k <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
363 netstat-program-options)) |
| 28210 | 364 |
| 365 ;;;###autoload | |
| 366 (defun arp () | |
| 367 "Run the arp program." | |
| 368 (interactive) | |
| 369 (net-utils-run-program | |
| 370 "Arp" | |
| 371 (concat "** Arp ** " arp-program " ** ") | |
| 372 arp-program | |
|
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Jan?k <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
373 arp-program-options)) |
| 28210 | 374 |
| 375 ;;;###autoload | |
| 376 (defun route () | |
| 377 "Run the route program." | |
| 378 (interactive) | |
| 379 (net-utils-run-program | |
| 380 "Route" | |
| 381 (concat "** Route ** " route-program " ** ") | |
| 382 route-program | |
|
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Jan?k <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
383 route-program-options)) |
| 28210 | 384 |
| 385 ;; FIXME -- Needs to be a process filter | |
| 386 ;; (defun netstat-with-filter (filter) | |
| 387 ;; "Run netstat program." | |
| 388 ;; (interactive "sFilter: ") | |
| 389 ;; (netstat) | |
| 390 ;; (set-buffer (get-buffer "*Netstat*")) | |
| 391 ;; (goto-char (point-min)) | |
|
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Jan?k <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
392 ;; (delete-matching-lines filter)) |
| 28210 | 393 |
| 394 ;;;###autoload | |
| 395 (defun nslookup-host (host) | |
| 396 "Lookup the DNS information for HOST." | |
| 397 (interactive | |
| 398 (list (read-from-minibuffer "Lookup host: " (net-utils-machine-at-point)))) | |
|
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
399 (let ((options |
| 28210 | 400 (if nslookup-program-options |
| 401 (append nslookup-program-options (list host)) | |
| 402 (list host)))) | |
| 403 (net-utils-run-program | |
| 404 "Nslookup" | |
| 405 (concat "** " | |
| 406 (mapconcat 'identity | |
| 407 (list "Nslookup" host nslookup-program) | |
| 408 " ** ")) | |
| 409 nslookup-program | |
|
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Jan?k <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
410 options))) |
| 28210 | 411 |
| 412 ;;;###autoload | |
| 413 (defun nslookup () | |
| 414 "Run nslookup program." | |
| 415 (interactive) | |
| 416 (require 'comint) | |
| 417 (comint-run nslookup-program) | |
|
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Jan?k <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
418 (nslookup-mode)) |
| 28210 | 419 |
| 420 ;; Using a derived mode gives us keymaps, hooks, etc. | |
|
32197
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
421 (define-derived-mode nslookup-mode comint-mode "Nslookup" |
| 28210 | 422 "Major mode for interacting with the nslookup program." |
|
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
423 (set |
| 28210 | 424 (make-local-variable 'font-lock-defaults) |
| 425 '((nslookup-font-lock-keywords))) | |
| 426 (setq comint-prompt-regexp nslookup-prompt-regexp) | |
|
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Jan?k <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
427 (setq comint-input-autoexpand t)) |
| 28210 | 428 |
| 429 (define-key nslookup-mode-map "\t" 'comint-dynamic-complete) | |
| 430 | |
| 431 ;;;###autoload | |
| 432 (defun dig (host) | |
| 433 "Run dig program." | |
| 434 (interactive | |
| 435 (list | |
| 436 (progn | |
| 437 (require 'ffap) | |
|
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
438 (read-from-minibuffer |
|
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
439 "Lookup host: " |
| 28210 | 440 (or (ffap-string-at-point 'machine) ""))))) |
| 441 (net-utils-run-program | |
| 442 "Dig" | |
| 443 (concat "** " | |
| 444 (mapconcat 'identity | |
| 445 (list "Dig" host dig-program) | |
| 446 " ** ")) | |
| 447 dig-program | |
|
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Jan?k <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
448 (list host))) |
| 28210 | 449 |
| 450 ;; This is a lot less than ange-ftp, but much simpler. | |
| 451 ;;;###autoload | |
| 452 (defun ftp (host) | |
| 453 "Run ftp program." | |
|
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
454 (interactive |
| 28210 | 455 (list |
|
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
456 (read-from-minibuffer |
| 28210 | 457 "Ftp to Host: " (net-utils-machine-at-point)))) |
| 458 (require 'comint) | |
| 459 (let ((buf (get-buffer-create (concat "*ftp [" host "]*")))) | |
| 460 (set-buffer buf) | |
|
32197
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
461 (ftp-mode) |
| 28210 | 462 (comint-exec buf (concat "ftp-" host) ftp-program nil |
| 463 (if ftp-program-options | |
| 464 (append (list host) ftp-program-options) | |
| 465 (list host))) | |
|
32197
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
466 (pop-to-buffer buf))) |
| 28210 | 467 |
|
32197
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
468 (define-derived-mode ftp-mode comint-mode "FTP" |
|
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
469 "Major mode for interacting with the ftp program." |
| 28210 | 470 (setq comint-prompt-regexp ftp-prompt-regexp) |
| 471 (setq comint-input-autoexpand t) | |
|
32197
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
472 ;; Only add the password-prompting hook if it's not already in the |
|
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
473 ;; global hook list. This stands a small chance of losing, if it's |
|
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
474 ;; later removed from the global list (very small, since any |
|
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
475 ;; password prompts will probably immediately follow the initial |
|
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
476 ;; connection), but it's better than getting prompted twice for the |
|
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
477 ;; same password. |
|
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
478 (unless (memq 'comint-watch-for-password-prompt |
|
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
479 (default-value 'comint-output-filter-functions)) |
|
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
480 (add-hook 'comint-output-filter-functions 'comint-watch-for-password-prompt |
|
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Jan?k <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
481 nil t))) |
| 28210 | 482 |
| 483 ;; Occasionally useful | |
| 484 (define-key ftp-mode-map "\t" 'comint-dynamic-complete) | |
| 485 | |
| 486 (defun smbclient (host service) | |
| 487 "Connect to SERVICE on HOST via SMB." | |
|
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
488 (interactive |
| 28210 | 489 (list |
|
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
490 (read-from-minibuffer |
| 28210 | 491 "Connect to Host: " (net-utils-machine-at-point)) |
| 492 (read-from-minibuffer "SMB Service: "))) | |
| 493 (require 'comint) | |
| 494 (let* ((name (format "smbclient [%s\\%s]" host service)) | |
| 495 (buf (get-buffer-create (concat "*" name "*"))) | |
| 496 (service-name (concat "\\\\" host "\\" service))) | |
| 497 (set-buffer buf) | |
|
32197
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
498 (smbclient-mode) |
| 28210 | 499 (comint-exec buf name smbclient-program nil |
| 500 (if smbclient-program-options | |
| 501 (append (list service-name) smbclient-program-options) | |
| 502 (list service-name))) | |
|
32197
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
503 (pop-to-buffer buf))) |
| 28210 | 504 |
| 505 (defun smbclient-list-shares (host) | |
| 506 "List services on HOST." | |
|
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
507 (interactive |
| 28210 | 508 (list |
|
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
509 (read-from-minibuffer |
|
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Jan?k <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
510 "Connect to Host: " (net-utils-machine-at-point)))) |
| 28210 | 511 (let ((buf (get-buffer-create (format "*SMB Shares on %s*" host)))) |
| 512 (set-buffer buf) | |
| 513 (smbclient-mode) | |
|
32197
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
514 (comint-exec buf "smbclient-list-shares" |
|
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
515 smbclient-program nil (list "-L" host)) |
|
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
516 (pop-to-buffer buf))) |
| 28210 | 517 |
|
32197
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
518 (define-derived-mode smbclient-mode comint-mode "smbclient" |
|
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
519 "Major mode for interacting with the smbclient program." |
| 28210 | 520 (setq comint-prompt-regexp smbclient-prompt-regexp) |
| 521 (setq comint-input-autoexpand t) | |
|
32197
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
522 ;; Only add the password-prompting hook if it's not already in the |
|
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
523 ;; global hook list. This stands a small chance of losing, if it's |
|
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
524 ;; later removed from the global list (very small, since any |
|
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
525 ;; password prompts will probably immediately follow the initial |
|
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
526 ;; connection), but it's better than getting prompted twice for the |
|
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
527 ;; same password. |
|
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
528 (unless (memq 'comint-watch-for-password-prompt |
|
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
529 (default-value 'comint-output-filter-functions)) |
|
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
530 (add-hook 'comint-output-filter-functions 'comint-watch-for-password-prompt |
|
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Jan?k <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
531 nil t))) |
| 28210 | 532 |
| 533 | |
| 534 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
| 535 ;; Network Connections | |
| 536 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
| 537 | |
| 538 ;; Full list is available at: | |
| 539 ;; ftp://ftp.isi.edu/in-notes/iana/assignments/port-numbers | |
|
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
540 (defvar network-connection-service-alist |
| 28210 | 541 (list |
| 542 (cons 'echo 7) | |
| 543 (cons 'active-users 11) | |
| 544 (cons 'daytime 13) | |
| 545 (cons 'chargen 19) | |
| 546 (cons 'ftp 21) | |
| 547 (cons 'telnet 23) | |
| 548 (cons 'smtp 25) | |
| 549 (cons 'time 37) | |
| 550 (cons 'whois 43) | |
| 551 (cons 'gopher 70) | |
| 552 (cons 'finger 79) | |
| 553 (cons 'www 80) | |
| 554 (cons 'pop2 109) | |
| 555 (cons 'pop3 110) | |
| 556 (cons 'sun-rpc 111) | |
| 557 (cons 'nntp 119) | |
| 558 (cons 'ntp 123) | |
| 559 (cons 'netbios-name 137) | |
| 560 (cons 'netbios-data 139) | |
| 561 (cons 'irc 194) | |
| 562 (cons 'https 443) | |
|
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Jan?k <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
563 (cons 'rlogin 513)) |
| 28210 | 564 "Alist of services and associated TCP port numbers. |
|
41257
0605a90581d4
(network-connection-service-abbrev-alist): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
565 This list is not complete.") |
|
0605a90581d4
(network-connection-service-abbrev-alist): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
566 |
| 28210 | 567 ;; Workhorse macro |
|
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
568 (defmacro run-network-program (process-name host port |
| 28210 | 569 &optional initial-string) |
|
32197
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
570 `(let ((tcp-connection) |
|
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Jan?k <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
571 (buf)) |
| 28210 | 572 (setq buf (get-buffer-create (concat "*" ,process-name "*"))) |
| 573 (set-buffer buf) | |
|
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
574 (or |
| 28210 | 575 (setq tcp-connection |
|
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
576 (open-network-stream |
| 28210 | 577 ,process-name |
| 578 buf | |
| 579 ,host | |
|
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Jan?k <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
580 ,port)) |
| 28210 | 581 (error "Could not open connection to %s" ,host)) |
| 582 (erase-buffer) | |
| 583 (set-marker (process-mark tcp-connection) (point-min)) | |
| 584 (set-process-filter tcp-connection 'net-utils-remove-ctrl-m-filter) | |
| 585 (and ,initial-string | |
|
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
586 (process-send-string tcp-connection |
| 28210 | 587 (concat ,initial-string "\r\n"))) |
| 588 (display-buffer buf))) | |
| 589 | |
| 590 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
| 591 ;; Simple protocols | |
| 592 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
| 593 | |
|
29303
a3541330de52
(finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents:
28419
diff
changeset
|
594 (defcustom finger-X.500-host-regexps nil |
|
a3541330de52
(finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents:
28419
diff
changeset
|
595 "A list of regular expressions matching host names. |
|
a3541330de52
(finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents:
28419
diff
changeset
|
596 If a host name passed to `finger' matches one of these regular |
|
a3541330de52
(finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents:
28419
diff
changeset
|
597 expressions, it is assumed to be a host that doesn't accept |
|
a3541330de52
(finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents:
28419
diff
changeset
|
598 queries of the form USER@HOST, and wants a query containing USER only." |
|
a3541330de52
(finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents:
28419
diff
changeset
|
599 :group 'net-utils |
|
a3541330de52
(finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents:
28419
diff
changeset
|
600 :type '(repeat regexp) |
|
a3541330de52
(finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents:
28419
diff
changeset
|
601 :version "21.1") |
|
a3541330de52
(finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents:
28419
diff
changeset
|
602 |
| 28210 | 603 ;; Finger protocol |
| 604 ;;;###autoload | |
| 605 (defun finger (user host) | |
| 606 "Finger USER on HOST." | |
| 607 ;; One of those great interactive statements that's actually | |
| 608 ;; longer than the function call! The idea is that if the user | |
| 609 ;; uses a string like "pbreton@cs.umb.edu", we won't ask for the | |
| 610 ;; host name. If we don't see an "@", we'll prompt for the host. | |
| 611 (interactive | |
| 612 (let* ((answer (read-from-minibuffer "Finger User: " | |
| 613 (net-utils-url-at-point))) | |
| 614 (index (string-match (regexp-quote "@") answer))) | |
| 615 (if index | |
|
29303
a3541330de52
(finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents:
28419
diff
changeset
|
616 (list (substring answer 0 index) |
|
a3541330de52
(finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents:
28419
diff
changeset
|
617 (substring answer (1+ index))) |
|
a3541330de52
(finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents:
28419
diff
changeset
|
618 (list answer |
|
a3541330de52
(finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents:
28419
diff
changeset
|
619 (read-from-minibuffer "At Host: " |
|
a3541330de52
(finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents:
28419
diff
changeset
|
620 (net-utils-machine-at-point)))))) |
|
a3541330de52
(finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents:
28419
diff
changeset
|
621 (let* ((user-and-host (concat user "@" host)) |
|
a3541330de52
(finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents:
28419
diff
changeset
|
622 (process-name (concat "Finger [" user-and-host "]")) |
|
a3541330de52
(finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents:
28419
diff
changeset
|
623 (regexps finger-X.500-host-regexps) |
|
a3541330de52
(finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents:
28419
diff
changeset
|
624 found) |
|
32197
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
625 (while (and regexps (not (string-match (car regexps) host))) |
|
29303
a3541330de52
(finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents:
28419
diff
changeset
|
626 (setq regexps (cdr regexps))) |
|
a3541330de52
(finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents:
28419
diff
changeset
|
627 (when regexps |
|
a3541330de52
(finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents:
28419
diff
changeset
|
628 (setq user-and-host user)) |
|
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
629 (run-network-program |
|
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
630 process-name |
|
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
631 host |
| 28210 | 632 (cdr (assoc 'finger network-connection-service-alist)) |
|
29303
a3541330de52
(finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents:
28419
diff
changeset
|
633 user-and-host))) |
| 28210 | 634 |
| 635 (defcustom whois-server-name "rs.internic.net" | |
| 636 "Default host name for the whois service." | |
| 637 :group 'net-utils | |
|
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Jan?k <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
638 :type 'string) |
| 28210 | 639 |
| 640 (defcustom whois-server-list | |
| 641 '(("whois.arin.net") ; Networks, ASN's, and related POC's (numbers) | |
| 642 ("rs.internic.net") ; domain related info | |
| 643 ("whois.abuse.net") | |
| 644 ("whois.apnic.net") | |
| 645 ("nic.ddn.mil") | |
| 646 ("whois.nic.mil") | |
| 647 ("whois.nic.gov") | |
| 648 ("whois.ripe.net")) | |
| 649 "A list of whois servers that can be queried." | |
| 650 :group 'net-utils | |
| 651 :type '(repeat (list string))) | |
| 652 | |
| 653 (defcustom whois-server-tld | |
| 654 '(("rs.internic.net" . "com") | |
| 655 ("rs.internic.net" . "org") | |
| 656 ("whois.ripe.net" . "be") | |
| 657 ("whois.ripe.net" . "de") | |
| 658 ("whois.ripe.net" . "dk") | |
| 659 ("whois.ripe.net" . "it") | |
| 660 ("whois.ripe.net" . "fi") | |
| 661 ("whois.ripe.net" . "fr") | |
| 662 ("whois.ripe.net" . "uk") | |
| 663 ("whois.apnic.net" . "au") | |
| 664 ("whois.apnic.net" . "ch") | |
| 665 ("whois.apnic.net" . "hk") | |
| 666 ("whois.apnic.net" . "jp") | |
| 667 ("whois.nic.gov" . "gov") | |
| 668 ("whois.nic.mil" . "mil")) | |
| 669 "Alist to map top level domains to whois servers." | |
| 670 :group 'net-utils | |
| 671 :type '(repeat (cons string string))) | |
| 672 | |
| 673 (defcustom whois-guess-server t | |
| 674 "If non-nil then whois will try to deduce the appropriate whois | |
| 675 server from the query. If the query doesn't look like a domain or hostname | |
| 676 then the server named by whois-server-name is used." | |
| 677 :group 'net-utils | |
| 678 :type 'boolean) | |
| 679 | |
| 680 (defun whois-get-tld (host) | |
| 681 "Return the top level domain of `host', or nil if it isn't a domain name." | |
| 682 (let ((i (1- (length host))) | |
| 683 (max-len (- (length host) 5))) | |
| 684 (while (not (or (= i max-len) (char-equal (aref host i) ?.))) | |
| 685 (setq i (1- i))) | |
| 686 (if (= i max-len) | |
| 687 nil | |
| 688 (substring host (1+ i))))) | |
| 689 | |
| 690 ;; Whois protocol | |
| 691 ;;;###autoload | |
| 692 (defun whois (arg search-string) | |
| 693 "Send SEARCH-STRING to server defined by the `whois-server-name' variable. | |
| 694 If `whois-guess-server' is non-nil, then try to deduce the correct server | |
| 695 from SEARCH-STRING. With argument, prompt for whois server." | |
| 696 (interactive "P\nsWhois: ") | |
| 697 (let* ((whois-apropos-host (if whois-guess-server | |
| 698 (rassoc (whois-get-tld search-string) | |
| 699 whois-server-tld) | |
| 700 nil)) | |
| 701 (server-name (if whois-apropos-host | |
| 702 (car whois-apropos-host) | |
| 703 whois-server-name)) | |
| 704 (host | |
| 705 (if arg | |
| 706 (completing-read "Whois server name: " | |
| 707 whois-server-list nil nil "whois.") | |
| 708 server-name))) | |
|
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
709 (run-network-program |
| 28210 | 710 "Whois" |
| 711 host | |
| 712 (cdr (assoc 'whois network-connection-service-alist)) | |
|
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Jan?k <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
713 search-string))) |
| 28210 | 714 |
| 715 (defcustom whois-reverse-lookup-server "whois.arin.net" | |
| 716 "Server which provides inverse DNS mapping." | |
| 717 :group 'net-utils | |
|
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Jan?k <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
718 :type 'string) |
| 28210 | 719 |
| 720 ;;;###autoload | |
| 721 (defun whois-reverse-lookup () | |
| 722 (interactive) | |
| 723 (let ((whois-server-name whois-reverse-lookup-server)) | |
| 724 (call-interactively 'whois))) | |
| 725 | |
| 726 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
| 727 ;;; General Network connection | |
| 728 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
| 729 | |
|
28419
fed834403704
network-connection-mode is derived from comint-mode
Peter Breton <pbreton@attbi.com>
parents:
28210
diff
changeset
|
730 ;; Using a derived mode gives us keymaps, hooks, etc. |
|
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
731 (define-derived-mode |
|
28419
fed834403704
network-connection-mode is derived from comint-mode
Peter Breton <pbreton@attbi.com>
parents:
28210
diff
changeset
|
732 network-connection-mode comint-mode "Network-Connection" |
|
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Jan?k <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
733 "Major mode for interacting with the network-connection program.") |
|
28419
fed834403704
network-connection-mode is derived from comint-mode
Peter Breton <pbreton@attbi.com>
parents:
28210
diff
changeset
|
734 |
|
fed834403704
network-connection-mode is derived from comint-mode
Peter Breton <pbreton@attbi.com>
parents:
28210
diff
changeset
|
735 (defun network-connection-mode-setup (host service) |
|
42303
c5ddbcd62234
(ftp-mode-abbrev-table): Don't define it.
Richard M. Stallman <rms@gnu.org>
parents:
41257
diff
changeset
|
736 (make-local-variable 'network-connection-host) |
|
c5ddbcd62234
(ftp-mode-abbrev-table): Don't define it.
Richard M. Stallman <rms@gnu.org>
parents:
41257
diff
changeset
|
737 (setq network-connection-host host) |
|
c5ddbcd62234
(ftp-mode-abbrev-table): Don't define it.
Richard M. Stallman <rms@gnu.org>
parents:
41257
diff
changeset
|
738 (make-local-variable 'network-connection-service) |
| 42310 | 739 (setq network-connection-service service)) |
|
28419
fed834403704
network-connection-mode is derived from comint-mode
Peter Breton <pbreton@attbi.com>
parents:
28210
diff
changeset
|
740 |
| 28210 | 741 ;;;###autoload |
| 742 (defun network-connection-to-service (host service) | |
| 743 "Open a network connection to SERVICE on HOST." | |
|
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
744 (interactive |
| 28210 | 745 (list |
| 746 (read-from-minibuffer "Host: " (net-utils-machine-at-point)) | |
|
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
747 (completing-read "Service: " |
|
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
748 (mapcar |
|
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
749 (function |
| 28210 | 750 (lambda (elt) |
| 751 (list (symbol-name (car elt))))) | |
| 752 network-connection-service-alist)))) | |
|
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
753 (network-connection |
|
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
754 host |
|
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Jan?k <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
755 (cdr (assoc (intern service) network-connection-service-alist)))) |
| 28210 | 756 |
| 757 ;;;###autoload | |
| 758 (defun network-connection (host port) | |
| 759 "Open a network connection to HOST on PORT." | |
| 760 (interactive "sHost: \nnPort: ") | |
| 761 (network-service-connection host (number-to-string port))) | |
| 762 | |
| 763 (defun network-service-connection (host service) | |
| 764 "Open a network connection to SERVICE on HOST." | |
| 765 (require 'comint) | |
|
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Jan?k <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
766 (let* ((process-name (concat "Network Connection [" host " " service "]")) |
|
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Jan?k <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
767 (portnum (string-to-number service)) |
|
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Jan?k <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
768 (buf (get-buffer-create (concat "*" process-name "*")))) |
| 28210 | 769 (or (zerop portnum) (setq service portnum)) |
|
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
770 (make-comint |
| 28210 | 771 process-name |
| 772 (cons host service)) | |
|
28419
fed834403704
network-connection-mode is derived from comint-mode
Peter Breton <pbreton@attbi.com>
parents:
28210
diff
changeset
|
773 (set-buffer buf) |
|
fed834403704
network-connection-mode is derived from comint-mode
Peter Breton <pbreton@attbi.com>
parents:
28210
diff
changeset
|
774 (network-connection-mode) |
|
fed834403704
network-connection-mode is derived from comint-mode
Peter Breton <pbreton@attbi.com>
parents:
28210
diff
changeset
|
775 (network-connection-mode-setup host service) |
|
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Jan?k <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
776 (pop-to-buffer buf))) |
| 28210 | 777 |
|
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
778 (defun network-connection-reconnect () |
|
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
779 "Reconnect a network connection, preserving the old input ring." |
|
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
780 (interactive) |
|
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
781 (let ((proc (get-buffer-process (current-buffer))) |
|
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
782 (old-comint-input-ring comint-input-ring) |
|
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
783 (host network-connection-host) |
|
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Jan?k <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
784 (service network-connection-service)) |
|
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
785 (if (not (or (not proc) |
|
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
786 (eq (process-status proc) 'closed))) |
|
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
787 (message "Still connected") |
|
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
788 (goto-char (point-max)) |
|
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
789 (insert (format "Reopening connection to %s\n" host)) |
|
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
790 (network-connection host |
|
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Jan?k <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
791 (if (numberp service) |
|
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Jan?k <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
792 service |
|
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Jan?k <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
793 (cdr (assoc service network-connection-service-alist)))) |
|
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
794 (and old-comint-input-ring |
|
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Jan?k <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
795 (setq comint-input-ring old-comint-input-ring))))) |
|
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
796 |
| 28210 | 797 (provide 'net-utils) |
| 798 | |
| 799 ;;; net-utils.el ends here |
