From: Gwern Branwen <gwern0@gmail.com>
To: "Richard M. Stallman" <rms@gnu.org>,
Emacs development list <emacs-pretest-bug@gnu.org>
Subject: 23.0.60; Allow ELinks in Emacs frames, or, Generalizing browse-url.el's browse-url-lynx-emacs
Date: Fri, 19 Oct 2007 19:12:21 -0400 [thread overview]
Message-ID: <20071019231221.GA21347@craft> (raw)
[-- Attachment #1.1.1: Type: text/plain, Size: 1605 bytes --]
RMS wrote:
> Would you like to send us a proposed patch?
Sure. Find attached 4 patches.
In order of application, they are:
1) browse-url-rm-grail.patch; this patch removes the Grail code. I understand it's nice to have compatibility with lots of browsers so people can use their favorites, but browse-url.el takes it a bit far by including support for browsers that haven't been updated in years or decades. Grail in particular hasn't been updated since something like 1999, doesn't run any more (I found one 2007 post complaining that the Sourceforge downloads had multiple significant and fatal errors), and probably no one uses.
2) browse-url-rm-ixi-mosaic.patch; ditto. I couldn't even find where to get IXI's version of Mosaic. It apparently got bought or released by SCO in 1995; besides echoes from browse-url.el's inclusion of it, I could find little to nothing in Google. I think it's safe to say that if anyone is still using it, they probably aren't in a position to be using Emacs 23 and up.
3) browse-url-rm-mmm.patch; like above. Last update in 1997 or so. The libraries this O'Caml browser uses seem to be similarly outdated.
4) browse-url-rm-generalize-and-add-text-browsers.patch; this is the important one. What I did was rename all the Lynx variables to text, pull the lynx specific parts out of browse-url-lynx-emacs, and made it more general. This was nice because it made it easier to add browse-url-links-emacs, browse-url-links2-emacs, etc. I've only lightly tested it, but it seems to work.
--
gwern
Masuda computer BRGE Elvis CCS FTS2000 satellite KGB P99 NAVELEXSYSSECENGCEN
[-- Attachment #1.1.2: browse-url-rm-grail.patch --]
[-- Type: text/plain, Size: 3381 bytes --]
--- browse-url.el 2007-10-19 18:18:50.000000000 -0400
+++ browse-url.original.el 2007-10-19 18:19:04.000000000 -0400
@@ -48,6 +48,7 @@
;; browse-url-w3-gnudoit w3 remotely
;; browse-url-iximosaic IXI Mosaic ?
;; browse-url-lynx-* Lynx 0
+;; browse-url-grail Grail 0.3b1
;; browse-url-mmm MMM ?
;; browse-url-generic arbitrary
;; browse-url-default-windows-browser MS-Windows browser
@@ -79,6 +80,14 @@
;; 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://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>.
+
;; Lynx is now distributed by the FSF. See also
;; <URL:http://lynx.browser.org/>.
@@ -253,6 +262,7 @@
: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 "KDE" :value browse-url-kde)
(function-item :tag "Elinks" :value browse-url-elinks)
@@ -1247,6 +1257,28 @@
(append browse-url-mosaic-arguments (list url)))
(message "Starting %s...done" browse-url-mosaic-program))))
+;; --- Grail ---
+
+(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
+(defun browse-url-grail (url &optional new-window)
+ "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...")
+ (with-current-buffer (get-buffer-create " *Shell Command Output*")
+ (erase-buffer)
+ ;; don't worry about this failing.
+ (if (browse-url-maybe-new-window 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 ---
;;;###autoload
@@ -1352,6 +1384,7 @@
used instead of `browse-url-new-window-flag'."
(interactive (browse-url-interactive-arg "Lynx URL: "))
(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))
@@ -1486,7 +1519,7 @@
(defun browse-url-elinks-new-window (url)
"Ask the Elinks WWW browser to load URL in a new window."
- (let ((process-environment (browse-url-process-environment)))
+ (let ((process-environment (browse-url-process-environment)))
(apply #'start-process
(append (list (concat "elinks:" url)
nil)
[-- Attachment #1.1.3: browse-url-rm-ixi-mosaic.patch --]
[-- Type: text/plain, Size: 6661 bytes --]
--- browse-url.el 2007-10-19 18:28:43.000000000 -0400
+++ browse-url.original.el 2007-10-19 18:19:04.000000000 -0400
@@ -46,7 +46,10 @@
;; 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-mmm MMM ?
;; browse-url-generic arbitrary
;; browse-url-default-windows-browser MS-Windows browser
;; browse-url-default-macosx-browser Mac OS X browser
@@ -77,6 +80,14 @@
;; 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://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>.
+
;; Lynx is now distributed by the FSF. See also
;; <URL:http://lynx.browser.org/>.
@@ -207,11 +218,11 @@
;; Variables
(eval-when-compile (require 'cl)
- (require 'thingatpt)
+ (require 'thingatpt)
(require 'term)
- (require 'dired)
+ (require 'dired)
(require 'executable)
- (require 'w3-auto nil t))
+ (require 'w3-auto nil t))
(defgroup browse-url nil
"Use a web browser to look at a URL."
@@ -246,10 +257,13 @@
(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 "KDE" :value browse-url-kde)
(function-item :tag "Elinks" :value browse-url-elinks)
(function-item :tag "Specified by `Browse Url Generic Program'"
@@ -866,8 +880,8 @@
used instead of `browse-url-new-window-flag'.
The order attempted is gnome-moz-remote, Mozilla, Firefox,
-Galeon, Konqueror, Netscape, Mosaic, Lynx in an
-xterm, and then W3."
+Galeon, Konqueror, Netscape, Mosaic, IXI Mosaic, Lynx in an
+xterm, MMM, and then W3."
(apply
(cond
((executable-find browse-url-gnome-moz-program) 'browse-url-gnome-moz)
@@ -877,7 +891,9 @@
((executable-find browse-url-kde-program) 'browse-url-kde)
((executable-find browse-url-netscape-program) 'browse-url-netscape)
((executable-find browse-url-mosaic-program) 'browse-url-mosaic)
+ ((executable-find "tellw3b") 'browse-url-iximosaic)
((executable-find browse-url-xterm-program) 'browse-url-lynx-xterm)
+ ((executable-find "mmm") 'browse-url-mmm)
((locate-library "w3") 'browse-url-w3)
(t
(lambda (&ignore args) (error "No usable browser found"))))
@@ -1241,6 +1257,28 @@
(append browse-url-mosaic-arguments (list url)))
(message "Starting %s...done" browse-url-mosaic-program))))
+;; --- Grail ---
+
+(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
+(defun browse-url-grail (url &optional new-window)
+ "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...")
+ (with-current-buffer (get-buffer-create " *Shell Command Output*")
+ (erase-buffer)
+ ;; don't worry about this failing.
+ (if (browse-url-maybe-new-window 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 ---
;;;###autoload
@@ -1272,6 +1310,17 @@
(process-send-string "browse-url" "disconnect\r\n")
(delete-process "browse-url"))
+;; --- IXI Mosaic ---
+
+;;;###autoload
+(defun browse-url-iximosaic (url &optional new-window)
+ ;; new-window ignored
+ "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"
+ "-service WWW_BROWSER ixi_showurl " url))
+
;; --- W3 ---
;;;###autoload
@@ -1335,6 +1384,7 @@
used instead of `browse-url-new-window-flag'."
(interactive (browse-url-interactive-arg "Lynx URL: "))
(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))
@@ -1383,6 +1433,24 @@
url
"\r")))))
+;; --- 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...")
+ (with-current-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 'rfc2368-parse-mailto-url "rfc2368")
@@ -1451,7 +1519,7 @@
(defun browse-url-elinks-new-window (url)
"Ask the Elinks WWW browser to load URL in a new window."
- (let ((process-environment (browse-url-process-environment)))
+ (let ((process-environment (browse-url-process-environment)))
(apply #'start-process
(append (list (concat "elinks:" url)
nil)
[-- Attachment #1.1.4: browse-url-rm-mmm.patch --]
[-- Type: text/plain, Size: 5463 bytes --]
--- browse-url.el 2007-10-19 18:22:41.000000000 -0400
+++ browse-url.original.el 2007-10-19 18:19:04.000000000 -0400
@@ -48,6 +48,8 @@
;; browse-url-w3-gnudoit w3 remotely
;; browse-url-iximosaic IXI Mosaic ?
;; browse-url-lynx-* Lynx 0
+;; browse-url-grail Grail 0.3b1
+;; browse-url-mmm MMM ?
;; browse-url-generic arbitrary
;; browse-url-default-windows-browser MS-Windows browser
;; browse-url-default-macosx-browser Mac OS X browser
@@ -78,6 +80,14 @@
;; 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://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>.
+
;; Lynx is now distributed by the FSF. See also
;; <URL:http://lynx.browser.org/>.
@@ -208,11 +218,11 @@
;; Variables
(eval-when-compile (require 'cl)
- (require 'thingatpt)
+ (require 'thingatpt)
(require 'term)
- (require 'dired)
+ (require 'dired)
(require 'executable)
- (require 'w3-auto nil t))
+ (require 'w3-auto nil t))
(defgroup browse-url nil
"Use a web browser to look at a URL."
@@ -252,6 +262,8 @@
: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 "KDE" :value browse-url-kde)
(function-item :tag "Elinks" :value browse-url-elinks)
(function-item :tag "Specified by `Browse Url Generic Program'"
@@ -869,7 +881,7 @@
The order attempted is gnome-moz-remote, Mozilla, Firefox,
Galeon, Konqueror, Netscape, Mosaic, IXI Mosaic, Lynx in an
-xterm, and then W3."
+xterm, MMM, and then W3."
(apply
(cond
((executable-find browse-url-gnome-moz-program) 'browse-url-gnome-moz)
@@ -881,6 +893,7 @@
((executable-find browse-url-mosaic-program) 'browse-url-mosaic)
((executable-find "tellw3b") 'browse-url-iximosaic)
((executable-find browse-url-xterm-program) 'browse-url-lynx-xterm)
+ ((executable-find "mmm") 'browse-url-mmm)
((locate-library "w3") 'browse-url-w3)
(t
(lambda (&ignore args) (error "No usable browser found"))))
@@ -1244,6 +1257,28 @@
(append browse-url-mosaic-arguments (list url)))
(message "Starting %s...done" browse-url-mosaic-program))))
+;; --- Grail ---
+
+(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
+(defun browse-url-grail (url &optional new-window)
+ "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...")
+ (with-current-buffer (get-buffer-create " *Shell Command Output*")
+ (erase-buffer)
+ ;; don't worry about this failing.
+ (if (browse-url-maybe-new-window 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 ---
;;;###autoload
@@ -1349,6 +1384,7 @@
used instead of `browse-url-new-window-flag'."
(interactive (browse-url-interactive-arg "Lynx URL: "))
(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))
@@ -1397,6 +1433,24 @@
url
"\r")))))
+;; --- 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...")
+ (with-current-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 'rfc2368-parse-mailto-url "rfc2368")
@@ -1465,7 +1519,7 @@
(defun browse-url-elinks-new-window (url)
"Ask the Elinks WWW browser to load URL in a new window."
- (let ((process-environment (browse-url-process-environment)))
+ (let ((process-environment (browse-url-process-environment)))
(apply #'start-process
(append (list (concat "elinks:" url)
nil)
[-- Attachment #1.1.5: browse-url-rm-generalize-and-add-text-browsers.patch --]
[-- Type: text/plain, Size: 42683 bytes --]
--- browse-url.el 2007-10-19 18:56:52.000000000 -0400
+++ browse-url.original.el 2007-10-19 18:19:04.000000000 -0400
@@ -46,17 +46,16 @@
;; 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-mmm MMM ?
;; browse-url-generic arbitrary
;; browse-url-default-windows-browser MS-Windows browser
;; browse-url-default-macosx-browser Mac OS X browser
;; browse-url-gnome-moz GNOME interface to Mozilla
;; browse-url-kde KDE konqueror (kfm)
-;; browse-url-elinks-* Elinks Don't know (tried with 0.12.GIT)
-;; browse-url-links-emacs Links (tried with 2.1)
-;; browse-url-links2-emacs Links2
-;; browse-url-netrik-emacs Netrik (tried with 1.15.3)
-;; browse-url-w3m-emacs W3M
+;; browse-url-elinks Elinks Don't know (tried with 0.12.GIT)
;; [A version of the Netscape browser is now free software
;; <URL:http://www.mozilla.org/>, albeit not GPLed, so it is
@@ -81,6 +80,14 @@
;; 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://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>.
+
;; Lynx is now distributed by the FSF. See also
;; <URL:http://lynx.browser.org/>.
@@ -210,14 +217,12 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Variables
-(eval-when-compile
- (require 'cl)
- (require 'dired)
- (require 'executable)
- (require 'term)
- (require 'thingatpt)
- (require 'url-handlers)
- (require 'w3-auto nil t))
+(eval-when-compile (require 'cl)
+ (require 'thingatpt)
+ (require 'term)
+ (require 'dired)
+ (require 'executable)
+ (require 'w3-auto nil t))
(defgroup browse-url nil
"Use a web browser to look at a URL."
@@ -242,35 +247,38 @@
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 "Mozilla" :value browse-url-mozilla)
- (function-item :tag "Firefox" :value browse-url-firefox)
- (function-item :tag "Galeon" :value browse-url-galeon)
- (function-item :tag "Epiphany" :value browse-url-epiphany)
- (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 "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 "KDE" :value browse-url-kde)
- (function-item :tag "Elinks" :value browse-url-elinks)
- (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-item :tag "Default Mac OS X browser"
- :value browse-url-default-macosx-browser)
- (function-item :tag "GNOME invoking Mozilla"
- :value browse-url-gnome-moz)
- (function-item :tag "Default browser"
- :value browse-url-default-browser)
- (function :tag "Your own function")
- (alist :tag "Regexp/function association list"
- :key-type regexp :value-type function))
+ (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 "Mozilla" :value browse-url-mozilla)
+ (function-item :tag "Firefox" :value browse-url-firefox)
+ (function-item :tag "Galeon" :value browse-url-galeon)
+ (function-item :tag "Epiphany" :value browse-url-epiphany)
+ (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 "KDE" :value browse-url-kde)
+ (function-item :tag "Elinks" :value browse-url-elinks)
+ (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-item :tag "Default Mac OS X browser"
+ :value browse-url-default-macosx-browser)
+ (function-item :tag "GNOME invoking Mozilla"
+ :value browse-url-gnome-moz)
+ (function-item :tag "Default browser"
+ :value browse-url-default-browser)
+ (function :tag "Your own function")
+ (alist :tag "Regexp/function association list"
+ :key-type regexp :value-type function))
:version "21.1"
:group 'browse-url)
@@ -521,9 +529,9 @@
:type '(repeat (string :tag "Argument"))
:group 'browse-url)
-(defcustom browse-url-text-emacs-args (and (not window-system)
+(defcustom browse-url-lynx-emacs-args (and (not window-system)
'("-show_cursor"))
- "A list of strings defining options for text browsers in an Emacs buffer.
+ "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
@@ -568,10 +576,10 @@
:type 'number
:group 'browse-url)
-(defcustom browse-url-text-input-field 'avoid
- "Action on selecting an existing text browser buffer at an input field.
-What to do when sending a new URL to an existing test browser buffer in Emacs
-if the text browser cursor is on an input field (in which case the `g' command
+(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
@@ -582,13 +590,13 @@
:version "20.3"
:group 'browse-url)
-(defcustom browse-url-text-input-attempts 10
- "How many times to try to move down from a series of text browser input fields."
+(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)
-(defcustom browse-url-text-input-delay 0.2
- "How many seconds to wait for a text browser between moves down from an input field."
+(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)
@@ -615,13 +623,13 @@
"URL-encode the chars in TEXT that match CHARS.
CHARS is a regexp-like character alternative (e.g., \"[,)$]\")."
(let ((encoded-text (copy-sequence text))
- (s 0))
+ (s 0))
(while (setq s (string-match chars encoded-text s))
(setq encoded-text
- (replace-match (format "%%%x"
- (string-to-char (match-string 0 encoded-text)))
- t t encoded-text)
- s (1+ s)))
+ (replace-match (format "%%%x"
+ (string-to-char (match-string 0 encoded-text)))
+ t t encoded-text)
+ s (1+ s)))
encoded-text))
(defun browse-url-encode-url (url)
@@ -643,6 +651,7 @@
;; 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.
If `transient-mark-mode' is non-nil and the mark is active,
@@ -655,14 +664,14 @@
(let ((event (elt (this-command-keys) 0)))
(and (listp event) (mouse-set-point event)))
(list (read-string prompt (or (and transient-mark-mode mark-active
- ;; rfc2396 Appendix E.
- (replace-regexp-in-string
- "[\t\r\f\n ]+" ""
- (buffer-substring-no-properties
- (region-beginning) (region-end))))
- (browse-url-url-at-point)))
- (not (eq (null browse-url-new-window-flag)
- (null current-prefix-arg)))))
+ ;; rfc2396 Appendix E.
+ (replace-regexp-in-string
+ "[\t\r\f\n ]+" ""
+ (buffer-substring-no-properties
+ (region-beginning) (region-end))))
+ (browse-url-url-at-point)))
+ (not (eq (null browse-url-new-window-flag)
+ (null current-prefix-arg)))))
;; called-interactive-p needs to be called at a function's top-level, hence
;; this macro. We use that rather than interactive-p because
@@ -688,10 +697,10 @@
(error "Current buffer has no file"))
(let ((buf (get-file-buffer file)))
(if buf
- (with-current-buffer buf
- (cond ((not (buffer-modified-p)))
- (browse-url-save-file (save-buffer))
- (t (message "%s modified since last save" file))))))
+ (with-current-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))
(run-hooks 'browse-url-of-file-hook))
@@ -699,8 +708,8 @@
"Return the URL corresponding to FILE.
Use variable `browse-url-filename-alist' to map filenames to URLs."
(let ((coding (and default-enable-multibyte-characters
- (or file-name-coding-system
- default-file-name-coding-system))))
+ (or file-name-coding-system
+ default-file-name-coding-system))))
(if coding (setq file (encode-coding-string file coding))))
(setq file (browse-url-url-encode-chars file "[*\"()',=;?% ]"))
(dolist (map browse-url-filename-alist)
@@ -718,20 +727,20 @@
(save-excursion
(and buffer (set-buffer buffer))
(let ((file-name
- ;; Ignore real name if restricted
- (and (= (- (point-max) (point-min)) (buffer-size))
- (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
- (convert-standard-filename
- (make-temp-file
- (expand-file-name "burl" browse-url-temp-dir)
- nil ".html"))))
- (setq file-name browse-url-temp-file-name)
- (write-region (point-min) (point-max) file-name nil 'no-message)))
+ (progn
+ (or browse-url-temp-file-name
+ (setq browse-url-temp-file-name
+ (convert-standard-filename
+ (make-temp-file
+ (expand-file-name "burl" browse-url-temp-dir)
+ nil ".html"))))
+ (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))))
(defun browse-url-delete-temp-file (&optional temp-file-name)
@@ -739,7 +748,7 @@
;; If optional arg TEMP-FILE-NAME is non-nil, delete it instead
(let ((file-name (or temp-file-name browse-url-temp-file-name)))
(if (and file-name (file-exists-p file-name))
- (delete-file file-name))))
+ (delete-file file-name))))
(add-hook 'kill-buffer-hook 'browse-url-delete-temp-file)
@@ -797,9 +806,9 @@
(interactive "P")
(let ((url (browse-url-url-at-point)))
(if url
- (browse-url url (if arg
- (not browse-url-new-window-flag)
- browse-url-new-window-flag))
+ (browse-url url (if arg
+ (not browse-url-new-window-flag)
+ browse-url-new-window-flag))
(error "No URL found"))))
;;;###autoload
@@ -827,8 +836,8 @@
(interactive (browse-url-interactive-arg "URL: "))
(if (eq system-type 'ms-dos)
(if dos-windows-version
- (shell-command (concat "start " (shell-quote-argument url)))
- (error "Browsing URLs is not supported on this system"))
+ (shell-command (concat "start " (shell-quote-argument url)))
+ (error "Browsing URLs is not supported on this system"))
(w32-shell-execute "open" url)))
(defun browse-url-default-macosx-browser (url &optional new-window)
@@ -844,7 +853,7 @@
environment, otherwise just use the current environment."
(let ((display (or browse-url-browser-display (browse-url-emacs-display))))
(if display
- (cons (concat "DISPLAY=" display) process-environment)
+ (cons (concat "DISPLAY=" display) process-environment)
process-environment)))
(defun browse-url-emacs-display ()
@@ -871,8 +880,8 @@
used instead of `browse-url-new-window-flag'.
The order attempted is gnome-moz-remote, Mozilla, Firefox,
-Galeon, Konqueror, Netscape, Mosaic, Lynx in an
-xterm, and then W3."
+Galeon, Konqueror, Netscape, Mosaic, IXI Mosaic, Lynx in an
+xterm, MMM, and then W3."
(apply
(cond
((executable-find browse-url-gnome-moz-program) 'browse-url-gnome-moz)
@@ -882,7 +891,9 @@
((executable-find browse-url-kde-program) 'browse-url-kde)
((executable-find browse-url-netscape-program) 'browse-url-netscape)
((executable-find browse-url-mosaic-program) 'browse-url-mosaic)
+ ((executable-find "tellw3b") 'browse-url-iximosaic)
((executable-find browse-url-xterm-program) 'browse-url-lynx-xterm)
+ ((executable-find "mmm") 'browse-url-mmm)
((locate-library "w3") 'browse-url-w3)
(t
(lambda (&ignore args) (error "No usable browser found"))))
@@ -908,37 +919,37 @@
(interactive (browse-url-interactive-arg "URL: "))
(setq url (browse-url-encode-url url))
(let* ((process-environment (browse-url-process-environment))
- (process
- (apply 'start-process
- (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 (browse-url-maybe-new-window
- new-window)
- (if browse-url-netscape-new-window-is-tab
- ",new-tab"
- ",new-window"))
- ")"))))))))
+ (process
+ (apply 'start-process
+ (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 (browse-url-maybe-new-window
+ new-window)
+ (if browse-url-netscape-new-window-is-tab
+ ",new-tab"
+ ",new-window"))
+ ")"))))))))
(set-process-sentinel process
- `(lambda (process change)
- (browse-url-netscape-sentinel process ,url)))))
+ `(lambda (process change)
+ (browse-url-netscape-sentinel process ,url)))))
(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
- (message "Starting %s..." browse-url-netscape-program)
- (apply 'start-process (concat "netscape" url) nil
- browse-url-netscape-program
- (append browse-url-netscape-startup-arguments (list url))))))
+ ;; Netscape not running - start it
+ (message "Starting %s..." browse-url-netscape-program)
+ (apply 'start-process (concat "netscape" url) nil
+ browse-url-netscape-program
+ (append browse-url-netscape-startup-arguments (list url))))))
(defun browse-url-netscape-reload ()
"Ask Netscape to reload its current document.
@@ -947,8 +958,8 @@
;; Backwards incompatibility reported by
;; <peter.kruse@psychologie.uni-regensburg.de>.
(browse-url-netscape-send (if (>= browse-url-netscape-version 4)
- "xfeDoCommand(reload)"
- "reload")))
+ "xfeDoCommand(reload)"
+ "reload")))
(defun browse-url-netscape-send (command)
"Send a remote control command to Netscape."
@@ -979,33 +990,33 @@
(setq url (browse-url-encode-url url))
(let* ((process-environment (browse-url-process-environment))
(process
- (apply 'start-process
- (concat "mozilla " url) nil
- browse-url-mozilla-program
- (append
- browse-url-mozilla-arguments
- (list "-remote"
- (concat "openURL("
- url
- (if (browse-url-maybe-new-window
- new-window)
- (if browse-url-mozilla-new-window-is-tab
- ",new-tab"
- ",new-window"))
- ")"))))))
+ (apply 'start-process
+ (concat "mozilla " url) nil
+ browse-url-mozilla-program
+ (append
+ browse-url-mozilla-arguments
+ (list "-remote"
+ (concat "openURL("
+ url
+ (if (browse-url-maybe-new-window
+ new-window)
+ (if browse-url-mozilla-new-window-is-tab
+ ",new-tab"
+ ",new-window"))
+ ")"))))))
(set-process-sentinel process
- `(lambda (process change)
- (browse-url-mozilla-sentinel process ,url)))))
+ `(lambda (process change)
+ (browse-url-mozilla-sentinel process ,url)))))
(defun browse-url-mozilla-sentinel (process url)
"Handle a change to the process communicating with Mozilla."
(or (eq (process-exit-status process) 0)
(let* ((process-environment (browse-url-process-environment)))
- ;; Mozilla is not running - start it
- (message "Starting %s..." browse-url-mozilla-program)
- (apply 'start-process (concat "mozilla " url) nil
- browse-url-mozilla-program
- (append browse-url-mozilla-startup-arguments (list url))))))
+ ;; Mozilla is not running - start it
+ (message "Starting %s..." browse-url-mozilla-program)
+ (apply 'start-process (concat "mozilla " url) nil
+ browse-url-mozilla-program
+ (append browse-url-mozilla-startup-arguments (list url))))))
;;;###autoload
(defun browse-url-firefox (url &optional new-window)
@@ -1036,37 +1047,37 @@
(interactive (browse-url-interactive-arg "URL: "))
(setq url (browse-url-encode-url url))
(let* ((process-environment (browse-url-process-environment))
- (process
- (apply 'start-process
- (concat "firefox " url) nil
- browse-url-firefox-program
- (append
- browse-url-firefox-arguments
- (if (or (featurep 'dos-w32)
- (string-match "win32" system-configuration))
- (list url)
- (list "-remote"
- (concat "openURL("
- url
- (if (browse-url-maybe-new-window
- new-window)
- (if browse-url-firefox-new-window-is-tab
- ",new-tab"
- ",new-window"))
- ")")))))))
+ (process
+ (apply 'start-process
+ (concat "firefox " url) nil
+ browse-url-firefox-program
+ (append
+ browse-url-firefox-arguments
+ (if (or (featurep 'dos-w32)
+ (string-match "win32" system-configuration))
+ (list url)
+ (list "-remote"
+ (concat "openURL("
+ url
+ (if (browse-url-maybe-new-window
+ new-window)
+ (if browse-url-firefox-new-window-is-tab
+ ",new-tab"
+ ",new-window"))
+ ")")))))))
(set-process-sentinel process
- `(lambda (process change)
- (browse-url-firefox-sentinel process ,url)))))
+ `(lambda (process change)
+ (browse-url-firefox-sentinel process ,url)))))
(defun browse-url-firefox-sentinel (process url)
"Handle a change to the process communicating with Firefox."
(or (eq (process-exit-status process) 0)
(let* ((process-environment (browse-url-process-environment)))
- ;; Firefox is not running - start it
- (message "Starting Firefox...")
- (apply 'start-process (concat "firefox " url) nil
- browse-url-firefox-program
- (append browse-url-firefox-startup-arguments (list url))))))
+ ;; Firefox is not running - start it
+ (message "Starting Firefox...")
+ (apply 'start-process (concat "firefox " url) nil
+ browse-url-firefox-program
+ (append browse-url-firefox-startup-arguments (list url))))))
;;;###autoload
(defun browse-url-galeon (url &optional new-window)
@@ -1089,30 +1100,30 @@
(setq url (browse-url-encode-url url))
(let* ((process-environment (browse-url-process-environment))
(process (apply 'start-process
- (concat "galeon " url)
- nil
- browse-url-galeon-program
- (append
- browse-url-galeon-arguments
+ (concat "galeon " url)
+ nil
+ browse-url-galeon-program
+ (append
+ browse-url-galeon-arguments
(if (browse-url-maybe-new-window new-window)
- (if browse-url-galeon-new-window-is-tab
- '("--new-tab")
- '("--new-window" "--noraise"))
+ (if browse-url-galeon-new-window-is-tab
+ '("--new-tab")
+ '("--new-window" "--noraise"))
'("--existing"))
(list url)))))
(set-process-sentinel process
- `(lambda (process change)
- (browse-url-galeon-sentinel process ,url)))))
+ `(lambda (process change)
+ (browse-url-galeon-sentinel process ,url)))))
(defun browse-url-galeon-sentinel (process url)
"Handle a change to the process communicating with Galeon."
(or (eq (process-exit-status process) 0)
(let* ((process-environment (browse-url-process-environment)))
- ;; Galeon is not running - start it
- (message "Starting %s..." browse-url-galeon-program)
- (apply 'start-process (concat "galeon " url) nil
- browse-url-galeon-program
- (append browse-url-galeon-startup-arguments (list url))))))
+ ;; Galeon is not running - start it
+ (message "Starting %s..." browse-url-galeon-program)
+ (apply 'start-process (concat "galeon " url) nil
+ browse-url-galeon-program
+ (append browse-url-galeon-startup-arguments (list url))))))
(defun browse-url-epiphany (url &optional new-window)
"Ask the Epiphany WWW browser to load URL.
@@ -1134,30 +1145,30 @@
(setq url (browse-url-encode-url url))
(let* ((process-environment (browse-url-process-environment))
(process (apply 'start-process
- (concat "epiphany " url)
- nil
- browse-url-epiphany-program
- (append
- browse-url-epiphany-arguments
+ (concat "epiphany " url)
+ nil
+ browse-url-epiphany-program
+ (append
+ browse-url-epiphany-arguments
(if (browse-url-maybe-new-window new-window)
- (if browse-url-epiphany-new-window-is-tab
- '("--new-tab")
- '("--new-window" "--noraise"))
+ (if browse-url-epiphany-new-window-is-tab
+ '("--new-tab")
+ '("--new-window" "--noraise"))
'("--existing"))
(list url)))))
(set-process-sentinel process
- `(lambda (process change)
- (browse-url-epiphany-sentinel process ,url)))))
+ `(lambda (process change)
+ (browse-url-epiphany-sentinel process ,url)))))
(defun browse-url-epiphany-sentinel (process url)
"Handle a change to the process communicating with Epiphany."
(or (eq (process-exit-status process) 0)
(let* ((process-environment (browse-url-process-environment)))
- ;; Epiphany is not running - start it
- (message "Starting %s..." browse-url-epiphany-program)
- (apply 'start-process (concat "epiphany " url) nil
- browse-url-epiphany-program
- (append browse-url-epiphany-startup-arguments (list url))))))
+ ;; Epiphany is not running - start it
+ (message "Starting %s..." browse-url-epiphany-program)
+ (apply 'start-process (concat "epiphany " url) nil
+ browse-url-epiphany-program
+ (append browse-url-epiphany-startup-arguments (list url))))))
;;;###autoload
(defun browse-url-emacs (url &optional new-window)
@@ -1188,13 +1199,13 @@
used instead of `browse-url-new-window-flag'."
(interactive (browse-url-interactive-arg "URL: "))
(apply 'start-process (concat "gnome-moz-remote " url)
- nil
- browse-url-gnome-moz-program
- (append
- browse-url-gnome-moz-arguments
- (if (browse-url-maybe-new-window new-window)
- '("--newwin"))
- (list "--raise" url))))
+ nil
+ browse-url-gnome-moz-program
+ (append
+ browse-url-gnome-moz-arguments
+ (if (browse-url-maybe-new-window new-window)
+ '("--newwin"))
+ (list "--raise" url))))
;; --- Mosaic ---
@@ -1216,36 +1227,58 @@
used instead of `browse-url-new-window-flag'."
(interactive (browse-url-interactive-arg "Mosaic URL: "))
(let ((pidfile (expand-file-name browse-url-mosaic-pidfile))
- pid)
+ pid)
(if (file-readable-p pidfile)
- (save-excursion
- (find-file pidfile)
- (goto-char (point-min))
- (setq pid (read (current-buffer)))
- (kill-buffer nil)))
+ (save-excursion
+ (find-file pidfile)
+ (goto-char (point-min))
+ (setq pid (read (current-buffer)))
+ (kill-buffer nil)))
(if (and pid (zerop (signal-process pid 0))) ; Mosaic running
- (save-excursion
- (find-file (format "/tmp/Mosaic.%d" pid))
- (erase-buffer)
- (insert (if (browse-url-maybe-new-window new-window)
- "newwin\n"
- "goto\n")
- url "\n")
- (save-buffer)
- (kill-buffer nil)
- ;; Send signal SIGUSR to Mosaic
- (message "Signaling Mosaic...")
- (signal-process pid 'SIGUSR1)
- ;; Or you could try:
- ;; (call-process "kill" nil 0 nil "-USR1" (int-to-string pid))
- (message "Signaling Mosaic...done")
- )
+ (save-excursion
+ (find-file (format "/tmp/Mosaic.%d" pid))
+ (erase-buffer)
+ (insert (if (browse-url-maybe-new-window new-window)
+ "newwin\n"
+ "goto\n")
+ url "\n")
+ (save-buffer)
+ (kill-buffer nil)
+ ;; Send signal SIGUSR to Mosaic
+ (message "Signaling Mosaic...")
+ (signal-process pid 'SIGUSR1)
+ ;; Or you could try:
+ ;; (call-process "kill" nil 0 nil "-USR1" (int-to-string pid))
+ (message "Signaling Mosaic...done")
+ )
;; Mosaic not running - start it
(message "Starting %s..." browse-url-mosaic-program)
(apply 'start-process "xmosaic" nil browse-url-mosaic-program
- (append browse-url-mosaic-arguments (list url)))
+ (append browse-url-mosaic-arguments (list url)))
(message "Starting %s...done" browse-url-mosaic-program))))
+;; --- Grail ---
+
+(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
+(defun browse-url-grail (url &optional new-window)
+ "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...")
+ (with-current-buffer (get-buffer-create " *Shell Command Output*")
+ (erase-buffer)
+ ;; don't worry about this failing.
+ (if (browse-url-maybe-new-window 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 ---
;;;###autoload
@@ -1266,17 +1299,28 @@
used instead of `browse-url-new-window-flag'."
(interactive (browse-url-interactive-arg "Mosaic URL: "))
(open-network-stream "browse-url" " *browse-url*"
- browse-url-CCI-host browse-url-CCI-port)
+ browse-url-CCI-host browse-url-CCI-port)
;; Todo: start browser if fails
(process-send-string "browse-url"
- (concat "get url (" url ") output "
- (if (browse-url-maybe-new-window new-window)
- "new"
- "current")
- "\r\n"))
+ (concat "get url (" url ") output "
+ (if (browse-url-maybe-new-window new-window)
+ "new"
+ "current")
+ "\r\n"))
(process-send-string "browse-url" "disconnect\r\n")
(delete-process "browse-url"))
+;; --- IXI Mosaic ---
+
+;;;###autoload
+(defun browse-url-iximosaic (url &optional new-window)
+ ;; new-window ignored
+ "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"
+ "-service WWW_BROWSER ixi_showurl " url))
+
;; --- W3 ---
;;;###autoload
@@ -1304,42 +1348,62 @@
`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)"))))
+ browse-url-gnudoit-program
+ (append browse-url-gnudoit-args
+ (list (concat "(w3-fetch \"" url "\")")
+ "(raise-frame)"))))
-;; A general function for browsing within an Emacs frame using a specified text-browser
-(defun browse-url-text-browser-emacs (url generic &optional new-buffer)
- "Ask for a Web address and an arbitrary text browser.
+;; --- 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
+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: "))
+ (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-buffer)
+ "Ask the Lynx WWW browser to load URL.
+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-flag' is
-non-nil, load the document in a new text browser in a new term window,
+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-flag'.
When called non-interactively, optional second argument NEW-WINDOW is
used instead of `browse-url-new-window-flag'."
- (interactive "MWeb address: \nMBrowser: ")
-
- (let* ((buf (get-buffer "*text-browser*"))
- (proc (and buf (get-buffer-process buf)))
- (n browse-url-text-input-attempts))
+ (interactive (browse-url-interactive-arg "Lynx URL: "))
+ (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, eg, *lynx* and would
- ;; choke on *lynx*<1>
- (progn (set-buffer buf)
- (rename-uniquely)))
+ ;; 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 text browser
- (progn
- (setq buf (apply #'make-term
- `("text-browser" ,generic nil ,@browse-url-text-emacs-args
- ,url)))
+ (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
@@ -1350,69 +1414,42 @@
(if (not (memq (process-status process) '(run stop)))
(let ((buf (process-buffer process)))
(if buf (kill-buffer buf)))))))
- ;; send the url to the text-browser in the old buffer
+ ;; 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 win
+ (select-window win)
+ (switch-to-buffer buf)))
(if (eq (following-char) ?_)
- (cond ((eq browse-url-text-input-field 'warn)
- (error "Please move out of the input field first"))
- ((eq browse-url-text-input-field 'avoid)
- (while (and (eq (following-char) ?_) (> n 0))
- (term-send-down) ; down arrow
- (sit-for browse-url-text-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")))))
-
-(defun browse-url-links-emacs (url &optional new-buffer)
- "Specializes browse-url-text-browser-emacs so it calls Links."
- (interactive (browse-url-interactive-arg "URL for Links: "))
- (browse-url-text-browser-emacs url "links" new-buffer))
-
-;; Untested
-(defun browse-url-links2-emacs (url &optional new-buffer)
- "Specializes browse-url-text-browser-emacs so it calls Links2."
- (interactive (browse-url-interactive-arg "URL for Links2: "))
- (browse-url-text-browser-emacs url "links2" new-buffer))
-
-(defun browse-url-netrik-emacs (url &optional new-buffer)
- "Specializes browse-url-text-browser-emacs so it calls Netrik."
- (interactive (browse-url-interactive-arg "URL for Netrik: "))
- (browse-url-text-browser-emacs url "netrik" new-buffer))
-
-;; Untested
-(defun browse-url-w3m-emacs (url &optional new-buffer)
- "Specializes browse-url-text-browser-emacs so it calls w3m."
- (interactive (browse-url-interactive-arg "URL for w3m: "))
- (browse-url-text-browser-emacs url "w3m" new-buffer))
-
-;; --- Lynx in an Emacs "term" window ---
-
-;;;###autoload
-(defun browse-url-lynx-emacs (url &optional new-buffer)
- "Specializes browse-url-text-browser-emacs so it calls Lynx."
- (interactive (browse-url-interactive-arg "URL for Lynx: "))
- (browse-url-text-browser-emacs url "lynx" new-buffer))
+ (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")))))
-;; --- Lynx in an xterm ---
+;; --- MMM ---
;;;###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
-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: "))
- (apply #'start-process `(,(concat "lynx" url) nil ,browse-url-xterm-program
- ,@browse-url-xterm-args "-e" "lynx"
- ,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 "MMM URL: "))
+ (message "Sending URL to MMM...")
+ (with-current-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 ---
@@ -1436,23 +1473,23 @@
(interactive (browse-url-interactive-arg "Mailto URL: "))
(save-excursion
(let* ((alist (rfc2368-parse-mailto-url url))
- (to (assoc "To" alist))
- (subject (assoc "Subject" alist))
- (body (assoc "Body" alist))
- (rest (delete to (delete subject (delete body alist))))
- (to (cdr to))
- (subject (cdr subject))
- (body (cdr body))
- (mail-citation-hook (unless body mail-citation-hook)))
+ (to (assoc "To" alist))
+ (subject (assoc "Subject" alist))
+ (body (assoc "Body" alist))
+ (rest (delete to (delete subject (delete body alist))))
+ (to (cdr to))
+ (subject (cdr subject))
+ (body (cdr body))
+ (mail-citation-hook (unless body mail-citation-hook)))
(if (browse-url-maybe-new-window new-window)
- (compose-mail-other-window to subject rest nil
- (if body
- (list 'insert body)
- (list 'insert-buffer (current-buffer))))
- (compose-mail to subject rest nil nil
- (if body
- (list 'insert body)
- (list 'insert-buffer (current-buffer))))))))
+ (compose-mail-other-window to subject rest nil
+ (if body
+ (list 'insert body)
+ (list 'insert-buffer (current-buffer))))
+ (compose-mail to subject rest nil nil
+ (if body
+ (list 'insert body)
+ (list 'insert-buffer (current-buffer))))))))
;; --- Random browser ---
@@ -1468,8 +1505,8 @@
(if (not browse-url-generic-program)
(error "No browser defined (`browse-url-generic-program')"))
(apply 'call-process browse-url-generic-program nil
- 0 nil
- (append browse-url-generic-args (list url))))
+ 0 nil
+ (append browse-url-generic-args (list url))))
;;;###autoload
(defun browse-url-kde (url &optional new-window)
@@ -1478,19 +1515,19 @@
(interactive (browse-url-interactive-arg "KDE URL: "))
(message "Sending URL to KDE...")
(apply #'start-process (concat "KDE " url) nil browse-url-kde-program
- (append browse-url-kde-args (list url))))
+ (append browse-url-kde-args (list url))))
(defun browse-url-elinks-new-window (url)
"Ask the Elinks WWW browser to load URL in a new window."
- (let ((process-environment (browse-url-process-environment)))
+ (let ((process-environment (browse-url-process-environment)))
(apply #'start-process
- (append (list (concat "elinks:" url)
- nil)
- browse-url-elinks-wrapper
- (list "elinks" url)))))
+ (append (list (concat "elinks:" url)
+ nil)
+ browse-url-elinks-wrapper
+ (list "elinks" url)))))
;;;###autoload
-(defun browse-url-elinks-emacs (url &optional new-buffer)
+(defun browse-url-elinks (url &optional new-window)
"Ask the Elinks WWW browser to load URL.
Default to the URL around the point.
@@ -1498,11 +1535,17 @@
none yet running, a newly started instance.
The Elinks command will be prepended by the program+arguments
-from `browse-url-elinks-wrapper'.
-
-This specializes browse-url-text-browser-emacs so it calls Elinks."
- (interactive (browse-url-interactive-arg "URL for Elinks: "))
- (browse-url-text-browser-emacs url "elinks" new-buffer))
+from `browse-url-elinks-wrapper'."
+ (interactive (browse-url-interactive-arg "URL: "))
+ (setq url (browse-url-encode-url url))
+ (if new-window
+ (browse-url-elinks-new-window url)
+ (let ((process-environment (browse-url-process-environment))
+ (elinks-ping-process (start-process "elinks-ping" nil
+ "elinks" "-remote" "ping()")))
+ (set-process-sentinel elinks-ping-process
+ `(lambda (process change)
+ (browse-url-elinks-sentinel process ,url))))))
(defun browse-url-elinks-sentinel (process url)
"Determines if Elinks is running or a new one has to be started."
@@ -1517,11 +1560,11 @@
;; Found an instance, open URL in new tab.
(let ((process-environment (browse-url-process-environment)))
(start-process (concat "elinks:" url) nil
- "elinks" "-remote"
- (concat "openURL(\"" url "\",new-tab)"))))
+ "elinks" "-remote"
+ (concat "openURL(\"" url "\",new-tab)"))))
(otherwise
(error "Unrecognized exit-code %d of process `elinks'"
- exit-status)))))
+ exit-status)))))
(provide 'browse-url)
[-- Attachment #1.2: Type: application/pgp-signature, Size: 189 bytes --]
[-- Attachment #2: Type: text/plain, Size: 142 bytes --]
_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel
next reply other threads:[~2007-10-19 23:12 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-19 23:12 Gwern Branwen [this message]
-- strict thread matches above, loose matches on Subject: below --
2007-10-16 21:55 23.0.60; Allow ELinks in Emacs frames, or, Generalizing browse-url.el's browse-url-lynx-emacs Gwern Branwen
2007-10-17 20:48 ` Richard Stallman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20071019231221.GA21347@craft \
--to=gwern0@gmail.com \
--cc=emacs-pretest-bug@gnu.org \
--cc=rms@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.