annotate lisp/browse-url.el @ 20210:622d0b6c6445

(byte-optimize-concat): New function.
author Karl Heuer <kwzh@gnu.org>
date Mon, 03 Nov 1997 03:58:23 +0000
parents 5bd2ed765d52
children dfd02d692b0c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
18253
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
1 ;;; browse-url.el --- Pass a URL to a WWW browser
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13938
diff changeset
2
18253
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
3 ;; Copyright 1995, 1996, 1997 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>
18224
0e98af37970d Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 17975
diff changeset
6 ;; Maintainer: Dave Love <d.love@dl.ac.uk>
13208
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7 ;; Created: 03 Apr 1995
18253
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
8 ;; Keywords: hypertext, hypermedia, mouse
13208
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
18253
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
42 ;; browse-url-netscape Netscape 1.1b1
20167
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
43 ;; browse-url-mosaic XMosaic/mMosaic <= 2.4
13208
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
18253
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
46 ;; browse-url-w3-gnudoit w3 remotely
13208
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
47 ;; browse-url-iximosaic IXI Mosaic ?
16415
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
48 ;; browse-url-lynx-* Lynx 0
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
49 ;; browse-url-grail Grail 0.3b1
18253
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
50 ;; browse-url-mmm MMM ?
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
51 ;; browse-url-generic arbitrary
13208
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
52
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
53 ;; Note that versions of Netscape before 1.1b1 did not have remote
18253
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
54 ;; control. <URL:http://www.netscape.com/newsref/std/x-remote.html>.
13208
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
55
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
56 ;; 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
57 ;; 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
58 ;; it). There is currently no perfect automatic solution to this.
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
59
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
60 ;; 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
61 ;; 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
62 ;; discover its id?
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
63
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
64 ;; If using XMosaic before version 2.5, check the definition of
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
65 ;; browse-url-usr1-signal below.
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
66 ;; <URL:http://www.ncsa.uiuc.edu/SDG/Software/XMosaic/remote-control.html>
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
67
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
68 ;; XMosaic version 2.5 introduced Common Client Interface allowing you
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
69 ;; to control mosaic through Unix sockets.
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
70 ;; <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
71
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
72 ;; William M. Perry's excellent "w3" WWW browser for
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
73 ;; Emacs <URL:ftp://cs.indiana.edu/pub/elisp/w3/>
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
74 ;; has a function w3-follow-url-at-point, but that
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
75 ;; doesn't let you edit the URL like browse-url.
18253
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
76 ;; The `gnuserv' package that can be used to control it in another
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
77 ;; Emacs process is available from
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
78 ;; <URL:http://hplbwww.hpl.hp.com/people/ange/gnuserv/>.
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
79
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
80 ;; Grail is the freely available WWW browser implemented in Python, a
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
81 ;; cool object-oriented freely available interpreted language. Grail
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
82 ;; 0.3b1 was the first version to have remote control as distributed.
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
83 ;; For more information on Grail see
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
84 ;; <URL:http://grail.cnri.reston.va.us/> and for more information on
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
85 ;; Python see <url:http://www.python.org/>. Grail support in
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
86 ;; browse-url.el written by Barry Warsaw <bwarsaw@python.org>.
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
87
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
88 ;; MMM is the freely available WWW browser implemented in Caml Special
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
89 ;; Light, a cool impure functional programming language, by Francois
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
90 ;; Rouaix. See the MMM home page
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
91 ;; <URL:http://pauillac.inria.fr/%7Erouaix/mmm/>.
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
92
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
93 ;; Lynx is now distributed by the FSF. See also
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
94 ;; <URL:http://lynx.browser.org/>.
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
95
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
96 ;; Free graphical browsers that could be used by `browse-url-generic'
19442
5b3f4890f757 Minor doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18611
diff changeset
97 ;; include Chimera <URL:ftp://ftp.cs.unlv.edu/pub/chimera> and
5b3f4890f757 Minor doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18611
diff changeset
98 ;; <URL:http://www.unlv.edu/chimera/>, Arena
20167
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
99 ;; <URL:ftp://ftp.yggdrasil.com/pub/dist/web/arena> and Amaya
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
100 ;; <URL:ftp://ftp.w3.org/pub/amaya>. mMosaic
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
101 ;; <URL:ftp://sig.enst.fr/pub/multicast/mMosaic/> (with development
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
102 ;; support for Java applets and multicast) can be used like Mosaic by
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
103 ;; setting `browse-url-mosaic-program' appropriately.
13208
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
104
19583
5c7badcafb2b (browse-url-mail): Use compose-mail[-other-window], not always `mail'.
Richard M. Stallman <rms@gnu.org>
parents: 19579
diff changeset
105 ;; I [Denis Howe] recommend Nelson Minar <nelson@santafe.edu>'s excellent
13208
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
106 ;; html-helper-mode.el for editing HTML and thank Nelson for
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
107 ;; his many useful comments on this code.
18253
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
108 ;; <URL:http://www.santafe.edu/%7Enelson/hhm-beta/>
13208
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
109
19583
5c7badcafb2b (browse-url-mail): Use compose-mail[-other-window], not always `mail'.
Richard M. Stallman <rms@gnu.org>
parents: 19579
diff changeset
110 ;; See also hm--html-menus <URL:http://www.tnt.uni-hannover.de/%7Emuenkel/
5c7badcafb2b (browse-url-mail): Use compose-mail[-other-window], not always `mail'.
Richard M. Stallman <rms@gnu.org>
parents: 19579
diff changeset
111 ;; software/own/hm--html-menus/>. For composing correct HTML see also
5c7badcafb2b (browse-url-mail): Use compose-mail[-other-window], not always `mail'.
Richard M. Stallman <rms@gnu.org>
parents: 19579
diff changeset
112 ;; PSGML the general SGML structure editor package
5c7badcafb2b (browse-url-mail): Use compose-mail[-other-window], not always `mail'.
Richard M. Stallman <rms@gnu.org>
parents: 19579
diff changeset
113 ;; <URL:ftp://ftp.lysator.liu.se/pub/sgml>; hm--html-menus can be used
5c7badcafb2b (browse-url-mail): Use compose-mail[-other-window], not always `mail'.
Richard M. Stallman <rms@gnu.org>
parents: 19579
diff changeset
114 ;; with this.
5c7badcafb2b (browse-url-mail): Use compose-mail[-other-window], not always `mail'.
Richard M. Stallman <rms@gnu.org>
parents: 19579
diff changeset
115
13208
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
116 ;; This package generalises function html-previewer-process in Marc
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
117 ;; Andreessen <marca@ncsa.uiuc.edu>'s html-mode (LCD
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
118 ;; modes/html-mode.el.Z) and provides better versions of the URL
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
119 ;; functions in Michelangelo Grigni <mic@cs.ucsd.edu>'s ffap.el
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
120 ;; (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
121 ;; hyperbole package also contains similar functions.
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
122
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
123 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
124 ;; Help!
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
125
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
126 ;; Can you write and test some code for the Macintrash and Windoze
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
127 ;; Netscape remote control APIs? (See the URL above).
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
128
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
129 ;; Do any other browsers have remote control?
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
130
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
131 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
132 ;; Usage
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
133
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
134 ;; To display the URL at or before point:
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
135 ;; M-x browse-url-at-point RET
18253
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
136 ;; or, similarly but with the opportunity to edit the URL extracted from
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
137 ;; the buffer, use:
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
138 ;; M-x browse-url
13208
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
139
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
140 ;; 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
141 ;; file:
13933
efd6ce432dc5 (browse-url-mosaic): Print "done" message
Richard M. Stallman <rms@gnu.org>
parents: 13224
diff changeset
142 ;; (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
143 ;; (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
144 ;; that event has a standard meaning in Emacs.)
13208
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
145
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
146 ;; To display the current buffer in a web browser:
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
147 ;; M-x browse-url-of-buffer RET
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
148
18253
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
149 ;; To display the current region in a web browser:
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
150 ;; M-x browse-url-of-region RET
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
151
13208
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
152 ;; In Dired, to display the file named on the current line:
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
153 ;; M-x browse-url-of-dired-file RET
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 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
156 ;; Customisation (~/.emacs)
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
157
16415
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
158 ;; To see what variables are available for customization, type
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
159 ;; `M-x set-variable browse-url TAB'.
13208
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
160
16415
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
161 ;; 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
162 ;; (as used by html-helper-mode):
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
163 ;; (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
164 ;; (global-set-key "\C-c\C-zb" 'browse-url-of-buffer)
18253
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
165 ;; (global-set-key "\C-c\C-zr" 'browse-url-of-region)
16415
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
166 ;; (global-set-key "\C-c\C-zu" 'browse-url)
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
167 ;; (global-set-key "\C-c\C-zv" 'browse-url-of-file)
18253
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
168 ;; (add-hook 'dired-mode-hook
16415
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
169 ;; (function (lambda ()
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
170 ;; (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
171
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
172 ;; Browse URLs in mail messages by clicking mouse-2:
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
173 ;; (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
174 ;; (define-key rmail-mode-map [mouse-2] 'browse-url-at-mouse))))
13208
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
175
16415
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
176 ;; Browse URLs in Usenet messages by clicking mouse-2:
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
177 ;; (eval-after-load "gnus"
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
178 ;; '(define-key gnus-article-mode-map [mouse-2] 'browse-url-at-mouse))
19583
5c7badcafb2b (browse-url-mail): Use compose-mail[-other-window], not always `mail'.
Richard M. Stallman <rms@gnu.org>
parents: 19579
diff changeset
179 ;; [The current version of Gnus provides a standard feature to
5c7badcafb2b (browse-url-mail): Use compose-mail[-other-window], not always `mail'.
Richard M. Stallman <rms@gnu.org>
parents: 19579
diff changeset
180 ;; activate URLs in article buffers for invocation of browse-url with
5c7badcafb2b (browse-url-mail): Use compose-mail[-other-window], not always `mail'.
Richard M. Stallman <rms@gnu.org>
parents: 19579
diff changeset
181 ;; mouse-2.]
16415
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
182
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
183 ;; 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
184 ;; (or (eq window-system 'x)
18253
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
185 ;; (setq browse-url-browser-function 'browse-url-w3))
13208
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
186
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
187 ;; To always save modified buffers before displaying the file in a browser:
18253
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
188 ;; (setq browse-url-save-file t)
13208
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
189
16415
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
190 ;; 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
191 ;; write-file in html-helper-mode make Netscape reload the document:
13208
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
192 ;;
18253
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
193 ;; (autoload 'browse-url-netscape-reload "browse-url"
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
194 ;; "Ask a WWW browser to redisplay the current file." t)
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
195 ;; (add-hook 'html-helper-mode-hook
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
196 ;; (function (lambda ()
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
197 ;; (add-hook 'local-write-file-hooks
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
198 ;; (function (lambda ()
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
199 ;; (let ((local-write-file-hooks))
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
200 ;; (save-buffer))
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
201 ;; (browse-url-netscape-reload)
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
202 ;; t)) ; => file written by hook
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
203 ;; t)))) ; append to l-w-f-hooks
13208
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
204 ;;
16415
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
205 ;; 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
206 ;; file:
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
207 ;;
18253
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
208 ;; (add-hook 'browse-url-of-file-hook 'browse-url-netscape-reload)
13208
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
209
16415
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
210 ;; You may also want to customise browse-url-netscape-arguments, e.g.
18253
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
211 ;; (setq browse-url-netscape-arguments '("-install"))
13208
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
212 ;;
18253
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
213 ;; or similarly for the other browsers.
13208
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
214
18253
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
215 ;; To invoke different browsers for different URLs:
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
216 ;; (setq browse-url-browser-function '(("^mailto:" . browse-url-mail)
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
217 ;; ("." . browse-url-netscape)))
13208
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
218
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
219 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
220 ;;; Code:
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
221
18611
a3267de991c3 Require thingatpt when compiling.
Richard M. Stallman <rms@gnu.org>
parents: 18253
diff changeset
222 (eval-when-compile (require 'dired)
a3267de991c3 Require thingatpt when compiling.
Richard M. Stallman <rms@gnu.org>
parents: 18253
diff changeset
223 (require 'thingatpt))
16415
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
224
18253
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
225 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
226 ;; Variables
13208
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
227
17443
02751f3ecbdd Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16670
diff changeset
228 (defgroup browse-url nil
02751f3ecbdd Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16670
diff changeset
229 "Use a web browser to look at a URL."
19579
bbb59d8bca28 Change the custom group to `hypermedia'.
Richard M. Stallman <rms@gnu.org>
parents: 19443
diff changeset
230 :group 'hypermedia)
16415
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
231
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
232 ;;;###autoload
17443
02751f3ecbdd Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16670
diff changeset
233 (defcustom browse-url-browser-function
16415
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
234 'browse-url-netscape
13208
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
235 "*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
236 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
237 `browse-url-of-file' commands.
18253
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
238
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
239 If the value is not a function it should be a list of pairs
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
240 (REGEXP.FUNCTION). In this case the function called will be the one
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
241 associated with the first REGEXP which matches the current URL. The
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
242 function is passed the URL and any other args of `browse-url'. The last
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
243 regexp should probably be \".\" to specify a default browser."
17443
02751f3ecbdd Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16670
diff changeset
244 :type 'function
02751f3ecbdd Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16670
diff changeset
245 :group 'browse-url)
13208
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
246
17443
02751f3ecbdd Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16670
diff changeset
247 (defcustom browse-url-netscape-program "netscape"
02751f3ecbdd Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16670
diff changeset
248 "*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
249 :type 'string
02751f3ecbdd Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16670
diff changeset
250 :group 'browse-url)
15656
e73cd7ff1d4a (browse-url-netscape-program): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 14734
diff changeset
251
17443
02751f3ecbdd Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16670
diff changeset
252 (defcustom browse-url-netscape-arguments nil
02751f3ecbdd Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16670
diff changeset
253 "*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
254 :type '(repeat (string :tag "Argument"))
02751f3ecbdd Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16670
diff changeset
255 :group 'browse-url)
13208
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
256
17443
02751f3ecbdd Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16670
diff changeset
257 (defcustom browse-url-netscape-startup-arguments browse-url-netscape-arguments
20167
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
258 "*A list of strings to pass to Netscape when it start up.
17443
02751f3ecbdd Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16670
diff changeset
259 Defaults to the value of `browse-url-netscape-arguments' at the time
18253
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
260 `browse-url' is loaded."
17443
02751f3ecbdd Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16670
diff changeset
261 :type '(repeat (string :tag "Argument"))
02751f3ecbdd Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16670
diff changeset
262 :group 'browse-url)
16415
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
263
17443
02751f3ecbdd Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16670
diff changeset
264 (defcustom browse-url-new-window-p nil
13208
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
265 "*If non-nil, always open a new browser window.
20167
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
266 Passing an interactive argument to \\[browse-url-netscape],
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
267 \\[browse-url-mosaic] or \\[browse-url-cci] reverses the effect of
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
268 this variable. Requires Netscape version 1.1N or later or XMosaic
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
269 version 2.5 or later."
17443
02751f3ecbdd Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16670
diff changeset
270 :type 'boolean
02751f3ecbdd Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16670
diff changeset
271 :group 'browse-url)
13208
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
272
18253
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
273 (defcustom browse-url-netscape-display nil
20167
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
274 "*The X display for running Netscape, if not same as Emacs'."
20016
14f83589db18 (browse-url-netscape-display): Fix customize type.
Karl Heuer <kwzh@gnu.org>
parents: 19835
diff changeset
275 :type '(choice string (const nil))
18253
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
276 :group 'browse-url)
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
277
20167
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
278 (defcustom browse-url-mosaic-program "xmosaic"
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
279 "*The name by which to invoke Mosaic (or mMosaic)."
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
280 :type 'string
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
281 :group 'browse-url)
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
282
17443
02751f3ecbdd Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16670
diff changeset
283 (defcustom browse-url-mosaic-arguments nil
02751f3ecbdd Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16670
diff changeset
284 "*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
285 :type '(repeat (string :tag "Argument"))
02751f3ecbdd Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 16670
diff changeset
286 :group 'browse-url)
13208
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
287
18253
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
288 (defvar browse-url-path-regexp
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
289 "[^]\t\n \"'()<>[^`{}]*[^]\t\n \"'()<>[^`{}.,;]+"
19443
39815ec1b9f8 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 19442
diff changeset
290 "A regular expression to match the host, path or e-mail part of a URL.")
18253
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
291
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
292 (defvar browse-url-short-regexp
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
293 (concat "[-A-Za-z0-9.]+" browse-url-path-regexp)
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
294 "A regular expression probably matching a URL without an access scheme.
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
295 Hostname matching is stricter in this case than for
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
296 ``browse-url-regexp''.")
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
297
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
298 (defvar browse-url-regexp
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
299 (concat
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
300 "\\(https?://\\|ftp://\\|gopher://\\|telnet://\\|wais://\\|file:/\\|s?news:\\|mailto:\\)"
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
301 browse-url-path-regexp)
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
302 "A regular expression probably matching a complete URL.")
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
303
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
304 (defvar browse-url-markedup-regexp
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
305 "<URL:[^>]+>"
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
306 "A regular expression matching a URL marked up per RFC1738.
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
307 This may be broken across lines.")
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
308
13208
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
309 (defvar browse-url-filename-alist
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
310 '(("^/+" . "file:/"))
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
311 "An alist of (REGEXP . STRING) pairs.
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
312 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
313 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
314 The default value prepends `file:' to any path beginning with `/'.
18253
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
315 Used by the `browse-url-of-file' command.
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
316
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
317 For example, to map EFS filenames to URLs:
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
318
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
319 (setq browse-url-filename-alist
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
320 '((\"/webmaster@webserver:/home/www/html/\" .
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
321 \"http://www.acme.co.uk/\")
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
322 (\"^/+\" . \"file:/\")))
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
323 ")
13208
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
324
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
325 (defvar browse-url-save-file nil
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
326 "If non-nil, save the buffer before displaying its file.
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
327 Used by the `browse-url-of-file' command.")
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
328
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
329 (defvar browse-url-of-file-hook nil
20167
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
330 "Run after `browse-url-of-file' has asked a browser to load a file.
13208
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
331
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
332 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
333 file rather than displaying a cached copy.")
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
334
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
335 (defvar browse-url-usr1-signal
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
336 (if (and (boundp 'emacs-major-version)
18253
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
337 (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
338 'SIGUSR1 ; Why did I think this was in lower case before?
18253
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
339 30) ; Check /usr/include/signal.h.
13208
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
340 "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
341 Emacs 19.29 accepts 'SIGUSR1, earlier versions require an integer
13208
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
342 which is 30 on SunOS and 16 on HP-UX and Solaris.")
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
343
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
344 (defvar browse-url-CCI-port 3003
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
345 "Port to access XMosaic via CCI.
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
346 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
347 the value set in the browser.")
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
348
16415
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
349 (defvar browse-url-CCI-host "localhost"
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
350 "*Host to access XMosaic via CCI.
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
351 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
352 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
353
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
354 (defvar browse-url-temp-file-name nil)
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
355 (make-variable-buffer-local 'browse-url-temp-file-name)
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
356
18253
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
357 (defcustom browse-url-xterm-program "xterm"
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
358 "*The name of the terminal emulator used by `browse-url-lynx-xterm'.
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
359 This might, for instance, be a separate colour version of xterm."
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
360 :type 'string
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
361 :group 'browse-url)
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
362
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
363 (defcustom browse-url-xterm-args nil
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
364 "*A list of strings defining options for `browse-url-xterm-program'.
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
365 These might set its size, for instance."
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
366 :type '(repeat (string :tag "Argument"))
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
367 :group 'browse-url)
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
368
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
369 (defcustom browse-url-gnudoit-program "gnudoit"
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
370 "*The name of the `gnudoit' program used by `browse-url-w3-gnudoit'."
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
371 :type 'string
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
372 :group 'browse-url)
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
373
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
374 (defcustom browse-url-gnudoit-args '("-q")
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
375 "*A list of strings defining options for `browse-url-gnudoit-program'.
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
376 These might set the port, for instance."
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
377 :type '(repeat (string :tag "Argument"))
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
378 :group 'browse-url)
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
379
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
380 (defcustom browse-url-generic-program nil
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
381 "*The name of the browser program used by `browse-url-generic'."
20016
14f83589db18 (browse-url-netscape-display): Fix customize type.
Karl Heuer <kwzh@gnu.org>
parents: 19835
diff changeset
382 :type '(choice string (const nil))
18253
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
383 :group 'browse-url)
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
384
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
385 (defcustom browse-url-generic-args nil
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
386 "*A list of strings defining options for `browse-url-generic-program'."
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
387 :type '(repeat (string :tag "Argument"))
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
388 :group 'browse-url)
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
389
19442
5b3f4890f757 Minor doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18611
diff changeset
390 (defcustom browse-url-temp-dir
5b3f4890f757 Minor doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18611
diff changeset
391 (or (getenv "TMPDIR") "/tmp")
20167
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
392 "*The name of a directory for browse-url's temporary files.
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
393 Such files are generated by functions like `browse-url-of-region'.
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
394 You might want to set this to somewhere with restricted read permissions
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
395 for privacy's sake."
19442
5b3f4890f757 Minor doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18611
diff changeset
396 :type 'string
5b3f4890f757 Minor doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18611
diff changeset
397 :group 'browse-url)
5b3f4890f757 Minor doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18611
diff changeset
398
19579
bbb59d8bca28 Change the custom group to `hypermedia'.
Richard M. Stallman <rms@gnu.org>
parents: 19443
diff changeset
399 (defcustom browse-url-netscape-version
bbb59d8bca28 Change the custom group to `hypermedia'.
Richard M. Stallman <rms@gnu.org>
parents: 19443
diff changeset
400 3
bbb59d8bca28 Change the custom group to `hypermedia'.
Richard M. Stallman <rms@gnu.org>
parents: 19443
diff changeset
401 "*The version of Netscape you are using.
bbb59d8bca28 Change the custom group to `hypermedia'.
Richard M. Stallman <rms@gnu.org>
parents: 19443
diff changeset
402 This affects how URL reloading is done; the mechanism changed
bbb59d8bca28 Change the custom group to `hypermedia'.
Richard M. Stallman <rms@gnu.org>
parents: 19443
diff changeset
403 incompatibly at version 4."
bbb59d8bca28 Change the custom group to `hypermedia'.
Richard M. Stallman <rms@gnu.org>
parents: 19443
diff changeset
404 :type 'number
bbb59d8bca28 Change the custom group to `hypermedia'.
Richard M. Stallman <rms@gnu.org>
parents: 19443
diff changeset
405 :group 'browse-url)
bbb59d8bca28 Change the custom group to `hypermedia'.
Richard M. Stallman <rms@gnu.org>
parents: 19443
diff changeset
406
20167
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
407 (defvar browse-url-lynx-input-field 'avoid
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
408 "*Action on selecting an existing Lynx buffer at an input field.
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
409 What to do when sending a new URL to an existing Lynx buffer in Emacs
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
410 if the Lynx cursor is on an input field (in which case the `g' command
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
411 would be entered as data). Such fields are recognized by the
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
412 underlines ____. Allowed values: nil: disregard it, 'warn: warn the
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
413 user and don't emit the URL, 'avoid: try to avoid the field by moving
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
414 down (this *won't* always work).")
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
415
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
416 (defvar browse-url-lynx-input-attempts 10
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
417 "*How many times to try to move down from a series of lynx input fields.")
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
418
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
419 (defvar browse-url-lynx-input-delay 0.2
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
420 "*How many seconds to wait for lynx between moves down from an input field.")
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
421
16415
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
422 (defvar browse-url-temp-file-list '())
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
423
13208
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
424 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
425 ;; URL input
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
426
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
427 (defun browse-url-url-at-point ()
18611
a3267de991c3 Require thingatpt when compiling.
Richard M. Stallman <rms@gnu.org>
parents: 18253
diff changeset
428 (let ((url (thing-at-point 'url)))
a3267de991c3 Require thingatpt when compiling.
Richard M. Stallman <rms@gnu.org>
parents: 18253
diff changeset
429 (set-text-properties 0 (length url) nil url)
18253
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
430 url))
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
431
16415
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
432 ;; 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
433 ;; 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
434 ;; to switch between browsers.
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
435
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
436 (defun browse-url-interactive-arg (prompt)
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
437 "Read a URL from the minibuffer, prompting with PROMPT.
19442
5b3f4890f757 Minor doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18611
diff changeset
438 Default to the URL at or before point. If invoked with a mouse button,
16415
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
439 set point to the position clicked first. Return a list for use in
18253
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
440 `interactive' containing the URL and `browse-url-new-window-p' or its
16415
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
441 negation if a prefix argument was given."
13208
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
442 (let ((event (elt (this-command-keys) 0)))
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
443 (and (listp event) (mouse-set-point event)))
16415
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
444 (list (read-string prompt (browse-url-url-at-point))
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
445 (not (eq (null browse-url-new-window-p)
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
446 (null current-prefix-arg)))))
13208
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
447
20167
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
448 (defun browse-url-maybe-new-window (arg)
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
449 (if (interactive-p)
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
450 arg
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
451 browse-url-new-window-p))
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
452
13208
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
453 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
454 ;; Browse current buffer
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
455
16416
c7622616333c (browse-url-at-point): Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents: 16415
diff changeset
456 ;;;###autoload
13208
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
457 (defun browse-url-of-file (&optional file)
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
458 "Ask a WWW browser to display FILE.
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
459 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
460 interactively. Turn the filename into a URL with function
18253
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
461 `browse-url-file-url'. Pass the URL to a browser using the
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
462 `browse-url' function then run `browse-url-of-file-hook'."
13208
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
463 (interactive)
18253
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
464 (or file
16415
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
465 (setq file (buffer-file-name))
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
466 (error "Current buffer has no file"))
13208
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
467 (let ((buf (get-file-buffer file)))
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
468 (if buf
18253
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
469 (save-excursion
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
470 (set-buffer buf)
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
471 (cond ((not (buffer-modified-p)))
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
472 (browse-url-save-file (save-buffer))
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
473 (t (message "%s modified since last save" file))))))
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
474 (browse-url (browse-url-file-url file))
13208
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
475 (run-hooks 'browse-url-of-file-hook))
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
476
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
477 (defun browse-url-file-url (file)
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
478 "Return the URL corresponding to FILE.
16415
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
479 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
480 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
481 ;; URL-encode special chars, do % first
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
482 (let ((s 0))
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
483 (while (setq s (string-match "%" file s))
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
484 (setq file (replace-match "%25" t t file)
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
485 s (1+ s))))
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
486 (while (string-match "[*\"()',=;? ]" file)
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
487 (let ((enc (format "%%%x" (aref file (match-beginning 0)))))
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
488 (setq file (replace-match enc t t file))))
13208
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
489 (let ((maps browse-url-filename-alist))
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
490 (while maps
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
491 (let* ((map (car maps))
18253
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
492 (from-re (car map))
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
493 (to-string (cdr map)))
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
494 (setq maps (cdr maps))
16415
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
495 (and (string-match from-re file)
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
496 (setq file (replace-match to-string t t file))))))
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
497 ;; Check for EFS path
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
498 (and (string-match "^/\\([^:@]+@\\)?\\([^:]+\\):/*" file)
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
499 (setq file (concat "ftp://"
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
500 (substring file (match-beginning 2) (match-end 2))
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
501 "/" (substring file (match-end 0)))))
13208
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
502 file)
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
503
16416
c7622616333c (browse-url-at-point): Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents: 16415
diff changeset
504 ;;;###autoload
13208
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
505 (defun browse-url-of-buffer (&optional buffer)
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
506 "Ask a WWW browser to display BUFFER.
18253
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
507 Display the current buffer if BUFFER is nil. Display only the
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
508 currently visible part of BUFFER (from a temporary file) if buffer is
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
509 narrowed."
13208
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
510 (interactive)
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
511 (save-excursion
16415
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
512 (and buffer (set-buffer buffer))
13208
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
513 (let ((file-name
18253
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
514 ;; Ignore real name if restricted
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
515 (and (= (- (point-max) (point-min)) (buffer-size))
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
516 (or buffer-file-name
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
517 (and (boundp 'dired-directory) dired-directory)))))
16415
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
518 (or file-name
18253
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
519 (progn
16415
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
520 (or browse-url-temp-file-name
18253
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
521 (setq browse-url-temp-file-name
19442
5b3f4890f757 Minor doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18611
diff changeset
522 (convert-standard-filename
5b3f4890f757 Minor doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18611
diff changeset
523 (make-temp-name
5b3f4890f757 Minor doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18611
diff changeset
524 (expand-file-name "burl" browse-url-temp-dir)))))
16415
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
525 (setq file-name browse-url-temp-file-name)
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
526 (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
527 (browse-url-of-file file-name))))
13208
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
528
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
529 (defun browse-url-delete-temp-file (&optional temp-file-name)
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
530 ;; Delete browse-url-temp-file-name from the file system and from
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
531 ;; browse-url-temp-file-list. If optional arg TEMP-FILE-NAME is
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
532 ;; non-nil, delete it instead, but only from the file system --
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
533 ;; browse-url-temp-file-list is not affected.
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
534 (let ((file-name (or temp-file-name browse-url-temp-file-name)))
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
535 (if (and file-name (file-exists-p file-name))
18253
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
536 (progn
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
537 (delete-file file-name)
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
538 (if (null temp-file-name)
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
539 (setq browse-url-temp-file-list
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
540 (delete browse-url-temp-file-name
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
541 browse-url-temp-file-list)))))))
13208
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
542
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
543 (defun browse-url-delete-temp-file-list ()
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
544 ;; Delete all elements of browse-url-temp-file-list.
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
545 (while browse-url-temp-file-list
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
546 (browse-url-delete-temp-file (car browse-url-temp-file-list))
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
547 (setq browse-url-temp-file-list
18253
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
548 (cdr browse-url-temp-file-list))))
13208
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
549
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
550 (add-hook 'kill-buffer-hook 'browse-url-delete-temp-file)
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
551 (add-hook 'kill-emacs-hook 'browse-url-delete-temp-file-list)
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
552
16416
c7622616333c (browse-url-at-point): Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents: 16415
diff changeset
553 ;;;###autoload
13208
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
554 (defun browse-url-of-dired-file ()
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
555 "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
556 (interactive)
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
557 (browse-url-of-file (dired-get-filename)))
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
558
18253
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
559 ;;;###autoload
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
560 (defun browse-url-of-region (min max)
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
561 "Ask a WWW browser to display the current region."
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
562 (interactive "r")
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
563 (save-excursion
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
564 (save-restriction
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
565 (narrow-to-region (mark) (point))
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
566 (browse-url-of-buffer))))
16415
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
567
18253
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
568 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
569 ;; Browser-independent commands
16415
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
570
18253
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
571 ;; A generic command to call the current browse-url-browser-function
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
572
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
573 ;;;###autoload
16415
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
574 (defun browse-url (&rest args)
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
575 "Ask a WWW browser to load URL.
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
576 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
577 `browse-url-browser-function' says which browser to use."
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
578 (interactive (browse-url-interactive-arg "URL: "))
18253
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
579 (if (consp browse-url-browser-function)
20167
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
580 (apply browse-url-choose-browser args)
18253
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
581 (apply browse-url-browser-function args)))
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
582
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
583 (defun browse-url-choose-browser (url &rest args)
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
584 "Pass URL to a browser function chosen.
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
585 This is done according to the association list in variable
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
586 `browse-url-browser-function'."
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
587 (let ((blist browse-url-browser-function)
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
588 re bf)
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
589 (while (consp blist)
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
590 (setq re (car (car blist))
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
591 bf (cdr (car blist))
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
592 blist (cdr blist))
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
593 (if (string-match re url)
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
594 (progn (apply bf url args) (setq blist t))))
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
595 (or blist
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
596 (error "No browser in browse-url-browser-function matching URL %s" url))))
16415
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
597
16416
c7622616333c (browse-url-at-point): Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents: 16415
diff changeset
598 ;;;###autoload
16415
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
599 (defun browse-url-at-point ()
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
600 "Ask a WWW browser to load the URL at or before point.
20167
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
601 Doesn't let you edit the URL like `browse-url'. Variable
16415
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
602 `browse-url-browser-function' says which browser to use."
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
603 (interactive)
18253
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
604 (browse-url (browse-url-url-at-point)))
16415
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
605
17802
77d8356a7eed (browse-url-event-buffer):
Richard M. Stallman <rms@gnu.org>
parents: 17456
diff changeset
606 (defun browse-url-event-buffer (event)
77d8356a7eed (browse-url-event-buffer):
Richard M. Stallman <rms@gnu.org>
parents: 17456
diff changeset
607 (window-buffer (posn-window (event-start event))))
16415
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
608
17802
77d8356a7eed (browse-url-event-buffer):
Richard M. Stallman <rms@gnu.org>
parents: 17456
diff changeset
609 (defun browse-url-event-point (event)
77d8356a7eed (browse-url-event-buffer):
Richard M. Stallman <rms@gnu.org>
parents: 17456
diff changeset
610 (posn-point (event-start event)))
13208
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
611
16416
c7622616333c (browse-url-at-point): Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents: 16415
diff changeset
612 ;;;###autoload
16415
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
613 (defun browse-url-at-mouse (event)
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
614 "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
615 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
616 but point is not changed. Doesn't let you edit the URL like
20167
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
617 `browse-url'. Variable `browse-url-browser-function' says which browser
16415
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
618 to use."
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
619 (interactive "e")
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
620 (save-excursion
17802
77d8356a7eed (browse-url-event-buffer):
Richard M. Stallman <rms@gnu.org>
parents: 17456
diff changeset
621 (set-buffer (browse-url-event-buffer event))
77d8356a7eed (browse-url-event-buffer):
Richard M. Stallman <rms@gnu.org>
parents: 17456
diff changeset
622 (goto-char (browse-url-event-point event))
16415
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
623 (let ((url (browse-url-url-at-point)))
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
624 (if (string-equal url "")
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
625 (error "No URL found"))
20167
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
626 (browse-url url browse-url-new-window-p))))
16415
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
627
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
628 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
629 ;; Browser-specific commands
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
630
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
631 ;; --- Netscape ---
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
632
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
633 (defun browse-url-process-environment ()
18253
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
634 "Set DISPLAY in the environment to the X display Netscape is running on.
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
635 This is either the value of variable `browse-url-netscape-display' if
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
636 non-nil, or the same display as Emacs if different from the current
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
637 environment, otherwise just use the current environment."
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
638 (let ((display (or browse-url-netscape-display (browse-url-emacs-display))))
16415
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
639 (if display
18253
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
640 (cons (concat "DISPLAY=" display) process-environment)
16415
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
641 process-environment)))
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
642
18253
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
643 (defun browse-url-emacs-display ()
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
644 "Return the X display Emacs is running on.
20167
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
645 This is nil if the display is the same as the DISPLAY environment variable.
18253
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
646
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
647 Actually Emacs could be using several screens on several displays, as
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
648 listed by (emacs-display-list) and (x-display-screens DISPLAY), this
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
649 just returns the display showing the selected frame. You got a
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
650 problem with that?"
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
651 (let (device display)
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
652 (and (fboundp 'selected-device) (fboundp 'device-type) (fboundp 'device-connection)
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
653 (setq device (selected-device))
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
654 (eq (device-type device) 'x)
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
655 (setq display (device-connection device))
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
656 (not (equal display (getenv "DISPLAY")))
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
657 display)))
16415
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
658
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
659 ;;;###autoload
13208
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
660 (defun browse-url-netscape (url &optional new-window)
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
661 "Ask the Netscape WWW browser to load URL.
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
662
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
663 Default to the URL around or before point. The strings in variable
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
664 `browse-url-netscape-arguments' are also passed to Netscape.
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
665
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
666 When called interactively, if variable `browse-url-new-window-p' is
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
667 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
668 random existing one. A non-nil interactive prefix argument reverses
18253
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
669 the effect of `browse-url-new-window-p'.
13208
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
670
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
671 When called non-interactively, optional second argument NEW-WINDOW is
18253
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
672 used instead of `browse-url-new-window-p'."
16415
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
673 (interactive (browse-url-interactive-arg "Netscape URL: "))
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
674 ;; URL encode any commas in the URL
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
675 (while (string-match "," url)
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
676 (setq url (replace-match "%2C" t t url)))
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
677 (let* ((process-environment (browse-url-process-environment))
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
678 (process (apply 'start-process
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
679 (concat "netscape " url) nil
17975
3f2cc6cc8705 (browse-url-netscape, browse-url-netscape-sentinel)
Richard M. Stallman <rms@gnu.org>
parents: 17862
diff changeset
680 browse-url-netscape-program
18253
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
681 (append browse-url-netscape-arguments
19677
b0f1b44e7a13 (browse-url-netscape): Check for w32 window-system symbol.
Geoff Voelker <voelker@cs.washington.edu>
parents: 19583
diff changeset
682 (if (eq window-system 'w32)
18253
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
683 (list url)
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
684 (if new-window '("-noraise"))
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
685 (list "-remote"
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
686 (concat "openURL(" url
20167
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
687 (if (browse-url-maybe-new-window
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
688 new-window)
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
689 ",new-window")
18253
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
690 ")")))))))
16415
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
691 (set-process-sentinel process
18253
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
692 (list 'lambda '(process change)
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
693 (list 'browse-url-netscape-sentinel 'process url)))))
16415
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
694
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
695 (defun browse-url-netscape-sentinel (process url)
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
696 "Handle a change to the process communicating with Netscape."
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
697 (or (eq (process-exit-status process) 0)
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
698 (let* ((process-environment (browse-url-process-environment)))
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
699 ;; Netscape not running - start it
18253
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
700 (message "Starting Netscape...")
16415
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
701 (apply 'start-process (concat "netscape" url) nil
17975
3f2cc6cc8705 (browse-url-netscape, browse-url-netscape-sentinel)
Richard M. Stallman <rms@gnu.org>
parents: 17862
diff changeset
702 browse-url-netscape-program
16415
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
703 (append browse-url-netscape-startup-arguments (list url))))))
13208
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
704
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
705 (defun browse-url-netscape-reload ()
20167
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
706 "Ask Netscape to reload its current document.
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
707 How depends on `browse-url-netscape-version'."
13208
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
708 (interactive)
19579
bbb59d8bca28 Change the custom group to `hypermedia'.
Richard M. Stallman <rms@gnu.org>
parents: 19443
diff changeset
709 ;; Backwards incompatibility reported by
bbb59d8bca28 Change the custom group to `hypermedia'.
Richard M. Stallman <rms@gnu.org>
parents: 19443
diff changeset
710 ;; <peter.kruse@psychologie.uni-regensburg.de>.
bbb59d8bca28 Change the custom group to `hypermedia'.
Richard M. Stallman <rms@gnu.org>
parents: 19443
diff changeset
711 (browse-url-netscape-send (if (>= browse-url-netscape-version 4)
bbb59d8bca28 Change the custom group to `hypermedia'.
Richard M. Stallman <rms@gnu.org>
parents: 19443
diff changeset
712 "xfeDoCommand(reload)"
bbb59d8bca28 Change the custom group to `hypermedia'.
Richard M. Stallman <rms@gnu.org>
parents: 19443
diff changeset
713 "reload")))
13208
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
714
16415
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
715 (defun browse-url-netscape-send (command)
13208
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
716 "Send a remote control command to Netscape."
16415
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
717 (let* ((process-environment (browse-url-process-environment)))
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
718 (apply 'start-process "netscape" nil
17975
3f2cc6cc8705 (browse-url-netscape, browse-url-netscape-sentinel)
Richard M. Stallman <rms@gnu.org>
parents: 17862
diff changeset
719 browse-url-netscape-program
18253
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
720 (append browse-url-netscape-arguments
16415
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
721 (list "-remote" command)))))
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
722
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
723 ;; --- Mosaic ---
13208
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
724
16415
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
725 ;;;###autoload
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
726 (defun browse-url-mosaic (url &optional new-window)
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
727 ;; new-window ignored
13208
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
728 "Ask the XMosaic WWW browser to load URL.
20167
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
729
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
730 Default to the URL around or before point. The strings in variable
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
731 `browse-url-mosaic-arguments' are also passed to Mosaic and the
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
732 program is invoked according to the variable
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
733 `browse-url-mosaic-program'.
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
734
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
735 When called interactively, if variable `browse-url-new-window-p' is
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
736 non-nil, load the document in a new Mosaic window, otherwise use a
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
737 random existing one. A non-nil interactive prefix argument reverses
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
738 the effect of `browse-url-new-window-p'.
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
739
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
740 When called non-interactively, optional second argument NEW-WINDOW is
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
741 used instead of `browse-url-new-window-p'."
13208
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
742 (interactive (browse-url-interactive-arg "Mosaic URL: "))
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
743 (let ((pidfile (expand-file-name "~/.mosaicpid"))
18253
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
744 pid pidbuf)
13208
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
745 (if (file-readable-p pidfile)
18253
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
746 (save-excursion
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
747 (find-file pidfile)
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
748 (goto-char (point-min))
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
749 (setq pid (read (current-buffer)))
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
750 (kill-buffer nil)))
13208
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
751 (if (and pid (zerop (signal-process pid 0))) ; Mosaic running
18253
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
752 (save-excursion
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
753 (find-file (format "/tmp/Mosaic.%d" pid))
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
754 (erase-buffer)
20167
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
755 (insert (if (browse-url-maybe-new-window new-window)
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
756 "newwin\n"
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
757 "goto\n")
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
758 url "\n")
18253
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
759 (save-buffer)
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
760 (kill-buffer nil)
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
761 ;; Send signal SIGUSR to Mosaic
16415
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
762 (message "Signalling Mosaic...")
18253
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
763 (signal-process pid browse-url-usr1-signal)
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
764 ;; Or you could try:
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
765 ;; (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
766 (message "Signalling Mosaic...done")
18253
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
767 )
13208
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
768 ;; Mosaic not running - start it
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
769 (message "Starting Mosaic...")
20167
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
770 (apply 'start-process "xmosaic" nil browse-url-mosaic-program
18253
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
771 (append browse-url-mosaic-arguments (list url)))
13933
efd6ce432dc5 (browse-url-mosaic): Print "done" message
Richard M. Stallman <rms@gnu.org>
parents: 13224
diff changeset
772 (message "Starting Mosaic...done"))))
13208
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
773
16415
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
774 ;; --- Grail ---
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
775
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
776 ;;;###autoload
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
777 (defvar browse-url-grail
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
778 (concat (or (getenv "GRAILDIR") "~/.grail") "/user/rcgrail.py")
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
779 "*Location of Grail remote control client script `rcgrail.py'.
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
780 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
781
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
782 ;;;###autoload
18253
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
783 (defun browse-url-grail (url &optional new-window)
16415
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
784 "Ask the Grail WWW browser to load URL.
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
785 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
786 variable `browse-url-grail'."
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
787 (interactive (browse-url-interactive-arg "Grail URL: "))
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
788 (message "Sending URL to Grail...")
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
789 (save-excursion
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
790 (set-buffer (get-buffer-create " *Shell Command Output*"))
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
791 (erase-buffer)
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
792 ;; don't worry about this failing.
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
793 (call-process browse-url-grail nil 0 nil url)
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
794 (message "Sending URL to Grail... done")))
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
795
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
796 ;; --- Mosaic using CCI ---
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
797
13208
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
798 (defun browse-url-cci (url &optional new-window)
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
799 "Ask the XMosaic WWW browser to load URL.
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
800 Default to the URL around or before point.
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
801
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
802 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
803 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
804 value of variable `browse-url-CCI-port', and enable `Accept requests'.
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
805
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
806 When called interactively, if variable `browse-url-new-window-p' is
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
807 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
808 random existing one. A non-nil interactive prefix argument reverses
18253
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
809 the effect of `browse-url-new-window-p'.
13208
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
810
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
811 When called non-interactively, optional second argument NEW-WINDOW is
18253
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
812 used instead of `browse-url-new-window-p'."
16415
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
813 (interactive (browse-url-interactive-arg "Mosaic URL: "))
13208
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
814 (open-network-stream "browse-url" " *browse-url*"
16415
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
815 browse-url-CCI-host browse-url-CCI-port)
13208
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
816 ;; Todo: start browser if fails
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
817 (process-send-string "browse-url"
18253
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
818 (concat "get url (" url ") output "
20167
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
819 (if (browse-url-maybe-new-window
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
820 new-window)
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
821 "new"
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
822 "current")
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
823 "\r\n"))
13208
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
824 (process-send-string "browse-url" "disconnect\r\n")
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
825 (delete-process "browse-url"))
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
826
16415
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
827 ;; --- IXI Mosaic ---
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
828
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
829 ;;;###autoload
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
830 (defun browse-url-iximosaic (url &optional new-window)
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
831 ;; new-window ignored
13208
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
832 "Ask the IXIMosaic WWW browser to load URL.
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
833 Default to the URL around or before point."
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
834 (interactive (browse-url-interactive-arg "IXI Mosaic URL: "))
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
835 (start-process "tellw3b" nil "tellw3b"
18253
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
836 "-service WWW_BROWSER ixi_showurl " url))
13208
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
837
16415
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
838 ;; --- W3 ---
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
839
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
840 ;;;###autoload
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
841 (defun browse-url-w3 (url &optional new-window)
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
842 ;; new-window ignored
13208
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
843 "Ask the w3 WWW browser to load URL.
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
844 Default to the URL around or before point."
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
845 (interactive (browse-url-interactive-arg "W3 URL: "))
20167
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
846 (if (browse-url-maybe-new-window new-window)
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
847 (w3-fetch-other-window)
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
848 (w3-fetch url)))
13208
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
849
18253
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
850 ;;;###autoload
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
851 (defun browse-url-w3-gnudoit (url &optional new-window)
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
852 ;; new-window ignored
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
853 "Ask another Emacs running gnuserv to load the URL using the W3 browser.
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
854 The `browse-url-gnudoit-program' program is used with options given by
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
855 `browse-url-gnudoit-args'. Default to the URL around or before point."
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
856 (interactive (browse-url-interactive-arg "W3 URL: "))
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
857 (apply 'start-process (concat "gnudoit:" url) nil
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
858 browse-url-gnudoit-program
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
859 (append browse-url-gnudoit-args (list (concat "(w3-fetch \"" url "\")") "(raise-frame)"))))
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
860
16415
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
861 ;; --- Lynx in an xterm ---
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
862
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
863 ;;;###autoload
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
864 (defun browse-url-lynx-xterm (url &optional new-window)
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
865 ;; new-window ignored
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
866 "Ask the Lynx WWW browser to load URL.
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
867 Default to the URL around or before point. A new Lynx process is run
18253
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
868 in an Xterm window using the Xterm program named by `browse-url-xterm-program'
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
869 with possible additional arguments `browse-url-xterm-args'."
16415
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
870 (interactive (browse-url-interactive-arg "Lynx URL: "))
18253
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
871 (apply 'start-process (concat "lynx" url) nil browse-url-xterm-program
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
872 (append browse-url-xterm-args (list "-e" "lynx" url))))
16415
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
873
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
874 ;; --- Lynx in an Emacs "term" window ---
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
875
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
876 ;;;###autoload
20167
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
877 (defun browse-url-lynx-emacs (url &optional new-buffer)
16415
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
878 "Ask the Lynx WWW browser to load URL.
20167
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
879 Default to the URL around or before point. With a prefix argument, run
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
880 a new Lynx process in a new buffer."
16415
e25afe6ea4d6 (browse-url): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15780
diff changeset
881 (interactive (browse-url-interactive-arg "Lynx URL: "))
20167
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
882 (let* ((system-uses-terminfo t) ; Lynx uses terminfo
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
883 ;; (term-term-name "vt100") ; ??
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
884 (buf (get-buffer "*lynx*"))
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
885 (proc (and buf (get-buffer-process buf)))
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
886 (n browse-url-lynx-input-attempts))
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
887 (if (and (browse-url-maybe-new-window new-buffer) buf)
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
888 ;; Rename away the OLD buffer. This isn't very polite, but
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
889 ;; term insists on working in a buffer named *lynx* and would
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
890 ;; choke on *lynx*<1>
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
891 (progn (set-buffer buf)
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
892 (rename-uniquely)))
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
893 (if (or (browse-url-maybe-new-window new-buffer)
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
894 (not buf)
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
895 (not proc)
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
896 (not (memq (process-status proc) '(run stop))))
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
897 ;; start a new lynx
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
898 (progn (switch-to-buffer (make-term "lynx" "lynx" nil url))
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
899 (term-char-mode))
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
900 ;; send the url to lynx in the old buffer
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
901 (let ((win (get-buffer-window buf t)))
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
902 (if win
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
903 (select-window win)
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
904 (switch-to-buffer buf)))
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
905 (if (eq (following-char) ?_)
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
906 (cond ((eq browse-url-lynx-input-field 'warn)
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
907 (error "Please move out of the input field first."))
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
908 ((eq browse-url-lynx-input-field 'avoid)
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
909 (while (and (eq (following-char) ?_) (> n 0))
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
910 (term-send-down) ; down arrow
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
911 (sit-for browse-url-lynx-input-delay))
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
912 (if (eq (following-char) ?_)
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
913 (error "Cannot move out of the input field, sorry.")))))
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
914 (term-send-string proc (concat "g" ; goto
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
915 "\C-u" ; kill default url
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
916 url
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
917 "\r")))))
15780
0a03d2b02ba1 (browse-url-choose-browser): New function.
Richard M. Stallman <rms@gnu.org>
parents: 15656
diff changeset
918
18253
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
919 ;; --- MMM ---
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
920
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
921 ;;;###autoload
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
922 (defun browse-url-mmm (url &optional new-window)
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
923 "Ask the MMM WWW browser to load URL.
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
924 Default to the URL around or before point."
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
925 (interactive (browse-url-interactive-arg "MMM URL: "))
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
926 (message "Sending URL to MMM...")
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
927 (save-excursion
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
928 (set-buffer (get-buffer-create " *Shell Command Output*"))
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
929 (erase-buffer)
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
930 ;; mmm_remote just SEGVs if the file isn't there...
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
931 (if (or (file-exists-p (expand-file-name "~/.mmm_remote"))
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
932 ;; location in v 0.4:
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
933 (file-exists-p (expand-file-name "~/.mmm/remote")))
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
934 (call-process "mmm_remote" nil 0 nil url)
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
935 (call-process "mmm" nil 0 nil "-external" url))
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
936 (message "Sending URL to MMM... done")))
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
937
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
938 ;; --- mailto ---
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
939
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
940 ;;;###autoload
19583
5c7badcafb2b (browse-url-mail): Use compose-mail[-other-window], not always `mail'.
Richard M. Stallman <rms@gnu.org>
parents: 19579
diff changeset
941 (defun browse-url-mail (url &optional new-window)
18253
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
942 "Open a new mail message buffer within Emacs.
19583
5c7badcafb2b (browse-url-mail): Use compose-mail[-other-window], not always `mail'.
Richard M. Stallman <rms@gnu.org>
parents: 19579
diff changeset
943 Default to using the mailto: URL around or before point as the
5c7badcafb2b (browse-url-mail): Use compose-mail[-other-window], not always `mail'.
Richard M. Stallman <rms@gnu.org>
parents: 19579
diff changeset
944 recipient's address. Supplying a non-nil interactive prefix argument
5c7badcafb2b (browse-url-mail): Use compose-mail[-other-window], not always `mail'.
Richard M. Stallman <rms@gnu.org>
parents: 19579
diff changeset
945 will cause the mail to be composed in another window rather than the
5c7badcafb2b (browse-url-mail): Use compose-mail[-other-window], not always `mail'.
Richard M. Stallman <rms@gnu.org>
parents: 19579
diff changeset
946 current one."
18253
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
947 (interactive (browse-url-interactive-arg "Mailto URL: "))
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
948 (save-excursion
20167
5bd2ed765d52 Doc fixes.
Dave Love <fx@gnu.org>
parents: 20016
diff changeset
949 (let ((func (if (browse-url-maybe-new-window new-window)
19583
5c7badcafb2b (browse-url-mail): Use compose-mail[-other-window], not always `mail'.
Richard M. Stallman <rms@gnu.org>
parents: 19579
diff changeset
950 'compose-mail-other-window
5c7badcafb2b (browse-url-mail): Use compose-mail[-other-window], not always `mail'.
Richard M. Stallman <rms@gnu.org>
parents: 19579
diff changeset
951 'compose-mail))
5c7badcafb2b (browse-url-mail): Use compose-mail[-other-window], not always `mail'.
Richard M. Stallman <rms@gnu.org>
parents: 19579
diff changeset
952 (to (if (string-match "^mailto:" url)
18253
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
953 (substring url 7)
19583
5c7badcafb2b (browse-url-mail): Use compose-mail[-other-window], not always `mail'.
Richard M. Stallman <rms@gnu.org>
parents: 19579
diff changeset
954 url)))
5c7badcafb2b (browse-url-mail): Use compose-mail[-other-window], not always `mail'.
Richard M. Stallman <rms@gnu.org>
parents: 19579
diff changeset
955 (apply func
5c7badcafb2b (browse-url-mail): Use compose-mail[-other-window], not always `mail'.
Richard M. Stallman <rms@gnu.org>
parents: 19579
diff changeset
956 (list to nil nil nil nil nil (cons 'insert-buffer
5c7badcafb2b (browse-url-mail): Use compose-mail[-other-window], not always `mail'.
Richard M. Stallman <rms@gnu.org>
parents: 19579
diff changeset
957 (current-buffer)))))))
18253
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
958
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
959 ;; --- Random browser ---
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
960
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
961 ;;;###autoload
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
962 (defun browse-url-generic (url &optional new-window)
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
963 ;; new-window ignored
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
964 "Ask the WWW browser defined by `browse-url-generic-program' to load URL.
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
965 Default to the URL around or before point. A fresh copy of the
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
966 browser is started up in a new process with possible additional arguments
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
967 `browse-url-generic-args'. This is appropriate for browsers which
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
968 don't offer a form of remote control."
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
969 (interactive (browse-url-interactive-arg "URL: "))
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
970 (if (not browse-url-generic-program)
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
971 (error "No browser defined (`browse-url-generic-program')"))
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
972 (apply 'start-process (concat browse-url-generic-program url) nil
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
973 browse-url-generic-program
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
974 (append browse-url-generic-args (list url))))
0c8339d10beb Update keywords to show up in finder.
Richard M. Stallman <rms@gnu.org>
parents: 18224
diff changeset
975
13208
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
976 (provide 'browse-url)
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
977
7a20f2bb5ac9 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
978 ;;; browse-url.el ends here