annotate lisp/utils/browse-url.el @ 12:bcdc7deadc19 r19-15b7

Import from CVS: tag r19-15b7
author cvs
date Mon, 13 Aug 2007 08:48:16 +0200
parents 376386a54a3c
children 131b0175ea99
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; browse-url.el --- ask a WWW browser to load a URL
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;; Copyright 1995 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; Author: Denis Howe <dbh@doc.ic.ac.uk>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;; Maintainer: Denis Howe <dbh@doc.ic.ac.uk>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;; Created: 03 Apr 1995
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;; Version: 0.38 18 Jun 1996
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;; Keywords: hypertext
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;; X-Home page: http://wombat.doc.ic.ac.uk/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11
12
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
12 ;; This file is part of XEmacs.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13
12
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
14 ;; XEmacs is free software; you can redistribute it and/or modify it
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
15 ;; under the terms of the GNU General Public License as published by
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
16 ;; the Free Software Foundation; either version 1, or (at your option)
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
17 ;; any later version.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18
12
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
19 ;; XEmacs is distributed in the hope that it will be useful, but
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;; General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;; You should have received a copy of the GNU General Public License
12
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
25 ;; along with XEmacs; see the file COPYING. If not, write to the Free
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
26 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
bcdc7deadc19 Import from CVS: tag r19-15b7
cvs
parents: 0
diff changeset
27 ;; 02111-1307, USA.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;;; Commentary:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 ;; The latest version of this package should be available from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 ;; <URL:http://wombat.doc.ic.ac.uk/emacs/browse-url.el>.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 ;; This package provides functions which read a URL (Uniform Resource
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 ;; Locator) from the minibuffer, defaulting to the URL around point,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 ;; and ask a World-Wide Web browser to load it. It can also load the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 ;; URL associated with the current buffer. Different browsers use
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 ;; different methods of remote control so there is one function for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 ;; each supported browser. If the chosen browser is not running, it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 ;; is started. Currently there is support for:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 ;; Function Browser Earliest version
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 ;; browse-url-netscape Netscape 1.1b1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 ;; browse-url-mosaic XMosaic <= 2.4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 ;; browse-url-cci XMosaic 2.5
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 ;; browse-url-w3 w3 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 ;; browse-url-iximosaic IXI Mosaic ?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 ;; browse-url-lynx-* Lynx 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 ;; browse-url-grail Grail 0.3b1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 ;; Note that versions of Netscape before 1.1b1 did not have remote
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 ;; control. <URL:http://www.netscape.com/newsref/std/x-remote.html>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 ;; and <URL:http://www.netscape.com/info/APIs/>.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 ;; Netscape can cache Web pages so it may be necessary to tell it to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 ;; reload the current page if it has changed (e.g. if you have edited
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 ;; it). There is currently no perfect automatic solution to this.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 ;; Netscape allows you to specify the id of the window you want to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 ;; control but which window DO you want to control and how do you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 ;; discover its id?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 ;; If using XMosaic before version 2.5, check the definition of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 ;; browse-url-usr1-signal below.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 ;; <URL:http://www.ncsa.uiuc.edu/SDG/Software/XMosaic/remote-control.html>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 ;; XMosaic version 2.5 introduced Common Client Interface allowing you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 ;; to control mosaic through Unix sockets.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 ;; <URL:http://www.ncsa.uiuc.edu/SDG/Software/XMosaic/CCI/cci-spec.html>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 ;; William M. Perry's excellent "w3" WWW browser for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 ;; Emacs <URL:ftp://cs.indiana.edu/pub/elisp/w3/>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 ;; has a function w3-follow-url-at-point, but that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 ;; doesn't let you edit the URL like browse-url.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 ;; I recommend Nelson Minar <nelson@santafe.edu>'s excellent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 ;; html-helper-mode.el for editing HTML and thank Nelson for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 ;; his many useful comments on this code.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 ;; <URL:http://www.santafe.edu/~nelson/hhm-beta/>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 ;; This package generalises function html-previewer-process in Marc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 ;; Andreessen <marca@ncsa.uiuc.edu>'s html-mode (LCD
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 ;; modes/html-mode.el.Z) and provides better versions of the URL
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 ;; functions in Michelangelo Grigni <mic@cs.ucsd.edu>'s ffap.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 ;; (find-file-at-point) <URL:ftp://cs.ucsd.edu:/pub/mic/>. The huge
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 ;; hyperbole package also contains similar functions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 ;; Grail is the freely available WWW browser implemented in Python, a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 ;; cool object-oriented freely available interpreted language. Grail
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 ;; 0.3b1 was the first version to have remote control as distributed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 ;; For more information on Grail see
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 ;; <URL:http://monty.cnri.reston.va.us/> and for more information on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 ;; Python see <url:http://www.python.org/>. Grail support in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 ;; browse-url.el written by Barry Warsaw <bwarsaw@python.org>.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 ;; Help!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 ;; Can you write and test some code for the Macintrash and Windoze
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 ;; Netscape remote control APIs? (See the URL above).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 ;; Do any other browsers have remote control?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 ;; Installation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 ;; Put the following in your ~/.emacs file:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 ;; (autoload 'browse-url-at-point "browse-url"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 ;; "Ask a WWW browser to load the URL at or before point." t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 ;; (autoload 'browse-url-at-mouse "browse-url"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 ;; "Ask a WWW browser to load a URL clicked with the mouse." t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 ;; (autoload 'browse-url-of-buffer "browse-url"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 ;; "Ask a WWW browser to display BUFFER." t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 ;; (autoload 'browse-url-of-file "browse-url"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 ;; "Ask a WWW browser to display FILE." t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 ;; (autoload 'browse-url-of-dired-file "browse-url"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 ;; "In Dired, ask a WWW browser to display the file named on this line." t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 ;; Usage
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 ;; To display the URL at or before point:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 ;; M-x browse-url-at-point RET
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 ;; To display a URL by shift-clicking on it, put this in your ~/.emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 ;; file:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 ;; (global-set-key [S-mouse-1] 'browse-url-at-mouse)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 ;; To display the current buffer in a web browser:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 ;; M-x browse-url-of-buffer RET
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 ;; In Dired, to display the file named on the current line:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 ;; M-x browse-url-of-dired-file RET
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 ;; Customisation (~/.emacs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 ;; To see what variables are available for customization, type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 ;; `M-x set-variable browse-url TAB'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 ;; Bind the browse-url commands to keys with the `C-c C-z' prefix
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 ;; (as used by html-helper-mode):
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 ;; (global-set-key "\C-c\C-z." 'browse-url-at-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 ;; (global-set-key "\C-c\C-zb" 'browse-url-of-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 ;; (global-set-key "\C-c\C-zu" 'browse-url)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 ;; (global-set-key "\C-c\C-zv" 'browse-url-of-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 ;; (add-hook 'dired-mode-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 ;; (function (lambda ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 ;; (local-set-key "\C-c\C-zf" 'browse-url-of-dired-file))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 ;; Browse URLs in mail messages by clicking mouse-2:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 ;; (add-hook 'rmail-mode-hook (function (lambda () ; rmail-mode startup
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 ;; (define-key rmail-mode-map [mouse-2] 'browse-url-at-mouse))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 ;; Browse URLs in Usenet messages by clicking mouse-2:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 ;; (eval-after-load "gnus"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 ;; '(define-key gnus-article-mode-map [mouse-2] 'browse-url-at-mouse))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 ;; Use the Emacs w3 browser when not running under X11:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 ;; (or (eq window-system 'x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 ;; (setq browse-url-browser-function 'browse-url-w3))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 ;; To always save modified buffers before displaying the file in a browser:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 ;; (setq browse-url-save-file t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 ;; To get round the Netscape caching problem, you could EITHER have
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 ;; write-file in html-helper-mode make Netscape reload the document:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 ;; (autoload 'browse-url-netscape-reload "browse-url"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 ;; "Ask a WWW browser to redisplay the current file." t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 ;; (add-hook 'html-helper-mode-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 ;; (function (lambda ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 ;; (add-hook 'local-write-file-hooks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 ;; (function (lambda ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 ;; (let ((local-write-file-hooks))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 ;; (save-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 ;; (browse-url-netscape-reload)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 ;; t)) ; => file written by hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 ;; t)))) ; append to l-w-f-hooks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 ;; OR have browse-url-of-file ask Netscape to load and then reload the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 ;; file:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 ;; (add-hook 'browse-url-of-file-hook 'browse-url-netscape-reload)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 ;; You may also want to customise browse-url-netscape-arguments, e.g.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 ;; (setq browse-url-netscape-arguments '("-install"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 ;; or similarly for mosaic.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 ;;; Change Log:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 ;; 0.00 03 Apr 1995 Denis Howe <dbh@doc.ic.ac.uk>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 ;; Created.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 ;; 0.01 04 Apr 1995
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 ;; All names start with "browse-url-". Added provide.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 ;; 0.02 05 Apr 1995
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 ;; Save file at start of browse-url-of-file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 ;; Use start-process instead of start-process-shell-command.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 ;; 0.03 06 Apr 1995
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 ;; Add browse-url-netscape-reload, browse-url-netscape-send.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 ;; browse-url-of-file save file option.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 ;; 0.04 08 Apr 1995
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 ;; b-u-file-url separate function. Change b-u-filename-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 ;; default.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 ;; 0.05 09 Apr 1995
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 ;; Added b-u-of-file-hook.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 ;; 0.06 11 Apr 1995
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 ;; Improved .emacs suggestions and documentation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 ;; 0.07 13 Apr 1995
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 ;; Added browse-url-interactive-arg optional prompt.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 ;; 0.08 18 Apr 1995
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 ;; Exclude final "." from browse-url-regexp.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 ;; 0.09 21 Apr 1995
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 ;; Added mouse-set-point to browse-url-interactive-arg.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 ;; 0.10 24 Apr 1995
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 ;; Added Mosaic signal sending variations.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 ;; Thanks Brian K Servis <servis@ecn.purdue.edu>.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 ;; Don't use xprop for Netscape.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 ;; 0.11 25 Apr 1995
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 ;; Fix reading of ~/.mosaicpid. Thanks Dag.H.Wanvik@kvatro.no.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 ;; 0.12 27 Apr 1995
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 ;; Interactive prefix arg => URL *after* point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 ;; Thanks Michelangelo Grigni <mic@cs.ucsd.edu>.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 ;; Added IXI Mosaic support.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 ;; Thanks David Karr <dkarr@nmo.gtegsc.com>.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 ;; 0.13 28 Apr 1995
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 ;; Exclude final [,;] from browse-url-regexp.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 ;; 0.14 02 May 1995
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 ;; Provide browser argument variables.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 ;; 0.15 07 May 1995
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 ;; More Netscape options. Thanks Peter Arius
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 ;; <arius@immd2.informatik.uni-erlangen.de>.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 ;; 0.16 17 May 1995
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 ;; Added browse-url-at-mouse.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 ;; Thanks Wayne Mesard <wmesard@sgi.com>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 ;; 0.17 27 Jun 1995
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 ;; Renamed browse-url-at-point to browse-url-url-at-point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 ;; Added browse-url-at-point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 ;; Thanks Jonathan Cano <cano@patch.tandem.com>.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 ;; 0.18 16 Aug 1995
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 ;; Fixed call to browse-url-url-at-point in browse-url-at-point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 ;; Thanks Eric Ding <ericding@San-Jose.ate.slb.com>.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 ;; 0.19 24 Aug 1995
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 ;; Improved documentation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 ;; Thanks Kevin Rodgers <kevin.rodgers@ihs.com>.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 ;; 0.20 31 Aug 1995
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 ;; browse-url-of-buffer to handle file-less buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 ;; browse-url-of-dired-file browses current file in dired.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 ;; Thanks Kevin Rodgers <kevin.rodgers@ihs.com>.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 ;; 0.21 09 Sep 1995
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 ;; XMosaic CCI functions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 ;; Thanks Marc Furrer <Marc.Furrer@di.epfl.ch>.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 ;; 0.22 13 Sep 1995
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 ;; Fixed new-window documentation and added to browse-url-cci.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 ;; Thanks Dilip Sequeira <djs@dcs.ed.ac.uk>.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 ;; 0.23 10 Nov 1995
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 ;; Added b-u-lynx. Thanks Steven L. Baur <steve@miranova.com>.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 ;; 0.24 22 Nov 1995
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 ;; Renamed b-u-netscape command to b-u-netscape-send.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 ;; Added b-u-netscape-command variable.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 ;; 0.25 03 Dec 1995
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 ;; Added event-buffer and event-point for XEmacs compatibility.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 ;; Thanks Eric Engstrom <engstrom@src.honeywell.com>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 ;; 0.26 13 Jan 1996
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 ;; Changed b-u-lynx to b-u-lynx-xterm, added b-u-lynx-emacs to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 ;; run Lynx in an Emacs buffer under terminal-emulator.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 ;; Thanks Jari Aalto <jaalto@tre.tele.nokia.fi>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 ;; 0.27 27 Feb 1996
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 ;; Changed event-buffer and event-point from macros to functions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 ;; Other fixes for byte-compilation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 ;; 0.28 07 Mar 1996
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 ;; browse-url-lynx-emacs uses term.el instead of terminal.el.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 ;; 0.29 13 Mar 1996
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 ;; Added browse-url-CCI-host. Thanks Greg Marr <gregm@WPI.EDU>.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 ;; 0.30 23 Mar 1996
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 ;; Contact/start Netscape in the background.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 ;; Thanks Per Abrahamsen <abraham@dina.kvl.dk>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 ;; 0.31 28 Apr 1996
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 ;; Added browse-url command.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 ;; Added new-window logic to b-u-interactive-arg.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 ;; b-u-file-url checks for EFS path.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 ;; 0.32 02 May 1996
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 ;; Improved b-u-url-at-point matching to supply missing "http://".
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 ;; 0.33 01 Jun 1996
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 ;; Jari Aalto <jaalto@tre.tele.nokia.fi> browse-url-lynx-emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 ;; fix. Thanks Jari.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 ;; 0.34 05 Jun 1996
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 ;; b-u-file-url checks for EFS after alist. Thanks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 ;; Jens-U H Petersen <petersen@kurims.kyoto-u.ac.jp>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 ;; 0.35 11 Jun 1996
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 ;; Grail support. Thanks Barry A. Warsaw
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 ;; <bwarsaw@anthem.cnri.reston.va.us>.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 ;; 0.36 12 Jun 1996
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 ;; Fixed browse-url-looking-at (I hope).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 ;; 0.37 15 Jun 1996
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 ;; b-u-file-url URL-encodes special chars.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 ;; Thanks Martin Schwenke <Martin.Schwenke@cs.anu.edu.au>.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 ;; 0.38 17 Jun 1996
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 ;; b-u-file-url encodes fewer chars. Multi-display support for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 ;; Netscape. Thanks Richard Mlynarik <mly@adoc.xerox.com>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 ;;; Code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 ;; Variables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 (eval-when-compile (require 'dired))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 (defvar browse-url-path-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 "[^]\t\n \"'()<>[^`{}]*[^]\t\n \"'()<>[^`{}.,;]+"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 "A regular expression probably matching the host, path or e-mail
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 part of a URL.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 (defvar browse-url-short-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 (concat "[-A-Za-z0-9.]+" browse-url-path-regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 "A regular expression probably matching a URL without an access scheme.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 Hostname matching is stricter in this case than for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 ``browse-url-regexp''.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 (defvar browse-url-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 "\\(https?://\\|ftp://\\|gopher://\\|telnet://\\|wais://\\|file:/\\|s?news:\\|mailto:\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 browse-url-path-regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 "A regular expression probably matching a complete URL.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 (defvar browse-url-browser-function 'browse-url-w3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 "*Function to display the current buffer in a WWW browser.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 Used by the `browse-url-at-point', `browse-url-at-mouse', and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 `browse-url-of-file' commands.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 (defvar browse-url-netscape-command "netscape"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 "*The name by which to invoke Netscape.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 (defvar browse-url-netscape-arguments nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 "*A list of strings to pass to Netscape as arguments.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 (defvar browse-url-new-window-p nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 "*If non-nil, always open a new browser window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 Passing an interactive argument to \\[browse-url-netscape] or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 \\[browse-url-cci] reverses the effect of this variable. Requires
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 Netscape version 1.1N or later or XMosaic version 2.5 or later.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 (defvar browse-url-mosaic-arguments nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 "*A list of strings to pass to Mosaic as arguments.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 (defvar browse-url-filename-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 '(("^/+" . "file:/"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 "An alist of (REGEXP . STRING) pairs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 Any substring of a filename matching one of the REGEXPs is replaced by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 the corresponding STRING. All pairs are applied in the order given.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 The default value prepends `file:' to any path beginning with `/'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 Used by the `browse-url-of-file' command.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 (defvar browse-url-save-file nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 "If non-nil, save the buffer before displaying its file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 Used by the `browse-url-of-file' command.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 (defvar browse-url-of-file-hook nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 "A hook to be run with run-hook after `browse-url-of-file' has asked
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 a browser to load a file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 Set this to `browse-url-netscape-reload' to force Netscape to load the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 file rather than displaying a cached copy.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 (defvar browse-url-usr1-signal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 (if (and (boundp 'emacs-major-version)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 (or (> emacs-major-version 19) (>= emacs-minor-version 29)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 'SIGUSR1 ; Why did I think this was in lower case before?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 30) ; Check /usr/include/signal.h.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 "The argument to `signal-process' for sending SIGUSR1 to XMosaic.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 Emacs 19.29 accepts 'SIGUSR1, earlier versions require an integer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 which is 30 on SunOS and 16 on HP-UX and Solaris.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 (defvar browse-url-CCI-port 3003
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 "Port to access XMosaic via CCI.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 This can be any number between 1024 and 65535 but must correspond to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 the value set in the browser.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 (defvar browse-url-CCI-host "localhost"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 "*Host to access XMosaic via CCI.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 This should be the host name of the machine running XMosaic with CCI
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 enabled. The port number should be set in `browse-url-CCI-port'.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 (defvar browse-url-temp-file-name nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 (make-variable-buffer-local 'browse-url-temp-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 (defvar browse-url-temp-file-list '())
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 ;; URL input
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 ;; thingatpt.el doesn't work for complex regexps
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 (defun browse-url-url-at-point ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 "Return the URL around or before point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 Search backwards for the start of a URL ending at or after
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 point. If no URL found, return the empty string. The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 access scheme, `http://' will be prepended if absent."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 (cond ((browse-url-looking-at browse-url-regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 (buffer-substring (match-beginning 0) (match-end 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 ;; Access scheme omitted?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 ((browse-url-looking-at browse-url-short-regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 (concat "http://"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 (buffer-substring (match-beginning 0) (match-end 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 (t ""))) ; No match
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 (defun browse-url-looking-at (regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 "Return non-nil if point is in or just after a match for REGEXP.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 Set the match data from the earliest such match in the current line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 ending at or after point."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 (let ((old-point (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 (eol (progn (end-of-line) (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 (hit nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 (or (and (looking-at regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 (>= (match-end 0) old-point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 (while (and (re-search-forward regexp eol t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 (<= (match-beginning 0) old-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 (not (setq hit (>= (match-end 0) old-point)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 hit)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 ;; Having this as a separate function called by the browser-specific
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 ;; functions allows them to be stand-alone commands, making it easier
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 ;; to switch between browsers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 (defun browse-url-interactive-arg (prompt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 "Read a URL from the minibuffer, prompting with PROMPT.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 Default to the URL at or before point. If invoke with a mouse button,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 set point to the position clicked first. Return a list for use in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 `interactive' containing the URL and browse-url-new-window-p or its
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 negation if a prefix argument was given."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 (let ((event (elt (this-command-keys) 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 (and (listp event) (mouse-set-point event)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 (list (read-string prompt (browse-url-url-at-point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 (not (eq (null browse-url-new-window-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 (null current-prefix-arg)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 ;; Browse current buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 (defun browse-url-of-file (&optional file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 "Ask a WWW browser to display FILE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 Display the current buffer's file if FILE is nil or if called
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 interactively. Turn the filename into a URL with function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 browse-url-file-url. Pass the URL to a browser using variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 `browse-url-browser-function' then run `browse-url-of-file-hook'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 (or file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 (setq file (buffer-file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 (error "Current buffer has no file"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 (let ((buf (get-file-buffer file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 (if buf
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 (set-buffer buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 (cond ((not (buffer-modified-p)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 (browse-url-save-file (save-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 (t (message "%s modified since last save" file))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 (funcall browse-url-browser-function (browse-url-file-url file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 (run-hooks 'browse-url-of-file-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 (defun browse-url-file-url (file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 "Return the URL corresponding to FILE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 Use variable `browse-url-filename-alist' to map filenames to URLs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 Convert EFS file names of the form /USER@HOST:PATH to ftp://HOST/PATH."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 ;; URL-encode special chars, do % first
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 (let ((s 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 (while (setq s (string-match "%" file s))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 (setq file (replace-match "%25" t t file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 s (1+ s))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 (while (string-match "[*\"()',=;? ]" file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 (setq enc (format "%%%x" (aref file (match-beginning 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 file (replace-match enc t t file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 (let ((maps browse-url-filename-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 (while maps
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 (let* ((map (car maps))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 (from-re (car map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 (to-string (cdr map)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 (setq maps (cdr maps))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 (and (string-match from-re file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 (setq file (replace-match to-string t t file))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 ;; Check for EFS path
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 (and (string-match "^/\\([^:@]+@\\)?\\([^:]+\\):/*" file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 (setq file (concat "ftp://"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 (substring file (match-beginning 2) (match-end 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 "/" (substring file (match-end 0)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 (defun browse-url-of-buffer (&optional buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 "Ask a WWW browser to display BUFFER.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 Display the current buffer if BUFFER is nil."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 (and buffer (set-buffer buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 (let ((file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 (or buffer-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 (and (boundp 'dired-directory) dired-directory))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 (or file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 (or browse-url-temp-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 (setq browse-url-temp-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 (make-temp-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 (expand-file-name (buffer-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 (or (getenv "TMPDIR") "/tmp")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 browse-url-temp-file-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 (cons browse-url-temp-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 browse-url-temp-file-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 (setq file-name browse-url-temp-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 (write-region (point-min) (point-max) file-name nil 'no-message)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 (browse-url-of-file file-name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 (defun browse-url-delete-temp-file (&optional temp-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 ;; Delete browse-url-temp-file-name from the file system and from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 ;; browse-url-temp-file-list. If optional arg TEMP-FILE-NAME is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 ;; non-nil, delete it instead, but only from the file system --
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 ;; browse-url-temp-file-list is not affected.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 (let ((file-name (or temp-file-name browse-url-temp-file-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 (if (and file-name (file-exists-p file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 (delete-file file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 (if (null temp-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 (setq browse-url-temp-file-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 (delete browse-url-temp-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 browse-url-temp-file-list)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 (defun browse-url-delete-temp-file-list ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 ;; Delete all elements of browse-url-temp-file-list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 (while browse-url-temp-file-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 (browse-url-delete-temp-file (car browse-url-temp-file-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 (setq browse-url-temp-file-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 (cdr browse-url-temp-file-list))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 (add-hook 'kill-buffer-hook 'browse-url-delete-temp-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 (add-hook 'kill-emacs-hook 'browse-url-delete-temp-file-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 (defun browse-url-of-dired-file ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 "In Dired, ask a WWW browser to display the file named on this line."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 (browse-url-of-file (dired-get-filename)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 ;; Browser-independant commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 ;; A generic command to call the current b-u-browser-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 (defun browse-url (&rest args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 "Ask a WWW browser to load URL.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 Prompts for a URL, defaulting to the URL at or before point. Variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 `browse-url-browser-function' says which browser to use."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 (interactive (browse-url-interactive-arg "URL: "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 (apply browse-url-browser-function args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 (defun browse-url-at-point ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 "Ask a WWW browser to load the URL at or before point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 Doesn't let you edit the URL like browse-url. Variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 `browse-url-browser-function' says which browser to use."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 (funcall browse-url-browser-function (browse-url-url-at-point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 ;; Define these if not already defined (XEmacs compatibility)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 (eval-and-compile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 (or (fboundp 'event-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 (defun event-buffer (event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 (window-buffer (posn-window (event-start event))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 (eval-and-compile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 (or (fboundp 'event-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 (defun event-point (event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 (posn-point (event-start event)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 (defun browse-url-at-mouse (event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 "Ask a WWW browser to load a URL clicked with the mouse.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 The URL is the one around or before the position of the mouse click
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 but point is not changed. Doesn't let you edit the URL like
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 browse-url. Variable `browse-url-browser-function' says which browser
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 to use."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 (interactive "e")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 (set-buffer (event-buffer event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 (goto-char (event-point event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 (let ((url (browse-url-url-at-point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 (if (string-equal url "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 (error "No URL found"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 (funcall browse-url-browser-function url))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 ;; Browser-specific commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 ;; --- Netscape ---
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 ;; Put the correct DISPLAY value in the environment for Netscape
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 ;; launched from multi-display Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 (defun browse-url-process-environment ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 (let* ((device (and (fboundp 'selected-device)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 (fboundp 'device-connection)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 (selected-device)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 (display (and device (fboundp 'device-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 (eq (device-type device) 'x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 (not (equal (device-connection device)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 (getenv "DISPLAY"))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 (if display
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 ;; Attempt to run on the correct display
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 (cons (concat "DISPLAY=" (device-connection device))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 process-environment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652 process-environment)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 (defun browse-url-netscape (url &optional new-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 "Ask the Netscape WWW browser to load URL.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659 Default to the URL around or before point. The strings in variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660 `browse-url-netscape-arguments' are also passed to Netscape.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 When called interactively, if variable `browse-url-new-window-p' is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 non-nil, load the document in a new Netscape window, otherwise use a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 random existing one. A non-nil interactive prefix argument reverses
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665 the effect of browse-url-new-window-p.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667 When called non-interactively, optional second argument NEW-WINDOW is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668 used instead of browse-url-new-window-p."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 (interactive (browse-url-interactive-arg "Netscape URL: "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 (let* ((process-environment (browse-url-process-environment))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671 (process (apply 'start-process
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672 (concat "netscape " url) nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673 browse-url-netscape-command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674 (append browse-url-netscape-arguments
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675 (if new-window '("-noraise"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676 (list "-remote"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 (concat "openURL(" url
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 (if new-window ",new-window")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679 ")"))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680 (set-process-sentinel process
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681 (list 'lambda '(process change)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682 (list 'browse-url-netscape-sentinel 'process url)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684 (defun browse-url-netscape-sentinel (process url)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 "Handle a change to the process communicating with Netscape."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686 (or (eq (process-exit-status process) 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687 (let* ((process-environment (browse-url-process-environment)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688 ;; Netscape not running - start it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689 (message "Starting Netscape...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690 (apply 'start-process (concat "netscape" url) nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691 browse-url-netscape-command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692 (append browse-url-netscape-arguments (list url))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694 (defun browse-url-netscape-reload ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695 "Ask Netscape to reload its current document."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697 (browse-url-netscape-send "reload"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699 (defun browse-url-netscape-send (command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700 "Send a remote control command to Netscape."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701 (let* ((process-environment (browse-url-process-environment)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702 (apply 'start-process "netscape" nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703 browse-url-netscape-command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704 (append browse-url-netscape-arguments
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 (list "-remote" command)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707 ;; --- Mosaic ---
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 (defun browse-url-mosaic (url &optional new-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711 ;; new-window ignored
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712 "Ask the XMosaic WWW browser to load URL.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713 Default to the URL around or before point."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714 (interactive (browse-url-interactive-arg "Mosaic URL: "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715 (let ((pidfile (expand-file-name "~/.mosaicpid"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716 pid pidbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
717 (if (file-readable-p pidfile)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
719 (find-file pidfile)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721 (setq pid (read (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722 (kill-buffer nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723 (if (and pid (zerop (signal-process pid 0))) ; Mosaic running
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725 (find-file (format "/tmp/Mosaic.%d" pid))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727 (insert "goto\n" url "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728 (save-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729 (kill-buffer nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730 ;; Send signal SIGUSR to Mosaic
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731 (message "Signalling Mosaic...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732 (signal-process pid browse-url-usr1-signal)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 ;; Or you could try:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734 ;; (call-process "kill" nil 0 nil "-USR1" (int-to-string pid))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735 (message "Signalling Mosaic...done")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737 ;; Mosaic not running - start it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738 (message "Starting Mosaic...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739 (apply 'start-process "xmosaic" nil "xmosaic"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740 (append browse-url-mosaic-arguments (list url)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741 (message "Starting Mosaic...done"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743 ;; --- Grail ---
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745 (defvar browse-url-grail
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746 (concat (or (getenv "GRAILDIR") "~/.grail") "/user/rcgrail.py")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747 "*Location of Grail remote control client script `rcgrail.py'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748 Typically found in $GRAILDIR/rcgrail.py, or ~/.grail/user/rcgrail.py.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751 (defun browse-url-grail (url)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752 "Ask the Grail WWW browser to load URL.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753 Default to the URL around or before point. Runs the program in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754 variable `browse-url-grail'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755 (interactive (browse-url-interactive-arg "Grail URL: "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756 (message "Sending URL to Grail...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758 (set-buffer (get-buffer-create " *Shell Command Output*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760 ;; don't worry about this failing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
761 (call-process browse-url-grail nil 0 nil url)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762 (message "Sending URL to Grail... done")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
764 ;; --- Mosaic using CCI ---
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
765
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766 (defun browse-url-cci (url &optional new-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767 "Ask the XMosaic WWW browser to load URL.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
768 Default to the URL around or before point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
769
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
770 This function only works for XMosaic version 2.5 or later. You must
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
771 select `CCI' from XMosaic's File menu, set the CCI Port Address to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
772 value of variable `browse-url-CCI-port', and enable `Accept requests'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
774 When called interactively, if variable `browse-url-new-window-p' is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775 non-nil, load the document in a new browser window, otherwise use a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776 random existing one. A non-nil interactive prefix argument reverses
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
777 the effect of browse-url-new-window-p.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
778
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779 When called non-interactively, optional second argument NEW-WINDOW is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780 used instead of browse-url-new-window-p."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781 (interactive (browse-url-interactive-arg "Mosaic URL: "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782 (open-network-stream "browse-url" " *browse-url*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783 browse-url-CCI-host browse-url-CCI-port)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784 ;; Todo: start browser if fails
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
785 (process-send-string "browse-url"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
786 (concat "get url (" url ") output "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787 (if new-window "new" "current") "\r\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
788 (process-send-string "browse-url" "disconnect\r\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789 (delete-process "browse-url"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791 ;; --- IXI Mosaic ---
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
792
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
794 (defun browse-url-iximosaic (url &optional new-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795 ;; new-window ignored
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
796 "Ask the IXIMosaic WWW browser to load URL.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
797 Default to the URL around or before point."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798 (interactive (browse-url-interactive-arg "IXI Mosaic URL: "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
799 (start-process "tellw3b" nil "tellw3b"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
800 "-service WWW_BROWSER ixi_showurl " url))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
801
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
802 ;; --- W3 ---
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
803
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
804 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
805 (defun browse-url-w3 (url &optional new-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
806 ;; new-window ignored
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
807 "Ask the w3 WWW browser to load URL.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
808 Default to the URL around or before point."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
809 (interactive (browse-url-interactive-arg "W3 URL: "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
810 (w3-fetch url))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
811
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
812 ;; --- Lynx in an xterm ---
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
813
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
814 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
815 (defun browse-url-lynx-xterm (url &optional new-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
816 ;; new-window ignored
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
817 "Ask the Lynx WWW browser to load URL.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
818 Default to the URL around or before point. A new Lynx process is run
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
819 in an Xterm window."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
820 (interactive (browse-url-interactive-arg "Lynx URL: "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
821 (start-process (concat "lynx" url) nil "xterm" "-e" "lynx" url))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
822
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
823 (eval-when-compile (require 'term))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
824
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
825 ;; --- Lynx in an Emacs "term" window ---
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
826
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
827 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
828 (defun browse-url-lynx-emacs (url &optional new-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
829 ;; new-window ignored
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
830 "Ask the Lynx WWW browser to load URL.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
831 Default to the URL around or before point. Run a new Lynx process in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
832 an Emacs buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
833 (interactive (browse-url-interactive-arg "Lynx URL: "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
834 (let ((system-uses-terminfo t)) ; Lynx uses terminfo
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
835 (if (fboundp 'make-term)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
836 (let ((term-term-name "vt100"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
837 (set-buffer (make-term "browse-url" "lynx" nil url))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
838 (term-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
839 (term-char-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
840 (switch-to-buffer "*browse-url*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
841 (terminal-emulator "*browse-url*" "lynx" (list url)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
842
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
843 (provide 'browse-url)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
844
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
845 ;;; browse-url.el ends here