Mercurial > emacs
annotate lisp/net/browse-url.el @ 41295:21cf5cfce29a
(describe_syntax): Add dummy arg.
(describe_syntax_1): Update call to describe_vector.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Mon, 19 Nov 2001 22:46:47 +0000 |
parents | c5d2c3683efb |
children | cdee72f7332b |
rev | line source |
---|---|
38436
b174db545cfd
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
38271
diff
changeset
|
1 ;;; browse-url.el --- pass a URL to a WWW browser |
28210 | 2 |
37378
c5e0aa9cbe69
(browse-url-new-window-flag): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35008
diff
changeset
|
3 ;; Copyright (C) 1995, 96, 97, 98, 99, 2000, 2001 |
c5e0aa9cbe69
(browse-url-new-window-flag): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35008
diff
changeset
|
4 ;; Free Software Foundation, Inc. |
28210 | 5 |
6 ;; Author: Denis Howe <dbh@doc.ic.ac.uk> | |
41282
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
7 ;; Maintainer: FSF |
28210 | 8 ;; Created: 03 Apr 1995 |
9 ;; Keywords: hypertext, hypermedia, mouse | |
10 | |
11 ;; This file is part of GNU Emacs. | |
12 | |
13 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
14 ;; it under the terms of the GNU General Public License as published by | |
15 ;; the Free Software Foundation; either version 2, or (at your option) | |
16 ;; any later version. | |
17 | |
18 ;; GNU Emacs is distributed in the hope that it will be useful, | |
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
21 ;; GNU General Public License for more details. | |
22 | |
23 ;; You should have received a copy of the GNU General Public License | |
24 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
25 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
26 ;; Boston, MA 02111-1307, USA. | |
27 | |
28 ;;; Commentary: | |
29 | |
30 ;; This package provides functions which read a URL (Uniform Resource | |
31 ;; Locator) from the minibuffer, defaulting to the URL around point, | |
32 ;; and ask a World-Wide Web browser to load it. It can also load the | |
33 ;; URL associated with the current buffer. Different browsers use | |
34 ;; different methods of remote control so there is one function for | |
35 ;; each supported browser. If the chosen browser is not running, it | |
30798
8884b93379ef
(browse-url-filename-alist): Add a clause for
Dave Love <fx@gnu.org>
parents:
28330
diff
changeset
|
36 ;; is started. Currently there is support for the following browsers, |
8884b93379ef
(browse-url-filename-alist): Add a clause for
Dave Love <fx@gnu.org>
parents:
28330
diff
changeset
|
37 ;; some of them probably now obsolete: |
28210 | 38 |
30798
8884b93379ef
(browse-url-filename-alist): Add a clause for
Dave Love <fx@gnu.org>
parents:
28330
diff
changeset
|
39 ;; Function Browser Earliest version |
41282
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
40 ;; browse-url-mozilla Mozilla Don't know |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
41 ;; browse-url-galeon Galeon Don't know |
30798
8884b93379ef
(browse-url-filename-alist): Add a clause for
Dave Love <fx@gnu.org>
parents:
28330
diff
changeset
|
42 ;; browse-url-netscape Netscape 1.1b1 |
8884b93379ef
(browse-url-filename-alist): Add a clause for
Dave Love <fx@gnu.org>
parents:
28330
diff
changeset
|
43 ;; browse-url-mosaic XMosaic/mMosaic <= 2.4 |
8884b93379ef
(browse-url-filename-alist): Add a clause for
Dave Love <fx@gnu.org>
parents:
28330
diff
changeset
|
44 ;; browse-url-cci XMosaic 2.5 |
8884b93379ef
(browse-url-filename-alist): Add a clause for
Dave Love <fx@gnu.org>
parents:
28330
diff
changeset
|
45 ;; browse-url-w3 w3 0 |
8884b93379ef
(browse-url-filename-alist): Add a clause for
Dave Love <fx@gnu.org>
parents:
28330
diff
changeset
|
46 ;; browse-url-w3-gnudoit w3 remotely |
8884b93379ef
(browse-url-filename-alist): Add a clause for
Dave Love <fx@gnu.org>
parents:
28330
diff
changeset
|
47 ;; browse-url-iximosaic IXI Mosaic ? |
8884b93379ef
(browse-url-filename-alist): Add a clause for
Dave Love <fx@gnu.org>
parents:
28330
diff
changeset
|
48 ;; browse-url-lynx-* Lynx 0 |
8884b93379ef
(browse-url-filename-alist): Add a clause for
Dave Love <fx@gnu.org>
parents:
28330
diff
changeset
|
49 ;; browse-url-grail Grail 0.3b1 |
8884b93379ef
(browse-url-filename-alist): Add a clause for
Dave Love <fx@gnu.org>
parents:
28330
diff
changeset
|
50 ;; browse-url-mmm MMM ? |
8884b93379ef
(browse-url-filename-alist): Add a clause for
Dave Love <fx@gnu.org>
parents:
28330
diff
changeset
|
51 ;; browse-url-generic arbitrary |
8884b93379ef
(browse-url-filename-alist): Add a clause for
Dave Love <fx@gnu.org>
parents:
28330
diff
changeset
|
52 ;; browse-url-default-windows-browser MS-Windows browser |
32246
851690316add
(browse-url-browser-function): Use it.
Dave Love <fx@gnu.org>
parents:
32245
diff
changeset
|
53 ;; browse-url-gnome-moz GNOME interface to Mozilla |
37803
ae3f8f955b05
(browse-url-browser-function): Add kde.
Gerd Moellmann <gerd@gnu.org>
parents:
37666
diff
changeset
|
54 ;; browse-url-kde KDE konqueror (kfm) |
28210 | 55 |
56 ;; [A version of the Netscape browser is now free software | |
57 ;; <URL:http://www.mozilla.org/>, albeit not GPLed, so it is | |
58 ;; reasonable to have that as the default.] | |
59 | |
60 ;; Note that versions of Netscape before 1.1b1 did not have remote | |
61 ;; control. <URL:http://www.netscape.com/newsref/std/x-remote.html>. | |
62 | |
63 ;; Browsers can cache Web pages so it may be necessary to tell them to | |
64 ;; reload the current page if it has changed (e.g. if you have edited | |
65 ;; it). There is currently no perfect automatic solution to this. | |
66 | |
67 ;; Netscape allows you to specify the id of the window you want to | |
68 ;; control but which window DO you want to control and how do you | |
69 ;; discover its id? | |
70 | |
71 ;; William M. Perry's excellent "w3" WWW browser for | |
72 ;; Emacs <URL:ftp://cs.indiana.edu/pub/elisp/w3/> | |
73 ;; has a function w3-follow-url-at-point, but that | |
74 ;; doesn't let you edit the URL like browse-url. | |
75 ;; The `gnuserv' package that can be used to control it in another | |
76 ;; Emacs process is available from | |
77 ;; <URL:ftp://ftp.splode.com/pub/users/friedman/packages/>. | |
78 | |
79 ;; Grail is the freely available WWW browser implemented in Python, a | |
80 ;; cool object-oriented freely available interpreted language. Grail | |
81 ;; 0.3b1 was the first version to have remote control as distributed. | |
82 ;; For more information on Grail see | |
83 ;; <URL:http://grail.cnri.reston.va.us/> and for more information on | |
84 ;; Python see <url:http://www.python.org/>. Grail support in | |
85 ;; browse-url.el written by Barry Warsaw <bwarsaw@python.org>. | |
86 | |
87 ;; Lynx is now distributed by the FSF. See also | |
88 ;; <URL:http://lynx.browser.org/>. | |
89 | |
90 ;; Free graphical browsers that could be used by `browse-url-generic' | |
91 ;; include Chimera <URL:ftp://ftp.cs.unlv.edu/pub/chimera> and | |
92 ;; <URL:http://www.unlv.edu/chimera/>, Arena | |
93 ;; <URL:ftp://ftp.yggdrasil.com/pub/dist/web/arena> and Amaya | |
94 ;; <URL:ftp://ftp.w3.org/pub/amaya>. mMosaic | |
95 ;; <URL:ftp://sig.enst.fr/pub/multicast/mMosaic/>, | |
96 ;; <URL:http://sig.enst.fr/~dauphin/mMosaic/> (with development | |
97 ;; support for Java applets and multicast) can be used like Mosaic by | |
98 ;; setting `browse-url-mosaic-program' appropriately. | |
99 | |
100 ;; I [Denis Howe, not Dave Love] recommend Nelson Minar | |
101 ;; <nelson@santafe.edu>'s excellent html-helper-mode.el for editing | |
102 ;; HTML and thank Nelson for his many useful comments on this code. | |
103 ;; <URL:http://www.santafe.edu/%7Enelson/hhm-beta/> | |
104 | |
105 ;; See also hm--html-menus <URL:http://www.tnt.uni-hannover.de/%7Emuenkel/ | |
106 ;; software/own/hm--html-menus/>. For composing correct HTML see also | |
107 ;; PSGML the general SGML structure editor package | |
108 ;; <URL:ftp://ftp.lysator.liu.se/pub/sgml>; hm--html-menus can be used | |
109 ;; with this. | |
110 | |
111 ;; This package generalises function html-previewer-process in Marc | |
112 ;; Andreessen's html-mode (LCD modes/html-mode.el.Z). See also the | |
113 ;; ffap.el package. The huge hyperbole package also contains similar | |
114 ;; functions. | |
115 | |
116 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
117 ;; Help! | |
118 | |
119 ;; Can you write and test some code for the Macintrash and Windoze | |
120 ;; Netscape remote control APIs? (See the URL above). | |
121 | |
122 ;; Do any other browsers have remote control? | |
123 | |
124 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
125 ;; Usage | |
126 | |
127 ;; To display the URL at or before point: | |
128 ;; M-x browse-url-at-point RET | |
129 ;; or, similarly but with the opportunity to edit the URL extracted from | |
130 ;; the buffer, use: | |
131 ;; M-x browse-url | |
132 | |
133 ;; To display a URL by shift-clicking on it, put this in your ~/.emacs | |
134 ;; file: | |
135 ;; (global-set-key [S-mouse-2] 'browse-url-at-mouse) | |
136 ;; (Note that using Shift-mouse-1 is not desirable because | |
137 ;; that event has a standard meaning in Emacs.) | |
138 | |
139 ;; To display the current buffer in a web browser: | |
140 ;; M-x browse-url-of-buffer RET | |
141 | |
142 ;; To display the current region in a web browser: | |
143 ;; M-x browse-url-of-region RET | |
144 | |
145 ;; In Dired, to display the file named on the current line: | |
146 ;; M-x browse-url-of-dired-file RET | |
147 | |
148 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
149 ;; Customisation (~/.emacs) | |
150 | |
151 ;; To see what variables are available for customization, type | |
152 ;; `M-x set-variable browse-url TAB'. Better, use | |
153 ;; `M-x customize-group browse-url'. | |
154 | |
155 ;; Bind the browse-url commands to keys with the `C-c C-z' prefix | |
156 ;; (as used by html-helper-mode): | |
157 ;; (global-set-key "\C-c\C-z." 'browse-url-at-point) | |
158 ;; (global-set-key "\C-c\C-zb" 'browse-url-of-buffer) | |
159 ;; (global-set-key "\C-c\C-zr" 'browse-url-of-region) | |
160 ;; (global-set-key "\C-c\C-zu" 'browse-url) | |
161 ;; (global-set-key "\C-c\C-zv" 'browse-url-of-file) | |
162 ;; (add-hook 'dired-mode-hook | |
163 ;; (lambda () | |
164 ;; (local-set-key "\C-c\C-zf" 'browse-url-of-dired-file))) | |
165 | |
30798
8884b93379ef
(browse-url-filename-alist): Add a clause for
Dave Love <fx@gnu.org>
parents:
28330
diff
changeset
|
166 ;; Browse URLs in mail messages under RMAIL by clicking mouse-2: |
28210 | 167 ;; (add-hook 'rmail-mode-hook (lambda () ; rmail-mode startup |
168 ;; (define-key rmail-mode-map [mouse-2] 'browse-url-at-mouse))) | |
30798
8884b93379ef
(browse-url-filename-alist): Add a clause for
Dave Love <fx@gnu.org>
parents:
28330
diff
changeset
|
169 ;; Alternatively, add `goto-address' to `rmail-show-message-hook'. |
28210 | 170 |
30798
8884b93379ef
(browse-url-filename-alist): Add a clause for
Dave Love <fx@gnu.org>
parents:
28330
diff
changeset
|
171 ;; Gnus provides a standard feature to activate URLs in article |
8884b93379ef
(browse-url-filename-alist): Add a clause for
Dave Love <fx@gnu.org>
parents:
28330
diff
changeset
|
172 ;; buffers for invocation of browse-url. |
28210 | 173 |
174 ;; Use the Emacs w3 browser when not running under X11: | |
175 ;; (or (eq window-system 'x) | |
176 ;; (setq browse-url-browser-function 'browse-url-w3)) | |
177 | |
178 ;; To always save modified buffers before displaying the file in a browser: | |
179 ;; (setq browse-url-save-file t) | |
180 | |
181 ;; To get round the Netscape caching problem, you could EITHER have | |
182 ;; write-file in html-helper-mode make Netscape reload the document: | |
183 ;; | |
184 ;; (autoload 'browse-url-netscape-reload "browse-url" | |
185 ;; "Ask a WWW browser to redisplay the current file." t) | |
186 ;; (add-hook 'html-helper-mode-hook | |
187 ;; (lambda () | |
188 ;; (add-hook 'local-write-file-hooks | |
189 ;; (lambda () | |
190 ;; (let ((local-write-file-hooks)) | |
191 ;; (save-buffer)) | |
192 ;; (browse-url-netscape-reload) | |
193 ;; t) ; => file written by hook | |
194 ;; t))) ; append to l-w-f-hooks | |
195 ;; | |
196 ;; OR have browse-url-of-file ask Netscape to load and then reload the | |
197 ;; file: | |
198 ;; | |
199 ;; (add-hook 'browse-url-of-file-hook 'browse-url-netscape-reload) | |
200 | |
201 ;; You may also want to customise browse-url-netscape-arguments, e.g. | |
202 ;; (setq browse-url-netscape-arguments '("-install")) | |
203 ;; | |
204 ;; or similarly for the other browsers. | |
205 | |
206 ;; To invoke different browsers for different URLs: | |
207 ;; (setq browse-url-browser-function '(("^mailto:" . browse-url-mail) | |
208 ;; ("." . browse-url-netscape))) | |
209 | |
210 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
211 ;;; Code: | |
212 | |
213 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
214 ;; Variables | |
215 | |
216 (eval-when-compile (require 'thingatpt) | |
217 (require 'term) | |
218 (require 'dired) | |
41282
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
219 (require 'executable) |
28210 | 220 (require 'w3-auto nil t)) |
221 | |
222 (defgroup browse-url nil | |
223 "Use a web browser to look at a URL." | |
224 :prefix "browse-url-" | |
28330 | 225 :link '(emacs-commentary-link "browse-url") |
28210 | 226 :group 'hypermedia) |
227 | |
228 ;;;###autoload | |
229 (defcustom browse-url-browser-function | |
38271
bb01ee99b910
(browse-url-default-windows-browser): Support
Eli Zaretskii <eliz@gnu.org>
parents:
37803
diff
changeset
|
230 (if (memq system-type '(windows-nt ms-dos)) |
28210 | 231 'browse-url-default-windows-browser |
41282
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
232 'browse-url-default-browser) |
28210 | 233 "*Function to display the current buffer in a WWW browser. |
234 This is used by the `browse-url-at-point', `browse-url-at-mouse', and | |
235 `browse-url-of-file' commands. | |
236 | |
237 If the value is not a function it should be a list of pairs | |
28330 | 238 \(REGEXP . FUNCTION). In this case the function called will be the one |
28210 | 239 associated with the first REGEXP which matches the current URL. The |
240 function is passed the URL and any other args of `browse-url'. The last | |
241 regexp should probably be \".\" to specify a default browser." | |
242 :type '(choice | |
28330 | 243 (function-item :tag "Emacs W3" :value browse-url-w3) |
244 (function-item :tag "W3 in another Emacs via `gnudoit'" | |
245 :value browse-url-w3-gnudoit) | |
41282
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
246 (function-item :tag "Mozilla" :value browse-url-mozilla) |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
247 (function-item :tag "Galeon" :value browse-url-galeon) |
28330 | 248 (function-item :tag "Netscape" :value browse-url-netscape) |
249 (function-item :tag "Mosaic" :value browse-url-mosaic) | |
250 (function-item :tag "Mosaic using CCI" :value browse-url-cci) | |
251 (function-item :tag "IXI Mosaic" :value browse-url-iximosaic) | |
252 (function-item :tag "Lynx in an xterm window" | |
253 :value browse-url-lynx-xterm) | |
254 (function-item :tag "Lynx in an Emacs window" | |
255 :value browse-url-lynx-emacs) | |
256 (function-item :tag "Grail" :value browse-url-grail) | |
257 (function-item :tag "MMM" :value browse-url-mmm) | |
37803
ae3f8f955b05
(browse-url-browser-function): Add kde.
Gerd Moellmann <gerd@gnu.org>
parents:
37666
diff
changeset
|
258 (function-item :tag "KDE" :value browse-url-kde) |
28330 | 259 (function-item :tag "Specified by `Browse Url Generic Program'" |
260 :value browse-url-generic) | |
261 (function-item :tag "Default Windows browser" | |
32246
851690316add
(browse-url-browser-function): Use it.
Dave Love <fx@gnu.org>
parents:
32245
diff
changeset
|
262 :value browse-url-default-windows-browser) |
851690316add
(browse-url-browser-function): Use it.
Dave Love <fx@gnu.org>
parents:
32245
diff
changeset
|
263 (function-item :tag "GNOME invoking Mozilla" |
851690316add
(browse-url-browser-function): Use it.
Dave Love <fx@gnu.org>
parents:
32245
diff
changeset
|
264 :value browse-url-gnome-moz) |
41282
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
265 (function-item :tag "Default browser" |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
266 :value browse-url-default-browser) |
28330 | 267 (function :tag "Your own function") |
268 (alist :tag "Regexp/function association list" | |
269 :key-type regexp :value-type function)) | |
33417
ea170167e034
(browse-url-browser-function): Update
Dave Love <fx@gnu.org>
parents:
32246
diff
changeset
|
270 :version "21.1" |
28210 | 271 :group 'browse-url) |
272 | |
273 (defcustom browse-url-netscape-program "netscape" | |
274 ;; Info about netscape-remote from Karl Berry. | |
275 "The name by which to invoke Netscape. | |
276 | |
277 The free program `netscape-remote' from | |
278 <URL:http://home.netscape.com/newsref/std/remote.c> is said to start | |
279 up very much quicker than `netscape'. Reported to compile on a GNU | |
280 system, given vroot.h from the same directory, with cc flags | |
281 -DSTANDALONE -L/usr/X11R6/lib -lXmu -lX11." | |
282 :type 'string | |
283 :group 'browse-url) | |
284 | |
285 (defcustom browse-url-netscape-arguments nil | |
286 "A list of strings to pass to Netscape as arguments." | |
287 :type '(repeat (string :tag "Argument")) | |
288 :group 'browse-url) | |
289 | |
290 (defcustom browse-url-netscape-startup-arguments browse-url-netscape-arguments | |
291 "A list of strings to pass to Netscape when it starts up. | |
292 Defaults to the value of `browse-url-netscape-arguments' at the time | |
293 `browse-url' is loaded." | |
294 :type '(repeat (string :tag "Argument")) | |
295 :group 'browse-url) | |
296 | |
297 ;;;###autoload | |
41282
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
298 (defcustom browse-url-browser-display nil |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
299 "*The X display for running the browser, if not same as Emacs'." |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
300 :type '(choice string (const :tag "Default" nil)) |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
301 :group 'browse-url) |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
302 |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
303 (defcustom browse-url-mozilla-program "mozilla" |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
304 "The name by which to invoke Mozilla." |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
305 :type 'string |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
306 :group 'browse-url) |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
307 |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
308 (defcustom browse-url-mozilla-arguments nil |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
309 "A list of strings to pass to Mozilla as arguments." |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
310 :type '(repeat (string :tag "Argument")) |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
311 :group 'browse-url) |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
312 |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
313 (defcustom browse-url-mozilla-startup-arguments browse-url-mozilla-arguments |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
314 "A list of strings to pass to Mozilla when it starts up. |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
315 Defaults to the value of `browse-url-mozilla-arguments' at the time |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
316 `browse-url' is loaded." |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
317 :type '(repeat (string :tag "Argument")) |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
318 :group 'browse-url) |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
319 |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
320 ;;;###autoload |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
321 (defcustom browse-url-galeon-program "galeon" |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
322 "The name by which to invoke Galeon." |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
323 :type 'string |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
324 :group 'browse-url) |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
325 |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
326 (defcustom browse-url-galeon-arguments nil |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
327 "A list of strings to pass to Galeon as arguments." |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
328 :type '(repeat (string :tag "Argument")) |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
329 :group 'browse-url) |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
330 |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
331 (defcustom browse-url-galeon-startup-arguments browse-url-galeon-arguments |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
332 "A list of strings to pass to Galeon when it starts up. |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
333 Defaults to the value of `browse-url-galeon-arguments' at the time |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
334 `browse-url' is loaded." |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
335 :type '(repeat (string :tag "Argument")) |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
336 :group 'browse-url) |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
337 |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
338 ;;;###autoload |
37378
c5e0aa9cbe69
(browse-url-new-window-flag): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35008
diff
changeset
|
339 (defcustom browse-url-new-window-flag nil |
28210 | 340 "*If non-nil, always open a new browser window with appropriate browsers. |
341 Passing an interactive argument to \\[browse-url], or specific browser | |
342 commands reverses the effect of this variable. Requires Netscape version | |
343 1.1N or later or XMosaic version 2.5 or later if using those browsers." | |
344 :type 'boolean | |
345 :group 'browse-url) | |
346 | |
347 (defcustom browse-url-mosaic-program "xmosaic" | |
348 "The name by which to invoke Mosaic (or mMosaic)." | |
349 :type 'string | |
350 :version "20.3" | |
351 :group 'browse-url) | |
352 | |
353 (defcustom browse-url-mosaic-arguments nil | |
354 "A list of strings to pass to Mosaic as arguments." | |
355 :type '(repeat (string :tag "Argument")) | |
356 :group 'browse-url) | |
357 | |
358 (defcustom browse-url-filename-alist | |
35008
392d90bba860
(browse-url-filename-alist): Avoid backquote
Dave Love <fx@gnu.org>
parents:
33417
diff
changeset
|
359 (\` ; Backquote syntax won't work. |
392d90bba860
(browse-url-filename-alist): Avoid backquote
Dave Love <fx@gnu.org>
parents:
33417
diff
changeset
|
360 (("^/\\(ftp@\\|anonymous@\\)?\\([^:]+\\):/*" . "ftp://\\2/") |
28210 | 361 ;; The above loses the username to avoid the browser prompting for |
362 ;; it in anonymous cases. If it's not anonymous the next regexp | |
363 ;; applies. | |
364 ("^/\\([^:@]+@\\)?\\([^:]+\\):/*" . "ftp://\\1\\2/") | |
35008
392d90bba860
(browse-url-filename-alist): Avoid backquote
Dave Love <fx@gnu.org>
parents:
33417
diff
changeset
|
365 (,@ (if (memq system-type '(windows-nt ms-dos)) |
37666
16a7e84d5ff3
(browse-url-filename-alist): Allow UNC file
Gerd Moellmann <gerd@gnu.org>
parents:
37378
diff
changeset
|
366 '(("^\\([a-zA-Z]:\\)[\\/]" . "file:\\1/") |
16a7e84d5ff3
(browse-url-filename-alist): Allow UNC file
Gerd Moellmann <gerd@gnu.org>
parents:
37378
diff
changeset
|
367 ("^[\\/][\\/]+" . "file://")))) |
35008
392d90bba860
(browse-url-filename-alist): Avoid backquote
Dave Love <fx@gnu.org>
parents:
33417
diff
changeset
|
368 ("^/+" . "file:/"))) |
28210 | 369 "An alist of (REGEXP . STRING) pairs used by `browse-url-of-file'. |
370 Any substring of a filename matching one of the REGEXPs is replaced by | |
371 the corresponding STRING using `replace-match', not treating STRING | |
372 literally. All pairs are applied in the order given. The default | |
373 value converts ange-ftp/EFS-style paths into ftp URLs and prepends | |
374 `file:' to any path beginning with `/'. | |
375 | |
376 For example, adding to the default a specific translation of an ange-ftp | |
377 address to an HTTP URL: | |
378 | |
379 (setq browse-url-filename-alist | |
380 '((\"/webmaster@webserver:/home/www/html/\" . | |
381 \"http://www.acme.co.uk/\") | |
382 (\"^/\\(ftp@\\|anonymous@\\)?\\([^:]+\\):/*\" . \"ftp://\\2/\") | |
383 (\"^/\\([^:@]+@\\)?\\([^:]+\\):/*\" . \"ftp://\\1\\2/\") | |
384 (\"^/+\" . \"file:/\"))) | |
385 " | |
386 :type '(repeat (cons :format "%v" | |
387 (regexp :tag "Regexp") | |
388 (string :tag "Replacement"))) | |
389 :version "20.3" | |
390 :group 'browse-url) | |
391 | |
392 ;;;###autoload | |
393 (defcustom browse-url-save-file nil | |
394 "*If non-nil, save the buffer before displaying its file. | |
395 Used by the `browse-url-of-file' command." | |
396 :type 'boolean | |
397 :group 'browse-url) | |
398 | |
399 (defcustom browse-url-of-file-hook nil | |
400 "Run after `browse-url-of-file' has asked a browser to load a file. | |
401 | |
402 Set this to `browse-url-netscape-reload' to force Netscape to load the | |
403 file rather than displaying a cached copy." | |
404 :type 'hook | |
405 :options '(browse-url-netscape-reload) | |
406 :group 'browse-url) | |
407 | |
408 (defvar browse-url-usr1-signal | |
409 (if (and (boundp 'emacs-major-version) | |
410 (or (> emacs-major-version 19) (>= emacs-minor-version 29))) | |
411 'SIGUSR1 ; Why did I think this was in lower case before? | |
412 30) ; Check /usr/include/signal.h. | |
413 "The argument to `signal-process' for sending SIGUSR1 to XMosaic. | |
414 Emacs 19.29 accepts 'SIGUSR1, earlier versions require an integer | |
415 which is 30 on SunOS and 16 on HP-UX and Solaris.") | |
416 | |
417 (defcustom browse-url-CCI-port 3003 | |
418 "Port to access XMosaic via CCI. | |
419 This can be any number between 1024 and 65535 but must correspond to | |
420 the value set in the browser." | |
421 :type 'integer | |
422 :group 'browse-url) | |
423 | |
424 (defcustom browse-url-CCI-host "localhost" | |
425 "*Host to access XMosaic via CCI. | |
426 This should be the host name of the machine running XMosaic with CCI | |
427 enabled. The port number should be set in `browse-url-CCI-port'." | |
428 :type 'string | |
429 :group 'browse-url) | |
430 | |
431 (defvar browse-url-temp-file-name nil) | |
432 (make-variable-buffer-local 'browse-url-temp-file-name) | |
433 | |
434 (defcustom browse-url-xterm-program "xterm" | |
435 "The name of the terminal emulator used by `browse-url-lynx-xterm'. | |
436 This might, for instance, be a separate colour version of xterm." | |
437 :type 'string | |
438 :group 'browse-url) | |
439 | |
440 (defcustom browse-url-xterm-args nil | |
441 "*A list of strings defining options for `browse-url-xterm-program'. | |
442 These might set its size, for instance." | |
443 :type '(repeat (string :tag "Argument")) | |
444 :group 'browse-url) | |
445 | |
31909
36892782f26a
(browse-url-file-url): Check for null maps.
Sam Steingold <sds@gnu.org>
parents:
31575
diff
changeset
|
446 (defcustom browse-url-lynx-emacs-args (and (not window-system) |
28210 | 447 '("-show_cursor")) |
448 "A list of strings defining options for Lynx in an Emacs buffer. | |
449 | |
450 The default is none in a window system, otherwise `-show_cursor' to | |
451 indicate the position of the current link in the absence of | |
452 highlighting, assuming the normal default for showing the cursor." | |
453 :type '(repeat (string :tag "Argument")) | |
454 :version "20.3" | |
455 :group 'browse-url) | |
456 | |
457 (defcustom browse-url-gnudoit-program "gnudoit" | |
458 "The name of the `gnudoit' program used by `browse-url-w3-gnudoit'." | |
459 :type 'string | |
460 :group 'browse-url) | |
461 | |
462 (defcustom browse-url-gnudoit-args '("-q") | |
463 "*A list of strings defining options for `browse-url-gnudoit-program'. | |
464 These might set the port, for instance." | |
465 :type '(repeat (string :tag "Argument")) | |
466 :group 'browse-url) | |
467 | |
468 ;;;###autoload | |
469 (defcustom browse-url-generic-program nil | |
470 "*The name of the browser program used by `browse-url-generic'." | |
471 :type '(choice string (const :tag "None" nil)) | |
472 :group 'browse-url) | |
473 | |
474 (defcustom browse-url-generic-args nil | |
475 "*A list of strings defining options for `browse-url-generic-program'." | |
476 :type '(repeat (string :tag "Argument")) | |
477 :group 'browse-url) | |
478 | |
479 (defcustom browse-url-temp-dir temporary-file-directory | |
480 "The name of a directory for browse-url's temporary files. | |
481 Such files are generated by functions like `browse-url-of-region'. | |
482 You might want to set this to somewhere with restricted read permissions | |
483 for privacy's sake." | |
484 :type 'string | |
485 :group 'browse-url) | |
486 | |
487 (defcustom browse-url-netscape-version | |
488 3 | |
489 "The version of Netscape you are using. | |
490 This affects how URL reloading is done; the mechanism changed | |
491 incompatibly at version 4." | |
492 :type 'number | |
493 :group 'browse-url) | |
494 | |
495 (defcustom browse-url-lynx-input-field 'avoid | |
496 "*Action on selecting an existing Lynx buffer at an input field. | |
497 What to do when sending a new URL to an existing Lynx buffer in Emacs | |
498 if the Lynx cursor is on an input field (in which case the `g' command | |
499 would be entered as data). Such fields are recognized by the | |
500 underlines ____. Allowed values: nil: disregard it, 'warn: warn the | |
501 user and don't emit the URL, 'avoid: try to avoid the field by moving | |
502 down (this *won't* always work)." | |
503 :type '(choice (const :tag "Move to try to avoid field" :value avoid) | |
504 (const :tag "Disregard" :value nil) | |
505 (const :tag "Warn, don't emit URL" :value warn)) | |
506 :version "20.3" | |
507 :group 'browse-url) | |
508 | |
509 (defvar browse-url-lynx-input-attempts 10 | |
510 "*How many times to try to move down from a series of lynx input fields.") | |
511 | |
512 (defcustom browse-url-lynx-input-delay 0.2 | |
513 "How many seconds to wait for lynx between moves down from an input field.") | |
514 | |
37803
ae3f8f955b05
(browse-url-browser-function): Add kde.
Gerd Moellmann <gerd@gnu.org>
parents:
37666
diff
changeset
|
515 (defcustom browse-url-kde-program "kfmclient" |
ae3f8f955b05
(browse-url-browser-function): Add kde.
Gerd Moellmann <gerd@gnu.org>
parents:
37666
diff
changeset
|
516 "The name by which to invoke the KDE web browser." |
ae3f8f955b05
(browse-url-browser-function): Add kde.
Gerd Moellmann <gerd@gnu.org>
parents:
37666
diff
changeset
|
517 :type 'string |
ae3f8f955b05
(browse-url-browser-function): Add kde.
Gerd Moellmann <gerd@gnu.org>
parents:
37666
diff
changeset
|
518 :version "21.1" |
ae3f8f955b05
(browse-url-browser-function): Add kde.
Gerd Moellmann <gerd@gnu.org>
parents:
37666
diff
changeset
|
519 :group 'browse-url) |
ae3f8f955b05
(browse-url-browser-function): Add kde.
Gerd Moellmann <gerd@gnu.org>
parents:
37666
diff
changeset
|
520 |
ae3f8f955b05
(browse-url-browser-function): Add kde.
Gerd Moellmann <gerd@gnu.org>
parents:
37666
diff
changeset
|
521 (defcustom browse-url-kde-args '("openURL") |
ae3f8f955b05
(browse-url-browser-function): Add kde.
Gerd Moellmann <gerd@gnu.org>
parents:
37666
diff
changeset
|
522 "*A list of strings defining options for `browse-url-kde-program'." |
ae3f8f955b05
(browse-url-browser-function): Add kde.
Gerd Moellmann <gerd@gnu.org>
parents:
37666
diff
changeset
|
523 :type '(repeat (string :tag "Argument")) |
ae3f8f955b05
(browse-url-browser-function): Add kde.
Gerd Moellmann <gerd@gnu.org>
parents:
37666
diff
changeset
|
524 :group 'browse-url) |
ae3f8f955b05
(browse-url-browser-function): Add kde.
Gerd Moellmann <gerd@gnu.org>
parents:
37666
diff
changeset
|
525 |
28210 | 526 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
527 ;; URL input | |
528 | |
529 (defun browse-url-url-at-point () | |
530 (let ((url (thing-at-point 'url))) | |
531 (set-text-properties 0 (length url) nil url) | |
532 url)) | |
533 | |
534 ;; Having this as a separate function called by the browser-specific | |
535 ;; functions allows them to be stand-alone commands, making it easier | |
536 ;; to switch between browsers. | |
537 | |
538 (defun browse-url-interactive-arg (prompt) | |
539 "Read a URL from the minibuffer, prompting with PROMPT. | |
540 Default to the URL at or before point. If invoked with a mouse button, | |
541 set point to the position clicked first. Return a list for use in | |
37378
c5e0aa9cbe69
(browse-url-new-window-flag): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35008
diff
changeset
|
542 `interactive' containing the URL and `browse-url-new-window-flag' or its |
28210 | 543 negation if a prefix argument was given." |
544 (let ((event (elt (this-command-keys) 0))) | |
545 (and (listp event) (mouse-set-point event))) | |
546 (list (read-string prompt (browse-url-url-at-point)) | |
37378
c5e0aa9cbe69
(browse-url-new-window-flag): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35008
diff
changeset
|
547 (not (eq (null browse-url-new-window-flag) |
28210 | 548 (null current-prefix-arg))))) |
549 | |
28274
e9c99955f520
Restore previous use of browse-url-maybe-new-window.
Dave Love <fx@gnu.org>
parents:
28210
diff
changeset
|
550 ;; interactive-p needs to be called at a function's top-level, hence |
e9c99955f520
Restore previous use of browse-url-maybe-new-window.
Dave Love <fx@gnu.org>
parents:
28210
diff
changeset
|
551 ;; the macro. |
e9c99955f520
Restore previous use of browse-url-maybe-new-window.
Dave Love <fx@gnu.org>
parents:
28210
diff
changeset
|
552 (defmacro browse-url-maybe-new-window (arg) |
e9c99955f520
Restore previous use of browse-url-maybe-new-window.
Dave Love <fx@gnu.org>
parents:
28210
diff
changeset
|
553 `(if (interactive-p) |
e9c99955f520
Restore previous use of browse-url-maybe-new-window.
Dave Love <fx@gnu.org>
parents:
28210
diff
changeset
|
554 ,arg |
37378
c5e0aa9cbe69
(browse-url-new-window-flag): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35008
diff
changeset
|
555 browse-url-new-window-flag)) |
28274
e9c99955f520
Restore previous use of browse-url-maybe-new-window.
Dave Love <fx@gnu.org>
parents:
28210
diff
changeset
|
556 |
28210 | 557 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
558 ;; Browse current buffer | |
559 | |
560 ;;;###autoload | |
561 (defun browse-url-of-file (&optional file) | |
562 "Ask a WWW browser to display FILE. | |
563 Display the current buffer's file if FILE is nil or if called | |
564 interactively. Turn the filename into a URL with function | |
565 `browse-url-file-url'. Pass the URL to a browser using the | |
566 `browse-url' function then run `browse-url-of-file-hook'." | |
567 (interactive) | |
568 (or file | |
569 (setq file (buffer-file-name)) | |
570 (error "Current buffer has no file")) | |
571 (let ((buf (get-file-buffer file))) | |
572 (if buf | |
573 (save-excursion | |
574 (set-buffer buf) | |
575 (cond ((not (buffer-modified-p))) | |
576 (browse-url-save-file (save-buffer)) | |
577 (t (message "%s modified since last save" file)))))) | |
578 (browse-url (browse-url-file-url file)) | |
579 (run-hooks 'browse-url-of-file-hook)) | |
580 | |
581 (defun browse-url-file-url (file) | |
582 "Return the URL corresponding to FILE. | |
583 Use variable `browse-url-filename-alist' to map filenames to URLs." | |
584 ;; URL-encode special chars, do % first | |
585 (let ((s 0)) | |
586 (while (setq s (string-match "%" file s)) | |
587 (setq file (replace-match "%25" t t file) | |
588 s (1+ s)))) | |
589 (while (string-match "[*\"()',=;? ]" file) | |
590 (let ((enc (format "%%%x" (aref file (match-beginning 0))))) | |
591 (setq file (replace-match enc t t file)))) | |
31909
36892782f26a
(browse-url-file-url): Check for null maps.
Sam Steingold <sds@gnu.org>
parents:
31575
diff
changeset
|
592 (dolist (map browse-url-filename-alist) |
36892782f26a
(browse-url-file-url): Check for null maps.
Sam Steingold <sds@gnu.org>
parents:
31575
diff
changeset
|
593 (when (and map (string-match (car map) file)) |
36892782f26a
(browse-url-file-url): Check for null maps.
Sam Steingold <sds@gnu.org>
parents:
31575
diff
changeset
|
594 (setq file (replace-match (cdr map) t nil file)))) |
28210 | 595 file) |
596 | |
597 ;;;###autoload | |
598 (defun browse-url-of-buffer (&optional buffer) | |
599 "Ask a WWW browser to display BUFFER. | |
600 Display the current buffer if BUFFER is nil. Display only the | |
601 currently visible part of BUFFER (from a temporary file) if buffer is | |
602 narrowed." | |
603 (interactive) | |
604 (save-excursion | |
605 (and buffer (set-buffer buffer)) | |
606 (let ((file-name | |
607 ;; Ignore real name if restricted | |
608 (and (= (- (point-max) (point-min)) (buffer-size)) | |
609 (or buffer-file-name | |
610 (and (boundp 'dired-directory) dired-directory))))) | |
611 (or file-name | |
612 (progn | |
613 (or browse-url-temp-file-name | |
614 (setq browse-url-temp-file-name | |
615 (convert-standard-filename | |
616 (make-temp-file | |
617 (expand-file-name "burl" browse-url-temp-dir))))) | |
618 (setq file-name browse-url-temp-file-name) | |
619 (write-region (point-min) (point-max) file-name nil 'no-message))) | |
620 (browse-url-of-file file-name)))) | |
621 | |
622 (defun browse-url-delete-temp-file (&optional temp-file-name) | |
623 ;; Delete browse-url-temp-file-name from the file system | |
624 ;; If optional arg TEMP-FILE-NAME is non-nil, delete it instead | |
625 (let ((file-name (or temp-file-name browse-url-temp-file-name))) | |
626 (if (and file-name (file-exists-p file-name)) | |
627 (delete-file file-name)))) | |
628 | |
629 (add-hook 'kill-buffer-hook 'browse-url-delete-temp-file) | |
630 | |
631 ;;;###autoload | |
632 (defun browse-url-of-dired-file () | |
633 "In Dired, ask a WWW browser to display the file named on this line." | |
634 (interactive) | |
635 (browse-url-of-file (dired-get-filename))) | |
636 | |
637 ;;;###autoload | |
638 (defun browse-url-of-region (min max) | |
639 "Ask a WWW browser to display the current region." | |
640 (interactive "r") | |
641 (save-excursion | |
642 (save-restriction | |
643 (narrow-to-region min max) | |
644 (browse-url-of-buffer)))) | |
645 | |
646 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
647 ;; Browser-independent commands | |
648 | |
649 ;; A generic command to call the current browse-url-browser-function | |
650 | |
651 ;;;###autoload | |
652 (defun browse-url (url &rest args) | |
653 "Ask a WWW browser to load URL. | |
654 Prompts for a URL, defaulting to the URL at or before point. Variable | |
655 `browse-url-browser-function' says which browser to use." | |
656 (interactive (browse-url-interactive-arg "URL: ")) | |
28274
e9c99955f520
Restore previous use of browse-url-maybe-new-window.
Dave Love <fx@gnu.org>
parents:
28210
diff
changeset
|
657 (unless (interactive-p) |
37378
c5e0aa9cbe69
(browse-url-new-window-flag): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35008
diff
changeset
|
658 (setq args (or args (list browse-url-new-window-flag)))) |
28210 | 659 (if (functionp browse-url-browser-function) |
660 (apply browse-url-browser-function url args) | |
661 ;; The `function' can be an alist; look down it for first match | |
662 ;; and apply the function (which might be a lambda). | |
663 (catch 'done | |
30798
8884b93379ef
(browse-url-filename-alist): Add a clause for
Dave Love <fx@gnu.org>
parents:
28330
diff
changeset
|
664 (dolist (bf browse-url-browser-function) |
8884b93379ef
(browse-url-filename-alist): Add a clause for
Dave Love <fx@gnu.org>
parents:
28330
diff
changeset
|
665 (when (string-match (car bf) url) |
8884b93379ef
(browse-url-filename-alist): Add a clause for
Dave Love <fx@gnu.org>
parents:
28330
diff
changeset
|
666 (apply (cdr bf) url args) |
8884b93379ef
(browse-url-filename-alist): Add a clause for
Dave Love <fx@gnu.org>
parents:
28330
diff
changeset
|
667 (throw 'done t))) |
8884b93379ef
(browse-url-filename-alist): Add a clause for
Dave Love <fx@gnu.org>
parents:
28330
diff
changeset
|
668 (error "No browse-url-browser-function matching URL %s" |
28210 | 669 url)))) |
670 | |
671 ;;;###autoload | |
28274
e9c99955f520
Restore previous use of browse-url-maybe-new-window.
Dave Love <fx@gnu.org>
parents:
28210
diff
changeset
|
672 (defun browse-url-at-point (&optional arg) |
28210 | 673 "Ask a WWW browser to load the URL at or before point. |
674 Doesn't let you edit the URL like `browse-url'. Variable | |
675 `browse-url-browser-function' says which browser to use." | |
28274
e9c99955f520
Restore previous use of browse-url-maybe-new-window.
Dave Love <fx@gnu.org>
parents:
28210
diff
changeset
|
676 (interactive "P") |
30798
8884b93379ef
(browse-url-filename-alist): Add a clause for
Dave Love <fx@gnu.org>
parents:
28330
diff
changeset
|
677 (let ((url (browse-url-url-at-point))) |
8884b93379ef
(browse-url-filename-alist): Add a clause for
Dave Love <fx@gnu.org>
parents:
28330
diff
changeset
|
678 (if url |
8884b93379ef
(browse-url-filename-alist): Add a clause for
Dave Love <fx@gnu.org>
parents:
28330
diff
changeset
|
679 (browse-url url (if arg |
37378
c5e0aa9cbe69
(browse-url-new-window-flag): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35008
diff
changeset
|
680 (not browse-url-new-window-flag) |
c5e0aa9cbe69
(browse-url-new-window-flag): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35008
diff
changeset
|
681 browse-url-new-window-flag)) |
30798
8884b93379ef
(browse-url-filename-alist): Add a clause for
Dave Love <fx@gnu.org>
parents:
28330
diff
changeset
|
682 (error "No URL found")))) |
28210 | 683 |
684 ;;;###autoload | |
685 (defun browse-url-at-mouse (event) | |
686 "Ask a WWW browser to load a URL clicked with the mouse. | |
687 The URL is the one around or before the position of the mouse click | |
688 but point is not changed. Doesn't let you edit the URL like | |
689 `browse-url'. Variable `browse-url-browser-function' says which browser | |
690 to use." | |
691 (interactive "e") | |
692 (save-excursion | |
30798
8884b93379ef
(browse-url-filename-alist): Add a clause for
Dave Love <fx@gnu.org>
parents:
28330
diff
changeset
|
693 (mouse-set-point event) |
37378
c5e0aa9cbe69
(browse-url-new-window-flag): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35008
diff
changeset
|
694 (browse-url-at-point browse-url-new-window-flag))) |
28210 | 695 |
696 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
697 ;; Browser-specific commands | |
698 | |
699 ;; --- Default MS-Windows browser --- | |
700 | |
701 (defun browse-url-default-windows-browser (url &optional new-window) | |
702 (interactive (browse-url-interactive-arg "URL: ")) | |
38271
bb01ee99b910
(browse-url-default-windows-browser): Support
Eli Zaretskii <eliz@gnu.org>
parents:
37803
diff
changeset
|
703 (if (eq system-type 'ms-dos) |
bb01ee99b910
(browse-url-default-windows-browser): Support
Eli Zaretskii <eliz@gnu.org>
parents:
37803
diff
changeset
|
704 (if dos-windows-version |
bb01ee99b910
(browse-url-default-windows-browser): Support
Eli Zaretskii <eliz@gnu.org>
parents:
37803
diff
changeset
|
705 (shell-command (concat "start " (shell-quote-argument url))) |
bb01ee99b910
(browse-url-default-windows-browser): Support
Eli Zaretskii <eliz@gnu.org>
parents:
37803
diff
changeset
|
706 (error "Browsing URLs is not supported on this system")) |
bb01ee99b910
(browse-url-default-windows-browser): Support
Eli Zaretskii <eliz@gnu.org>
parents:
37803
diff
changeset
|
707 (w32-shell-execute "open" url))) |
28210 | 708 |
709 ;; --- Netscape --- | |
710 | |
711 (defun browse-url-process-environment () | |
41282
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
712 "Set DISPLAY in the environment to the X display the browser will use. |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
713 This is either the value of variable `browse-url-browser-display' if |
28210 | 714 non-nil, or the same display as Emacs if different from the current |
715 environment, otherwise just use the current environment." | |
41282
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
716 (let ((display (or browse-url-browser-display (browse-url-emacs-display)))) |
28210 | 717 (if display |
718 (cons (concat "DISPLAY=" display) process-environment) | |
719 process-environment))) | |
720 | |
721 (defun browse-url-emacs-display () | |
722 "Return the X display Emacs is running on. | |
723 This is nil if the display is the same as the DISPLAY environment variable. | |
724 | |
725 Actually Emacs could be using several displays; this just returns the | |
726 one showing the selected frame." | |
727 (let ((display (cdr-safe (assq 'display (frame-parameters))))) | |
728 (and (not (equal display (getenv "DISPLAY"))) | |
729 display))) | |
730 | |
731 ;;;###autoload | |
41282
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
732 (defun browse-url-default-browser (url &rest args) |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
733 "Find a suitable browser and ask it to load URL. |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
734 Default to the URL around or before point. |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
735 |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
736 When called interactively, if variable `browse-url-new-window-flag' is |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
737 non-nil, load the document in a new window, if possible, otherwise use |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
738 a random existing one. A non-nil interactive prefix argument reverses |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
739 the effect of `browse-url-new-window-flag'. |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
740 |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
741 When called non-interactively, optional second argument NEW-WINDOW is |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
742 used instead of `browse-url-new-window-flag'. |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
743 |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
744 The order attempted is gnome-moz-remote, Mozilla, Galeon, Netscape, |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
745 Mosaic, IXI Mosaic, Lynx in an xterm, MMM, Konqueror, and then W3." |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
746 (apply |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
747 (cond |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
748 ((executable-find "gnome-moz-remote") 'browse-url-gnome-moz) |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
749 ((executable-find browse-url-mozilla-program) 'browse-url-mozilla) |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
750 ((executable-find browse-url-galeon-program) 'browse-url-galeon) |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
751 ((executable-find browse-url-kde-program) 'browse-url-kde) |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
752 ((executable-find browse-url-netscape-program) 'browse-url-netscape) |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
753 ((executable-find browse-url-mosaic-program) 'browse-url-mosaic) |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
754 ((executable-find "tellw3b") 'browse-url-iximosaic) |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
755 ((executable-find browse-url-xterm-program) 'browse-url-lynx-xterm) |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
756 ((executable-find "mmm") 'browse-url-mmm) |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
757 (t 'browse-url-w3)) |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
758 url args)) |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
759 |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
760 ;;;###autoload |
28210 | 761 (defun browse-url-netscape (url &optional new-window) |
762 "Ask the Netscape WWW browser to load URL. | |
763 Default to the URL around or before point. The strings in variable | |
764 `browse-url-netscape-arguments' are also passed to Netscape. | |
765 | |
37378
c5e0aa9cbe69
(browse-url-new-window-flag): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35008
diff
changeset
|
766 When called interactively, if variable `browse-url-new-window-flag' is |
28210 | 767 non-nil, load the document in a new Netscape window, otherwise use a |
768 random existing one. A non-nil interactive prefix argument reverses | |
37378
c5e0aa9cbe69
(browse-url-new-window-flag): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35008
diff
changeset
|
769 the effect of `browse-url-new-window-flag'. |
28210 | 770 |
771 When called non-interactively, optional second argument NEW-WINDOW is | |
37378
c5e0aa9cbe69
(browse-url-new-window-flag): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35008
diff
changeset
|
772 used instead of `browse-url-new-window-flag'." |
32245
d35dba8183fd
(browse-url-gnome-moz-arguments): New option.
Dave Love <fx@gnu.org>
parents:
31909
diff
changeset
|
773 (interactive (browse-url-interactive-arg "URL: ")) |
28210 | 774 ;; URL encode any `confusing' characters in the URL. This needs to |
775 ;; include at least commas; presumably also close parens. | |
776 (while (string-match "[,)]" url) | |
777 (setq url (replace-match | |
778 (format "%%%x" (string-to-char (match-string 0 url))) t t url))) | |
779 (let* ((process-environment (browse-url-process-environment)) | |
780 (process (apply 'start-process | |
781 (concat "netscape " url) nil | |
782 browse-url-netscape-program | |
783 (append | |
784 browse-url-netscape-arguments | |
785 (if (eq window-system 'w32) | |
786 (list url) | |
787 (append | |
788 (if new-window '("-noraise")) | |
789 (list "-remote" | |
790 (concat "openURL(" url | |
28274
e9c99955f520
Restore previous use of browse-url-maybe-new-window.
Dave Love <fx@gnu.org>
parents:
28210
diff
changeset
|
791 (if (browse-url-maybe-new-window |
e9c99955f520
Restore previous use of browse-url-maybe-new-window.
Dave Love <fx@gnu.org>
parents:
28210
diff
changeset
|
792 new-window) |
e9c99955f520
Restore previous use of browse-url-maybe-new-window.
Dave Love <fx@gnu.org>
parents:
28210
diff
changeset
|
793 ",new-window") |
28210 | 794 ")")))))))) |
795 (set-process-sentinel process | |
30798
8884b93379ef
(browse-url-filename-alist): Add a clause for
Dave Love <fx@gnu.org>
parents:
28330
diff
changeset
|
796 `(lambda (process change) |
8884b93379ef
(browse-url-filename-alist): Add a clause for
Dave Love <fx@gnu.org>
parents:
28330
diff
changeset
|
797 (browse-url-netscape-sentinel process ,url))))) |
28210 | 798 |
799 (defun browse-url-netscape-sentinel (process url) | |
800 "Handle a change to the process communicating with Netscape." | |
801 (or (eq (process-exit-status process) 0) | |
802 (let* ((process-environment (browse-url-process-environment))) | |
803 ;; Netscape not running - start it | |
804 (message "Starting Netscape...") | |
805 (apply 'start-process (concat "netscape" url) nil | |
806 browse-url-netscape-program | |
807 (append browse-url-netscape-startup-arguments (list url)))))) | |
808 | |
809 (defun browse-url-netscape-reload () | |
810 "Ask Netscape to reload its current document. | |
811 How depends on `browse-url-netscape-version'." | |
812 (interactive) | |
813 ;; Backwards incompatibility reported by | |
814 ;; <peter.kruse@psychologie.uni-regensburg.de>. | |
815 (browse-url-netscape-send (if (>= browse-url-netscape-version 4) | |
816 "xfeDoCommand(reload)" | |
817 "reload"))) | |
818 | |
819 (defun browse-url-netscape-send (command) | |
820 "Send a remote control command to Netscape." | |
821 (let* ((process-environment (browse-url-process-environment))) | |
822 (apply 'start-process "netscape" nil | |
823 browse-url-netscape-program | |
824 (append browse-url-netscape-arguments | |
825 (list "-remote" command))))) | |
826 | |
41282
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
827 ;;;###autoload |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
828 (defun browse-url-mozilla (url &optional new-window) |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
829 "Ask the Mozilla WWW browser to load URL. |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
830 Default to the URL around or before point. The strings in variable |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
831 `browse-url-mozilla-arguments' are also passed to Mozilla. |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
832 |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
833 When called interactively, if variable `browse-url-new-window-flag' is |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
834 non-nil, load the document in a new Mozilla window, otherwise use a |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
835 random existing one. A non-nil interactive prefix argument reverses |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
836 the effect of `browse-url-new-window-flag'. |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
837 |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
838 When called non-interactively, optional second argument NEW-WINDOW is |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
839 used instead of `browse-url-new-window-flag'." |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
840 (interactive (browse-url-interactive-arg "URL: ")) |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
841 ;; URL encode any `confusing' characters in the URL. This needs to |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
842 ;; include at least commas; presumably also close parens. |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
843 (while (string-match "[,)]" url) |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
844 (setq url (replace-match |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
845 (format "%%%x" (string-to-char (match-string 0 url))) t t url))) |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
846 (let* ((process-environment (browse-url-process-environment)) |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
847 (process (apply 'start-process |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
848 (concat "mozilla " url) nil |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
849 browse-url-mozilla-program |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
850 (append |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
851 browse-url-mozilla-arguments |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
852 (list "-remote" |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
853 (concat "openURL(" |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
854 url |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
855 (if new-window ",new-window") |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
856 ")")))))) |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
857 (set-process-sentinel process |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
858 `(lambda (process change) |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
859 (browse-url-mozilla-sentinel process ,url))))) |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
860 |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
861 (defun browse-url-mozilla-sentinel (process url) |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
862 "Handle a change to the process communicating with Mozilla." |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
863 (or (eq (process-exit-status process) 0) |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
864 (let* ((process-environment (browse-url-process-environment))) |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
865 ;; Mozilla is not running - start it |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
866 (message "Starting Mozilla...") |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
867 (apply 'start-process (concat "mozilla " url) nil |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
868 browse-url-mozilla-program |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
869 (append browse-url-mozilla-startup-arguments (list url)))))) |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
870 |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
871 ;;;###autoload |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
872 (defun browse-url-galeon (url &optional new-window) |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
873 "Ask the Galeon WWW browser to load URL. |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
874 Default to the URL around or before point. The strings in variable |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
875 `browse-url-galeon-arguments' are also passed to Galeon. |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
876 |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
877 When called interactively, if variable `browse-url-new-window-flag' is |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
878 non-nil, load the document in a new Galeon window, otherwise use a |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
879 random existing one. A non-nil interactive prefix argument reverses |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
880 the effect of `browse-url-new-window-flag'. |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
881 |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
882 When called non-interactively, optional second argument NEW-WINDOW is |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
883 used instead of `browse-url-new-window-flag'." |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
884 (interactive (browse-url-interactive-arg "URL: ")) |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
885 ;; URL encode any `confusing' characters in the URL. This needs to |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
886 ;; include at least commas; presumably also close parens. |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
887 (while (string-match "[,)]" url) |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
888 (setq url (replace-match |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
889 (format "%%%x" (string-to-char (match-string 0 url))) t t url))) |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
890 (let* ((process-environment (browse-url-process-environment)) |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
891 (process (apply 'start-process |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
892 (concat "galeon " url) nil |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
893 browse-url-galeon-program |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
894 (append |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
895 browse-url-galeon-arguments |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
896 (if new-window '("-w" "--noraise")) |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
897 (list "-x" url))))) |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
898 (set-process-sentinel process |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
899 `(lambda (process change) |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
900 (browse-url-galeon-sentinel process ,url))))) |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
901 |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
902 (defun browse-url-galeon-sentinel (process url) |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
903 "Handle a change to the process communicating with Galeon." |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
904 (or (eq (process-exit-status process) 0) |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
905 (let* ((process-environment (browse-url-process-environment))) |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
906 ;; Galeon is not running - start it |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
907 (message "Starting Galeon...") |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
908 (apply 'start-process (concat "galeon " url) nil |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
909 browse-url-galeon-program |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
910 (append browse-url-galeon-startup-arguments (list url)))))) |
c5d2c3683efb
Support Mozilla and Galeon.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
911 |
32245
d35dba8183fd
(browse-url-gnome-moz-arguments): New option.
Dave Love <fx@gnu.org>
parents:
31909
diff
changeset
|
912 ;; GNOME means of invoking either Mozilla or Netrape. |
d35dba8183fd
(browse-url-gnome-moz-arguments): New option.
Dave Love <fx@gnu.org>
parents:
31909
diff
changeset
|
913 |
d35dba8183fd
(browse-url-gnome-moz-arguments): New option.
Dave Love <fx@gnu.org>
parents:
31909
diff
changeset
|
914 (defcustom browse-url-gnome-moz-arguments '() |
d35dba8183fd
(browse-url-gnome-moz-arguments): New option.
Dave Love <fx@gnu.org>
parents:
31909
diff
changeset
|
915 "A list of strings passed to the GNOME mozilla viewer as arguments." |
d35dba8183fd
(browse-url-gnome-moz-arguments): New option.
Dave Love <fx@gnu.org>
parents:
31909
diff
changeset
|
916 :version "21.1" |
d35dba8183fd
(browse-url-gnome-moz-arguments): New option.
Dave Love <fx@gnu.org>
parents:
31909
diff
changeset
|
917 :type '(repeat (string :tag "Argument")) |
d35dba8183fd
(browse-url-gnome-moz-arguments): New option.
Dave Love <fx@gnu.org>
parents:
31909
diff
changeset
|
918 :group 'browse-url) |
d35dba8183fd
(browse-url-gnome-moz-arguments): New option.
Dave Love <fx@gnu.org>
parents:
31909
diff
changeset
|
919 |
32246
851690316add
(browse-url-browser-function): Use it.
Dave Love <fx@gnu.org>
parents:
32245
diff
changeset
|
920 ;;;###autoload |
32245
d35dba8183fd
(browse-url-gnome-moz-arguments): New option.
Dave Love <fx@gnu.org>
parents:
31909
diff
changeset
|
921 (defun browse-url-gnome-moz (url &optional new-window) |
d35dba8183fd
(browse-url-gnome-moz-arguments): New option.
Dave Love <fx@gnu.org>
parents:
31909
diff
changeset
|
922 "Ask Mozilla/Netscape to load URL via the GNOME program `gnome-moz-remote'. |
d35dba8183fd
(browse-url-gnome-moz-arguments): New option.
Dave Love <fx@gnu.org>
parents:
31909
diff
changeset
|
923 Default to the URL around or before point. The strings in variable |
d35dba8183fd
(browse-url-gnome-moz-arguments): New option.
Dave Love <fx@gnu.org>
parents:
31909
diff
changeset
|
924 `browse-url-gnome-moz-arguments' are also passed. |
d35dba8183fd
(browse-url-gnome-moz-arguments): New option.
Dave Love <fx@gnu.org>
parents:
31909
diff
changeset
|
925 |
37378
c5e0aa9cbe69
(browse-url-new-window-flag): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35008
diff
changeset
|
926 When called interactively, if variable `browse-url-new-window-flag' is |
32245
d35dba8183fd
(browse-url-gnome-moz-arguments): New option.
Dave Love <fx@gnu.org>
parents:
31909
diff
changeset
|
927 non-nil, load the document in a new browser window, otherwise use an |
d35dba8183fd
(browse-url-gnome-moz-arguments): New option.
Dave Love <fx@gnu.org>
parents:
31909
diff
changeset
|
928 existing one. A non-nil interactive prefix argument reverses the |
37378
c5e0aa9cbe69
(browse-url-new-window-flag): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35008
diff
changeset
|
929 effect of `browse-url-new-window-flag'. |
32245
d35dba8183fd
(browse-url-gnome-moz-arguments): New option.
Dave Love <fx@gnu.org>
parents:
31909
diff
changeset
|
930 |
d35dba8183fd
(browse-url-gnome-moz-arguments): New option.
Dave Love <fx@gnu.org>
parents:
31909
diff
changeset
|
931 When called non-interactively, optional second argument NEW-WINDOW is |
37378
c5e0aa9cbe69
(browse-url-new-window-flag): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35008
diff
changeset
|
932 used instead of `browse-url-new-window-flag'." |
32245
d35dba8183fd
(browse-url-gnome-moz-arguments): New option.
Dave Love <fx@gnu.org>
parents:
31909
diff
changeset
|
933 (interactive (browse-url-interactive-arg "URL: ")) |
d35dba8183fd
(browse-url-gnome-moz-arguments): New option.
Dave Love <fx@gnu.org>
parents:
31909
diff
changeset
|
934 (apply 'start-process (concat "gnome-moz-remote " url) |
d35dba8183fd
(browse-url-gnome-moz-arguments): New option.
Dave Love <fx@gnu.org>
parents:
31909
diff
changeset
|
935 nil |
d35dba8183fd
(browse-url-gnome-moz-arguments): New option.
Dave Love <fx@gnu.org>
parents:
31909
diff
changeset
|
936 "gnome-moz-remote" |
d35dba8183fd
(browse-url-gnome-moz-arguments): New option.
Dave Love <fx@gnu.org>
parents:
31909
diff
changeset
|
937 (append |
d35dba8183fd
(browse-url-gnome-moz-arguments): New option.
Dave Love <fx@gnu.org>
parents:
31909
diff
changeset
|
938 browse-url-gnome-moz-arguments |
d35dba8183fd
(browse-url-gnome-moz-arguments): New option.
Dave Love <fx@gnu.org>
parents:
31909
diff
changeset
|
939 (if (browse-url-maybe-new-window new-window) |
d35dba8183fd
(browse-url-gnome-moz-arguments): New option.
Dave Love <fx@gnu.org>
parents:
31909
diff
changeset
|
940 '("--newwin")) |
d35dba8183fd
(browse-url-gnome-moz-arguments): New option.
Dave Love <fx@gnu.org>
parents:
31909
diff
changeset
|
941 (list "--raise" url)))) |
d35dba8183fd
(browse-url-gnome-moz-arguments): New option.
Dave Love <fx@gnu.org>
parents:
31909
diff
changeset
|
942 |
28210 | 943 ;; --- Mosaic --- |
944 | |
945 ;;;###autoload | |
946 (defun browse-url-mosaic (url &optional new-window) | |
947 "Ask the XMosaic WWW browser to load URL. | |
948 | |
949 Default to the URL around or before point. The strings in variable | |
950 `browse-url-mosaic-arguments' are also passed to Mosaic and the | |
951 program is invoked according to the variable | |
952 `browse-url-mosaic-program'. | |
953 | |
37378
c5e0aa9cbe69
(browse-url-new-window-flag): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35008
diff
changeset
|
954 When called interactively, if variable `browse-url-new-window-flag' is |
28210 | 955 non-nil, load the document in a new Mosaic window, otherwise use a |
956 random existing one. A non-nil interactive prefix argument reverses | |
37378
c5e0aa9cbe69
(browse-url-new-window-flag): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35008
diff
changeset
|
957 the effect of `browse-url-new-window-flag'. |
28210 | 958 |
959 When called non-interactively, optional second argument NEW-WINDOW is | |
37378
c5e0aa9cbe69
(browse-url-new-window-flag): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35008
diff
changeset
|
960 used instead of `browse-url-new-window-flag'." |
28210 | 961 (interactive (browse-url-interactive-arg "Mosaic URL: ")) |
962 (let ((pidfile (expand-file-name "~/.mosaicpid")) | |
963 pid) | |
964 (if (file-readable-p pidfile) | |
965 (save-excursion | |
966 (find-file pidfile) | |
967 (goto-char (point-min)) | |
968 (setq pid (read (current-buffer))) | |
969 (kill-buffer nil))) | |
970 (if (and pid (zerop (signal-process pid 0))) ; Mosaic running | |
971 (save-excursion | |
972 (find-file (format "/tmp/Mosaic.%d" pid)) | |
973 (erase-buffer) | |
28274
e9c99955f520
Restore previous use of browse-url-maybe-new-window.
Dave Love <fx@gnu.org>
parents:
28210
diff
changeset
|
974 (insert (if (browse-url-maybe-new-window new-window) |
28210 | 975 "newwin\n" |
976 "goto\n") | |
977 url "\n") | |
978 (save-buffer) | |
979 (kill-buffer nil) | |
980 ;; Send signal SIGUSR to Mosaic | |
981 (message "Signalling Mosaic...") | |
982 (signal-process pid browse-url-usr1-signal) | |
983 ;; Or you could try: | |
984 ;; (call-process "kill" nil 0 nil "-USR1" (int-to-string pid)) | |
985 (message "Signalling Mosaic...done") | |
986 ) | |
987 ;; Mosaic not running - start it | |
988 (message "Starting Mosaic...") | |
989 (apply 'start-process "xmosaic" nil browse-url-mosaic-program | |
990 (append browse-url-mosaic-arguments (list url))) | |
991 (message "Starting Mosaic...done")))) | |
992 | |
993 ;; --- Grail --- | |
994 | |
995 ;;;###autoload | |
996 (defvar browse-url-grail | |
997 (concat (or (getenv "GRAILDIR") "~/.grail") "/user/rcgrail.py") | |
998 "Location of Grail remote control client script `rcgrail.py'. | |
999 Typically found in $GRAILDIR/rcgrail.py, or ~/.grail/user/rcgrail.py.") | |
1000 | |
1001 ;;;###autoload | |
1002 (defun browse-url-grail (url &optional new-window) | |
1003 "Ask the Grail WWW browser to load URL. | |
1004 Default to the URL around or before point. Runs the program in the | |
1005 variable `browse-url-grail'." | |
1006 (interactive (browse-url-interactive-arg "Grail URL: ")) | |
1007 (message "Sending URL to Grail...") | |
1008 (save-excursion | |
1009 (set-buffer (get-buffer-create " *Shell Command Output*")) | |
1010 (erase-buffer) | |
1011 ;; don't worry about this failing. | |
1012 (if new-window | |
1013 (call-process browse-url-grail nil 0 nil "-b" url) | |
1014 (call-process browse-url-grail nil 0 nil url)) | |
1015 (message "Sending URL to Grail... done"))) | |
1016 | |
1017 ;; --- Mosaic using CCI --- | |
1018 | |
1019 ;;;###autoload | |
1020 (defun browse-url-cci (url &optional new-window) | |
1021 "Ask the XMosaic WWW browser to load URL. | |
1022 Default to the URL around or before point. | |
1023 | |
1024 This function only works for XMosaic version 2.5 or later. You must | |
1025 select `CCI' from XMosaic's File menu, set the CCI Port Address to the | |
1026 value of variable `browse-url-CCI-port', and enable `Accept requests'. | |
1027 | |
37378
c5e0aa9cbe69
(browse-url-new-window-flag): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35008
diff
changeset
|
1028 When called interactively, if variable `browse-url-new-window-flag' is |
28210 | 1029 non-nil, load the document in a new browser window, otherwise use a |
1030 random existing one. A non-nil interactive prefix argument reverses | |
37378
c5e0aa9cbe69
(browse-url-new-window-flag): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35008
diff
changeset
|
1031 the effect of `browse-url-new-window-flag'. |
28210 | 1032 |
1033 When called non-interactively, optional second argument NEW-WINDOW is | |
37378
c5e0aa9cbe69
(browse-url-new-window-flag): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35008
diff
changeset
|
1034 used instead of `browse-url-new-window-flag'." |
28210 | 1035 (interactive (browse-url-interactive-arg "Mosaic URL: ")) |
1036 (open-network-stream "browse-url" " *browse-url*" | |
1037 browse-url-CCI-host browse-url-CCI-port) | |
1038 ;; Todo: start browser if fails | |
1039 (process-send-string "browse-url" | |
1040 (concat "get url (" url ") output " | |
28274
e9c99955f520
Restore previous use of browse-url-maybe-new-window.
Dave Love <fx@gnu.org>
parents:
28210
diff
changeset
|
1041 (if (browse-url-maybe-new-window new-window) |
28210 | 1042 "new" |
1043 "current") | |
1044 "\r\n")) | |
1045 (process-send-string "browse-url" "disconnect\r\n") | |
1046 (delete-process "browse-url")) | |
1047 | |
1048 ;; --- IXI Mosaic --- | |
1049 | |
1050 ;;;###autoload | |
1051 (defun browse-url-iximosaic (url &optional new-window) | |
1052 ;; new-window ignored | |
1053 "Ask the IXIMosaic WWW browser to load URL. | |
1054 Default to the URL around or before point." | |
1055 (interactive (browse-url-interactive-arg "IXI Mosaic URL: ")) | |
1056 (start-process "tellw3b" nil "tellw3b" | |
1057 "-service WWW_BROWSER ixi_showurl " url)) | |
1058 | |
1059 ;; --- W3 --- | |
1060 | |
1061 ;;;###autoload | |
1062 (defun browse-url-w3 (url &optional new-window) | |
1063 "Ask the w3 WWW browser to load URL. | |
1064 Default to the URL around or before point. | |
1065 | |
37378
c5e0aa9cbe69
(browse-url-new-window-flag): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35008
diff
changeset
|
1066 When called interactively, if variable `browse-url-new-window-flag' is |
28210 | 1067 non-nil, load the document in a new window. A non-nil interactive |
37378
c5e0aa9cbe69
(browse-url-new-window-flag): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35008
diff
changeset
|
1068 prefix argument reverses the effect of `browse-url-new-window-flag'. |
28210 | 1069 |
1070 When called non-interactively, optional second argument NEW-WINDOW is | |
37378
c5e0aa9cbe69
(browse-url-new-window-flag): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35008
diff
changeset
|
1071 used instead of `browse-url-new-window-flag'." |
28210 | 1072 (interactive (browse-url-interactive-arg "W3 URL: ")) |
1073 (require 'w3) ; w3-fetch-other-window not autoloaded | |
28274
e9c99955f520
Restore previous use of browse-url-maybe-new-window.
Dave Love <fx@gnu.org>
parents:
28210
diff
changeset
|
1074 (if (browse-url-maybe-new-window new-window) |
28210 | 1075 (w3-fetch-other-window url) |
1076 (w3-fetch url))) | |
1077 | |
1078 ;;;###autoload | |
1079 (defun browse-url-w3-gnudoit (url &optional new-window) | |
1080 ;; new-window ignored | |
1081 "Ask another Emacs running gnuserv to load the URL using the W3 browser. | |
1082 The `browse-url-gnudoit-program' program is used with options given by | |
1083 `browse-url-gnudoit-args'. Default to the URL around or before point." | |
1084 (interactive (browse-url-interactive-arg "W3 URL: ")) | |
1085 (apply 'start-process (concat "gnudoit:" url) nil | |
1086 browse-url-gnudoit-program | |
28274
e9c99955f520
Restore previous use of browse-url-maybe-new-window.
Dave Love <fx@gnu.org>
parents:
28210
diff
changeset
|
1087 (append browse-url-gnudoit-args |
e9c99955f520
Restore previous use of browse-url-maybe-new-window.
Dave Love <fx@gnu.org>
parents:
28210
diff
changeset
|
1088 (list (concat "(w3-fetch \"" url "\")") |
e9c99955f520
Restore previous use of browse-url-maybe-new-window.
Dave Love <fx@gnu.org>
parents:
28210
diff
changeset
|
1089 "(raise-frame)")))) |
28210 | 1090 |
1091 ;; --- Lynx in an xterm --- | |
1092 | |
1093 ;;;###autoload | |
1094 (defun browse-url-lynx-xterm (url &optional new-window) | |
1095 ;; new-window ignored | |
1096 "Ask the Lynx WWW browser to load URL. | |
1097 Default to the URL around or before point. A new Lynx process is run | |
1098 in an Xterm window using the Xterm program named by `browse-url-xterm-program' | |
1099 with possible additional arguments `browse-url-xterm-args'." | |
1100 (interactive (browse-url-interactive-arg "Lynx URL: ")) | |
1101 (apply #'start-process `(,(concat "lynx" url) nil ,browse-url-xterm-program | |
28274
e9c99955f520
Restore previous use of browse-url-maybe-new-window.
Dave Love <fx@gnu.org>
parents:
28210
diff
changeset
|
1102 ,@browse-url-xterm-args "-e" "lynx" |
e9c99955f520
Restore previous use of browse-url-maybe-new-window.
Dave Love <fx@gnu.org>
parents:
28210
diff
changeset
|
1103 ,url))) |
28210 | 1104 |
1105 ;; --- Lynx in an Emacs "term" window --- | |
1106 | |
1107 ;;;###autoload | |
1108 (defun browse-url-lynx-emacs (url &optional new-buffer) | |
1109 "Ask the Lynx WWW browser to load URL. | |
1110 Default to the URL around or before point. With a prefix argument, run | |
1111 a new Lynx process in a new buffer. | |
1112 | |
37378
c5e0aa9cbe69
(browse-url-new-window-flag): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35008
diff
changeset
|
1113 When called interactively, if variable `browse-url-new-window-flag' is |
28210 | 1114 non-nil, load the document in a new lynx in a new term window, |
1115 otherwise use any existing one. A non-nil interactive prefix argument | |
37378
c5e0aa9cbe69
(browse-url-new-window-flag): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35008
diff
changeset
|
1116 reverses the effect of `browse-url-new-window-flag'. |
28210 | 1117 |
1118 When called non-interactively, optional second argument NEW-WINDOW is | |
37378
c5e0aa9cbe69
(browse-url-new-window-flag): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35008
diff
changeset
|
1119 used instead of `browse-url-new-window-flag'." |
28210 | 1120 (interactive (browse-url-interactive-arg "Lynx URL: ")) |
1121 (let* ((system-uses-terminfo t) ; Lynx uses terminfo | |
1122 ;; (term-term-name "vt100") ; ?? | |
1123 (buf (get-buffer "*lynx*")) | |
1124 (proc (and buf (get-buffer-process buf))) | |
1125 (n browse-url-lynx-input-attempts)) | |
28274
e9c99955f520
Restore previous use of browse-url-maybe-new-window.
Dave Love <fx@gnu.org>
parents:
28210
diff
changeset
|
1126 (if (and (browse-url-maybe-new-window new-buffer) buf) |
28210 | 1127 ;; Rename away the OLD buffer. This isn't very polite, but |
1128 ;; term insists on working in a buffer named *lynx* and would | |
1129 ;; choke on *lynx*<1> | |
1130 (progn (set-buffer buf) | |
1131 (rename-uniquely))) | |
28274
e9c99955f520
Restore previous use of browse-url-maybe-new-window.
Dave Love <fx@gnu.org>
parents:
28210
diff
changeset
|
1132 (if (or (browse-url-maybe-new-window new-buffer) |
28210 | 1133 (not buf) |
1134 (not proc) | |
1135 (not (memq (process-status proc) '(run stop)))) | |
1136 ;; start a new lynx | |
1137 (progn | |
1138 (setq buf | |
1139 (apply #'make-term | |
28274
e9c99955f520
Restore previous use of browse-url-maybe-new-window.
Dave Love <fx@gnu.org>
parents:
28210
diff
changeset
|
1140 `("lynx" "lynx" nil ,@browse-url-lynx-emacs-args |
e9c99955f520
Restore previous use of browse-url-maybe-new-window.
Dave Love <fx@gnu.org>
parents:
28210
diff
changeset
|
1141 ,url))) |
28210 | 1142 (switch-to-buffer buf) |
1143 (term-char-mode) | |
1144 (set-process-sentinel | |
1145 (get-buffer-process buf) | |
1146 ;; Don't leave around a dead one (especially because of its | |
1147 ;; munged keymap.) | |
1148 (lambda (process event) | |
1149 (if (not (memq (process-status process) '(run stop))) | |
1150 (let ((buf (process-buffer process))) | |
1151 (if buf (kill-buffer buf))))))) | |
1152 ;; send the url to lynx in the old buffer | |
1153 (let ((win (get-buffer-window buf t))) | |
1154 (if win | |
1155 (select-window win) | |
1156 (switch-to-buffer buf))) | |
1157 (if (eq (following-char) ?_) | |
1158 (cond ((eq browse-url-lynx-input-field 'warn) | |
38436
b174db545cfd
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
38271
diff
changeset
|
1159 (error "Please move out of the input field first")) |
28210 | 1160 ((eq browse-url-lynx-input-field 'avoid) |
1161 (while (and (eq (following-char) ?_) (> n 0)) | |
1162 (term-send-down) ; down arrow | |
1163 (sit-for browse-url-lynx-input-delay)) | |
1164 (if (eq (following-char) ?_) | |
38436
b174db545cfd
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
38271
diff
changeset
|
1165 (error "Cannot move out of the input field, sorry"))))) |
28210 | 1166 (term-send-string proc (concat "g" ; goto |
1167 "\C-u" ; kill default url | |
1168 url | |
1169 "\r"))))) | |
1170 | |
1171 ;; --- MMM --- | |
1172 | |
1173 ;;;###autoload | |
1174 (defun browse-url-mmm (url &optional new-window) | |
1175 "Ask the MMM WWW browser to load URL. | |
1176 Default to the URL around or before point." | |
1177 (interactive (browse-url-interactive-arg "MMM URL: ")) | |
1178 (message "Sending URL to MMM...") | |
1179 (save-excursion | |
1180 (set-buffer (get-buffer-create " *Shell Command Output*")) | |
1181 (erase-buffer) | |
1182 ;; mmm_remote just SEGVs if the file isn't there... | |
1183 (if (or (file-exists-p (expand-file-name "~/.mmm_remote")) | |
1184 ;; location in v 0.4: | |
1185 (file-exists-p (expand-file-name "~/.mmm/remote"))) | |
1186 (call-process "mmm_remote" nil 0 nil url) | |
1187 (call-process "mmm" nil 0 nil "-external" url)) | |
1188 (message "Sending URL to MMM... done"))) | |
1189 | |
1190 ;; --- mailto --- | |
1191 | |
1192 ;;;###autoload | |
1193 (defun browse-url-mail (url &optional new-window) | |
1194 "Open a new mail message buffer within Emacs. | |
1195 Default to using the mailto: URL around or before point as the | |
1196 recipient's address. Supplying a non-nil interactive prefix argument | |
1197 will cause the mail to be composed in another window rather than the | |
1198 current one. | |
1199 | |
37378
c5e0aa9cbe69
(browse-url-new-window-flag): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35008
diff
changeset
|
1200 When called interactively, if variable `browse-url-new-window-flag' is |
28210 | 1201 non-nil use `compose-mail-other-window', otherwise `compose-mail'. A |
1202 non-nil interactive prefix argument reverses the effect of | |
37378
c5e0aa9cbe69
(browse-url-new-window-flag): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35008
diff
changeset
|
1203 `browse-url-new-window-flag'. |
28210 | 1204 |
1205 When called non-interactively, optional second argument NEW-WINDOW is | |
37378
c5e0aa9cbe69
(browse-url-new-window-flag): Renamed from
Gerd Moellmann <gerd@gnu.org>
parents:
35008
diff
changeset
|
1206 used instead of `browse-url-new-window-flag'." |
28210 | 1207 (interactive (browse-url-interactive-arg "Mailto URL: ")) |
1208 (save-excursion | |
1209 (let ((to (if (string-match "^mailto:" url) | |
1210 (substring url 7) | |
1211 url))) | |
28274
e9c99955f520
Restore previous use of browse-url-maybe-new-window.
Dave Love <fx@gnu.org>
parents:
28210
diff
changeset
|
1212 (if (browse-url-maybe-new-window new-window) |
28210 | 1213 (compose-mail-other-window to nil nil nil |
1214 (list 'insert-buffer (current-buffer))) | |
1215 (compose-mail to nil nil nil nil | |
1216 (list 'insert-buffer (current-buffer))))))) | |
1217 | |
1218 ;; --- Random browser --- | |
1219 | |
1220 ;;;###autoload | |
1221 (defun browse-url-generic (url &optional new-window) | |
1222 ;; new-window ignored | |
1223 "Ask the WWW browser defined by `browse-url-generic-program' to load URL. | |
1224 Default to the URL around or before point. A fresh copy of the | |
1225 browser is started up in a new process with possible additional arguments | |
1226 `browse-url-generic-args'. This is appropriate for browsers which | |
1227 don't offer a form of remote control." | |
1228 (interactive (browse-url-interactive-arg "URL: ")) | |
1229 (if (not browse-url-generic-program) | |
1230 (error "No browser defined (`browse-url-generic-program')")) | |
1231 (apply 'start-process (concat browse-url-generic-program url) nil | |
1232 browse-url-generic-program | |
1233 (append browse-url-generic-args (list url)))) | |
1234 | |
37803
ae3f8f955b05
(browse-url-browser-function): Add kde.
Gerd Moellmann <gerd@gnu.org>
parents:
37666
diff
changeset
|
1235 ;;;###autoload |
ae3f8f955b05
(browse-url-browser-function): Add kde.
Gerd Moellmann <gerd@gnu.org>
parents:
37666
diff
changeset
|
1236 (defun browse-url-kde (url &optional new-window) |
ae3f8f955b05
(browse-url-browser-function): Add kde.
Gerd Moellmann <gerd@gnu.org>
parents:
37666
diff
changeset
|
1237 "Ask the KDE WWW browser to load URL. |
ae3f8f955b05
(browse-url-browser-function): Add kde.
Gerd Moellmann <gerd@gnu.org>
parents:
37666
diff
changeset
|
1238 Default to the URL around or before point." |
ae3f8f955b05
(browse-url-browser-function): Add kde.
Gerd Moellmann <gerd@gnu.org>
parents:
37666
diff
changeset
|
1239 (interactive (browse-url-interactive-arg "KDE URL: ")) |
ae3f8f955b05
(browse-url-browser-function): Add kde.
Gerd Moellmann <gerd@gnu.org>
parents:
37666
diff
changeset
|
1240 (message "Sending URL to KDE...") |
ae3f8f955b05
(browse-url-browser-function): Add kde.
Gerd Moellmann <gerd@gnu.org>
parents:
37666
diff
changeset
|
1241 (apply #'start-process `(,(concat "KDE" url) nil ,browse-url-kde-program |
ae3f8f955b05
(browse-url-browser-function): Add kde.
Gerd Moellmann <gerd@gnu.org>
parents:
37666
diff
changeset
|
1242 ,@browse-url-kde-args ,url))) |
ae3f8f955b05
(browse-url-browser-function): Add kde.
Gerd Moellmann <gerd@gnu.org>
parents:
37666
diff
changeset
|
1243 |
28210 | 1244 (provide 'browse-url) |
1245 | |
1246 ;;; browse-url.el ends here |