annotate lisp/browse-url.el @ 17553:1dc9754cbf8e

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