annotate lisp/utils/browse-url.el @ 70:131b0175ea99 r20-0b30

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