Matt Curtin <cmcurtin(a)interhack.net> writes:
FSF does have a new maintainer, though; perhaps I should submit the
patch to him, and then we can incorporate the new browse-url.el that
way.
FSF 20.4's browse-url escape's "," and ")".
Here is the diff between there version and ours. Note that the diff
cannot be applied as is because it removes useful stuff (like in
annyoing FSF tradition the version numbers and history)
I suggest you still act as "our" Maintainer.
What would be cool if somebody would implement the netscape remote protocol
directly (Unfortunately part of that includes "Grab the global X lock")
Jan
diff -u /scratch/vroonhof/cvs/xemacs-20/xemacs-packages/lisp/mail-lib/browse-url.el
/usr/local/app/emacs/20.4/share/emacs/20.4/lisp/browse-url.el
--- /scratch/vroonhof/cvs/xemacs-20/xemacs-packages/lisp/mail-lib/browse-url.el Wed Nov 10
19:45:59 1999
+++ /usr/local/app/emacs/20.4/share/emacs/20.4/lisp/browse-url.el Wed Nov 10 19:45:59
1999
@@ -1,37 +1,31 @@
-;;; browse-url.el --- ask a WWW browser to load a URL
+;;; browse-url.el --- Pass a URL to a WWW browser
-;; Copyright 1995 Free Software Foundation, Inc.
+;; Copyright (C) 1995, 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
;; Author: Denis Howe <dbh(a)doc.ic.ac.uk>
-;; Maintainer: Denis Howe <dbh(a)doc.ic.ac.uk>
+;; Maintainer: Dave Love <fx(a)gnu.org>
;; Created: 03 Apr 1995
-;; Version: 0.38 18 Jun 1996
-;; Keywords: hypertext
-;; X-Home page:
http://wombat.doc.ic.ac.uk/
-
-;; This file is part of XEmacs.
-
-;; XEmacs is free software; you can redistribute it and/or modify it
-;; under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 1, or (at your option)
+;; Keywords: hypertext, hypermedia, mouse
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software; you can redistribute it and/or modify
+;; 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.
-;; XEmacs 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.
+;; 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.
;; You should have received a copy of the GNU General Public License
-;; along with XEmacs; see the file COPYING. If not, write to the Free
-;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-;; 02111-1307, USA.
+;; along with GNU Emacs; see the file COPYING. If not, write to the
+;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; 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
@@ -41,20 +35,25 @@
;; is started. Currently there is support for:
;; Function Browser Earliest version
-;; browse-url-netscape Netscape 1.1b1
-;; browse-url-mosaic XMosaic <= 2.4
+;; browse-url-netscape Netscape 1.1b1
+;; browse-url-mosaic XMosaic/mMosaic <= 2.4
;; browse-url-cci XMosaic 2.5
;; browse-url-w3 w3 0
+;; browse-url-w3-gnudoit w3 remotely
;; browse-url-iximosaic IXI Mosaic ?
;; browse-url-lynx-* Lynx 0
;; browse-url-grail Grail 0.3b1
-;; browse-url-kfm kde
+;; browse-url-mmm MMM ?
+;; browse-url-generic arbitrary
+
+;; [A version of the Netscape browser is now free software
+;; <
URL:http://www.mozilla.org/>, albeit not GPLed, so it is
+;; reasonable to have that as the default.]
;; Note that versions of Netscape before 1.1b1 did not have remote
-;; control. <
URL:http://www.netscape.com/newsref/std/x-remote.html>
-;; and <
URL:http://www.netscape.com/info/APIs/>.
+;; control. <
URL:http://www.netscape.com/newsref/std/x-remote.html>.
-;; Netscape can cache Web pages so it may be necessary to tell it to
+;; Browsers can cache Web pages so it may be necessary to tell them to
;; reload the current page if it has changed (e.g. if you have edited
;; it). There is currently no perfect automatic solution to this.
@@ -74,27 +73,51 @@
;; 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.
-
-;; I recommend Nelson Minar <nelson(a)santafe.edu>'s excellent
-;; html-helper-mode.el for editing HTML and thank Nelson for
-;; his many useful comments on this code.
-;; <
URL:http://www.santafe.edu/~nelson/hhm-beta/>
-
-;; This package generalises function html-previewer-process in Marc
-;; Andreessen <marca(a)ncsa.uiuc.edu>'s html-mode (LCD
-;; modes/html-mode.el.Z) and provides better versions of the URL
-;; functions in Michelangelo Grigni <mic(a)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.
+;; The `gnuserv' package that can be used to control it in another
+;; Emacs process is available from
+;; <
URL:ftp://ftp.splode.com/pub/users/friedman/packages/>.
;; 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://monty.cnri.reston.va.us/> and for more information on
+;; <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(a)python.org>.
+;; MMM is the freely available WWW browser implemented in Objective
+;; Caml, 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'
+;; include Chimera <
URL:ftp://ftp.cs.unlv.edu/pub/chimera> and
+;; <
URL:http://www.unlv.edu/chimera/>, Arena
+;; <
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.
+
+;; I [Denis Howe, not Dave Love] recommend Nelson Minar
+;; <nelson(a)santafe.edu>'s excellent html-helper-mode.el for editing
+;; HTML and thank Nelson for his many useful comments on this code.
+;; <
URL:http://www.santafe.edu/%7Enelson/hhm-beta/>
+
+;; 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.
+
+;; This package generalises function html-previewer-process in Marc
+;; Andreessen's html-mode (LCD modes/html-mode.el.Z). See also the
+;; ffap.el package. The huge hyperbole package also contains similar
+;; functions.
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Help!
@@ -104,34 +127,26 @@
;; Do any other browsers have remote control?
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; Installation
-
-;; Put the following in your ~/.emacs file:
-;;
-;; (autoload 'browse-url-at-point "browse-url"
-;; "Ask a WWW browser to load the URL at or before point." t)
-;; (autoload 'browse-url-at-mouse "browse-url"
-;; "Ask a WWW browser to load a URL clicked with the mouse." t)
-;; (autoload 'browse-url-of-buffer "browse-url"
-;; "Ask a WWW browser to display BUFFER." t)
-;; (autoload 'browse-url-of-file "browse-url"
-;; "Ask a WWW browser to display FILE." t)
-;; (autoload 'browse-url-of-dired-file "browse-url"
-;; "In Dired, ask a WWW browser to display the file named on this line." t)
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Usage
;; To display the URL at or before point:
;; M-x browse-url-at-point RET
+;; or, similarly but with the opportunity to edit the URL extracted from
+;; the buffer, use:
+;; M-x browse-url
;; To display a URL by shift-clicking on it, put this in your ~/.emacs
;; file:
-;; (global-set-key [S-mouse-1] 'browse-url-at-mouse)
+;; (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.)
;; To display the current buffer in a web browser:
;; M-x browse-url-of-buffer RET
+;; To display the current region in a web browser:
+;; M-x browse-url-of-region RET
+
;; In Dired, to display the file named on the current line:
;; M-x browse-url-of-dired-file RET
@@ -139,25 +154,30 @@
;; Customisation (~/.emacs)
;; To see what variables are available for customization, type
-;; `M-x set-variable browse-url TAB'.
+;; `M-x set-variable browse-url TAB'. Better, use
+;; `M-x customize-group browse-url'.
;; 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)
+;; (global-set-key "\C-c\C-zr" 'browse-url-of-region)
;; (global-set-key "\C-c\C-zu" 'browse-url)
;; (global-set-key "\C-c\C-zv" 'browse-url-of-file)
;; (add-hook 'dired-mode-hook
-;; (function (lambda ()
-;; (local-set-key "\C-c\C-zf" 'browse-url-of-dired-file))))
+;; (lambda ()
+;; (local-set-key "\C-c\C-zf" 'browse-url-of-dired-file)))
;; Browse URLs in mail messages by clicking mouse-2:
-;; (add-hook 'rmail-mode-hook (function (lambda () ; rmail-mode startup
-;; (define-key rmail-mode-map [mouse-2] 'browse-url-at-mouse))))
+;; (add-hook 'rmail-mode-hook (lambda () ; rmail-mode startup
+;; (define-key rmail-mode-map [mouse-2] 'browse-url-at-mouse)))
;; 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))
+;; [The current version of Gnus provides a standard feature to
+;; activate URLs in article buffers for invocation of browse-url with
+;; mouse-2.]
;; Use the Emacs w3 browser when not running under X11:
;; (or (eq window-system 'x)
@@ -172,14 +192,14 @@
;; (autoload 'browse-url-netscape-reload "browse-url"
;; "Ask a WWW browser to redisplay the current file." t)
;; (add-hook 'html-helper-mode-hook
-;; (function (lambda ()
+;; (lambda ()
;; (add-hook 'local-write-file-hooks
-;; (function (lambda ()
+;; (lambda ()
;; (let ((local-write-file-hooks))
;; (save-buffer))
;; (browse-url-netscape-reload)
-;; t)) ; => file written by hook
-;; t)))) ; append to l-w-f-hooks
+;; t) ; => file written by hook
+;; t))) ; append to l-w-f-hooks
;;
;; OR have browse-url-of-file ask Netscape to load and then reload the
;; file:
@@ -189,247 +209,158 @@
;; You may also want to customise browse-url-netscape-arguments, e.g.
;; (setq browse-url-netscape-arguments '("-install"))
;;
-;; or similarly for mosaic.
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;; Change Log:
-
-;; 0.00 03 Apr 1995 Denis Howe <dbh(a)doc.ic.ac.uk>
-;; Created.
-
-;; 0.01 04 Apr 1995
-;; All names start with "browse-url-". Added provide.
-
-;; 0.02 05 Apr 1995
-;; Save file at start of browse-url-of-file.
-;; Use start-process instead of start-process-shell-command.
-
-;; 0.03 06 Apr 1995
-;; Add browse-url-netscape-reload, browse-url-netscape-send.
-;; browse-url-of-file save file option.
-
-;; 0.04 08 Apr 1995
-;; b-u-file-url separate function. Change b-u-filename-alist
-;; default.
-
-;; 0.05 09 Apr 1995
-;; Added b-u-of-file-hook.
-
-;; 0.06 11 Apr 1995
-;; Improved .emacs suggestions and documentation.
-
-;; 0.07 13 Apr 1995
-;; Added browse-url-interactive-arg optional prompt.
-
-;; 0.08 18 Apr 1995
-;; Exclude final "." from browse-url-regexp.
-
-;; 0.09 21 Apr 1995
-;; Added mouse-set-point to browse-url-interactive-arg.
-
-;; 0.10 24 Apr 1995
-;; Added Mosaic signal sending variations.
-;; Thanks Brian K Servis <servis(a)ecn.purdue.edu>.
-;; Don't use xprop for Netscape.
-
-;; 0.11 25 Apr 1995
-;; Fix reading of ~/.mosaicpid. Thanks Dag.H.Wanvik(a)kvatro.no.
-
-;; 0.12 27 Apr 1995
-;; Interactive prefix arg => URL *after* point.
-;; Thanks Michelangelo Grigni <mic(a)cs.ucsd.edu>.
-;; Added IXI Mosaic support.
-;; Thanks David Karr <dkarr(a)nmo.gtegsc.com>.
-
-;; 0.13 28 Apr 1995
-;; Exclude final [,;] from browse-url-regexp.
-
-;; 0.14 02 May 1995
-;; Provide browser argument variables.
-
-;; 0.15 07 May 1995
-;; More Netscape options. Thanks Peter Arius
-;; <arius(a)immd2.informatik.uni-erlangen.de>.
-
-;; 0.16 17 May 1995
-;; Added browse-url-at-mouse.
-;; Thanks Wayne Mesard <wmesard(a)sgi.com>
-
-;; 0.17 27 Jun 1995
-;; Renamed browse-url-at-point to browse-url-url-at-point.
-;; Added browse-url-at-point.
-;; Thanks Jonathan Cano <cano(a)patch.tandem.com>.
-
-;; 0.18 16 Aug 1995
-;; Fixed call to browse-url-url-at-point in browse-url-at-point.
-;; Thanks Eric Ding <ericding(a)San-Jose.ate.slb.com>.
-
-;; 0.19 24 Aug 1995
-;; Improved documentation.
-;; Thanks Kevin Rodgers <kevin.rodgers(a)ihs.com>.
-
-;; 0.20 31 Aug 1995
-;; browse-url-of-buffer to handle file-less buffers.
-;; browse-url-of-dired-file browses current file in dired.
-;; Thanks Kevin Rodgers <kevin.rodgers(a)ihs.com>.
-
-;; 0.21 09 Sep 1995
-;; XMosaic CCI functions.
-;; Thanks Marc Furrer <Marc.Furrer(a)di.epfl.ch>.
-
-;; 0.22 13 Sep 1995
-;; Fixed new-window documentation and added to browse-url-cci.
-;; Thanks Dilip Sequeira <djs(a)dcs.ed.ac.uk>.
-
-;; 0.23 10 Nov 1995
-;; Added b-u-lynx. Thanks Steven L. Baur <steve(a)miranova.com>.
-
-;; 0.24 22 Nov 1995
-;; Renamed b-u-netscape command to b-u-netscape-send.
-;; Added b-u-netscape-command variable.
-
-;; 0.25 03 Dec 1995
-;; Added event-buffer and event-point for XEmacs compatibility.
-;; Thanks Eric Engstrom <engstrom(a)src.honeywell.com>
+;; or similarly for the other browsers.
-;; 0.26 13 Jan 1996
-;; Changed b-u-lynx to b-u-lynx-xterm, added b-u-lynx-emacs to
-;; run Lynx in an Emacs buffer under terminal-emulator.
-;; Thanks Jari Aalto <jaalto(a)tre.tele.nokia.fi>
-
-;; 0.27 27 Feb 1996
-;; Changed event-buffer and event-point from macros to functions.
-;; Other fixes for byte-compilation.
-
-;; 0.28 07 Mar 1996
-;; browse-url-lynx-emacs uses term.el instead of terminal.el.
-
-;; 0.29 13 Mar 1996
-;; Added browse-url-CCI-host. Thanks Greg Marr <gregm(a)WPI.EDU>.
-
-;; 0.30 23 Mar 1996
-;; Contact/start Netscape in the background.
-;; Thanks Per Abrahamsen <abraham(a)dina.kvl.dk>
-
-;; 0.31 28 Apr 1996
-;; Added browse-url command.
-;; Added new-window logic to b-u-interactive-arg.
-;; b-u-file-url checks for EFS path.
-
-;; 0.32 02 May 1996
-;; Improved b-u-url-at-point matching to supply missing "http://".
-
-;; 0.33 01 Jun 1996
-;; Jari Aalto <jaalto(a)tre.tele.nokia.fi> browse-url-lynx-emacs
-;; fix. Thanks Jari.
-
-;; 0.34 05 Jun 1996
-;; b-u-file-url checks for EFS after alist. Thanks
-;; Jens-U H Petersen <petersen(a)kurims.kyoto-u.ac.jp>
-
-;; 0.35 11 Jun 1996
-;; Grail support. Thanks Barry A. Warsaw
-;; <bwarsaw(a)anthem.cnri.reston.va.us>.
-
-;; 0.36 12 Jun 1996
-;; Fixed browse-url-looking-at (I hope).
-
-;; 0.37 15 Jun 1996
-;; b-u-file-url URL-encodes special chars.
-;; Thanks Martin Schwenke <Martin.Schwenke(a)cs.anu.edu.au>.
-
-;; 0.38 17 Jun 1996
-;; b-u-file-url encodes fewer chars. Multi-display support for
-;; Netscape. Thanks Richard Mlynarik <mly(a)adoc.xerox.com>
+;; To invoke different browsers for different URLs:
+;; (setq browse-url-browser-function '(("^mailto:" . browse-url-mail)
+;; ("." . browse-url-netscape)))
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Code:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Variables
-;; (eval-when-compile (require 'dired))
+(eval-when-compile (require 'thingatpt)
+ (require 'term)
+ (require 'w3-auto nil t))
(defgroup browse-url nil
- "Ask a WWW browser to load a URL."
+ "Use a web browser to look at a URL."
+ :prefix "browse-url-"
:group 'hypermedia)
-
-(defvar browse-url-path-regexp
- "[^]\t\n \"'()<>[^`{}]*[^]\t\n
\"'()<>[^`{}.,;]+"
- "A regular expression probably matching the host, path or e-mail
-part of a URL.")
-
-(defvar browse-url-short-regexp
- (concat "[-A-Za-z0-9.]+" browse-url-path-regexp)
- "A regular expression probably matching a URL without an access scheme.
-Hostname matching is stricter in this case than for
-``browse-url-regexp''.")
-
-(defvar browse-url-regexp
- (concat
-
"\\(https?://\\|ftp://\\|gopher://\\|telnet://\\|wais://\\|file:/\\|s?news:\\|mailto:\\)"
- browse-url-path-regexp)
- "A regular expression probably matching a complete URL.")
-
-
;;;###autoload
-(defcustom browse-url-browser-function 'browse-url-w3
+(defcustom browse-url-browser-function
+ (if (eq system-type 'windows-nt)
+ 'browse-url-default-windows-browser
+ 'browse-url-netscape)
"*Function to display the current buffer in a WWW browser.
-Used by the `browse-url-at-point', `browse-url-at-mouse', and
-`browse-url-of-file' commands."
- :type '(radio (function-item browse-url-w3)
- (function-item browse-url-netscape)
- (function-item browse-url-mosaic)
- (function-item browse-url-cci)
- (function-item browse-url-iximosaic)
- (function-item browse-url-lynx-xterm)
- (function-item browse-url-lynx-emacs)
- (function-item browse-url-grail)
- (function-item browse-url-kfm)
- (function :tag "Other" nil))
+This is used by the `browse-url-at-point', `browse-url-at-mouse', and
+`browse-url-of-file' commands.
+
+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."
+ :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-item :tag "Default Windows browser"
+ :value browse-url-default-windows-browser)
+ (function :tag "Your own function"))
+ :version "20.4"
:group 'browse-url)
-(defcustom browse-url-netscape-command "netscape"
- "*The name by which to invoke Netscape."
+(defcustom browse-url-netscape-program "netscape"
+ ;; Info about netscape-remote from Karl Berry.
+ "The name by which to invoke Netscape.
+
+The free program `netscape-remote' from
+<URL:http://home.netscape.com/newsref/std/remote.c> is said to start
+up very much quicker than `netscape'. Reported to compile on a GNU
+system, given vroot.h from the same directory, with cc flags
+ -DSTANDALONE -L/usr/X11R6/lib -lXmu -lX11."
:type 'string
:group 'browse-url)
(defcustom browse-url-netscape-arguments nil
- "*A list of strings to pass to Netscape as arguments."
+ "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
+ "A list of strings to pass to Netscape when it starts up.
+Defaults to the value of `browse-url-netscape-arguments' at the time
+`browse-url' is loaded."
+ :type '(repeat (string :tag "Argument"))
+ :group 'browse-url)
+
+;;;###autoload
(defcustom browse-url-new-window-p nil
- "*If non-nil, always open a new browser window.
-Passing an interactive argument to \\[browse-url-netscape] or
-\\[browse-url-cci] reverses the effect of this variable. Requires
-Netscape version 1.1N or later or XMosaic version 2.5 or later."
+ "*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."
:type 'boolean
:group 'browse-url)
+;;;###autoload
+(defcustom browse-url-netscape-display nil
+ "*The X display for running Netscape, if not same as Emacs'."
+ :type '(choice string (const :tag "Default" nil))
+ :group 'browse-url)
+
+(defcustom browse-url-mosaic-program "xmosaic"
+ "The name by which to invoke Mosaic (or mMosaic)."
+ :type 'string
+ :version "20.3"
+ :group 'browse-url)
+
(defcustom browse-url-mosaic-arguments nil
- "*A list of strings to pass to Mosaic as arguments."
+ "A list of strings to pass to Mosaic as arguments."
:type '(repeat (string :tag "Argument"))
:group 'browse-url)
-(defvar browse-url-filename-alist
- '(("^/+" . "file:/"))
- "An alist of (REGEXP . STRING) pairs.
+(defcustom browse-url-filename-alist
+ '(("^/\\(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'.
Any substring of a filename matching one of the REGEXPs is replaced by
-the corresponding STRING. All pairs are applied in the order given.
-The default value prepends `file:' to any path beginning with `/'.
-Used by the `browse-url-of-file' command.")
-
-(defvar browse-url-save-file nil
- "If non-nil, save the buffer before displaying its file.
-Used by the `browse-url-of-file' command.")
-
-(defvar browse-url-of-file-hook nil
- "A hook to be run with run-hook after `browse-url-of-file' has asked
-a browser to load a file.
+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 `/'.
+
+For example, adding to the default a specific translation of an ange-ftp
+address to an HTTP URL:
+
+ (setq browse-url-filename-alist
+ '((\"/webmaster@webserver:/home/www/html/\" .
+ \"http://www.acme.co.uk/\")
+ (\"^/\\(ftp@\\|anonymous@\\)?\\([^:]+\\):/*\" .
\"ftp://\\2/\")
+ (\"^/\\([^:@]+@\\)?\\([^:]+\\):/*\" . \"ftp://\\1\\2/\")
+ (\"^/+\" . \"file:/\")))
+"
+ :type '(repeat (cons :format "%v"
+ (regexp :tag "Regexp")
+ (string :tag "Replacement")))
+ :version "20.3"
+ :group 'browse-url)
+
+;;;###autoload
+(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)
+
+(defcustom browse-url-of-file-hook nil
+ "Run after `browse-url-of-file' has asked a browser to load a file.
Set this to `browse-url-netscape-reload' to force Netscape to load the
-file rather than displaying a cached copy.")
+file rather than displaying a cached copy."
+ :type 'hook
+ :options '(browse-url-netscape-reload)
+ :group 'browse-url)
(defvar browse-url-usr1-signal
(if (and (boundp 'emacs-major-version)
@@ -440,55 +371,113 @@
Emacs 19.29 accepts 'SIGUSR1, earlier versions require an integer
which is 30 on SunOS and 16 on HP-UX and Solaris.")
-(defvar browse-url-CCI-port 3003
+(defcustom browse-url-CCI-port 3003
"Port to access XMosaic via CCI.
This can be any number between 1024 and 65535 but must correspond to
-the value set in the browser.")
+the value set in the browser."
+ :type 'integer
+ :group 'browse-url)
-(defvar browse-url-CCI-host "localhost"
+(defcustom browse-url-CCI-host "localhost"
"*Host to access XMosaic via CCI.
This should be the host name of the machine running XMosaic with CCI
-enabled. The port number should be set in `browse-url-CCI-port'.")
+enabled. The port number should be set in `browse-url-CCI-port'."
+ :type 'string
+ :group 'browse-url)
(defvar browse-url-temp-file-name nil)
(make-variable-buffer-local 'browse-url-temp-file-name)
+(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-lynx-emacs-args (and (not window-system)
+ '("-show_cursor"))
+ "A list of strings defining options for Lynx in an Emacs buffer.
+
+The default is none in a window system, otherwise `-show_cursor' to
+indicate the position of the current link in the absence of
+highlighting, assuming the normal default for showing the cursor."
+ :type '(repeat (string :tag "Argument"))
+ :version "20.3"
+ :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)
+
+;;;###autoload
+(defcustom browse-url-generic-program nil
+ "*The name of the browser program used by `browse-url-generic'."
+ :type '(choice string (const :tag "None" nil))
+ :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)
+
+(defcustom browse-url-temp-dir temporary-file-directory
+ "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."
+ :type 'string
+ :group 'browse-url)
+
+(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)
+
+(defcustom browse-url-lynx-input-field 'avoid
+ "*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
+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))
+ :version "20.3"
+ :group 'browse-url)
+
+(defvar browse-url-lynx-input-attempts 10
+ "*How many times to try to move down from a series of lynx input fields.")
+
+(defcustom browse-url-lynx-input-delay 0.2
+ "How many seconds to wait for lynx between moves down from an input field.")
+
(defvar browse-url-temp-file-list '())
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; URL input
-;; thingatpt.el doesn't work for complex regexps
-
(defun browse-url-url-at-point ()
- "Return the URL around or before point.
-Search backwards for the start of a URL ending at or after
-point. If no URL found, return the empty string. The
-access scheme, `http://' will be prepended if absent."
- (cond ((browse-url-looking-at browse-url-regexp)
- (buffer-substring (match-beginning 0) (match-end 0)))
- ;; Access scheme omitted?
- ((browse-url-looking-at browse-url-short-regexp)
- (concat "http://"
- (buffer-substring (match-beginning 0) (match-end 0))))
- (t ""))) ; No match
-
-(defun browse-url-looking-at (regexp)
- "Return non-nil if point is in or just after a match for REGEXP.
-Set the match data from the earliest such match in the current line
-ending at or after point."
- (save-excursion
- (let ((old-point (point))
- (eol (progn (end-of-line) (point)))
- (hit nil))
- (beginning-of-line)
- (or (and (looking-at regexp)
- (>= (match-end 0) old-point))
- (progn
- (while (and (re-search-forward regexp eol t)
- (<= (match-beginning 0) old-point)
- (not (setq hit (>= (match-end 0) old-point)))))
- hit)))))
+ (let ((url (thing-at-point 'url)))
+ (set-text-properties 0 (length url) nil url)
+ url))
;; Having this as a separate function called by the browser-specific
;; functions allows them to be stand-alone commands, making it easier
@@ -496,9 +485,9 @@
(defun browse-url-interactive-arg (prompt)
"Read a URL from the minibuffer, prompting with PROMPT.
-Default to the URL at or before point. If invoke with a mouse button,
+Default to the URL at or before point. If invoked with a mouse button,
set point to the position clicked first. Return a list for use in
-`interactive' containing the URL and browse-url-new-window-p or its
+`interactive' containing the URL and `browse-url-new-window-p' or its
negation if a prefix argument was given."
(let ((event (elt (this-command-keys) 0)))
(and (listp event) (mouse-set-point event)))
@@ -509,12 +498,13 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Browse current buffer
+;;;###autoload
(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
interactively. Turn the filename into a URL with function
-browse-url-file-url. Pass the URL to a browser using variable
-`browse-url-browser-function' then run `browse-url-of-file-hook'."
+`browse-url-file-url'. Pass the URL to a browser using the
+`browse-url' function then run `browse-url-of-file-hook'."
(interactive)
(or file
(setq file (buffer-file-name))
@@ -526,21 +516,20 @@
(cond ((not (buffer-modified-p)))
(browse-url-save-file (save-buffer))
(t (message "%s modified since last save" file))))))
- (funcall browse-url-browser-function (browse-url-file-url file))
+ (browse-url (browse-url-file-url file))
(run-hooks 'browse-url-of-file-hook))
(defun browse-url-file-url (file)
"Return the URL corresponding to FILE.
-Use variable `browse-url-filename-alist' to map filenames to URLs.
-Convert EFS file names of the form /USER@HOST:PATH to ftp://HOST/PATH."
+Use variable `browse-url-filename-alist' to map filenames to URLs."
;; 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)
- (setq file (replace-match (format "%%%x" (aref file (match-beginning 0)))
- t t file)))
+ (let ((enc (format "%%%x" (aref file (match-beginning 0)))))
+ (setq file (replace-match enc t t file))))
(let ((maps browse-url-filename-alist))
(while maps
(let* ((map (car maps))
@@ -548,33 +537,30 @@
(to-string (cdr map)))
(setq maps (cdr maps))
(and (string-match from-re file)
- (setq file (replace-match to-string t t file))))))
- ;; Check for EFS path
- (and (string-match "^/\\([^:@]+@\\)?\\([^:]+\\):/*" file)
- (setq file (concat "ftp://"
- (substring file (match-beginning 2) (match-end 2))
- "/" (substring file (match-end 0)))))
+ (setq file (replace-match to-string t nil file))))))
file)
+;;;###autoload
(defun browse-url-of-buffer (&optional buffer)
"Ask a WWW browser to display BUFFER.
-Display the current buffer if BUFFER is nil."
+Display the current buffer if BUFFER is nil. Display only the
+currently visible part of BUFFER (from a temporary file) if buffer is
+narrowed."
(interactive)
(save-excursion
(and buffer (set-buffer buffer))
(let ((file-name
- (or buffer-file-name
- (and (boundp 'dired-directory) dired-directory))))
+ ;; Ignore real name if restricted
+ (and (= (- (point-max) (point-min)) (buffer-size))
+ (or buffer-file-name
+ (and (boundp 'dired-directory) dired-directory)))))
(or file-name
(progn
(or browse-url-temp-file-name
(setq browse-url-temp-file-name
- (make-temp-name
- (expand-file-name (buffer-name)
- (or (getenv "TMPDIR") "/tmp")))
- browse-url-temp-file-list
- (cons browse-url-temp-file-name
- browse-url-temp-file-list)))
+ (convert-standard-filename
+ (make-temp-name
+ (expand-file-name "burl" browse-url-temp-dir)))))
(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))))
@@ -603,79 +589,103 @@
(add-hook 'kill-buffer-hook 'browse-url-delete-temp-file)
(add-hook 'kill-emacs-hook 'browse-url-delete-temp-file-list)
+;;;###autoload
(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)))
+;;;###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 min max)
+ (browse-url-of-buffer))))
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; Browser-independant commands
+;; Browser-independent commands
-;; A generic command to call the current b-u-browser-function
+;; A generic command to call the current browse-url-browser-function
-(defun browse-url (&rest args)
+;;;###autoload
+(defun browse-url (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: "))
- (apply browse-url-browser-function args))
+ (let ((bf browse-url-browser-function) re)
+ (unless (functionp bf)
+ (while (consp bf)
+ (setq re (car (car bf))
+ bf (if (string-match re url)
+ (cdr (car bf)) ; The function
+ (cdr bf))))) ; More pairs
+ (or bf (error "No browser in browse-url-browser-function matching URL %s"
+ url))
+ (apply bf url args)))
+;;;###autoload
(defun browse-url-at-point ()
"Ask a WWW browser to load the URL at or before point.
-Doesn't let you edit the URL like browse-url. Variable
+Doesn't let you edit the URL like `browse-url'. Variable
`browse-url-browser-function' says which browser to use."
(interactive)
- (funcall browse-url-browser-function (browse-url-url-at-point)))
+ (browse-url (browse-url-url-at-point)))
-;; Define these if not already defined (XEmacs compatibility)
+(defun browse-url-event-buffer (event)
+ (window-buffer (posn-window (event-start event))))
-(eval-and-compile
- (or (fboundp 'event-buffer)
- (defun event-buffer (event)
- (window-buffer (posn-window (event-start event))))))
-
-(eval-and-compile
- (or (fboundp 'event-point)
- (defun event-point (event)
- (posn-point (event-start event)))))
+(defun browse-url-event-point (event)
+ (posn-point (event-start event)))
+;;;###autoload
(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
-browse-url. Variable `browse-url-browser-function' says which browser
+`browse-url'. Variable `browse-url-browser-function' says which browser
to use."
(interactive "e")
(save-excursion
- (set-buffer (event-buffer event))
- (goto-char (event-point event))
+ (set-buffer (browse-url-event-buffer event))
+ (goto-char (browse-url-event-point event))
(let ((url (browse-url-url-at-point)))
(if (string-equal url "")
(error "No URL found"))
- (funcall browse-url-browser-function url))))
+ (browse-url url browse-url-new-window-p))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Browser-specific commands
-;; --- Netscape ---
+;; --- Default MS-Windows browser ---
-;; Put the correct DISPLAY value in the environment for Netscape
-;; launched from multi-display Emacs.
+(defun browse-url-default-windows-browser (url &optional new-window)
+ (interactive (browse-url-interactive-arg "URL: "))
+ (w32-shell-execute "open" url))
+
+;; --- Netscape ---
(defun browse-url-process-environment ()
- (let* ((device (and (fboundp 'selected-device)
- (fboundp 'device-connection)
- (selected-device)))
- (display (and device (fboundp 'device-type)
- (eq (device-type device) 'x)
- (not (equal (device-connection device)
- (getenv "DISPLAY"))))))
+ "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))))
(if display
- ;; Attempt to run on the correct display
- (cons (concat "DISPLAY=" (device-connection device))
- process-environment)
+ (cons (concat "DISPLAY=" display) process-environment)
process-environment)))
+(defun browse-url-emacs-display ()
+ "Return the X display Emacs is running on.
+This is nil if the display is the same as the DISPLAY environment variable.
+
+Actually Emacs could be using several displays; this just returns the
+one showing the selected frame."
+ (let ((display (cdr-safe (assq 'display (frame-parameters)))))
+ (and (not (equal display (getenv "DISPLAY")))
+ display)))
;;;###autoload
(defun browse-url-netscape (url &optional new-window)
@@ -687,24 +697,33 @@
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
-the effect of browse-url-new-window-p.
+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."
+used instead of `browse-url-new-window-p'."
(interactive (browse-url-interactive-arg "Netscape URL: "))
+ ;; URL encode any `confusing' characters in the URL. This needs to
+ ;; include at least commas; presumably also close parens.
+ (while (string-match "[,)]" url)
+ (setq url (replace-match
+ (format "%%%x" (string-to-char (match-string 0 url))) t t url)))
(let* ((process-environment (browse-url-process-environment))
(process (apply 'start-process
- (concat "netscape " url) nil
- browse-url-netscape-command
- (append browse-url-netscape-arguments
- (if new-window '("-noraise"))
- (list "-remote"
- (concat "openURL(" url
- (if new-window ",new-window")
- ")"))))))
+ (concat "netscape " url) nil
+ browse-url-netscape-program
+ (append
+ browse-url-netscape-arguments
+ (if (eq window-system 'w32)
+ (list url)
+ (append
+ (if new-window '("-noraise"))
+ (list "-remote"
+ (concat "openURL(" url
+ (if new-window ",new-window")
+ ")"))))))))
(set-process-sentinel process
- (list 'lambda '(process change)
- (list 'browse-url-netscape-sentinel 'process url)))))
+ (list 'lambda '(process change)
+ (list 'browse-url-netscape-sentinel 'process url)))))
(defun browse-url-netscape-sentinel (process url)
"Handle a change to the process communicating with Netscape."
@@ -713,19 +732,24 @@
;; Netscape not running - start it
(message "Starting Netscape...")
(apply 'start-process (concat "netscape" url) nil
- browse-url-netscape-command
- (append browse-url-netscape-arguments (list url))))))
+ browse-url-netscape-program
+ (append browse-url-netscape-startup-arguments (list url))))))
(defun browse-url-netscape-reload ()
- "Ask Netscape to reload its current document."
+ "Ask Netscape to reload its current document.
+How depends on `browse-url-netscape-version'."
(interactive)
- (browse-url-netscape-send "reload"))
+ ;; Backwards incompatibility reported by
+ ;; <peter.kruse(a)psychologie.uni-regensburg.de>.
+ (browse-url-netscape-send (if (>= browse-url-netscape-version 4)
+ "xfeDoCommand(reload)"
+ "reload")))
(defun browse-url-netscape-send (command)
"Send a remote control command to Netscape."
(let* ((process-environment (browse-url-process-environment)))
(apply 'start-process "netscape" nil
- browse-url-netscape-command
+ browse-url-netscape-program
(append browse-url-netscape-arguments
(list "-remote" command)))))
@@ -733,9 +757,20 @@
;;;###autoload
(defun browse-url-mosaic (url &optional new-window)
- ;; new-window ignored
"Ask the XMosaic WWW browser to load URL.
-Default to the URL around or before point."
+
+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'."
(interactive (browse-url-interactive-arg "Mosaic URL: "))
(let ((pidfile (expand-file-name "~/.mosaicpid"))
pid)
@@ -749,7 +784,10 @@
(save-excursion
(find-file (format "/tmp/Mosaic.%d" pid))
(erase-buffer)
- (insert "goto\n" url "\n")
+ (insert (if new-window
+ "newwin\n"
+ "goto\n")
+ url "\n")
(save-buffer)
(kill-buffer nil)
;; Send signal SIGUSR to Mosaic
@@ -761,20 +799,20 @@
)
;; Mosaic not running - start it
(message "Starting Mosaic...")
- (apply 'start-process "xmosaic" nil "xmosaic"
+ (apply 'start-process "xmosaic" nil browse-url-mosaic-program
(append browse-url-mosaic-arguments (list url)))
(message "Starting Mosaic...done"))))
;; --- Grail ---
+;;;###autoload
(defvar browse-url-grail
(concat (or (getenv "GRAILDIR") "~/.grail")
"/user/rcgrail.py")
- "*Location of Grail remote control client script `rcgrail.py'.
+ "Location of Grail remote control client script `rcgrail.py'.
Typically found in $GRAILDIR/rcgrail.py, or ~/.grail/user/rcgrail.py.")
;;;###autoload
(defun browse-url-grail (url &optional new-window)
- ;; new-window ignored
"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'."
@@ -784,7 +822,9 @@
(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)
+ (if new-window
+ (call-process browse-url-grail nil 0 nil "-b" url)
+ (call-process browse-url-grail nil 0 nil url))
(message "Sending URL to Grail... done")))
;; --- Mosaic using CCI ---
@@ -801,17 +841,20 @@
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
-the effect of browse-url-new-window-p.
+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."
+used instead of `browse-url-new-window-p'."
(interactive (browse-url-interactive-arg "Mosaic URL: "))
(open-network-stream "browse-url" " *browse-url*"
browse-url-CCI-host browse-url-CCI-port)
;; Todo: start browser if fails
(process-send-string "browse-url"
(concat "get url (" url ") output "
- (if new-window "new" "current") "\r\n"))
+ (if new-window
+ "new"
+ "current")
+ "\r\n"))
(process-send-string "browse-url" "disconnect\r\n")
(delete-process "browse-url"))
@@ -830,11 +873,31 @@
;;;###autoload
(defun browse-url-w3 (url &optional new-window)
- ;; new-window ignored
"Ask the w3 WWW browser to load URL.
-Default to the URL around or before point."
+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'."
(interactive (browse-url-interactive-arg "W3 URL: "))
- (w3-fetch url))
+ (require 'w3) ; w3-fetch-other-window not autoloaded
+ (if new-window
+ (w3-fetch-other-window url)
+ (w3-fetch url)))
+
+;;;###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)"))))
;; --- Lynx in an xterm ---
@@ -843,43 +906,140 @@
;; 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
-in an Xterm window."
+in an Xterm window using the Xterm program named by `browse-url-xterm-program'
+with possible additional arguments `browse-url-xterm-args'."
(interactive (browse-url-interactive-arg "Lynx URL: "))
- (start-process (concat "lynx" url) nil "xterm" "-e"
"lynx" url))
-
+ (apply #'start-process `(,(concat "lynx" url) nil
,browse-url-xterm-program
+ ,@browse-url-xterm-args "-e" "lynx" ,url)))
;; --- Lynx in an Emacs "term" window ---
;;;###autoload
-(defun browse-url-lynx-emacs (url &optional new-window)
- ;; new-window ignored
+(defun browse-url-lynx-emacs (url &optional new-buffer)
"Ask the Lynx WWW browser to load URL.
-Default to the URL around or before point. Run a new Lynx process in
-an Emacs buffer."
+Default to the URL around or before point. With a prefix argument, run
+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'."
(interactive (browse-url-interactive-arg "Lynx URL: "))
- (unless (featurep 'term)
- (condition-case nil
- (require 'term)
- (t (error "No terminal emulation in this XEmacs"))))
- (let ((system-uses-terminfo t)) ; Lynx uses terminfo
- (cond ((fboundp 'make-term)
- (let ((term-term-name "vt100"))
- (set-buffer (make-term "browse-url" "lynx" nil url))
- (term-mode)
- (term-char-mode)
- (switch-to-buffer "*browse-url*")))
- ((fboundp 'terminal-emulator)
- (terminal-emulator "*browse-url*" "lynx" (list url)))
- (t (error "No terminal emulation in this XEmacs")))))
+ (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 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 new-buffer
+ (not buf)
+ (not proc)
+ (not (memq (process-status proc) '(run stop))))
+ ;; start a new lynx
+ (progn
+ (setq buf
+ (apply #'make-term
+ `("lynx" "lynx" nil
,@browse-url-lynx-emacs-args ,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)))))))
+ ;; 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")))))
+
+;; --- MMM ---
;;;###autoload
-(defun browse-url-kfm (url &optional new-window)
- ;; new-window ignored
- "Ask the kfm WWW browser to load URL.
+(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 "kfm URL: "))
- (message "Sending URL to kfm...")
- (start-process "kfmclient" nil "kfmclient" "openURL"
url))
+ (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
+(defun browse-url-mail (url &optional new-window)
+ "Open a new mail message buffer within Emacs.
+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
+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'."
+ (interactive (browse-url-interactive-arg "Mailto URL: "))
+ (save-excursion
+ (let ((to (if (string-match "^mailto:" url)
+ (substring url 7)
+ url)))
+ (if new-window
+ (compose-mail-other-window to nil nil nil
+ (list 'insert-buffer (current-buffer)))
+ (compose-mail to nil nil nil nil
+ (list 'insert-buffer (current-buffer)))))))
+
+;; --- 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))))
(provide 'browse-url)