comparison lisp/browse-url.el @ 27196:64fe9058e235

(browse-url): Fix case of browse-url-browser-function being an alist.
author Dave Love <fx@gnu.org>
date Wed, 05 Jan 2000 15:41:44 +0000
parents fb6b9c37cdc4
children f130c453e796
comparison
equal deleted inserted replaced
27195:d7311a9cb223 27196:64fe9058e235
1 ;;; browse-url.el --- Pass a URL to a WWW browser 1 ;;; browse-url.el --- Pass a URL to a WWW browser
2 2
3 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999 Free Software Foundation, Inc. 3 ;; Copyright (C) 1995, 96-99, 2000 Free Software Foundation, Inc.
4 4
5 ;; Author: Denis Howe <dbh@doc.ic.ac.uk> 5 ;; Author: Denis Howe <dbh@doc.ic.ac.uk>
6 ;; Maintainer: Dave Love <fx@gnu.org> 6 ;; Maintainer: Dave Love <fx@gnu.org>
7 ;; Created: 03 Apr 1995 7 ;; Created: 03 Apr 1995
8 ;; Keywords: hypertext, hypermedia, mouse 8 ;; Keywords: hypertext, hypermedia, mouse
83 ;; For more information on Grail see 83 ;; For more information on Grail see
84 ;; <URL:http://grail.cnri.reston.va.us/> and for more information on 84 ;; <URL:http://grail.cnri.reston.va.us/> and for more information on
85 ;; Python see <url:http://www.python.org/>. Grail support in 85 ;; Python see <url:http://www.python.org/>. Grail support in
86 ;; browse-url.el written by Barry Warsaw <bwarsaw@python.org>. 86 ;; browse-url.el written by Barry Warsaw <bwarsaw@python.org>.
87 87
88 ;; MMM is the freely available WWW browser implemented in Objective 88 ;; MMM is a semi-free WWW browser implemented in Objective Caml, an
89 ;; Caml, a cool impure functional programming language, by Francois 89 ;; interesting impure functional programming language. See
90 ;; Rouaix. See the MMM home page
91 ;; <URL:http://pauillac.inria.fr/%7Erouaix/mmm/>. 90 ;; <URL:http://pauillac.inria.fr/%7Erouaix/mmm/>.
92 91
93 ;; Lynx is now distributed by the FSF. See also 92 ;; Lynx is now distributed by the FSF. See also
94 ;; <URL:http://lynx.browser.org/>. 93 ;; <URL:http://lynx.browser.org/>.
95 94
96 ;; Free graphical browsers that could be used by `browse-url-generic' 95 ;; Free graphical browsers that could be used by `browse-url-generic'
97 ;; include Chimera <URL:ftp://ftp.cs.unlv.edu/pub/chimera> and 96 ;; include Chimera <URL:ftp://ftp.cs.unlv.edu/pub/chimera> and
98 ;; <URL:http://www.unlv.edu/chimera/>, Arena 97 ;; <URL:http://www.unlv.edu/chimera/>, Arena
99 ;; <URL:ftp://ftp.yggdrasil.com/pub/dist/web/arena> and Amaya 98 ;; <URL:ftp://ftp.yggdrasil.com/pub/dist/web/arena> and Amaya
100 ;; <URL:ftp://ftp.w3.org/pub/amaya>. mMosaic 99 ;; <URL:ftp://ftp.w3.org/pub/amaya>. mMosaic
101 ;; <URL:ftp://sig.enst.fr/pub/multicast/mMosaic/> (with development 100 ;; <URL:ftp://sig.enst.fr/pub/multicast/mMosaic/>,
101 ;; <URL:http://sig.enst.fr/~dauphin/mMosaic/> (with development
102 ;; support for Java applets and multicast) can be used like Mosaic by 102 ;; support for Java applets and multicast) can be used like Mosaic by
103 ;; setting `browse-url-mosaic-program' appropriately. 103 ;; setting `browse-url-mosaic-program' appropriately.
104 104
105 ;; I [Denis Howe, not Dave Love] recommend Nelson Minar 105 ;; I [Denis Howe, not Dave Love] recommend Nelson Minar
106 ;; <nelson@santafe.edu>'s excellent html-helper-mode.el for editing 106 ;; <nelson@santafe.edu>'s excellent html-helper-mode.el for editing
221 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 221 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
222 ;; Variables 222 ;; Variables
223 223
224 (eval-when-compile (require 'thingatpt) 224 (eval-when-compile (require 'thingatpt)
225 (require 'term) 225 (require 'term)
226 (require 'dired)
226 (require 'w3-auto nil t)) 227 (require 'w3-auto nil t))
227 228
228 (defgroup browse-url nil 229 (defgroup browse-url nil
229 "Use a web browser to look at a URL." 230 "Use a web browser to look at a URL."
230 :prefix "browse-url-" 231 :prefix "browse-url-"
596 (defun browse-url (url &rest args) 597 (defun browse-url (url &rest args)
597 "Ask a WWW browser to load URL. 598 "Ask a WWW browser to load URL.
598 Prompts for a URL, defaulting to the URL at or before point. Variable 599 Prompts for a URL, defaulting to the URL at or before point. Variable
599 `browse-url-browser-function' says which browser to use." 600 `browse-url-browser-function' says which browser to use."
600 (interactive (browse-url-interactive-arg "URL: ")) 601 (interactive (browse-url-interactive-arg "URL: "))
601 (let ((bf browse-url-browser-function) re) 602 (if (functionp browse-url-browser-function)
602 (unless (functionp bf) 603 (apply browse-url-browser-function url args)
603 (while (consp bf) 604 ;; The `function' can be an alist; look down it for first match
604 (setq re (car (car bf)) 605 ;; and apply the function (which might be a lambda).
605 bf (if (string-match re url) 606 (catch 'done
606 (cdr (car bf)) ; The function 607 (mapcar
607 (cdr bf))))) ; More pairs 608 (lambda (bf)
608 (or bf (error "No browser in browse-url-browser-function matching URL %s" 609 (when (string-match (car bf) url)
609 url)) 610 (apply (cdr bf) url args)
610 (apply bf url args))) 611 (throw 'done t)))
612 browse-url-browser-function)
613 (error "No browser in browse-url-browser-function matching URL %s"
614 url))))
611 615
612 ;;;###autoload 616 ;;;###autoload
613 (defun browse-url-at-point () 617 (defun browse-url-at-point ()
614 "Ask a WWW browser to load the URL at or before point. 618 "Ask a WWW browser to load the URL at or before point.
615 Doesn't let you edit the URL like `browse-url'. Variable 619 Doesn't let you edit the URL like `browse-url'. Variable