1997-06-15 02:49:03 +00:00
|
|
|
;;; browse-url.el --- Pass a URL to a WWW browser
|
1996-01-14 07:34:30 +00:00
|
|
|
|
1997-06-15 02:49:03 +00:00
|
|
|
;; Copyright 1995, 1996, 1997 Free Software Foundation, Inc.
|
1995-10-13 19:18:29 +00:00
|
|
|
|
|
|
|
;; Author: Denis Howe <dbh@doc.ic.ac.uk>
|
1997-06-12 00:50:08 +00:00
|
|
|
;; Maintainer: Dave Love <d.love@dl.ac.uk>
|
1995-10-13 19:18:29 +00:00
|
|
|
;; Created: 03 Apr 1995
|
1997-06-15 02:49:03 +00:00
|
|
|
;; Keywords: hypertext, hypermedia, mouse
|
1995-10-13 19:18:29 +00:00
|
|
|
|
|
|
|
;; This file is part of GNU Emacs.
|
|
|
|
|
|
|
|
;; GNU Emacs is free software; you can redistribute it and/or modify
|
1996-01-14 07:34:30 +00:00
|
|
|
;; it under the terms of the GNU General Public License as published by
|
|
|
|
;; the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
;; any later version.
|
1995-10-13 19:18:29 +00:00
|
|
|
|
1996-01-14 07:34:30 +00:00
|
|
|
;; GNU Emacs is distributed in the hope that it will be useful,
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
;; GNU General Public License for more details.
|
1995-10-13 19:18:29 +00:00
|
|
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
|
|
|
;; along with GNU Emacs; see the file COPYING. If not, write to the
|
1996-01-14 07:34:30 +00:00
|
|
|
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
;; Boston, MA 02111-1307, USA.
|
1995-10-13 19:18:29 +00:00
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
|
|
|
;; The latest version of this package should be available from
|
|
|
|
;; <URL:http://wombat.doc.ic.ac.uk/emacs/browse-url.el>.
|
|
|
|
|
|
|
|
;; This package provides functions which read a URL (Uniform Resource
|
|
|
|
;; Locator) from the minibuffer, defaulting to the URL around point,
|
|
|
|
;; and ask a World-Wide Web browser to load it. It can also load the
|
|
|
|
;; URL associated with the current buffer. Different browsers use
|
|
|
|
;; different methods of remote control so there is one function for
|
|
|
|
;; each supported browser. If the chosen browser is not running, it
|
|
|
|
;; is started. Currently there is support for:
|
|
|
|
|
|
|
|
;; Function Browser Earliest version
|
1997-06-15 02:49:03 +00:00
|
|
|
;; browse-url-netscape Netscape 1.1b1
|
Doc fixes.
(browse-url): Apply, don't just call, browse-url-choose-browser, so
args works properly.
(browse-url-maybe-new-window): New function.
(browse-url-netscape, browse-url-mosaic, browse-url-cci,
browse-url-w3, browse-url-lynx-emacs, browse-url-mail): Use it.
(browse-url-lynx-emacs): Don't call term-term-name.
(browse-url-lynx-input-field, browse-url-lynx-input-delay,
browse-url-lynx-input-attempts): New variables.
(browse-url-lynx-emacs): Use any existing Lynx buffer; take care to
move off input fields. (After Vladimir Alexiev
<vladimir@cs.ualberta.ca>.)
(browse-url-mosaic-program): New variable.
(browse-url-mosaic): Use browse-url-mosaic-program and
browse-url-new-window-p.
(browse-url-at-mouse): Use browse-url-new-window-p.
1997-10-23 13:43:14 +00:00
|
|
|
;; browse-url-mosaic XMosaic/mMosaic <= 2.4
|
1995-10-13 19:18:29 +00:00
|
|
|
;; browse-url-cci XMosaic 2.5
|
|
|
|
;; browse-url-w3 w3 0
|
1997-06-15 02:49:03 +00:00
|
|
|
;; browse-url-w3-gnudoit w3 remotely
|
1995-10-13 19:18:29 +00:00
|
|
|
;; browse-url-iximosaic IXI Mosaic ?
|
1996-10-11 02:32:17 +00:00
|
|
|
;; browse-url-lynx-* Lynx 0
|
|
|
|
;; browse-url-grail Grail 0.3b1
|
1997-06-15 02:49:03 +00:00
|
|
|
;; browse-url-mmm MMM ?
|
|
|
|
;; browse-url-generic arbitrary
|
1995-10-13 19:18:29 +00:00
|
|
|
|
|
|
|
;; Note that versions of Netscape before 1.1b1 did not have remote
|
1997-06-15 02:49:03 +00:00
|
|
|
;; control. <URL:http://www.netscape.com/newsref/std/x-remote.html>.
|
1995-10-13 19:18:29 +00:00
|
|
|
|
|
|
|
;; Netscape can cache Web pages so it may be necessary to tell it to
|
1996-10-11 02:32:17 +00:00
|
|
|
;; reload the current page if it has changed (e.g. if you have edited
|
1995-10-13 19:18:29 +00:00
|
|
|
;; it). There is currently no perfect automatic solution to this.
|
|
|
|
|
|
|
|
;; Netscape allows you to specify the id of the window you want to
|
|
|
|
;; control but which window DO you want to control and how do you
|
|
|
|
;; discover its id?
|
|
|
|
|
|
|
|
;; If using XMosaic before version 2.5, check the definition of
|
|
|
|
;; browse-url-usr1-signal below.
|
|
|
|
;; <URL:http://www.ncsa.uiuc.edu/SDG/Software/XMosaic/remote-control.html>
|
|
|
|
|
|
|
|
;; XMosaic version 2.5 introduced Common Client Interface allowing you
|
|
|
|
;; to control mosaic through Unix sockets.
|
|
|
|
;; <URL:http://www.ncsa.uiuc.edu/SDG/Software/XMosaic/CCI/cci-spec.html>
|
|
|
|
|
|
|
|
;; William M. Perry's excellent "w3" WWW browser for
|
|
|
|
;; Emacs <URL:ftp://cs.indiana.edu/pub/elisp/w3/>
|
|
|
|
;; has a function w3-follow-url-at-point, but that
|
|
|
|
;; doesn't let you edit the URL like browse-url.
|
1997-06-15 02:49:03 +00:00
|
|
|
;; The `gnuserv' package that can be used to control it in another
|
|
|
|
;; Emacs process is available from
|
|
|
|
;; <URL:http://hplbwww.hpl.hp.com/people/ange/gnuserv/>.
|
|
|
|
|
|
|
|
;; Grail is the freely available WWW browser implemented in Python, a
|
|
|
|
;; cool object-oriented freely available interpreted language. Grail
|
|
|
|
;; 0.3b1 was the first version to have remote control as distributed.
|
|
|
|
;; For more information on Grail see
|
|
|
|
;; <URL:http://grail.cnri.reston.va.us/> and for more information on
|
|
|
|
;; Python see <url:http://www.python.org/>. Grail support in
|
|
|
|
;; browse-url.el written by Barry Warsaw <bwarsaw@python.org>.
|
|
|
|
|
|
|
|
;; MMM is the freely available WWW browser implemented in Caml Special
|
|
|
|
;; Light, a cool impure functional programming language, by Francois
|
|
|
|
;; Rouaix. See the MMM home page
|
|
|
|
;; <URL:http://pauillac.inria.fr/%7Erouaix/mmm/>.
|
|
|
|
|
|
|
|
;; Lynx is now distributed by the FSF. See also
|
|
|
|
;; <URL:http://lynx.browser.org/>.
|
|
|
|
|
|
|
|
;; Free graphical browsers that could be used by `browse-url-generic'
|
1997-08-20 17:22:42 +00:00
|
|
|
;; include Chimera <URL:ftp://ftp.cs.unlv.edu/pub/chimera> and
|
|
|
|
;; <URL:http://www.unlv.edu/chimera/>, Arena
|
Doc fixes.
(browse-url): Apply, don't just call, browse-url-choose-browser, so
args works properly.
(browse-url-maybe-new-window): New function.
(browse-url-netscape, browse-url-mosaic, browse-url-cci,
browse-url-w3, browse-url-lynx-emacs, browse-url-mail): Use it.
(browse-url-lynx-emacs): Don't call term-term-name.
(browse-url-lynx-input-field, browse-url-lynx-input-delay,
browse-url-lynx-input-attempts): New variables.
(browse-url-lynx-emacs): Use any existing Lynx buffer; take care to
move off input fields. (After Vladimir Alexiev
<vladimir@cs.ualberta.ca>.)
(browse-url-mosaic-program): New variable.
(browse-url-mosaic): Use browse-url-mosaic-program and
browse-url-new-window-p.
(browse-url-at-mouse): Use browse-url-new-window-p.
1997-10-23 13:43:14 +00:00
|
|
|
;; <URL:ftp://ftp.yggdrasil.com/pub/dist/web/arena> and Amaya
|
|
|
|
;; <URL:ftp://ftp.w3.org/pub/amaya>. mMosaic
|
|
|
|
;; <URL:ftp://sig.enst.fr/pub/multicast/mMosaic/> (with development
|
|
|
|
;; support for Java applets and multicast) can be used like Mosaic by
|
|
|
|
;; setting `browse-url-mosaic-program' appropriately.
|
1995-10-13 19:18:29 +00:00
|
|
|
|
1997-08-27 21:20:47 +00:00
|
|
|
;; I [Denis Howe] recommend Nelson Minar <nelson@santafe.edu>'s excellent
|
1995-10-13 19:18:29 +00:00
|
|
|
;; html-helper-mode.el for editing HTML and thank Nelson for
|
|
|
|
;; his many useful comments on this code.
|
1997-06-15 02:49:03 +00:00
|
|
|
;; <URL:http://www.santafe.edu/%7Enelson/hhm-beta/>
|
1995-10-13 19:18:29 +00:00
|
|
|
|
1997-08-27 21:20:47 +00:00
|
|
|
;; See also hm--html-menus <URL:http://www.tnt.uni-hannover.de/%7Emuenkel/
|
|
|
|
;; software/own/hm--html-menus/>. For composing correct HTML see also
|
|
|
|
;; PSGML the general SGML structure editor package
|
|
|
|
;; <URL:ftp://ftp.lysator.liu.se/pub/sgml>; hm--html-menus can be used
|
|
|
|
;; with this.
|
|
|
|
|
1995-10-13 19:18:29 +00:00
|
|
|
;; This package generalises function html-previewer-process in Marc
|
|
|
|
;; Andreessen <marca@ncsa.uiuc.edu>'s html-mode (LCD
|
|
|
|
;; modes/html-mode.el.Z) and provides better versions of the URL
|
|
|
|
;; functions in Michelangelo Grigni <mic@cs.ucsd.edu>'s ffap.el
|
|
|
|
;; (find-file-at-point) <URL:ftp://cs.ucsd.edu:/pub/mic/>. The huge
|
|
|
|
;; hyperbole package also contains similar functions.
|
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; Help!
|
|
|
|
|
|
|
|
;; Can you write and test some code for the Macintrash and Windoze
|
|
|
|
;; Netscape remote control APIs? (See the URL above).
|
|
|
|
|
|
|
|
;; Do any other browsers have remote control?
|
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; Usage
|
|
|
|
|
|
|
|
;; To display the URL at or before point:
|
|
|
|
;; M-x browse-url-at-point RET
|
1997-06-15 02:49:03 +00:00
|
|
|
;; or, similarly but with the opportunity to edit the URL extracted from
|
|
|
|
;; the buffer, use:
|
|
|
|
;; M-x browse-url
|
1995-10-13 19:18:29 +00:00
|
|
|
|
|
|
|
;; To display a URL by shift-clicking on it, put this in your ~/.emacs
|
|
|
|
;; file:
|
1996-01-04 08:32:49 +00:00
|
|
|
;; (global-set-key [S-mouse-2] 'browse-url-at-mouse)
|
|
|
|
;; (Note that using Shift-mouse-1 is not desirable because
|
|
|
|
;; that event has a standard meaning in Emacs.)
|
1995-10-13 19:18:29 +00:00
|
|
|
|
|
|
|
;; To display the current buffer in a web browser:
|
|
|
|
;; M-x browse-url-of-buffer RET
|
|
|
|
|
1997-06-15 02:49:03 +00:00
|
|
|
;; To display the current region in a web browser:
|
|
|
|
;; M-x browse-url-of-region RET
|
|
|
|
|
1995-10-13 19:18:29 +00:00
|
|
|
;; In Dired, to display the file named on the current line:
|
|
|
|
;; M-x browse-url-of-dired-file RET
|
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; Customisation (~/.emacs)
|
|
|
|
|
1996-10-11 02:32:17 +00:00
|
|
|
;; To see what variables are available for customization, type
|
1997-11-21 23:57:48 +00:00
|
|
|
;; `M-x set-variable browse-url TAB'. Better, use
|
|
|
|
;; `M-x customize-group browse-url'.
|
1995-10-13 19:18:29 +00:00
|
|
|
|
1996-10-11 02:32:17 +00:00
|
|
|
;; Bind the browse-url commands to keys with the `C-c C-z' prefix
|
|
|
|
;; (as used by html-helper-mode):
|
|
|
|
;; (global-set-key "\C-c\C-z." 'browse-url-at-point)
|
|
|
|
;; (global-set-key "\C-c\C-zb" 'browse-url-of-buffer)
|
1997-06-15 02:49:03 +00:00
|
|
|
;; (global-set-key "\C-c\C-zr" 'browse-url-of-region)
|
1996-10-11 02:32:17 +00:00
|
|
|
;; (global-set-key "\C-c\C-zu" 'browse-url)
|
|
|
|
;; (global-set-key "\C-c\C-zv" 'browse-url-of-file)
|
1997-06-15 02:49:03 +00:00
|
|
|
;; (add-hook 'dired-mode-hook
|
1997-12-12 17:43:13 +00:00
|
|
|
;; (lambda ()
|
|
|
|
;; (local-set-key "\C-c\C-zf" 'browse-url-of-dired-file)))
|
1996-10-11 02:32:17 +00:00
|
|
|
|
|
|
|
;; Browse URLs in mail messages by clicking mouse-2:
|
1997-12-12 17:43:13 +00:00
|
|
|
;; (add-hook 'rmail-mode-hook (lambda () ; rmail-mode startup
|
|
|
|
;; (define-key rmail-mode-map [mouse-2] 'browse-url-at-mouse)))
|
1996-10-11 02:32:17 +00:00
|
|
|
|
|
|
|
;; Browse URLs in Usenet messages by clicking mouse-2:
|
|
|
|
;; (eval-after-load "gnus"
|
|
|
|
;; '(define-key gnus-article-mode-map [mouse-2] 'browse-url-at-mouse))
|
1997-08-27 21:20:47 +00:00
|
|
|
;; [The current version of Gnus provides a standard feature to
|
|
|
|
;; activate URLs in article buffers for invocation of browse-url with
|
|
|
|
;; mouse-2.]
|
1996-10-11 02:32:17 +00:00
|
|
|
|
|
|
|
;; Use the Emacs w3 browser when not running under X11:
|
|
|
|
;; (or (eq window-system 'x)
|
1997-06-15 02:49:03 +00:00
|
|
|
;; (setq browse-url-browser-function 'browse-url-w3))
|
1995-10-13 19:18:29 +00:00
|
|
|
|
|
|
|
;; To always save modified buffers before displaying the file in a browser:
|
1997-06-15 02:49:03 +00:00
|
|
|
;; (setq browse-url-save-file t)
|
1995-10-13 19:18:29 +00:00
|
|
|
|
1996-10-11 02:32:17 +00:00
|
|
|
;; To get round the Netscape caching problem, you could EITHER have
|
|
|
|
;; write-file in html-helper-mode make Netscape reload the document:
|
1995-10-13 19:18:29 +00:00
|
|
|
;;
|
1997-06-15 02:49:03 +00:00
|
|
|
;; (autoload 'browse-url-netscape-reload "browse-url"
|
|
|
|
;; "Ask a WWW browser to redisplay the current file." t)
|
|
|
|
;; (add-hook 'html-helper-mode-hook
|
1997-12-12 17:43:13 +00:00
|
|
|
;; (lambda ()
|
1997-06-15 02:49:03 +00:00
|
|
|
;; (add-hook 'local-write-file-hooks
|
1997-12-12 17:43:13 +00:00
|
|
|
;; (lambda ()
|
1997-06-15 02:49:03 +00:00
|
|
|
;; (let ((local-write-file-hooks))
|
|
|
|
;; (save-buffer))
|
|
|
|
;; (browse-url-netscape-reload)
|
1997-12-12 17:43:13 +00:00
|
|
|
;; t) ; => file written by hook
|
|
|
|
;; t))) ; append to l-w-f-hooks
|
1995-10-13 19:18:29 +00:00
|
|
|
;;
|
1996-10-11 02:32:17 +00:00
|
|
|
;; OR have browse-url-of-file ask Netscape to load and then reload the
|
1995-10-13 19:18:29 +00:00
|
|
|
;; file:
|
|
|
|
;;
|
1997-06-15 02:49:03 +00:00
|
|
|
;; (add-hook 'browse-url-of-file-hook 'browse-url-netscape-reload)
|
1995-10-13 19:18:29 +00:00
|
|
|
|
1996-10-11 02:32:17 +00:00
|
|
|
;; You may also want to customise browse-url-netscape-arguments, e.g.
|
1997-06-15 02:49:03 +00:00
|
|
|
;; (setq browse-url-netscape-arguments '("-install"))
|
1995-10-13 19:18:29 +00:00
|
|
|
;;
|
1997-06-15 02:49:03 +00:00
|
|
|
;; or similarly for the other browsers.
|
1995-10-13 19:18:29 +00:00
|
|
|
|
1997-06-15 02:49:03 +00:00
|
|
|
;; To invoke different browsers for different URLs:
|
|
|
|
;; (setq browse-url-browser-function '(("^mailto:" . browse-url-mail)
|
|
|
|
;; ("." . browse-url-netscape)))
|
1995-10-13 19:18:29 +00:00
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;;; Code:
|
|
|
|
|
1997-07-04 20:00:43 +00:00
|
|
|
(eval-when-compile (require 'dired)
|
|
|
|
(require 'thingatpt))
|
1996-10-11 02:32:17 +00:00
|
|
|
|
1997-06-15 02:49:03 +00:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; Variables
|
1995-10-13 19:18:29 +00:00
|
|
|
|
1997-04-14 03:00:06 +00:00
|
|
|
(defgroup browse-url nil
|
|
|
|
"Use a web browser to look at a URL."
|
1997-11-21 23:57:48 +00:00
|
|
|
:prefix "browse-url-"
|
1997-08-27 18:43:39 +00:00
|
|
|
:group 'hypermedia)
|
1996-10-11 02:32:17 +00:00
|
|
|
|
|
|
|
;;;###autoload
|
1997-04-14 03:00:06 +00:00
|
|
|
(defcustom browse-url-browser-function
|
1996-10-11 02:32:17 +00:00
|
|
|
'browse-url-netscape
|
1995-10-13 19:18:29 +00:00
|
|
|
"*Function to display the current buffer in a WWW browser.
|
1997-04-14 03:00:06 +00:00
|
|
|
This is used by the `browse-url-at-point', `browse-url-at-mouse', and
|
1997-04-14 19:15:42 +00:00
|
|
|
`browse-url-of-file' commands.
|
1997-06-15 02:49:03 +00:00
|
|
|
|
|
|
|
If the value is not a function it should be a list of pairs
|
|
|
|
(REGEXP.FUNCTION). In this case the function called will be the one
|
|
|
|
associated with the first REGEXP which matches the current URL. The
|
|
|
|
function is passed the URL and any other args of `browse-url'. The last
|
|
|
|
regexp should probably be \".\" to specify a default browser."
|
1997-12-12 17:43:13 +00:00
|
|
|
:type '(choice
|
|
|
|
(function-item :tag "Emacs W3" :value browse-url-w3)
|
|
|
|
(function-item :tag "W3 in another Emacs via `gnudoit'"
|
|
|
|
:value browse-url-w3-gnudoit)
|
|
|
|
(function-item :tag "Netscape" :value browse-url-netscape)
|
|
|
|
(function-item :tag "Mosaic" :value browse-url-mosaic)
|
|
|
|
(function-item :tag "Mosaic using CCI" :value browse-url-cci)
|
|
|
|
(function-item :tag "IXI Mosaic" :value browse-url-iximosaic)
|
|
|
|
(function-item :tag "Lynx in an xterm window"
|
|
|
|
:value browse-url-lynx-xterm)
|
|
|
|
(function-item :tag "Lynx in an Emacs window"
|
|
|
|
:value browse-url-lynx-emacs)
|
|
|
|
(function-item :tag "Grail" :value browse-url-grail)
|
|
|
|
(function-item :tag "MMM" :value browse-url-mmm)
|
|
|
|
(function-item :tag "Specified by `Browse Url Generic Program'"
|
|
|
|
:value browse-url-generic)
|
|
|
|
(function :tag "Your own function"))
|
1997-04-14 03:00:06 +00:00
|
|
|
:group 'browse-url)
|
|
|
|
|
|
|
|
(defcustom browse-url-netscape-program "netscape"
|
1997-12-22 19:26:10 +00:00
|
|
|
;; Info about netscape-remote from Kurt Swanson in gnu.emacs.gnus
|
|
|
|
"*The name by which to invoke Netscape.
|
|
|
|
|
|
|
|
It is said that source is available for a program `netscape-remote'
|
|
|
|
which starts up very much quicker than `netscape' and that it is
|
|
|
|
useful to set this variable to the name of a script which invokes that
|
|
|
|
program like:
|
|
|
|
#!/bin/sh
|
|
|
|
/usr/local/bin/netscape-remote \"$@\" > /dev/null 2>&1
|
|
|
|
"
|
1997-04-14 03:00:06 +00:00
|
|
|
:type 'string
|
|
|
|
:group 'browse-url)
|
|
|
|
|
|
|
|
(defcustom browse-url-netscape-arguments nil
|
|
|
|
"*A list of strings to pass to Netscape as arguments."
|
|
|
|
:type '(repeat (string :tag "Argument"))
|
|
|
|
:group 'browse-url)
|
|
|
|
|
|
|
|
(defcustom browse-url-netscape-startup-arguments browse-url-netscape-arguments
|
Doc fixes.
(browse-url): Apply, don't just call, browse-url-choose-browser, so
args works properly.
(browse-url-maybe-new-window): New function.
(browse-url-netscape, browse-url-mosaic, browse-url-cci,
browse-url-w3, browse-url-lynx-emacs, browse-url-mail): Use it.
(browse-url-lynx-emacs): Don't call term-term-name.
(browse-url-lynx-input-field, browse-url-lynx-input-delay,
browse-url-lynx-input-attempts): New variables.
(browse-url-lynx-emacs): Use any existing Lynx buffer; take care to
move off input fields. (After Vladimir Alexiev
<vladimir@cs.ualberta.ca>.)
(browse-url-mosaic-program): New variable.
(browse-url-mosaic): Use browse-url-mosaic-program and
browse-url-new-window-p.
(browse-url-at-mouse): Use browse-url-new-window-p.
1997-10-23 13:43:14 +00:00
|
|
|
"*A list of strings to pass to Netscape when it start up.
|
1997-04-14 03:00:06 +00:00
|
|
|
Defaults to the value of `browse-url-netscape-arguments' at the time
|
1997-06-15 02:49:03 +00:00
|
|
|
`browse-url' is loaded."
|
1997-04-14 03:00:06 +00:00
|
|
|
:type '(repeat (string :tag "Argument"))
|
|
|
|
:group 'browse-url)
|
1996-10-11 02:32:17 +00:00
|
|
|
|
1997-04-14 03:00:06 +00:00
|
|
|
(defcustom browse-url-new-window-p nil
|
1997-12-12 17:43:13 +00:00
|
|
|
"*If non-nil, always open a new browser window with appropriate browsers.
|
|
|
|
Passing an interactive argument to \\[browse-url], or specific browser
|
|
|
|
commands reverses the effect of this variable. Requires Netscape version
|
|
|
|
1.1N or later or XMosaic version 2.5 or later if using those browsers."
|
1997-04-14 03:00:06 +00:00
|
|
|
:type 'boolean
|
|
|
|
:group 'browse-url)
|
|
|
|
|
1997-06-15 02:49:03 +00:00
|
|
|
(defcustom browse-url-netscape-display nil
|
Doc fixes.
(browse-url): Apply, don't just call, browse-url-choose-browser, so
args works properly.
(browse-url-maybe-new-window): New function.
(browse-url-netscape, browse-url-mosaic, browse-url-cci,
browse-url-w3, browse-url-lynx-emacs, browse-url-mail): Use it.
(browse-url-lynx-emacs): Don't call term-term-name.
(browse-url-lynx-input-field, browse-url-lynx-input-delay,
browse-url-lynx-input-attempts): New variables.
(browse-url-lynx-emacs): Use any existing Lynx buffer; take care to
move off input fields. (After Vladimir Alexiev
<vladimir@cs.ualberta.ca>.)
(browse-url-mosaic-program): New variable.
(browse-url-mosaic): Use browse-url-mosaic-program and
browse-url-new-window-p.
(browse-url-at-mouse): Use browse-url-new-window-p.
1997-10-23 13:43:14 +00:00
|
|
|
"*The X display for running Netscape, if not same as Emacs'."
|
1997-12-12 17:43:13 +00:00
|
|
|
:type '(choice string (const :tag "Default" nil))
|
1997-06-15 02:49:03 +00:00
|
|
|
:group 'browse-url)
|
|
|
|
|
Doc fixes.
(browse-url): Apply, don't just call, browse-url-choose-browser, so
args works properly.
(browse-url-maybe-new-window): New function.
(browse-url-netscape, browse-url-mosaic, browse-url-cci,
browse-url-w3, browse-url-lynx-emacs, browse-url-mail): Use it.
(browse-url-lynx-emacs): Don't call term-term-name.
(browse-url-lynx-input-field, browse-url-lynx-input-delay,
browse-url-lynx-input-attempts): New variables.
(browse-url-lynx-emacs): Use any existing Lynx buffer; take care to
move off input fields. (After Vladimir Alexiev
<vladimir@cs.ualberta.ca>.)
(browse-url-mosaic-program): New variable.
(browse-url-mosaic): Use browse-url-mosaic-program and
browse-url-new-window-p.
(browse-url-at-mouse): Use browse-url-new-window-p.
1997-10-23 13:43:14 +00:00
|
|
|
(defcustom browse-url-mosaic-program "xmosaic"
|
|
|
|
"*The name by which to invoke Mosaic (or mMosaic)."
|
|
|
|
:type 'string
|
|
|
|
:group 'browse-url)
|
|
|
|
|
1997-04-14 03:00:06 +00:00
|
|
|
(defcustom browse-url-mosaic-arguments nil
|
|
|
|
"*A list of strings to pass to Mosaic as arguments."
|
|
|
|
:type '(repeat (string :tag "Argument"))
|
|
|
|
:group 'browse-url)
|
1995-10-13 19:18:29 +00:00
|
|
|
|
1997-11-21 23:57:48 +00:00
|
|
|
(defcustom browse-url-filename-alist
|
1997-12-22 19:26:10 +00:00
|
|
|
'(("^/\\(ftp@\\|anonymous@\\)?\\([^:]+\\):/*" . "ftp://\\2/")
|
|
|
|
;; The above loses the username to avoid the browser prompting for
|
|
|
|
;; it in anonymous cases. If it's not anonymous the next regexp
|
|
|
|
;; applies.
|
|
|
|
("^/\\([^:@]+@\\)?\\([^:]+\\):/*" . "ftp://\\1\\2/")
|
|
|
|
("^/+" . "file:/"))
|
|
|
|
"*An alist of (REGEXP . STRING) pairs used by `browse-url-of-file'.
|
1995-10-13 19:18:29 +00:00
|
|
|
Any substring of a filename matching one of the REGEXPs is replaced by
|
1997-12-22 19:26:10 +00:00
|
|
|
the corresponding STRING using `replace-match', not treating STRING
|
|
|
|
literally. All pairs are applied in the order given. The default
|
|
|
|
value converts ange-ftp/EFS-style paths into ftp URLs and prepends
|
|
|
|
`file:' to any path beginning with `/'.
|
1997-06-15 02:49:03 +00:00
|
|
|
|
1997-12-22 19:26:10 +00:00
|
|
|
For example, adding to the default a specific translation of an ange-ftp
|
|
|
|
address to an HTTP URL:
|
1997-06-15 02:49:03 +00:00
|
|
|
|
|
|
|
(setq browse-url-filename-alist
|
|
|
|
'((\"/webmaster@webserver:/home/www/html/\" .
|
|
|
|
\"http://www.acme.co.uk/\")
|
1997-12-22 19:26:10 +00:00
|
|
|
(\"^/\\(ftp@\\|anonymous@\\)?\\([^:]+\\):/*\" . \"ftp://\\2/\")
|
|
|
|
(\"^/\\([^:@]+@\\)?\\([^:]+\\):/*\" . \"ftp://\\1\\2/\")
|
1997-06-15 02:49:03 +00:00
|
|
|
(\"^/+\" . \"file:/\")))
|
1997-11-21 23:57:48 +00:00
|
|
|
"
|
|
|
|
:type '(repeat (cons :format "%v"
|
1997-12-12 17:43:13 +00:00
|
|
|
(regexp :tag "Regexp")
|
1997-11-21 23:57:48 +00:00
|
|
|
(string :tag "Replacement")))
|
1997-12-22 19:26:10 +00:00
|
|
|
:version "20.3"
|
1997-11-21 23:57:48 +00:00
|
|
|
:group 'browse-url)
|
1995-10-13 19:18:29 +00:00
|
|
|
|
1997-11-21 23:57:48 +00:00
|
|
|
(defcustom browse-url-save-file nil
|
|
|
|
"*If non-nil, save the buffer before displaying its file.
|
|
|
|
Used by the `browse-url-of-file' command."
|
|
|
|
:type 'boolean
|
|
|
|
:group 'browse-url)
|
1995-10-13 19:18:29 +00:00
|
|
|
|
1997-11-21 23:57:48 +00:00
|
|
|
(defcustom browse-url-of-file-hook nil
|
|
|
|
"*Run after `browse-url-of-file' has asked a browser to load a file.
|
1995-10-13 19:18:29 +00:00
|
|
|
|
|
|
|
Set this to `browse-url-netscape-reload' to force Netscape to load the
|
1997-11-21 23:57:48 +00:00
|
|
|
file rather than displaying a cached copy."
|
|
|
|
:type 'hook
|
|
|
|
:group 'browse-url)
|
1995-10-13 19:18:29 +00:00
|
|
|
|
|
|
|
(defvar browse-url-usr1-signal
|
|
|
|
(if (and (boundp 'emacs-major-version)
|
1997-06-15 02:49:03 +00:00
|
|
|
(or (> emacs-major-version 19) (>= emacs-minor-version 29)))
|
1996-10-11 02:32:17 +00:00
|
|
|
'SIGUSR1 ; Why did I think this was in lower case before?
|
1997-06-15 02:49:03 +00:00
|
|
|
30) ; Check /usr/include/signal.h.
|
1995-10-13 19:18:29 +00:00
|
|
|
"The argument to `signal-process' for sending SIGUSR1 to XMosaic.
|
1996-01-04 22:53:41 +00:00
|
|
|
Emacs 19.29 accepts 'SIGUSR1, earlier versions require an integer
|
1995-10-13 19:18:29 +00:00
|
|
|
which is 30 on SunOS and 16 on HP-UX and Solaris.")
|
|
|
|
|
1997-11-21 23:57:48 +00:00
|
|
|
(defcustom browse-url-CCI-port 3003
|
|
|
|
"*Port to access XMosaic via CCI.
|
1995-10-13 19:18:29 +00:00
|
|
|
This can be any number between 1024 and 65535 but must correspond to
|
1997-11-21 23:57:48 +00:00
|
|
|
the value set in the browser."
|
|
|
|
:type 'integer
|
|
|
|
:group 'browse-url)
|
1995-10-13 19:18:29 +00:00
|
|
|
|
1997-11-21 23:57:48 +00:00
|
|
|
(defcustom browse-url-CCI-host "localhost"
|
1996-10-11 02:32:17 +00:00
|
|
|
"*Host to access XMosaic via CCI.
|
|
|
|
This should be the host name of the machine running XMosaic with CCI
|
1997-11-21 23:57:48 +00:00
|
|
|
enabled. The port number should be set in `browse-url-CCI-port'."
|
|
|
|
:type 'string
|
|
|
|
:group 'browse-url)
|
1996-10-11 02:32:17 +00:00
|
|
|
|
|
|
|
(defvar browse-url-temp-file-name nil)
|
|
|
|
(make-variable-buffer-local 'browse-url-temp-file-name)
|
|
|
|
|
1997-06-15 02:49:03 +00:00
|
|
|
(defcustom browse-url-xterm-program "xterm"
|
|
|
|
"*The name of the terminal emulator used by `browse-url-lynx-xterm'.
|
|
|
|
This might, for instance, be a separate colour version of xterm."
|
|
|
|
:type 'string
|
|
|
|
:group 'browse-url)
|
|
|
|
|
|
|
|
(defcustom browse-url-xterm-args nil
|
|
|
|
"*A list of strings defining options for `browse-url-xterm-program'.
|
|
|
|
These might set its size, for instance."
|
|
|
|
:type '(repeat (string :tag "Argument"))
|
|
|
|
:group 'browse-url)
|
|
|
|
|
|
|
|
(defcustom browse-url-gnudoit-program "gnudoit"
|
|
|
|
"*The name of the `gnudoit' program used by `browse-url-w3-gnudoit'."
|
|
|
|
:type 'string
|
|
|
|
:group 'browse-url)
|
|
|
|
|
|
|
|
(defcustom browse-url-gnudoit-args '("-q")
|
|
|
|
"*A list of strings defining options for `browse-url-gnudoit-program'.
|
|
|
|
These might set the port, for instance."
|
|
|
|
:type '(repeat (string :tag "Argument"))
|
|
|
|
:group 'browse-url)
|
|
|
|
|
|
|
|
(defcustom browse-url-generic-program nil
|
|
|
|
"*The name of the browser program used by `browse-url-generic'."
|
1997-12-12 17:43:13 +00:00
|
|
|
:type '(choice string (const :tag "None" nil))
|
1997-06-15 02:49:03 +00:00
|
|
|
:group 'browse-url)
|
|
|
|
|
|
|
|
(defcustom browse-url-generic-args nil
|
|
|
|
"*A list of strings defining options for `browse-url-generic-program'."
|
|
|
|
:type '(repeat (string :tag "Argument"))
|
|
|
|
:group 'browse-url)
|
|
|
|
|
1997-08-20 17:22:42 +00:00
|
|
|
(defcustom browse-url-temp-dir
|
|
|
|
(or (getenv "TMPDIR") "/tmp")
|
Doc fixes.
(browse-url): Apply, don't just call, browse-url-choose-browser, so
args works properly.
(browse-url-maybe-new-window): New function.
(browse-url-netscape, browse-url-mosaic, browse-url-cci,
browse-url-w3, browse-url-lynx-emacs, browse-url-mail): Use it.
(browse-url-lynx-emacs): Don't call term-term-name.
(browse-url-lynx-input-field, browse-url-lynx-input-delay,
browse-url-lynx-input-attempts): New variables.
(browse-url-lynx-emacs): Use any existing Lynx buffer; take care to
move off input fields. (After Vladimir Alexiev
<vladimir@cs.ualberta.ca>.)
(browse-url-mosaic-program): New variable.
(browse-url-mosaic): Use browse-url-mosaic-program and
browse-url-new-window-p.
(browse-url-at-mouse): Use browse-url-new-window-p.
1997-10-23 13:43:14 +00:00
|
|
|
"*The name of a directory for browse-url's temporary files.
|
|
|
|
Such files are generated by functions like `browse-url-of-region'.
|
|
|
|
You might want to set this to somewhere with restricted read permissions
|
|
|
|
for privacy's sake."
|
1997-08-20 17:22:42 +00:00
|
|
|
:type 'string
|
|
|
|
:group 'browse-url)
|
|
|
|
|
1997-08-27 18:43:39 +00:00
|
|
|
(defcustom browse-url-netscape-version
|
|
|
|
3
|
|
|
|
"*The version of Netscape you are using.
|
|
|
|
This affects how URL reloading is done; the mechanism changed
|
|
|
|
incompatibly at version 4."
|
|
|
|
:type 'number
|
|
|
|
:group 'browse-url)
|
|
|
|
|
1997-11-21 23:57:48 +00:00
|
|
|
(defcustom browse-url-lynx-input-field 'avoid
|
Doc fixes.
(browse-url): Apply, don't just call, browse-url-choose-browser, so
args works properly.
(browse-url-maybe-new-window): New function.
(browse-url-netscape, browse-url-mosaic, browse-url-cci,
browse-url-w3, browse-url-lynx-emacs, browse-url-mail): Use it.
(browse-url-lynx-emacs): Don't call term-term-name.
(browse-url-lynx-input-field, browse-url-lynx-input-delay,
browse-url-lynx-input-attempts): New variables.
(browse-url-lynx-emacs): Use any existing Lynx buffer; take care to
move off input fields. (After Vladimir Alexiev
<vladimir@cs.ualberta.ca>.)
(browse-url-mosaic-program): New variable.
(browse-url-mosaic): Use browse-url-mosaic-program and
browse-url-new-window-p.
(browse-url-at-mouse): Use browse-url-new-window-p.
1997-10-23 13:43:14 +00:00
|
|
|
"*Action on selecting an existing Lynx buffer at an input field.
|
|
|
|
What to do when sending a new URL to an existing Lynx buffer in Emacs
|
|
|
|
if the Lynx cursor is on an input field (in which case the `g' command
|
|
|
|
would be entered as data). Such fields are recognized by the
|
|
|
|
underlines ____. Allowed values: nil: disregard it, 'warn: warn the
|
|
|
|
user and don't emit the URL, 'avoid: try to avoid the field by moving
|
1997-11-21 23:57:48 +00:00
|
|
|
down (this *won't* always work)."
|
|
|
|
:type '(choice (const :tag "Move to try to avoid field" :value avoid)
|
|
|
|
(const :tag "Disregard" :value nil)
|
|
|
|
(const :tag "Warn, don't emit URL" :value warn))
|
|
|
|
:group 'browse-url)
|
Doc fixes.
(browse-url): Apply, don't just call, browse-url-choose-browser, so
args works properly.
(browse-url-maybe-new-window): New function.
(browse-url-netscape, browse-url-mosaic, browse-url-cci,
browse-url-w3, browse-url-lynx-emacs, browse-url-mail): Use it.
(browse-url-lynx-emacs): Don't call term-term-name.
(browse-url-lynx-input-field, browse-url-lynx-input-delay,
browse-url-lynx-input-attempts): New variables.
(browse-url-lynx-emacs): Use any existing Lynx buffer; take care to
move off input fields. (After Vladimir Alexiev
<vladimir@cs.ualberta.ca>.)
(browse-url-mosaic-program): New variable.
(browse-url-mosaic): Use browse-url-mosaic-program and
browse-url-new-window-p.
(browse-url-at-mouse): Use browse-url-new-window-p.
1997-10-23 13:43:14 +00:00
|
|
|
|
1997-11-21 23:57:48 +00:00
|
|
|
(defcustom browse-url-lynx-input-attempts 10
|
|
|
|
"*How many times to try to move down from a series of lynx input fields."
|
|
|
|
:type 'integer
|
|
|
|
:group 'browse-url)
|
Doc fixes.
(browse-url): Apply, don't just call, browse-url-choose-browser, so
args works properly.
(browse-url-maybe-new-window): New function.
(browse-url-netscape, browse-url-mosaic, browse-url-cci,
browse-url-w3, browse-url-lynx-emacs, browse-url-mail): Use it.
(browse-url-lynx-emacs): Don't call term-term-name.
(browse-url-lynx-input-field, browse-url-lynx-input-delay,
browse-url-lynx-input-attempts): New variables.
(browse-url-lynx-emacs): Use any existing Lynx buffer; take care to
move off input fields. (After Vladimir Alexiev
<vladimir@cs.ualberta.ca>.)
(browse-url-mosaic-program): New variable.
(browse-url-mosaic): Use browse-url-mosaic-program and
browse-url-new-window-p.
(browse-url-at-mouse): Use browse-url-new-window-p.
1997-10-23 13:43:14 +00:00
|
|
|
|
1997-11-21 23:57:48 +00:00
|
|
|
(defcustom browse-url-lynx-input-delay 0.2
|
|
|
|
"*How many seconds to wait for lynx between moves down from an input field."
|
|
|
|
:type 'number
|
|
|
|
:group 'browse-url)
|
Doc fixes.
(browse-url): Apply, don't just call, browse-url-choose-browser, so
args works properly.
(browse-url-maybe-new-window): New function.
(browse-url-netscape, browse-url-mosaic, browse-url-cci,
browse-url-w3, browse-url-lynx-emacs, browse-url-mail): Use it.
(browse-url-lynx-emacs): Don't call term-term-name.
(browse-url-lynx-input-field, browse-url-lynx-input-delay,
browse-url-lynx-input-attempts): New variables.
(browse-url-lynx-emacs): Use any existing Lynx buffer; take care to
move off input fields. (After Vladimir Alexiev
<vladimir@cs.ualberta.ca>.)
(browse-url-mosaic-program): New variable.
(browse-url-mosaic): Use browse-url-mosaic-program and
browse-url-new-window-p.
(browse-url-at-mouse): Use browse-url-new-window-p.
1997-10-23 13:43:14 +00:00
|
|
|
|
1996-10-11 02:32:17 +00:00
|
|
|
(defvar browse-url-temp-file-list '())
|
|
|
|
|
1995-10-13 19:18:29 +00:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; URL input
|
|
|
|
|
|
|
|
(defun browse-url-url-at-point ()
|
1997-07-04 20:00:43 +00:00
|
|
|
(let ((url (thing-at-point 'url)))
|
|
|
|
(set-text-properties 0 (length url) nil url)
|
1997-06-15 02:49:03 +00:00
|
|
|
url))
|
|
|
|
|
1996-10-11 02:32:17 +00:00
|
|
|
;; Having this as a separate function called by the browser-specific
|
|
|
|
;; functions allows them to be stand-alone commands, making it easier
|
|
|
|
;; to switch between browsers.
|
|
|
|
|
|
|
|
(defun browse-url-interactive-arg (prompt)
|
|
|
|
"Read a URL from the minibuffer, prompting with PROMPT.
|
1997-08-20 17:22:42 +00:00
|
|
|
Default to the URL at or before point. If invoked with a mouse button,
|
1996-10-11 02:32:17 +00:00
|
|
|
set point to the position clicked first. Return a list for use in
|
1997-06-15 02:49:03 +00:00
|
|
|
`interactive' containing the URL and `browse-url-new-window-p' or its
|
1996-10-11 02:32:17 +00:00
|
|
|
negation if a prefix argument was given."
|
1995-10-13 19:18:29 +00:00
|
|
|
(let ((event (elt (this-command-keys) 0)))
|
|
|
|
(and (listp event) (mouse-set-point event)))
|
1996-10-11 02:32:17 +00:00
|
|
|
(list (read-string prompt (browse-url-url-at-point))
|
|
|
|
(not (eq (null browse-url-new-window-p)
|
|
|
|
(null current-prefix-arg)))))
|
1995-10-13 19:18:29 +00:00
|
|
|
|
Doc fixes.
(browse-url): Apply, don't just call, browse-url-choose-browser, so
args works properly.
(browse-url-maybe-new-window): New function.
(browse-url-netscape, browse-url-mosaic, browse-url-cci,
browse-url-w3, browse-url-lynx-emacs, browse-url-mail): Use it.
(browse-url-lynx-emacs): Don't call term-term-name.
(browse-url-lynx-input-field, browse-url-lynx-input-delay,
browse-url-lynx-input-attempts): New variables.
(browse-url-lynx-emacs): Use any existing Lynx buffer; take care to
move off input fields. (After Vladimir Alexiev
<vladimir@cs.ualberta.ca>.)
(browse-url-mosaic-program): New variable.
(browse-url-mosaic): Use browse-url-mosaic-program and
browse-url-new-window-p.
(browse-url-at-mouse): Use browse-url-new-window-p.
1997-10-23 13:43:14 +00:00
|
|
|
(defun browse-url-maybe-new-window (arg)
|
|
|
|
(if (interactive-p)
|
|
|
|
arg
|
|
|
|
browse-url-new-window-p))
|
|
|
|
|
1995-10-13 19:18:29 +00:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; Browse current buffer
|
|
|
|
|
1996-10-11 02:34:27 +00:00
|
|
|
;;;###autoload
|
1995-10-13 19:18:29 +00:00
|
|
|
(defun browse-url-of-file (&optional file)
|
|
|
|
"Ask a WWW browser to display FILE.
|
|
|
|
Display the current buffer's file if FILE is nil or if called
|
1996-10-11 02:32:17 +00:00
|
|
|
interactively. Turn the filename into a URL with function
|
1997-06-15 02:49:03 +00:00
|
|
|
`browse-url-file-url'. Pass the URL to a browser using the
|
|
|
|
`browse-url' function then run `browse-url-of-file-hook'."
|
1995-10-13 19:18:29 +00:00
|
|
|
(interactive)
|
1997-06-15 02:49:03 +00:00
|
|
|
(or file
|
1996-10-11 02:32:17 +00:00
|
|
|
(setq file (buffer-file-name))
|
|
|
|
(error "Current buffer has no file"))
|
1995-10-13 19:18:29 +00:00
|
|
|
(let ((buf (get-file-buffer file)))
|
|
|
|
(if buf
|
1997-06-15 02:49:03 +00:00
|
|
|
(save-excursion
|
|
|
|
(set-buffer buf)
|
|
|
|
(cond ((not (buffer-modified-p)))
|
|
|
|
(browse-url-save-file (save-buffer))
|
|
|
|
(t (message "%s modified since last save" file))))))
|
|
|
|
(browse-url (browse-url-file-url file))
|
1995-10-13 19:18:29 +00:00
|
|
|
(run-hooks 'browse-url-of-file-hook))
|
|
|
|
|
|
|
|
(defun browse-url-file-url (file)
|
|
|
|
"Return the URL corresponding to FILE.
|
1997-12-22 19:26:10 +00:00
|
|
|
Use variable `browse-url-filename-alist' to map filenames to URLs."
|
1996-10-11 02:32:17 +00:00
|
|
|
;; URL-encode special chars, do % first
|
|
|
|
(let ((s 0))
|
|
|
|
(while (setq s (string-match "%" file s))
|
|
|
|
(setq file (replace-match "%25" t t file)
|
|
|
|
s (1+ s))))
|
|
|
|
(while (string-match "[*\"()',=;? ]" file)
|
|
|
|
(let ((enc (format "%%%x" (aref file (match-beginning 0)))))
|
|
|
|
(setq file (replace-match enc t t file))))
|
1995-10-13 19:18:29 +00:00
|
|
|
(let ((maps browse-url-filename-alist))
|
|
|
|
(while maps
|
|
|
|
(let* ((map (car maps))
|
1997-06-15 02:49:03 +00:00
|
|
|
(from-re (car map))
|
|
|
|
(to-string (cdr map)))
|
|
|
|
(setq maps (cdr maps))
|
1996-10-11 02:32:17 +00:00
|
|
|
(and (string-match from-re file)
|
1997-12-22 19:26:10 +00:00
|
|
|
(setq file (replace-match to-string t nil file))))))
|
1995-10-13 19:18:29 +00:00
|
|
|
file)
|
|
|
|
|
1996-10-11 02:34:27 +00:00
|
|
|
;;;###autoload
|
1995-10-13 19:18:29 +00:00
|
|
|
(defun browse-url-of-buffer (&optional buffer)
|
|
|
|
"Ask a WWW browser to display BUFFER.
|
1997-06-15 02:49:03 +00:00
|
|
|
Display the current buffer if BUFFER is nil. Display only the
|
|
|
|
currently visible part of BUFFER (from a temporary file) if buffer is
|
|
|
|
narrowed."
|
1995-10-13 19:18:29 +00:00
|
|
|
(interactive)
|
|
|
|
(save-excursion
|
1996-10-11 02:32:17 +00:00
|
|
|
(and buffer (set-buffer buffer))
|
1995-10-13 19:18:29 +00:00
|
|
|
(let ((file-name
|
1997-06-15 02:49:03 +00:00
|
|
|
;; Ignore real name if restricted
|
|
|
|
(and (= (- (point-max) (point-min)) (buffer-size))
|
|
|
|
(or buffer-file-name
|
|
|
|
(and (boundp 'dired-directory) dired-directory)))))
|
1996-10-11 02:32:17 +00:00
|
|
|
(or file-name
|
1997-06-15 02:49:03 +00:00
|
|
|
(progn
|
1996-10-11 02:32:17 +00:00
|
|
|
(or browse-url-temp-file-name
|
1997-06-15 02:49:03 +00:00
|
|
|
(setq browse-url-temp-file-name
|
1997-08-20 17:22:42 +00:00
|
|
|
(convert-standard-filename
|
|
|
|
(make-temp-name
|
|
|
|
(expand-file-name "burl" browse-url-temp-dir)))))
|
1996-10-11 02:32:17 +00:00
|
|
|
(setq file-name browse-url-temp-file-name)
|
|
|
|
(write-region (point-min) (point-max) file-name nil 'no-message)))
|
|
|
|
(browse-url-of-file file-name))))
|
1995-10-13 19:18:29 +00:00
|
|
|
|
|
|
|
(defun browse-url-delete-temp-file (&optional temp-file-name)
|
|
|
|
;; Delete browse-url-temp-file-name from the file system and from
|
|
|
|
;; browse-url-temp-file-list. If optional arg TEMP-FILE-NAME is
|
|
|
|
;; non-nil, delete it instead, but only from the file system --
|
|
|
|
;; browse-url-temp-file-list is not affected.
|
|
|
|
(let ((file-name (or temp-file-name browse-url-temp-file-name)))
|
|
|
|
(if (and file-name (file-exists-p file-name))
|
1997-06-15 02:49:03 +00:00
|
|
|
(progn
|
|
|
|
(delete-file file-name)
|
|
|
|
(if (null temp-file-name)
|
|
|
|
(setq browse-url-temp-file-list
|
|
|
|
(delete browse-url-temp-file-name
|
|
|
|
browse-url-temp-file-list)))))))
|
1995-10-13 19:18:29 +00:00
|
|
|
|
|
|
|
(defun browse-url-delete-temp-file-list ()
|
|
|
|
;; Delete all elements of browse-url-temp-file-list.
|
|
|
|
(while browse-url-temp-file-list
|
|
|
|
(browse-url-delete-temp-file (car browse-url-temp-file-list))
|
|
|
|
(setq browse-url-temp-file-list
|
1997-06-15 02:49:03 +00:00
|
|
|
(cdr browse-url-temp-file-list))))
|
1995-10-13 19:18:29 +00:00
|
|
|
|
|
|
|
(add-hook 'kill-buffer-hook 'browse-url-delete-temp-file)
|
|
|
|
(add-hook 'kill-emacs-hook 'browse-url-delete-temp-file-list)
|
|
|
|
|
1996-10-11 02:34:27 +00:00
|
|
|
;;;###autoload
|
1995-10-13 19:18:29 +00:00
|
|
|
(defun browse-url-of-dired-file ()
|
|
|
|
"In Dired, ask a WWW browser to display the file named on this line."
|
|
|
|
(interactive)
|
|
|
|
(browse-url-of-file (dired-get-filename)))
|
|
|
|
|
1997-06-15 02:49:03 +00:00
|
|
|
;;;###autoload
|
|
|
|
(defun browse-url-of-region (min max)
|
|
|
|
"Ask a WWW browser to display the current region."
|
|
|
|
(interactive "r")
|
|
|
|
(save-excursion
|
|
|
|
(save-restriction
|
|
|
|
(narrow-to-region (mark) (point))
|
|
|
|
(browse-url-of-buffer))))
|
|
|
|
|
1995-10-13 19:18:29 +00:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
1997-06-15 02:49:03 +00:00
|
|
|
;; Browser-independent commands
|
1996-10-11 02:32:17 +00:00
|
|
|
|
1997-06-15 02:49:03 +00:00
|
|
|
;; A generic command to call the current browse-url-browser-function
|
1996-10-11 02:32:17 +00:00
|
|
|
|
1997-06-15 02:49:03 +00:00
|
|
|
;;;###autoload
|
1996-10-11 02:32:17 +00:00
|
|
|
(defun browse-url (&rest args)
|
|
|
|
"Ask a WWW browser to load URL.
|
|
|
|
Prompts for a URL, defaulting to the URL at or before point. Variable
|
|
|
|
`browse-url-browser-function' says which browser to use."
|
|
|
|
(interactive (browse-url-interactive-arg "URL: "))
|
1997-06-15 02:49:03 +00:00
|
|
|
(if (consp browse-url-browser-function)
|
1997-11-21 23:57:48 +00:00
|
|
|
(apply 'browse-url-choose-browser args)
|
1997-06-15 02:49:03 +00:00
|
|
|
(apply browse-url-browser-function args)))
|
|
|
|
|
|
|
|
(defun browse-url-choose-browser (url &rest args)
|
|
|
|
"Pass URL to a browser function chosen.
|
|
|
|
This is done according to the association list in variable
|
|
|
|
`browse-url-browser-function'."
|
|
|
|
(let ((blist browse-url-browser-function)
|
|
|
|
re bf)
|
|
|
|
(while (consp blist)
|
|
|
|
(setq re (car (car blist))
|
|
|
|
bf (cdr (car blist))
|
|
|
|
blist (cdr blist))
|
|
|
|
(if (string-match re url)
|
|
|
|
(progn (apply bf url args) (setq blist t))))
|
|
|
|
(or blist
|
|
|
|
(error "No browser in browse-url-browser-function matching URL %s" url))))
|
1996-10-11 02:32:17 +00:00
|
|
|
|
1996-10-11 02:34:27 +00:00
|
|
|
;;;###autoload
|
1996-10-11 02:32:17 +00:00
|
|
|
(defun browse-url-at-point ()
|
|
|
|
"Ask a WWW browser to load the URL at or before point.
|
Doc fixes.
(browse-url): Apply, don't just call, browse-url-choose-browser, so
args works properly.
(browse-url-maybe-new-window): New function.
(browse-url-netscape, browse-url-mosaic, browse-url-cci,
browse-url-w3, browse-url-lynx-emacs, browse-url-mail): Use it.
(browse-url-lynx-emacs): Don't call term-term-name.
(browse-url-lynx-input-field, browse-url-lynx-input-delay,
browse-url-lynx-input-attempts): New variables.
(browse-url-lynx-emacs): Use any existing Lynx buffer; take care to
move off input fields. (After Vladimir Alexiev
<vladimir@cs.ualberta.ca>.)
(browse-url-mosaic-program): New variable.
(browse-url-mosaic): Use browse-url-mosaic-program and
browse-url-new-window-p.
(browse-url-at-mouse): Use browse-url-new-window-p.
1997-10-23 13:43:14 +00:00
|
|
|
Doesn't let you edit the URL like `browse-url'. Variable
|
1996-10-11 02:32:17 +00:00
|
|
|
`browse-url-browser-function' says which browser to use."
|
|
|
|
(interactive)
|
1997-06-15 02:49:03 +00:00
|
|
|
(browse-url (browse-url-url-at-point)))
|
1996-10-11 02:32:17 +00:00
|
|
|
|
1997-05-14 19:47:48 +00:00
|
|
|
(defun browse-url-event-buffer (event)
|
|
|
|
(window-buffer (posn-window (event-start event))))
|
1996-10-11 02:32:17 +00:00
|
|
|
|
1997-05-14 19:47:48 +00:00
|
|
|
(defun browse-url-event-point (event)
|
|
|
|
(posn-point (event-start event)))
|
1996-10-11 02:32:17 +00:00
|
|
|
|
1996-10-11 02:34:27 +00:00
|
|
|
;;;###autoload
|
1996-10-11 02:32:17 +00:00
|
|
|
(defun browse-url-at-mouse (event)
|
|
|
|
"Ask a WWW browser to load a URL clicked with the mouse.
|
|
|
|
The URL is the one around or before the position of the mouse click
|
|
|
|
but point is not changed. Doesn't let you edit the URL like
|
Doc fixes.
(browse-url): Apply, don't just call, browse-url-choose-browser, so
args works properly.
(browse-url-maybe-new-window): New function.
(browse-url-netscape, browse-url-mosaic, browse-url-cci,
browse-url-w3, browse-url-lynx-emacs, browse-url-mail): Use it.
(browse-url-lynx-emacs): Don't call term-term-name.
(browse-url-lynx-input-field, browse-url-lynx-input-delay,
browse-url-lynx-input-attempts): New variables.
(browse-url-lynx-emacs): Use any existing Lynx buffer; take care to
move off input fields. (After Vladimir Alexiev
<vladimir@cs.ualberta.ca>.)
(browse-url-mosaic-program): New variable.
(browse-url-mosaic): Use browse-url-mosaic-program and
browse-url-new-window-p.
(browse-url-at-mouse): Use browse-url-new-window-p.
1997-10-23 13:43:14 +00:00
|
|
|
`browse-url'. Variable `browse-url-browser-function' says which browser
|
1996-10-11 02:32:17 +00:00
|
|
|
to use."
|
|
|
|
(interactive "e")
|
|
|
|
(save-excursion
|
1997-05-14 19:47:48 +00:00
|
|
|
(set-buffer (browse-url-event-buffer event))
|
|
|
|
(goto-char (browse-url-event-point event))
|
1996-10-11 02:32:17 +00:00
|
|
|
(let ((url (browse-url-url-at-point)))
|
|
|
|
(if (string-equal url "")
|
|
|
|
(error "No URL found"))
|
Doc fixes.
(browse-url): Apply, don't just call, browse-url-choose-browser, so
args works properly.
(browse-url-maybe-new-window): New function.
(browse-url-netscape, browse-url-mosaic, browse-url-cci,
browse-url-w3, browse-url-lynx-emacs, browse-url-mail): Use it.
(browse-url-lynx-emacs): Don't call term-term-name.
(browse-url-lynx-input-field, browse-url-lynx-input-delay,
browse-url-lynx-input-attempts): New variables.
(browse-url-lynx-emacs): Use any existing Lynx buffer; take care to
move off input fields. (After Vladimir Alexiev
<vladimir@cs.ualberta.ca>.)
(browse-url-mosaic-program): New variable.
(browse-url-mosaic): Use browse-url-mosaic-program and
browse-url-new-window-p.
(browse-url-at-mouse): Use browse-url-new-window-p.
1997-10-23 13:43:14 +00:00
|
|
|
(browse-url url browse-url-new-window-p))))
|
1996-10-11 02:32:17 +00:00
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; Browser-specific commands
|
|
|
|
|
|
|
|
;; --- Netscape ---
|
|
|
|
|
|
|
|
(defun browse-url-process-environment ()
|
1997-06-15 02:49:03 +00:00
|
|
|
"Set DISPLAY in the environment to the X display Netscape is running on.
|
|
|
|
This is either the value of variable `browse-url-netscape-display' if
|
|
|
|
non-nil, or the same display as Emacs if different from the current
|
|
|
|
environment, otherwise just use the current environment."
|
|
|
|
(let ((display (or browse-url-netscape-display (browse-url-emacs-display))))
|
1996-10-11 02:32:17 +00:00
|
|
|
(if display
|
1997-06-15 02:49:03 +00:00
|
|
|
(cons (concat "DISPLAY=" display) process-environment)
|
1996-10-11 02:32:17 +00:00
|
|
|
process-environment)))
|
|
|
|
|
1997-06-15 02:49:03 +00:00
|
|
|
(defun browse-url-emacs-display ()
|
|
|
|
"Return the X display Emacs is running on.
|
Doc fixes.
(browse-url): Apply, don't just call, browse-url-choose-browser, so
args works properly.
(browse-url-maybe-new-window): New function.
(browse-url-netscape, browse-url-mosaic, browse-url-cci,
browse-url-w3, browse-url-lynx-emacs, browse-url-mail): Use it.
(browse-url-lynx-emacs): Don't call term-term-name.
(browse-url-lynx-input-field, browse-url-lynx-input-delay,
browse-url-lynx-input-attempts): New variables.
(browse-url-lynx-emacs): Use any existing Lynx buffer; take care to
move off input fields. (After Vladimir Alexiev
<vladimir@cs.ualberta.ca>.)
(browse-url-mosaic-program): New variable.
(browse-url-mosaic): Use browse-url-mosaic-program and
browse-url-new-window-p.
(browse-url-at-mouse): Use browse-url-new-window-p.
1997-10-23 13:43:14 +00:00
|
|
|
This is nil if the display is the same as the DISPLAY environment variable.
|
1997-06-15 02:49:03 +00:00
|
|
|
|
|
|
|
Actually Emacs could be using several screens on several displays, as
|
|
|
|
listed by (emacs-display-list) and (x-display-screens DISPLAY), this
|
|
|
|
just returns the display showing the selected frame. You got a
|
|
|
|
problem with that?"
|
|
|
|
(let (device display)
|
|
|
|
(and (fboundp 'selected-device) (fboundp 'device-type) (fboundp 'device-connection)
|
|
|
|
(setq device (selected-device))
|
|
|
|
(eq (device-type device) 'x)
|
|
|
|
(setq display (device-connection device))
|
|
|
|
(not (equal display (getenv "DISPLAY")))
|
|
|
|
display)))
|
1995-10-13 19:18:29 +00:00
|
|
|
|
1996-10-11 02:32:17 +00:00
|
|
|
;;;###autoload
|
1995-10-13 19:18:29 +00:00
|
|
|
(defun browse-url-netscape (url &optional new-window)
|
|
|
|
"Ask the Netscape WWW browser to load URL.
|
|
|
|
|
|
|
|
Default to the URL around or before point. The strings in variable
|
|
|
|
`browse-url-netscape-arguments' are also passed to Netscape.
|
|
|
|
|
|
|
|
When called interactively, if variable `browse-url-new-window-p' is
|
|
|
|
non-nil, load the document in a new Netscape window, otherwise use a
|
|
|
|
random existing one. A non-nil interactive prefix argument reverses
|
1997-06-15 02:49:03 +00:00
|
|
|
the effect of `browse-url-new-window-p'.
|
1995-10-13 19:18:29 +00:00
|
|
|
|
|
|
|
When called non-interactively, optional second argument NEW-WINDOW is
|
1997-06-15 02:49:03 +00:00
|
|
|
used instead of `browse-url-new-window-p'."
|
1996-10-11 02:32:17 +00:00
|
|
|
(interactive (browse-url-interactive-arg "Netscape URL: "))
|
|
|
|
;; URL encode any commas in the URL
|
|
|
|
(while (string-match "," url)
|
|
|
|
(setq url (replace-match "%2C" t t url)))
|
|
|
|
(let* ((process-environment (browse-url-process-environment))
|
|
|
|
(process (apply 'start-process
|
|
|
|
(concat "netscape " url) nil
|
1997-05-27 17:06:24 +00:00
|
|
|
browse-url-netscape-program
|
1997-06-15 02:49:03 +00:00
|
|
|
(append browse-url-netscape-arguments
|
1997-09-02 19:37:13 +00:00
|
|
|
(if (eq window-system 'w32)
|
1997-06-15 02:49:03 +00:00
|
|
|
(list url)
|
|
|
|
(if new-window '("-noraise"))
|
|
|
|
(list "-remote"
|
|
|
|
(concat "openURL(" url
|
Doc fixes.
(browse-url): Apply, don't just call, browse-url-choose-browser, so
args works properly.
(browse-url-maybe-new-window): New function.
(browse-url-netscape, browse-url-mosaic, browse-url-cci,
browse-url-w3, browse-url-lynx-emacs, browse-url-mail): Use it.
(browse-url-lynx-emacs): Don't call term-term-name.
(browse-url-lynx-input-field, browse-url-lynx-input-delay,
browse-url-lynx-input-attempts): New variables.
(browse-url-lynx-emacs): Use any existing Lynx buffer; take care to
move off input fields. (After Vladimir Alexiev
<vladimir@cs.ualberta.ca>.)
(browse-url-mosaic-program): New variable.
(browse-url-mosaic): Use browse-url-mosaic-program and
browse-url-new-window-p.
(browse-url-at-mouse): Use browse-url-new-window-p.
1997-10-23 13:43:14 +00:00
|
|
|
(if (browse-url-maybe-new-window
|
|
|
|
new-window)
|
|
|
|
",new-window")
|
1997-06-15 02:49:03 +00:00
|
|
|
")")))))))
|
1996-10-11 02:32:17 +00:00
|
|
|
(set-process-sentinel process
|
1997-06-15 02:49:03 +00:00
|
|
|
(list 'lambda '(process change)
|
|
|
|
(list 'browse-url-netscape-sentinel 'process url)))))
|
1996-10-11 02:32:17 +00:00
|
|
|
|
|
|
|
(defun browse-url-netscape-sentinel (process url)
|
|
|
|
"Handle a change to the process communicating with Netscape."
|
|
|
|
(or (eq (process-exit-status process) 0)
|
|
|
|
(let* ((process-environment (browse-url-process-environment)))
|
|
|
|
;; Netscape not running - start it
|
1997-06-15 02:49:03 +00:00
|
|
|
(message "Starting Netscape...")
|
1996-10-11 02:32:17 +00:00
|
|
|
(apply 'start-process (concat "netscape" url) nil
|
1997-05-27 17:06:24 +00:00
|
|
|
browse-url-netscape-program
|
1996-10-11 02:32:17 +00:00
|
|
|
(append browse-url-netscape-startup-arguments (list url))))))
|
1995-10-13 19:18:29 +00:00
|
|
|
|
|
|
|
(defun browse-url-netscape-reload ()
|
Doc fixes.
(browse-url): Apply, don't just call, browse-url-choose-browser, so
args works properly.
(browse-url-maybe-new-window): New function.
(browse-url-netscape, browse-url-mosaic, browse-url-cci,
browse-url-w3, browse-url-lynx-emacs, browse-url-mail): Use it.
(browse-url-lynx-emacs): Don't call term-term-name.
(browse-url-lynx-input-field, browse-url-lynx-input-delay,
browse-url-lynx-input-attempts): New variables.
(browse-url-lynx-emacs): Use any existing Lynx buffer; take care to
move off input fields. (After Vladimir Alexiev
<vladimir@cs.ualberta.ca>.)
(browse-url-mosaic-program): New variable.
(browse-url-mosaic): Use browse-url-mosaic-program and
browse-url-new-window-p.
(browse-url-at-mouse): Use browse-url-new-window-p.
1997-10-23 13:43:14 +00:00
|
|
|
"Ask Netscape to reload its current document.
|
|
|
|
How depends on `browse-url-netscape-version'."
|
1995-10-13 19:18:29 +00:00
|
|
|
(interactive)
|
1997-08-27 18:43:39 +00:00
|
|
|
;; Backwards incompatibility reported by
|
|
|
|
;; <peter.kruse@psychologie.uni-regensburg.de>.
|
|
|
|
(browse-url-netscape-send (if (>= browse-url-netscape-version 4)
|
|
|
|
"xfeDoCommand(reload)"
|
|
|
|
"reload")))
|
1995-10-13 19:18:29 +00:00
|
|
|
|
1996-10-11 02:32:17 +00:00
|
|
|
(defun browse-url-netscape-send (command)
|
1995-10-13 19:18:29 +00:00
|
|
|
"Send a remote control command to Netscape."
|
1996-10-11 02:32:17 +00:00
|
|
|
(let* ((process-environment (browse-url-process-environment)))
|
|
|
|
(apply 'start-process "netscape" nil
|
1997-05-27 17:06:24 +00:00
|
|
|
browse-url-netscape-program
|
1997-06-15 02:49:03 +00:00
|
|
|
(append browse-url-netscape-arguments
|
1996-10-11 02:32:17 +00:00
|
|
|
(list "-remote" command)))))
|
|
|
|
|
|
|
|
;; --- Mosaic ---
|
1995-10-13 19:18:29 +00:00
|
|
|
|
1996-10-11 02:32:17 +00:00
|
|
|
;;;###autoload
|
|
|
|
(defun browse-url-mosaic (url &optional new-window)
|
|
|
|
;; new-window ignored
|
1995-10-13 19:18:29 +00:00
|
|
|
"Ask the XMosaic WWW browser to load URL.
|
Doc fixes.
(browse-url): Apply, don't just call, browse-url-choose-browser, so
args works properly.
(browse-url-maybe-new-window): New function.
(browse-url-netscape, browse-url-mosaic, browse-url-cci,
browse-url-w3, browse-url-lynx-emacs, browse-url-mail): Use it.
(browse-url-lynx-emacs): Don't call term-term-name.
(browse-url-lynx-input-field, browse-url-lynx-input-delay,
browse-url-lynx-input-attempts): New variables.
(browse-url-lynx-emacs): Use any existing Lynx buffer; take care to
move off input fields. (After Vladimir Alexiev
<vladimir@cs.ualberta.ca>.)
(browse-url-mosaic-program): New variable.
(browse-url-mosaic): Use browse-url-mosaic-program and
browse-url-new-window-p.
(browse-url-at-mouse): Use browse-url-new-window-p.
1997-10-23 13:43:14 +00:00
|
|
|
|
|
|
|
Default to the URL around or before point. The strings in variable
|
|
|
|
`browse-url-mosaic-arguments' are also passed to Mosaic and the
|
|
|
|
program is invoked according to the variable
|
|
|
|
`browse-url-mosaic-program'.
|
|
|
|
|
|
|
|
When called interactively, if variable `browse-url-new-window-p' is
|
|
|
|
non-nil, load the document in a new Mosaic window, otherwise use a
|
|
|
|
random existing one. A non-nil interactive prefix argument reverses
|
|
|
|
the effect of `browse-url-new-window-p'.
|
|
|
|
|
|
|
|
When called non-interactively, optional second argument NEW-WINDOW is
|
|
|
|
used instead of `browse-url-new-window-p'."
|
1995-10-13 19:18:29 +00:00
|
|
|
(interactive (browse-url-interactive-arg "Mosaic URL: "))
|
|
|
|
(let ((pidfile (expand-file-name "~/.mosaicpid"))
|
1997-06-15 02:49:03 +00:00
|
|
|
pid pidbuf)
|
1995-10-13 19:18:29 +00:00
|
|
|
(if (file-readable-p pidfile)
|
1997-06-15 02:49:03 +00:00
|
|
|
(save-excursion
|
|
|
|
(find-file pidfile)
|
|
|
|
(goto-char (point-min))
|
|
|
|
(setq pid (read (current-buffer)))
|
|
|
|
(kill-buffer nil)))
|
1995-10-13 19:18:29 +00:00
|
|
|
(if (and pid (zerop (signal-process pid 0))) ; Mosaic running
|
1997-06-15 02:49:03 +00:00
|
|
|
(save-excursion
|
|
|
|
(find-file (format "/tmp/Mosaic.%d" pid))
|
|
|
|
(erase-buffer)
|
Doc fixes.
(browse-url): Apply, don't just call, browse-url-choose-browser, so
args works properly.
(browse-url-maybe-new-window): New function.
(browse-url-netscape, browse-url-mosaic, browse-url-cci,
browse-url-w3, browse-url-lynx-emacs, browse-url-mail): Use it.
(browse-url-lynx-emacs): Don't call term-term-name.
(browse-url-lynx-input-field, browse-url-lynx-input-delay,
browse-url-lynx-input-attempts): New variables.
(browse-url-lynx-emacs): Use any existing Lynx buffer; take care to
move off input fields. (After Vladimir Alexiev
<vladimir@cs.ualberta.ca>.)
(browse-url-mosaic-program): New variable.
(browse-url-mosaic): Use browse-url-mosaic-program and
browse-url-new-window-p.
(browse-url-at-mouse): Use browse-url-new-window-p.
1997-10-23 13:43:14 +00:00
|
|
|
(insert (if (browse-url-maybe-new-window new-window)
|
|
|
|
"newwin\n"
|
|
|
|
"goto\n")
|
|
|
|
url "\n")
|
1997-06-15 02:49:03 +00:00
|
|
|
(save-buffer)
|
|
|
|
(kill-buffer nil)
|
|
|
|
;; Send signal SIGUSR to Mosaic
|
1996-10-11 02:32:17 +00:00
|
|
|
(message "Signalling Mosaic...")
|
1997-06-15 02:49:03 +00:00
|
|
|
(signal-process pid browse-url-usr1-signal)
|
|
|
|
;; Or you could try:
|
|
|
|
;; (call-process "kill" nil 0 nil "-USR1" (int-to-string pid))
|
1996-10-11 02:32:17 +00:00
|
|
|
(message "Signalling Mosaic...done")
|
1997-06-15 02:49:03 +00:00
|
|
|
)
|
1995-10-13 19:18:29 +00:00
|
|
|
;; Mosaic not running - start it
|
|
|
|
(message "Starting Mosaic...")
|
Doc fixes.
(browse-url): Apply, don't just call, browse-url-choose-browser, so
args works properly.
(browse-url-maybe-new-window): New function.
(browse-url-netscape, browse-url-mosaic, browse-url-cci,
browse-url-w3, browse-url-lynx-emacs, browse-url-mail): Use it.
(browse-url-lynx-emacs): Don't call term-term-name.
(browse-url-lynx-input-field, browse-url-lynx-input-delay,
browse-url-lynx-input-attempts): New variables.
(browse-url-lynx-emacs): Use any existing Lynx buffer; take care to
move off input fields. (After Vladimir Alexiev
<vladimir@cs.ualberta.ca>.)
(browse-url-mosaic-program): New variable.
(browse-url-mosaic): Use browse-url-mosaic-program and
browse-url-new-window-p.
(browse-url-at-mouse): Use browse-url-new-window-p.
1997-10-23 13:43:14 +00:00
|
|
|
(apply 'start-process "xmosaic" nil browse-url-mosaic-program
|
1997-06-15 02:49:03 +00:00
|
|
|
(append browse-url-mosaic-arguments (list url)))
|
1996-01-04 08:32:49 +00:00
|
|
|
(message "Starting Mosaic...done"))))
|
1995-10-13 19:18:29 +00:00
|
|
|
|
1996-10-11 02:32:17 +00:00
|
|
|
;; --- Grail ---
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
(defvar browse-url-grail
|
|
|
|
(concat (or (getenv "GRAILDIR") "~/.grail") "/user/rcgrail.py")
|
|
|
|
"*Location of Grail remote control client script `rcgrail.py'.
|
|
|
|
Typically found in $GRAILDIR/rcgrail.py, or ~/.grail/user/rcgrail.py.")
|
|
|
|
|
|
|
|
;;;###autoload
|
1997-06-15 02:49:03 +00:00
|
|
|
(defun browse-url-grail (url &optional new-window)
|
1996-10-11 02:32:17 +00:00
|
|
|
"Ask the Grail WWW browser to load URL.
|
|
|
|
Default to the URL around or before point. Runs the program in the
|
|
|
|
variable `browse-url-grail'."
|
|
|
|
(interactive (browse-url-interactive-arg "Grail URL: "))
|
|
|
|
(message "Sending URL to Grail...")
|
|
|
|
(save-excursion
|
|
|
|
(set-buffer (get-buffer-create " *Shell Command Output*"))
|
|
|
|
(erase-buffer)
|
|
|
|
;; don't worry about this failing.
|
|
|
|
(call-process browse-url-grail nil 0 nil url)
|
|
|
|
(message "Sending URL to Grail... done")))
|
|
|
|
|
|
|
|
;; --- Mosaic using CCI ---
|
|
|
|
|
1995-10-13 19:18:29 +00:00
|
|
|
(defun browse-url-cci (url &optional new-window)
|
|
|
|
"Ask the XMosaic WWW browser to load URL.
|
|
|
|
Default to the URL around or before point.
|
|
|
|
|
|
|
|
This function only works for XMosaic version 2.5 or later. You must
|
|
|
|
select `CCI' from XMosaic's File menu, set the CCI Port Address to the
|
|
|
|
value of variable `browse-url-CCI-port', and enable `Accept requests'.
|
|
|
|
|
|
|
|
When called interactively, if variable `browse-url-new-window-p' is
|
|
|
|
non-nil, load the document in a new browser window, otherwise use a
|
|
|
|
random existing one. A non-nil interactive prefix argument reverses
|
1997-06-15 02:49:03 +00:00
|
|
|
the effect of `browse-url-new-window-p'.
|
1995-10-13 19:18:29 +00:00
|
|
|
|
|
|
|
When called non-interactively, optional second argument NEW-WINDOW is
|
1997-06-15 02:49:03 +00:00
|
|
|
used instead of `browse-url-new-window-p'."
|
1996-10-11 02:32:17 +00:00
|
|
|
(interactive (browse-url-interactive-arg "Mosaic URL: "))
|
1995-10-13 19:18:29 +00:00
|
|
|
(open-network-stream "browse-url" " *browse-url*"
|
1996-10-11 02:32:17 +00:00
|
|
|
browse-url-CCI-host browse-url-CCI-port)
|
1995-10-13 19:18:29 +00:00
|
|
|
;; Todo: start browser if fails
|
|
|
|
(process-send-string "browse-url"
|
1997-06-15 02:49:03 +00:00
|
|
|
(concat "get url (" url ") output "
|
Doc fixes.
(browse-url): Apply, don't just call, browse-url-choose-browser, so
args works properly.
(browse-url-maybe-new-window): New function.
(browse-url-netscape, browse-url-mosaic, browse-url-cci,
browse-url-w3, browse-url-lynx-emacs, browse-url-mail): Use it.
(browse-url-lynx-emacs): Don't call term-term-name.
(browse-url-lynx-input-field, browse-url-lynx-input-delay,
browse-url-lynx-input-attempts): New variables.
(browse-url-lynx-emacs): Use any existing Lynx buffer; take care to
move off input fields. (After Vladimir Alexiev
<vladimir@cs.ualberta.ca>.)
(browse-url-mosaic-program): New variable.
(browse-url-mosaic): Use browse-url-mosaic-program and
browse-url-new-window-p.
(browse-url-at-mouse): Use browse-url-new-window-p.
1997-10-23 13:43:14 +00:00
|
|
|
(if (browse-url-maybe-new-window
|
|
|
|
new-window)
|
|
|
|
"new"
|
|
|
|
"current")
|
|
|
|
"\r\n"))
|
1995-10-13 19:18:29 +00:00
|
|
|
(process-send-string "browse-url" "disconnect\r\n")
|
|
|
|
(delete-process "browse-url"))
|
|
|
|
|
1996-10-11 02:32:17 +00:00
|
|
|
;; --- IXI Mosaic ---
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
(defun browse-url-iximosaic (url &optional new-window)
|
|
|
|
;; new-window ignored
|
1995-10-13 19:18:29 +00:00
|
|
|
"Ask the IXIMosaic WWW browser to load URL.
|
|
|
|
Default to the URL around or before point."
|
|
|
|
(interactive (browse-url-interactive-arg "IXI Mosaic URL: "))
|
|
|
|
(start-process "tellw3b" nil "tellw3b"
|
1997-06-15 02:49:03 +00:00
|
|
|
"-service WWW_BROWSER ixi_showurl " url))
|
1995-10-13 19:18:29 +00:00
|
|
|
|
1996-10-11 02:32:17 +00:00
|
|
|
;; --- W3 ---
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
(defun browse-url-w3 (url &optional new-window)
|
1995-10-13 19:18:29 +00:00
|
|
|
"Ask the w3 WWW browser to load URL.
|
1997-12-12 17:43:13 +00:00
|
|
|
Default to the URL around or before point.
|
|
|
|
|
|
|
|
When called interactively, if variable `browse-url-new-window-p' is
|
|
|
|
non-nil, load the document in a new window. A non-nil interactive
|
|
|
|
prefix argument reverses the effect of `browse-url-new-window-p'.
|
|
|
|
|
|
|
|
When called non-interactively, optional second argument NEW-WINDOW is
|
|
|
|
used instead of `browse-url-new-window-p'."
|
1995-10-13 19:18:29 +00:00
|
|
|
(interactive (browse-url-interactive-arg "W3 URL: "))
|
Doc fixes.
(browse-url): Apply, don't just call, browse-url-choose-browser, so
args works properly.
(browse-url-maybe-new-window): New function.
(browse-url-netscape, browse-url-mosaic, browse-url-cci,
browse-url-w3, browse-url-lynx-emacs, browse-url-mail): Use it.
(browse-url-lynx-emacs): Don't call term-term-name.
(browse-url-lynx-input-field, browse-url-lynx-input-delay,
browse-url-lynx-input-attempts): New variables.
(browse-url-lynx-emacs): Use any existing Lynx buffer; take care to
move off input fields. (After Vladimir Alexiev
<vladimir@cs.ualberta.ca>.)
(browse-url-mosaic-program): New variable.
(browse-url-mosaic): Use browse-url-mosaic-program and
browse-url-new-window-p.
(browse-url-at-mouse): Use browse-url-new-window-p.
1997-10-23 13:43:14 +00:00
|
|
|
(if (browse-url-maybe-new-window new-window)
|
|
|
|
(w3-fetch-other-window)
|
|
|
|
(w3-fetch url)))
|
1995-10-13 19:18:29 +00:00
|
|
|
|
1997-06-15 02:49:03 +00:00
|
|
|
;;;###autoload
|
|
|
|
(defun browse-url-w3-gnudoit (url &optional new-window)
|
|
|
|
;; new-window ignored
|
|
|
|
"Ask another Emacs running gnuserv to load the URL using the W3 browser.
|
|
|
|
The `browse-url-gnudoit-program' program is used with options given by
|
|
|
|
`browse-url-gnudoit-args'. Default to the URL around or before point."
|
|
|
|
(interactive (browse-url-interactive-arg "W3 URL: "))
|
|
|
|
(apply 'start-process (concat "gnudoit:" url) nil
|
|
|
|
browse-url-gnudoit-program
|
|
|
|
(append browse-url-gnudoit-args (list (concat "(w3-fetch \"" url "\")") "(raise-frame)"))))
|
|
|
|
|
1996-10-11 02:32:17 +00:00
|
|
|
;; --- Lynx in an xterm ---
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
(defun browse-url-lynx-xterm (url &optional new-window)
|
|
|
|
;; new-window ignored
|
|
|
|
"Ask the Lynx WWW browser to load URL.
|
|
|
|
Default to the URL around or before point. A new Lynx process is run
|
1997-06-15 02:49:03 +00:00
|
|
|
in an Xterm window using the Xterm program named by `browse-url-xterm-program'
|
|
|
|
with possible additional arguments `browse-url-xterm-args'."
|
1996-10-11 02:32:17 +00:00
|
|
|
(interactive (browse-url-interactive-arg "Lynx URL: "))
|
1997-06-15 02:49:03 +00:00
|
|
|
(apply 'start-process (concat "lynx" url) nil browse-url-xterm-program
|
|
|
|
(append browse-url-xterm-args (list "-e" "lynx" url))))
|
1996-10-11 02:32:17 +00:00
|
|
|
|
|
|
|
;; --- Lynx in an Emacs "term" window ---
|
|
|
|
|
|
|
|
;;;###autoload
|
Doc fixes.
(browse-url): Apply, don't just call, browse-url-choose-browser, so
args works properly.
(browse-url-maybe-new-window): New function.
(browse-url-netscape, browse-url-mosaic, browse-url-cci,
browse-url-w3, browse-url-lynx-emacs, browse-url-mail): Use it.
(browse-url-lynx-emacs): Don't call term-term-name.
(browse-url-lynx-input-field, browse-url-lynx-input-delay,
browse-url-lynx-input-attempts): New variables.
(browse-url-lynx-emacs): Use any existing Lynx buffer; take care to
move off input fields. (After Vladimir Alexiev
<vladimir@cs.ualberta.ca>.)
(browse-url-mosaic-program): New variable.
(browse-url-mosaic): Use browse-url-mosaic-program and
browse-url-new-window-p.
(browse-url-at-mouse): Use browse-url-new-window-p.
1997-10-23 13:43:14 +00:00
|
|
|
(defun browse-url-lynx-emacs (url &optional new-buffer)
|
1996-10-11 02:32:17 +00:00
|
|
|
"Ask the Lynx WWW browser to load URL.
|
Doc fixes.
(browse-url): Apply, don't just call, browse-url-choose-browser, so
args works properly.
(browse-url-maybe-new-window): New function.
(browse-url-netscape, browse-url-mosaic, browse-url-cci,
browse-url-w3, browse-url-lynx-emacs, browse-url-mail): Use it.
(browse-url-lynx-emacs): Don't call term-term-name.
(browse-url-lynx-input-field, browse-url-lynx-input-delay,
browse-url-lynx-input-attempts): New variables.
(browse-url-lynx-emacs): Use any existing Lynx buffer; take care to
move off input fields. (After Vladimir Alexiev
<vladimir@cs.ualberta.ca>.)
(browse-url-mosaic-program): New variable.
(browse-url-mosaic): Use browse-url-mosaic-program and
browse-url-new-window-p.
(browse-url-at-mouse): Use browse-url-new-window-p.
1997-10-23 13:43:14 +00:00
|
|
|
Default to the URL around or before point. With a prefix argument, run
|
1997-12-12 17:43:13 +00:00
|
|
|
a new Lynx process in a new buffer.
|
|
|
|
|
|
|
|
When called interactively, if variable `browse-url-new-window-p' is
|
|
|
|
non-nil, load the document in a new lynx in a new term window,
|
|
|
|
otherwise use any existing one. A non-nil interactive prefix argument
|
|
|
|
reverses the effect of `browse-url-new-window-p'.
|
|
|
|
|
|
|
|
When called non-interactively, optional second argument NEW-WINDOW is
|
|
|
|
used instead of `browse-url-new-window-p'."
|
1996-10-11 02:32:17 +00:00
|
|
|
(interactive (browse-url-interactive-arg "Lynx URL: "))
|
Doc fixes.
(browse-url): Apply, don't just call, browse-url-choose-browser, so
args works properly.
(browse-url-maybe-new-window): New function.
(browse-url-netscape, browse-url-mosaic, browse-url-cci,
browse-url-w3, browse-url-lynx-emacs, browse-url-mail): Use it.
(browse-url-lynx-emacs): Don't call term-term-name.
(browse-url-lynx-input-field, browse-url-lynx-input-delay,
browse-url-lynx-input-attempts): New variables.
(browse-url-lynx-emacs): Use any existing Lynx buffer; take care to
move off input fields. (After Vladimir Alexiev
<vladimir@cs.ualberta.ca>.)
(browse-url-mosaic-program): New variable.
(browse-url-mosaic): Use browse-url-mosaic-program and
browse-url-new-window-p.
(browse-url-at-mouse): Use browse-url-new-window-p.
1997-10-23 13:43:14 +00:00
|
|
|
(let* ((system-uses-terminfo t) ; Lynx uses terminfo
|
|
|
|
;; (term-term-name "vt100") ; ??
|
|
|
|
(buf (get-buffer "*lynx*"))
|
|
|
|
(proc (and buf (get-buffer-process buf)))
|
|
|
|
(n browse-url-lynx-input-attempts))
|
|
|
|
(if (and (browse-url-maybe-new-window new-buffer) buf)
|
|
|
|
;; Rename away the OLD buffer. This isn't very polite, but
|
|
|
|
;; term insists on working in a buffer named *lynx* and would
|
|
|
|
;; choke on *lynx*<1>
|
|
|
|
(progn (set-buffer buf)
|
|
|
|
(rename-uniquely)))
|
|
|
|
(if (or (browse-url-maybe-new-window new-buffer)
|
|
|
|
(not buf)
|
|
|
|
(not proc)
|
|
|
|
(not (memq (process-status proc) '(run stop))))
|
|
|
|
;; start a new lynx
|
1997-12-12 17:43:13 +00:00
|
|
|
(progn (setq buf (make-term "lynx" "lynx" nil url))
|
|
|
|
(switch-to-buffer buf)
|
|
|
|
(term-char-mode)
|
|
|
|
(set-process-sentinel
|
|
|
|
(get-buffer-process buf)
|
|
|
|
;; Don't leave around a dead one (especially because
|
|
|
|
;; of its munged keymap.)
|
|
|
|
(lambda (process event)
|
|
|
|
(if (not (memq (process-status process) '(run stop)))
|
|
|
|
(let ((buf (process-buffer process)))
|
|
|
|
(if buf (kill-buffer buf)))))))
|
Doc fixes.
(browse-url): Apply, don't just call, browse-url-choose-browser, so
args works properly.
(browse-url-maybe-new-window): New function.
(browse-url-netscape, browse-url-mosaic, browse-url-cci,
browse-url-w3, browse-url-lynx-emacs, browse-url-mail): Use it.
(browse-url-lynx-emacs): Don't call term-term-name.
(browse-url-lynx-input-field, browse-url-lynx-input-delay,
browse-url-lynx-input-attempts): New variables.
(browse-url-lynx-emacs): Use any existing Lynx buffer; take care to
move off input fields. (After Vladimir Alexiev
<vladimir@cs.ualberta.ca>.)
(browse-url-mosaic-program): New variable.
(browse-url-mosaic): Use browse-url-mosaic-program and
browse-url-new-window-p.
(browse-url-at-mouse): Use browse-url-new-window-p.
1997-10-23 13:43:14 +00:00
|
|
|
;; send the url to lynx in the old buffer
|
|
|
|
(let ((win (get-buffer-window buf t)))
|
|
|
|
(if win
|
|
|
|
(select-window win)
|
|
|
|
(switch-to-buffer buf)))
|
|
|
|
(if (eq (following-char) ?_)
|
|
|
|
(cond ((eq browse-url-lynx-input-field 'warn)
|
|
|
|
(error "Please move out of the input field first."))
|
|
|
|
((eq browse-url-lynx-input-field 'avoid)
|
|
|
|
(while (and (eq (following-char) ?_) (> n 0))
|
|
|
|
(term-send-down) ; down arrow
|
|
|
|
(sit-for browse-url-lynx-input-delay))
|
|
|
|
(if (eq (following-char) ?_)
|
|
|
|
(error "Cannot move out of the input field, sorry.")))))
|
|
|
|
(term-send-string proc (concat "g" ; goto
|
|
|
|
"\C-u" ; kill default url
|
|
|
|
url
|
|
|
|
"\r")))))
|
1996-07-24 16:11:21 +00:00
|
|
|
|
1997-06-15 02:49:03 +00:00
|
|
|
;; --- MMM ---
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
(defun browse-url-mmm (url &optional new-window)
|
|
|
|
"Ask the MMM WWW browser to load URL.
|
|
|
|
Default to the URL around or before point."
|
|
|
|
(interactive (browse-url-interactive-arg "MMM URL: "))
|
|
|
|
(message "Sending URL to MMM...")
|
|
|
|
(save-excursion
|
|
|
|
(set-buffer (get-buffer-create " *Shell Command Output*"))
|
|
|
|
(erase-buffer)
|
|
|
|
;; mmm_remote just SEGVs if the file isn't there...
|
|
|
|
(if (or (file-exists-p (expand-file-name "~/.mmm_remote"))
|
|
|
|
;; location in v 0.4:
|
|
|
|
(file-exists-p (expand-file-name "~/.mmm/remote")))
|
|
|
|
(call-process "mmm_remote" nil 0 nil url)
|
|
|
|
(call-process "mmm" nil 0 nil "-external" url))
|
|
|
|
(message "Sending URL to MMM... done")))
|
|
|
|
|
|
|
|
;; --- mailto ---
|
|
|
|
|
|
|
|
;;;###autoload
|
1997-08-27 21:20:47 +00:00
|
|
|
(defun browse-url-mail (url &optional new-window)
|
1997-06-15 02:49:03 +00:00
|
|
|
"Open a new mail message buffer within Emacs.
|
1997-08-27 21:20:47 +00:00
|
|
|
Default to using the mailto: URL around or before point as the
|
|
|
|
recipient's address. Supplying a non-nil interactive prefix argument
|
|
|
|
will cause the mail to be composed in another window rather than the
|
1997-12-12 17:43:13 +00:00
|
|
|
current one.
|
|
|
|
|
|
|
|
When called interactively, if variable `browse-url-new-window-p' is
|
|
|
|
non-nil use `compose-mail-other-window', otherwise `compose-mail'. A
|
|
|
|
non-nil interactive prefix argument reverses the effect of
|
|
|
|
`browse-url-new-window-p'.
|
|
|
|
|
|
|
|
When called non-interactively, optional second argument NEW-WINDOW is
|
|
|
|
used instead of `browse-url-new-window-p'."
|
1997-06-15 02:49:03 +00:00
|
|
|
(interactive (browse-url-interactive-arg "Mailto URL: "))
|
|
|
|
(save-excursion
|
Doc fixes.
(browse-url): Apply, don't just call, browse-url-choose-browser, so
args works properly.
(browse-url-maybe-new-window): New function.
(browse-url-netscape, browse-url-mosaic, browse-url-cci,
browse-url-w3, browse-url-lynx-emacs, browse-url-mail): Use it.
(browse-url-lynx-emacs): Don't call term-term-name.
(browse-url-lynx-input-field, browse-url-lynx-input-delay,
browse-url-lynx-input-attempts): New variables.
(browse-url-lynx-emacs): Use any existing Lynx buffer; take care to
move off input fields. (After Vladimir Alexiev
<vladimir@cs.ualberta.ca>.)
(browse-url-mosaic-program): New variable.
(browse-url-mosaic): Use browse-url-mosaic-program and
browse-url-new-window-p.
(browse-url-at-mouse): Use browse-url-new-window-p.
1997-10-23 13:43:14 +00:00
|
|
|
(let ((func (if (browse-url-maybe-new-window new-window)
|
1997-08-27 21:20:47 +00:00
|
|
|
'compose-mail-other-window
|
|
|
|
'compose-mail))
|
|
|
|
(to (if (string-match "^mailto:" url)
|
1997-06-15 02:49:03 +00:00
|
|
|
(substring url 7)
|
1997-08-27 21:20:47 +00:00
|
|
|
url)))
|
|
|
|
(apply func
|
|
|
|
(list to nil nil nil nil nil (cons 'insert-buffer
|
|
|
|
(current-buffer)))))))
|
1997-06-15 02:49:03 +00:00
|
|
|
|
|
|
|
;; --- Random browser ---
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
(defun browse-url-generic (url &optional new-window)
|
|
|
|
;; new-window ignored
|
|
|
|
"Ask the WWW browser defined by `browse-url-generic-program' to load URL.
|
|
|
|
Default to the URL around or before point. A fresh copy of the
|
|
|
|
browser is started up in a new process with possible additional arguments
|
|
|
|
`browse-url-generic-args'. This is appropriate for browsers which
|
|
|
|
don't offer a form of remote control."
|
|
|
|
(interactive (browse-url-interactive-arg "URL: "))
|
|
|
|
(if (not browse-url-generic-program)
|
|
|
|
(error "No browser defined (`browse-url-generic-program')"))
|
|
|
|
(apply 'start-process (concat browse-url-generic-program url) nil
|
|
|
|
browse-url-generic-program
|
|
|
|
(append browse-url-generic-args (list url))))
|
|
|
|
|
1995-10-13 19:18:29 +00:00
|
|
|
(provide 'browse-url)
|
|
|
|
|
|
|
|
;;; browse-url.el ends here
|