diff options
| author | Karl Heuer | 1998-10-01 18:51:39 +0000 |
|---|---|---|
| committer | Karl Heuer | 1998-10-01 18:51:39 +0000 |
| commit | 380c917db0d6fd2e7a5bc46986750bf9c1985453 (patch) | |
| tree | b666f2abbc118b3a6dbdd8fe8e89f2d7d367014b | |
| parent | c01ee596b5946168f30e5c37b7ac368be6e6564c (diff) | |
| download | emacs-380c917db0d6fd2e7a5bc46986750bf9c1985453.tar.gz emacs-380c917db0d6fd2e7a5bc46986750bf9c1985453.zip | |
Don't require ffap.
(net-utils-machine-at-point, net-utils-url-at-point): New functions.
(ping, nslookup-host, finger, network-connection-to-service): Use them.
| -rw-r--r-- | lisp/net-utils.el | 71 |
1 files changed, 40 insertions, 31 deletions
diff --git a/lisp/net-utils.el b/lisp/net-utils.el index db1645cfc53..c4b3e8f8c63 100644 --- a/lisp/net-utils.el +++ b/lisp/net-utils.el | |||
| @@ -44,8 +44,7 @@ | |||
| 44 | 44 | ||
| 45 | ;;; Code: | 45 | ;;; Code: |
| 46 | (eval-when-compile | 46 | (eval-when-compile |
| 47 | (require 'comint) | 47 | (require 'comint)) |
| 48 | (require 'ffap)) | ||
| 49 | 48 | ||
| 50 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 49 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 51 | ;; Customization Variables | 50 | ;; Customization Variables |
| @@ -263,6 +262,32 @@ These options can be used to limit how many ICMP packets are emitted." | |||
| 263 | ;; Utility functions | 262 | ;; Utility functions |
| 264 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 263 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 265 | 264 | ||
| 265 | ;; Simplified versions of some at-point functions from ffap.el. | ||
| 266 | ;; It's not worth loading all of ffap just for these. | ||
| 267 | (defun net-utils-machine-at-point () | ||
| 268 | (let ((pt (point))) | ||
| 269 | (buffer-substring-no-properties | ||
| 270 | (save-excursion | ||
| 271 | (skip-chars-backward "-a-zA-Z0-9.") | ||
| 272 | (point)) | ||
| 273 | (save-excursion | ||
| 274 | (skip-chars-forward "-a-zA-Z0-9.") | ||
| 275 | (skip-chars-backward "." pt) | ||
| 276 | (point))))) | ||
| 277 | |||
| 278 | (defun net-utils-url-at-point () | ||
| 279 | (let ((pt (point))) | ||
| 280 | (buffer-substring-no-properties | ||
| 281 | (save-excursion | ||
| 282 | (skip-chars-backward "--:=&?$+@-Z_a-z~#,%") | ||
| 283 | (skip-chars-forward "^A-Za-z0-9" pt) | ||
| 284 | (point)) | ||
| 285 | (save-excursion | ||
| 286 | (skip-chars-forward "--:=&?$+@-Z_a-z~#,%") | ||
| 287 | (skip-chars-backward ":;.,!?" pt) | ||
| 288 | (point))))) | ||
| 289 | |||
| 290 | |||
| 266 | (defun net-utils-remove-ctrl-m-filter (process output-string) | 291 | (defun net-utils-remove-ctrl-m-filter (process output-string) |
| 267 | "Remove trailing control Ms." | 292 | "Remove trailing control Ms." |
| 268 | (let ((old-buffer (current-buffer)) | 293 | (let ((old-buffer (current-buffer)) |
| @@ -321,12 +346,7 @@ These options can be used to limit how many ICMP packets are emitted." | |||
| 321 | If your system's ping continues until interrupted, you can try setting | 346 | If your system's ping continues until interrupted, you can try setting |
| 322 | `ping-program-options'." | 347 | `ping-program-options'." |
| 323 | (interactive | 348 | (interactive |
| 324 | (list | 349 | (list (read-from-minibuffer "Ping host: " (net-utils-machine-at-point)))) |
| 325 | (progn | ||
| 326 | (require 'ffap) | ||
| 327 | (read-from-minibuffer | ||
| 328 | "Ping host: " | ||
| 329 | (or (ffap-string-at-point 'machine) ""))))) | ||
| 330 | (let ((options | 350 | (let ((options |
| 331 | (if ping-program-options | 351 | (if ping-program-options |
| 332 | (append ping-program-options (list host)) | 352 | (append ping-program-options (list host)) |
| @@ -400,10 +420,7 @@ If your system's ping continues until interrupted, you can try setting | |||
| 400 | (defun nslookup-host (host) | 420 | (defun nslookup-host (host) |
| 401 | "Lookup the DNS information for HOST." | 421 | "Lookup the DNS information for HOST." |
| 402 | (interactive | 422 | (interactive |
| 403 | (list | 423 | (list (read-from-minibuffer "Lookup host: " (net-utils-machine-at-point)))) |
| 404 | (read-from-minibuffer | ||
| 405 | "Lookup host: " | ||
| 406 | (or (ffap-string-at-point 'machine) "")))) | ||
| 407 | (let ((options | 424 | (let ((options |
| 408 | (if nslookup-program-options | 425 | (if nslookup-program-options |
| 409 | (append nslookup-program-options (list host)) | 426 | (append nslookup-program-options (list host)) |
| @@ -539,21 +556,16 @@ This list in not complete.") | |||
| 539 | ;; uses a string like "pbreton@cs.umb.edu", we won't ask for the | 556 | ;; uses a string like "pbreton@cs.umb.edu", we won't ask for the |
| 540 | ;; host name. If we don't see an "@", we'll prompt for the host. | 557 | ;; host name. If we don't see an "@", we'll prompt for the host. |
| 541 | (interactive | 558 | (interactive |
| 542 | (progn | 559 | (let* ((answer (read-from-minibuffer "Finger User: " |
| 543 | (require 'ffap) | 560 | (net-utils-url-at-point))) |
| 544 | (let* ((answer (read-from-minibuffer "Finger User: " | 561 | (index (string-match (regexp-quote "@") answer))) |
| 545 | (ffap-string-at-point 'url))) | 562 | (if index |
| 546 | (index (string-match (regexp-quote "@") answer)) | 563 | (list |
| 547 | ) | 564 | (substring answer 0 index) |
| 548 | (if index | 565 | (substring answer (1+ index))) |
| 549 | (list | 566 | (list |
| 550 | (substring answer 0 index) | 567 | answer |
| 551 | (substring answer (1+ index))) | 568 | (read-from-minibuffer "At Host: " (net-utils-machine-at-point)))))) |
| 552 | (list | ||
| 553 | answer | ||
| 554 | (read-from-minibuffer | ||
| 555 | "At Host: " | ||
| 556 | (or (ffap-string-at-point 'machine) ""))))))) | ||
| 557 | (let* ( | 569 | (let* ( |
| 558 | (user-and-host (concat user "@" host)) | 570 | (user-and-host (concat user "@" host)) |
| 559 | (process-name | 571 | (process-name |
| @@ -611,10 +623,7 @@ With argument, prompt for whois server." | |||
| 611 | "Open a network connection to SERVICE on HOST." | 623 | "Open a network connection to SERVICE on HOST." |
| 612 | (interactive | 624 | (interactive |
| 613 | (list | 625 | (list |
| 614 | (progn | 626 | (read-from-minibuffer "Host: " (net-utils-machine-at-point)) |
| 615 | (require 'ffap) | ||
| 616 | (read-from-minibuffer "Host: " | ||
| 617 | (ffap-string-at-point 'machine))) | ||
| 618 | (completing-read "Service: " | 627 | (completing-read "Service: " |
| 619 | (mapcar | 628 | (mapcar |
| 620 | (function | 629 | (function |