From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Gwern Branwen Newsgroups: gmane.emacs.devel,gmane.emacs.pretest.bugs 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 Message-ID: <20071019231221.GA21347@craft> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0842692298==" X-Trace: ger.gmane.org 1192836449 10445 80.91.229.12 (19 Oct 2007 23:27:29 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 19 Oct 2007 23:27:29 +0000 (UTC) To: "Richard M. Stallman" , Emacs development list Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Oct 20 01:27:25 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1Ij1FR-0003iH-1R for ged-emacs-devel@m.gmane.org; Sat, 20 Oct 2007 01:27:23 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ij1FI-000275-T8 for ged-emacs-devel@m.gmane.org; Fri, 19 Oct 2007 19:27:12 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Ij1FC-00026u-G2 for emacs-devel@gnu.org; Fri, 19 Oct 2007 19:27:06 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Ij1F8-00026P-U5 for emacs-devel@gnu.org; Fri, 19 Oct 2007 19:27:06 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ij1F8-00026M-PL for emacs-devel@gnu.org; Fri, 19 Oct 2007 19:27:02 -0400 Original-Received: from fencepost.gnu.org ([140.186.70.10]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Ij1F8-0000LC-4T for emacs-devel@gnu.org; Fri, 19 Oct 2007 19:27:02 -0400 Original-Received: from mx10.gnu.org ([199.232.76.166]) by fencepost.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Ij1F7-0004pD-Do for emacs-pretest-bug@gnu.org; Fri, 19 Oct 2007 19:27:01 -0400 Original-Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1Ij1F2-0000KW-6q for emacs-pretest-bug@gnu.org; Fri, 19 Oct 2007 19:27:01 -0400 Original-Received: from wx-out-0506.google.com ([66.249.82.236]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Ij1F0-0000Jq-UP for emacs-pretest-bug@gnu.org; Fri, 19 Oct 2007 19:26:56 -0400 Original-Received: by wx-out-0506.google.com with SMTP id s7so599336wxc for ; Fri, 19 Oct 2007 16:26:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:received:date:from:to:subject:message-id:mime-version:content-type:content-disposition:x-gnupg-keyid:x-gnupg-fingerprint:x-editor:x-operating-system:user-agent; bh=9U5AzI9vConOQkwgCmphAeXxfdWBj8GpttKbUL1BRAI=; b=dbDa0JcTn6fJrY8UpsQtB1j+IrtCc9EWWSTvhDH1iVTkfUy8O4OBsbBE0W2y5A6Od6ZVv8t7+w0s9Yts+AY6cB0iIN8EwDYXYH5lmcjiUkGeI+73oiri2RW/ZKJAN+z3EzPann+f/ya0Z+YT6HGqNZwqgfYr4SNB/DNewVcIPk8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:date:from:to:subject:message-id:mime-version:content-type:content-disposition:x-gnupg-keyid:x-gnupg-fingerprint:x-editor:x-operating-system:user-agent; b=PSr0QgbJ9HrhzpBEG7XNaEXXns+CoBa1+MJW+EgdzGoqX2JhwMcIUrn3wyGJhV89GS0f5chxg1GyW/Gg2h1PxByaYKRFUF1AQQJ7wWhO2+KWpYV8lyIpUA2G5NJmf2zf/hcc06Dv8iPVzlLlA0y/jLE0Exbm8jdwLzw8GSK1blE= Original-Received: by 10.70.33.8 with SMTP id g8mr3851047wxg.1192836413321; Fri, 19 Oct 2007 16:26:53 -0700 (PDT) Original-Received: from craft ( [80.190.249.77]) by mx.google.com with ESMTPS id i17sm3414726wxd.2007.10.19.16.23.26 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 19 Oct 2007 16:26:51 -0700 (PDT) Original-Received: by craft (sSMTP sendmail emulation); Fri, 19 Oct 2007 19:12:22 -0400 X-GnuPG-KeyID: F7E5D682 X-GnuPG-Fingerprint: 85F9 9FDE 8F20 898F 59BC DF32 BE90 E8E4 F7E5 D682 X-Editor: "GNU Emacs 23.0.50.1" X-Operating-System: "Gentoo x86_64 GNU/Linux" User-Agent: Mutt/1.5.16 (2007-06-09) X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 2) X-detected-kernel: by monty-python.gnu.org: Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:81268 gmane.emacs.pretest.bugs:20175 Archived-At: --===============0842692298== Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="oLBj+sq0vYjzfsbl" Content-Disposition: inline --oLBj+sq0vYjzfsbl Content-Type: multipart/mixed; boundary="yrj/dFKFPuw6o+aM" Content-Disposition: inline --yrj/dFKFPuw6o+aM Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 --yrj/dFKFPuw6o+aM Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="browse-url-rm-grail.patch" Content-Transfer-Encoding: quoted-printable --- 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 ;; . =20 +;; 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 +;; and for more information on +;; Python see . Grail support in +;; browse-url.el written by Barry Warsaw . + ;; Lynx is now distributed by the FSF. See also ;; . =20 @@ -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)))) =20 +;; --- 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 --- =20 ;;;###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 @@ =20 (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))) =20 (apply #'start-process (append (list (concat "elinks:" url) nil) --yrj/dFKFPuw6o+aM Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="browse-url-rm-ixi-mosaic.patch" Content-Transfer-Encoding: quoted-printable --- 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 ;; . =20 +;; 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 +;; and for more information on +;; Python see . Grail support in +;; browse-url.el written by Barry Warsaw . + ;; Lynx is now distributed by the FSF. See also ;; . =20 @@ -207,11 +218,11 @@ ;; Variables =20 (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)) =20 (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'. =20 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)))) =20 +;; --- 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 --- =20 ;;;###autoload @@ -1272,6 +1310,17 @@ (process-send-string "browse-url" "disconnect\r\n") (delete-process "browse-url")) =20 +;; --- 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 --- =20 ;;;###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"))))) =20 +;; --- 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 --- =20 (autoload 'rfc2368-parse-mailto-url "rfc2368") @@ -1451,7 +1519,7 @@ =20 (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))) =20 (apply #'start-process (append (list (concat "elinks:" url) nil) --yrj/dFKFPuw6o+aM Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="browse-url-rm-mmm.patch" Content-Transfer-Encoding: quoted-printable --- 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 ;; . =20 +;; 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 +;; and for more information on +;; Python see . Grail support in +;; browse-url.el written by Barry Warsaw . + ;; Lynx is now distributed by the FSF. See also ;; . =20 @@ -208,11 +218,11 @@ ;; Variables =20 (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)) =20 (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 @@ =20 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)))) =20 +;; --- 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 --- =20 ;;;###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"))))) =20 +;; --- 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 --- =20 (autoload 'rfc2368-parse-mailto-url "rfc2368") @@ -1465,7 +1519,7 @@ =20 (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))) =20 (apply #'start-process (append (list (concat "elinks:" url) nil) --yrj/dFKFPuw6o+aM Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="browse-url-rm-generalize-and-add-text-browsers.patch" Content-Transfer-Encoding: quoted-printable --- 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= =2E12.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= =2E12.GIT) =20 ;; [A version of the Netscape browser is now free software ;; , albeit not GPLed, so it is @@ -81,6 +80,14 @@ ;; Emacs process is available from ;; . =20 +;; 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 +;; and for more information on +;; Python see . Grail support in +;; browse-url.el written by Barry Warsaw . + ;; Lynx is now distributed by the FSF. See also ;; . =20 @@ -210,14 +217,12 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Variables =20 -(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)) =20 (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) =20 @@ -521,9 +529,9 @@ :type '(repeat (string :tag "Argument")) :group 'browse-url) =20 -(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. =20 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) =20 -(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 Em= acs -if the text browser cursor is on an input field (in which case the `g' com= mand +(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) =20 -(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) =20 -(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 fiel= d." :type 'number :group 'browse-url) =20 @@ -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)) =20 (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))))) =20 ;; 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)) =20 @@ -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 "[*\"()',=3D;?% ]")) (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 (=3D (- (point-max) (point-min)) (buffer-size)) - (or buffer-file-name - (and (boundp 'dired-directory) dired-directory))))) + ;; Ignore real name if restricted + (and (=3D (- (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)))) =20 (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)))) =20 (add-hook 'kill-buffer-hook 'browse-url-delete-temp-file) =20 @@ -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")))) =20 ;;;###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))) =20 (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=3D" display) process-environment) + (cons (concat "DISPLAY=3D" display) process-environment) process-environment))) =20 (defun browse-url-emacs-display () @@ -871,8 +880,8 @@ used instead of `browse-url-new-window-flag'. =20 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))))) =20 (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)))))) =20 (defun browse-url-netscape-reload () "Ask Netscape to reload its current document. @@ -947,8 +958,8 @@ ;; Backwards incompatibility reported by ;; . (browse-url-netscape-send (if (>=3D browse-url-netscape-version 4) - "xfeDoCommand(reload)" - "reload"))) + "xfeDoCommand(reload)" + "reload"))) =20 (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))))) =20 (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)))))) =20 ;;;###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))))) =20 (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)))))) =20 ;;;###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))))) =20 (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)))))) =20 (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))))) =20 (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)))))) =20 ;;;###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)))) =20 ;; --- Mosaic --- =20 @@ -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)))) =20 +;; --- 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 --- =20 ;;;###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")) =20 +;; --- 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 --- =20 ;;;###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)")))) =20 -;; 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-prog= ram' +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-prog= ram + ,@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. =20 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'. =20 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"))))) =20 -;; --- Lynx in an xterm --- +;; --- MMM --- =20 ;;;###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-prog= ram' -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-prog= ram - ,@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"))) =20 ;; --- mailto --- =20 @@ -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)))))))) =20 ;; --- Random browser --- =20 @@ -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)))) =20 ;;;###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)))) =20 (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))) =20 (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))))) =20 ;;;###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. =20 @@ -1498,11 +1535,17 @@ none yet running, a newly started instance. =20 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)))))) =20 (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))))) =20 (provide 'browse-url) =20 --yrj/dFKFPuw6o+aM-- --oLBj+sq0vYjzfsbl Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.7 (GNU/Linux) iD8DBQFHGTnVvpDo5Pfl1oIRCoD4AKCTZCTl+KoEQVygS8w2i9AjpZG4RQCfZRE9 Hes/L0OXAsw0mF3h7gvAI9I= =yjU8 -----END PGP SIGNATURE----- --oLBj+sq0vYjzfsbl-- --===============0842692298== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-devel --===============0842692298==--