Commit 380c917d authored by Karl Heuer's avatar Karl Heuer
Browse files

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.
parent c01ee596
...@@ -44,8 +44,7 @@ ...@@ -44,8 +44,7 @@
;;; Code: ;;; Code:
(eval-when-compile (eval-when-compile
(require 'comint) (require 'comint))
(require 'ffap))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Customization Variables ;; Customization Variables
...@@ -263,6 +262,32 @@ These options can be used to limit how many ICMP packets are emitted." ...@@ -263,6 +262,32 @@ These options can be used to limit how many ICMP packets are emitted."
;; Utility functions ;; Utility functions
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Simplified versions of some at-point functions from ffap.el.
;; It's not worth loading all of ffap just for these.
(defun net-utils-machine-at-point ()
(let ((pt (point)))
(buffer-substring-no-properties
(save-excursion
(skip-chars-backward "-a-zA-Z0-9.")
(point))
(save-excursion
(skip-chars-forward "-a-zA-Z0-9.")
(skip-chars-backward "." pt)
(point)))))
(defun net-utils-url-at-point ()
(let ((pt (point)))
(buffer-substring-no-properties
(save-excursion
(skip-chars-backward "--:=&?$+@-Z_a-z~#,%")
(skip-chars-forward "^A-Za-z0-9" pt)
(point))
(save-excursion
(skip-chars-forward "--:=&?$+@-Z_a-z~#,%")
(skip-chars-backward ":;.,!?" pt)
(point)))))
(defun net-utils-remove-ctrl-m-filter (process output-string) (defun net-utils-remove-ctrl-m-filter (process output-string)
"Remove trailing control Ms." "Remove trailing control Ms."
(let ((old-buffer (current-buffer)) (let ((old-buffer (current-buffer))
...@@ -321,12 +346,7 @@ These options can be used to limit how many ICMP packets are emitted." ...@@ -321,12 +346,7 @@ These options can be used to limit how many ICMP packets are emitted."
If your system's ping continues until interrupted, you can try setting If your system's ping continues until interrupted, you can try setting
`ping-program-options'." `ping-program-options'."
(interactive (interactive
(list (list (read-from-minibuffer "Ping host: " (net-utils-machine-at-point))))
(progn
(require 'ffap)
(read-from-minibuffer
"Ping host: "
(or (ffap-string-at-point 'machine) "")))))
(let ((options (let ((options
(if ping-program-options (if ping-program-options
(append ping-program-options (list host)) (append ping-program-options (list host))
...@@ -400,10 +420,7 @@ If your system's ping continues until interrupted, you can try setting ...@@ -400,10 +420,7 @@ If your system's ping continues until interrupted, you can try setting
(defun nslookup-host (host) (defun nslookup-host (host)
"Lookup the DNS information for HOST." "Lookup the DNS information for HOST."
(interactive (interactive
(list (list (read-from-minibuffer "Lookup host: " (net-utils-machine-at-point))))
(read-from-minibuffer
"Lookup host: "
(or (ffap-string-at-point 'machine) ""))))
(let ((options (let ((options
(if nslookup-program-options (if nslookup-program-options
(append nslookup-program-options (list host)) (append nslookup-program-options (list host))
...@@ -539,21 +556,16 @@ This list in not complete.") ...@@ -539,21 +556,16 @@ This list in not complete.")
;; uses a string like "pbreton@cs.umb.edu", we won't ask for the ;; uses a string like "pbreton@cs.umb.edu", we won't ask for the
;; host name. If we don't see an "@", we'll prompt for the host. ;; host name. If we don't see an "@", we'll prompt for the host.
(interactive (interactive
(progn (let* ((answer (read-from-minibuffer "Finger User: "
(require 'ffap) (net-utils-url-at-point)))
(let* ((answer (read-from-minibuffer "Finger User: " (index (string-match (regexp-quote "@") answer)))
(ffap-string-at-point 'url))) (if index
(index (string-match (regexp-quote "@") answer)) (list
) (substring answer 0 index)
(if index (substring answer (1+ index)))
(list (list
(substring answer 0 index) answer
(substring answer (1+ index))) (read-from-minibuffer "At Host: " (net-utils-machine-at-point))))))
(list
answer
(read-from-minibuffer
"At Host: "
(or (ffap-string-at-point 'machine) "")))))))
(let* ( (let* (
(user-and-host (concat user "@" host)) (user-and-host (concat user "@" host))
(process-name (process-name
...@@ -611,10 +623,7 @@ With argument, prompt for whois server." ...@@ -611,10 +623,7 @@ With argument, prompt for whois server."
"Open a network connection to SERVICE on HOST." "Open a network connection to SERVICE on HOST."
(interactive (interactive
(list (list
(progn (read-from-minibuffer "Host: " (net-utils-machine-at-point))
(require 'ffap)
(read-from-minibuffer "Host: "
(ffap-string-at-point 'machine)))
(completing-read "Service: " (completing-read "Service: "
(mapcar (mapcar
(function (function
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment