aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Love2000-08-15 11:17:17 +0000
committerDave Love2000-08-15 11:17:17 +0000
commit3abc9fa14b0cd60f573047f77c540d4cee9e0e20 (patch)
tree47b99596305439f0d2a93d92ed154c49a1a45add
parentdf7c0cb421ea6cd1bd3b7d61130bbd33fbda790c (diff)
downloademacs-3abc9fa14b0cd60f573047f77c540d4cee9e0e20.tar.gz
emacs-3abc9fa14b0cd60f573047f77c540d4cee9e0e20.zip
(browse-url-filename-alist): Add a clause for
Doze and Dog. (browse-url): Use dolist, not mapcar. (browse-url-at-point): Check for null url. (browse-url-event-buffer, browse-url-event-point): Functions deleted. (browse-url-at-mouse, browse-url-netscape): Simplify.
-rw-r--r--lisp/net/browse-url.el85
1 files changed, 38 insertions, 47 deletions
diff --git a/lisp/net/browse-url.el b/lisp/net/browse-url.el
index 4c5696f1499..57a28b5e536 100644
--- a/lisp/net/browse-url.el
+++ b/lisp/net/browse-url.el
@@ -32,19 +32,21 @@
32;; URL associated with the current buffer. Different browsers use 32;; URL associated with the current buffer. Different browsers use
33;; different methods of remote control so there is one function for 33;; different methods of remote control so there is one function for
34;; each supported browser. If the chosen browser is not running, it 34;; each supported browser. If the chosen browser is not running, it
35;; is started. Currently there is support for: 35;; is started. Currently there is support for the following browsers,
36 36;; some of them probably now obsolete:
37;; Function Browser Earliest version 37
38;; browse-url-netscape Netscape 1.1b1 38;; Function Browser Earliest version
39;; browse-url-mosaic XMosaic/mMosaic <= 2.4 39;; browse-url-netscape Netscape 1.1b1
40;; browse-url-cci XMosaic 2.5 40;; browse-url-mosaic XMosaic/mMosaic <= 2.4
41;; browse-url-w3 w3 0 41;; browse-url-cci XMosaic 2.5
42;; browse-url-w3-gnudoit w3 remotely 42;; browse-url-w3 w3 0
43;; browse-url-iximosaic IXI Mosaic ? 43;; browse-url-w3-gnudoit w3 remotely
44;; browse-url-lynx-* Lynx 0 44;; browse-url-iximosaic IXI Mosaic ?
45;; browse-url-grail Grail 0.3b1 45;; browse-url-lynx-* Lynx 0
46;; browse-url-mmm MMM ? 46;; browse-url-grail Grail 0.3b1
47;; browse-url-generic arbitrary 47;; browse-url-mmm MMM ?
48;; browse-url-generic arbitrary
49;; browse-url-default-windows-browser MS-Windows browser
48 50
49;; [A version of the Netscape browser is now free software 51;; [A version of the Netscape browser is now free software
50;; <URL:http://www.mozilla.org/>, albeit not GPLed, so it is 52;; <URL:http://www.mozilla.org/>, albeit not GPLed, so it is
@@ -168,16 +170,13 @@
168;; (lambda () 170;; (lambda ()
169;; (local-set-key "\C-c\C-zf" 'browse-url-of-dired-file))) 171;; (local-set-key "\C-c\C-zf" 'browse-url-of-dired-file)))
170 172
171;; Browse URLs in mail messages by clicking mouse-2: 173;; Browse URLs in mail messages under RMAIL by clicking mouse-2:
172;; (add-hook 'rmail-mode-hook (lambda () ; rmail-mode startup 174;; (add-hook 'rmail-mode-hook (lambda () ; rmail-mode startup
173;; (define-key rmail-mode-map [mouse-2] 'browse-url-at-mouse))) 175;; (define-key rmail-mode-map [mouse-2] 'browse-url-at-mouse)))
176;; Alternatively, add `goto-address' to `rmail-show-message-hook'.
174 177
175;; Browse URLs in Usenet messages by clicking mouse-2: 178;; Gnus provides a standard feature to activate URLs in article
176;; (eval-after-load "gnus" 179;; buffers for invocation of browse-url.
177;; '(define-key gnus-article-mode-map [mouse-2] 'browse-url-at-mouse))
178;; [The current version of Gnus provides a standard feature to
179;; activate URLs in article buffers for invocation of browse-url with
180;; mouse-2.]
181 180
182;; Use the Emacs w3 browser when not running under X11: 181;; Use the Emacs w3 browser when not running under X11:
183;; (or (eq window-system 'x) 182;; (or (eq window-system 'x)
@@ -321,11 +320,13 @@ commands reverses the effect of this variable. Requires Netscape version
321 :group 'browse-url) 320 :group 'browse-url)
322 321
323(defcustom browse-url-filename-alist 322(defcustom browse-url-filename-alist
324 '(("^/\\(ftp@\\|anonymous@\\)?\\([^:]+\\):/*" . "ftp://\\2/") 323 `(("^/\\(ftp@\\|anonymous@\\)?\\([^:]+\\):/*" . "ftp://\\2/")
325 ;; The above loses the username to avoid the browser prompting for 324 ;; The above loses the username to avoid the browser prompting for
326 ;; it in anonymous cases. If it's not anonymous the next regexp 325 ;; it in anonymous cases. If it's not anonymous the next regexp
327 ;; applies. 326 ;; applies.
328 ("^/\\([^:@]+@\\)?\\([^:]+\\):/*" . "ftp://\\1\\2/") 327 ("^/\\([^:@]+@\\)?\\([^:]+\\):/*" . "ftp://\\1\\2/")
328 ,@(if (memq system-type '(windows-nt ms-dos))
329 '("^\\([a-zA-Z]:\\)[\\/]" . "file:\\1/"))
329 ("^/+" . "file:/")) 330 ("^/+" . "file:/"))
330 "An alist of (REGEXP . STRING) pairs used by `browse-url-of-file'. 331 "An alist of (REGEXP . STRING) pairs used by `browse-url-of-file'.
331Any substring of a filename matching one of the REGEXPs is replaced by 332Any substring of a filename matching one of the REGEXPs is replaced by
@@ -610,19 +611,17 @@ Prompts for a URL, defaulting to the URL at or before point. Variable
610`browse-url-browser-function' says which browser to use." 611`browse-url-browser-function' says which browser to use."
611 (interactive (browse-url-interactive-arg "URL: ")) 612 (interactive (browse-url-interactive-arg "URL: "))
612 (unless (interactive-p) 613 (unless (interactive-p)
613 (setq args (list browse-url-new-window-p))) 614 (setq args (or args (list browse-url-new-window-p))))
614 (if (functionp browse-url-browser-function) 615 (if (functionp browse-url-browser-function)
615 (apply browse-url-browser-function url args) 616 (apply browse-url-browser-function url args)
616 ;; The `function' can be an alist; look down it for first match 617 ;; The `function' can be an alist; look down it for first match
617 ;; and apply the function (which might be a lambda). 618 ;; and apply the function (which might be a lambda).
618 (catch 'done 619 (catch 'done
619 (mapcar 620 (dolist (bf browse-url-browser-function)
620 (lambda (bf) 621 (when (string-match (car bf) url)
621 (when (string-match (car bf) url) 622 (apply (cdr bf) url args)
622 (apply (cdr bf) url args) 623 (throw 'done t)))
623 (throw 'done t))) 624 (error "No browse-url-browser-function matching URL %s"
624 browse-url-browser-function)
625 (error "No browser in browse-url-browser-function matching URL %s"
626 url)))) 625 url))))
627 626
628;;;###autoload 627;;;###autoload
@@ -631,16 +630,12 @@ Prompts for a URL, defaulting to the URL at or before point. Variable
631Doesn't let you edit the URL like `browse-url'. Variable 630Doesn't let you edit the URL like `browse-url'. Variable
632`browse-url-browser-function' says which browser to use." 631`browse-url-browser-function' says which browser to use."
633 (interactive "P") 632 (interactive "P")
634 (browse-url (browse-url-url-at-point) 633 (let ((url (browse-url-url-at-point)))
635 (if arg 634 (if url
636 (not browse-url-new-window-p) 635 (browse-url url (if arg
637 browse-url-new-window-p))) 636 (not browse-url-new-window-p)
638 637 browse-url-new-window-p))
639(defun browse-url-event-buffer (event) 638 (error "No URL found"))))
640 (window-buffer (posn-window (event-start event))))
641
642(defun browse-url-event-point (event)
643 (posn-point (event-start event)))
644 639
645;;;###autoload 640;;;###autoload
646(defun browse-url-at-mouse (event) 641(defun browse-url-at-mouse (event)
@@ -651,12 +646,8 @@ but point is not changed. Doesn't let you edit the URL like
651to use." 646to use."
652 (interactive "e") 647 (interactive "e")
653 (save-excursion 648 (save-excursion
654 (set-buffer (browse-url-event-buffer event)) 649 (mouse-set-point event)
655 (goto-char (browse-url-event-point event)) 650 (browse-url-at-point browse-url-new-window-p)))
656 (let ((url (browse-url-url-at-point)))
657 (if (string-equal url "")
658 (error "No URL found"))
659 (browse-url url browse-url-new-window-p))))
660 651
661;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 652;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
662;; Browser-specific commands 653;; Browser-specific commands
@@ -726,8 +717,8 @@ used instead of `browse-url-new-window-p'."
726 ",new-window") 717 ",new-window")
727 ")")))))))) 718 ")"))))))))
728 (set-process-sentinel process 719 (set-process-sentinel process
729 (list 'lambda '(process change) 720 `(lambda (process change)
730 (list 'browse-url-netscape-sentinel 'process url))))) 721 (browse-url-netscape-sentinel process ,url)))))
731 722
732(defun browse-url-netscape-sentinel (process url) 723(defun browse-url-netscape-sentinel (process url)
733 "Handle a change to the process communicating with Netscape." 724 "Handle a change to the process communicating with Netscape."