Mercurial > emacs
comparison lisp/net-utils.el @ 23359:0757f6ee2e53
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.
author | Karl Heuer <kwzh@gnu.org> |
---|---|
date | Thu, 01 Oct 1998 18:51:39 +0000 |
parents | 16780f249ece |
children | 4120f9e06191 |
comparison
equal
deleted
inserted
replaced
23358:3812bb3ae006 | 23359:0757f6ee2e53 |
---|---|
42 ;; but rather in /sbin, /usr/sbin, and so on. | 42 ;; but rather in /sbin, /usr/sbin, and so on. |
43 | 43 |
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 |
52 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 51 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
53 | 52 |
261 | 260 |
262 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 261 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
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)) |
269 (filtered-string output-string)) | 294 (filtered-string output-string)) |
270 (unwind-protect | 295 (unwind-protect |
319 (defun ping (host) | 344 (defun ping (host) |
320 "Ping HOST. | 345 "Ping HOST. |
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)) |
333 (list host)))) | 353 (list host)))) |
334 (net-utils-run-program | 354 (net-utils-run-program |
398 | 418 |
399 ;;;###autoload | 419 ;;;###autoload |
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)) |
410 (list host)))) | 427 (list host)))) |
411 (net-utils-run-program | 428 (net-utils-run-program |
537 ;; One of those great interactive statements that's actually | 554 ;; One of those great interactive statements that's actually |
538 ;; longer than the function call! The idea is that if the user | 555 ;; longer than the function call! The idea is that if the user |
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 |
560 (concat "Finger [" user-and-host "]")) | 572 (concat "Finger [" user-and-host "]")) |
561 ) | 573 ) |
609 ;;;###autoload | 621 ;;;###autoload |
610 (defun network-connection-to-service (host service) | 622 (defun network-connection-to-service (host service) |
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 |
621 (lambda (elt) | 630 (lambda (elt) |
622 (list (symbol-name (car elt))))) | 631 (list (symbol-name (car elt))))) |