From edd at debian.org  Thu Sep 15 14:16:32 2011
From: edd at debian.org (Dirk Eddelbuettel)
Date: Thu, 15 Sep 2011 07:16:32 -0500
Subject: [Rd] Revision of shell.exec?
In-Reply-To: <914EDA75-E5B9-4B75-8171-1A3A2B87C9A7@r-project.org>
References: <4E708194.8060406@gmail.com>
	<4E709447.10305@statistik.tu-dortmund.de>
	<CALh21i+JyvKJf=UGi2ENTXtB5rbbG-DZuwCYtGb97afG7Nguxg@mail.gmail.com>
	<4E70C350.6020506@gmail.com>
	<74357D3F-67CC-4D09-BBE9-C3988293317F@r-project.org>
	<CAFDcVCRiTPc1f9q+KnsEAoD3SUtb1Za_4waCw1O0r_PbWQFQ+Q@mail.gmail.com>
	<4E710B62.10703@gmail.com>
	<012257AC-B91F-4E7E-86AC-95E5833F74AA@r-project.org>
	<20081.4680.253129.80251@max.nulle.part>
	<914EDA75-E5B9-4B75-8171-1A3A2B87C9A7@r-project.org>
Message-ID: <20081.60576.249765.23714@max.nulle.part>


On 14 September 2011 at 16:56, Simon Urbanek wrote:
| 
| On Sep 14, 2011, at 4:44 PM, Dirk Eddelbuettel wrote:
| 
| > 
| > On 14 September 2011 at 16:22, Simon Urbanek wrote:
| > | 
| > | On Sep 14, 2011, at 4:15 PM, Brian Oney wrote:
| > | 
| > | > Hi there,
| > | > new idea (at 10 at night). All the emails keep me thinking (btw thanks for all the feedback).
| > | > What does this do on linux?
| > | > 
| > | > getOption("pdfviewer")
| > | > ### I got this idea from: getS3method("print","vignette")
| > | > 
| > | 
| > | It gives you the detected PDF viewer as I was explaining (essentially R_PDFVIEWER). The two detected settings I was referring to are R_PDFVIEWER (for PDF) and R_BROWSER (for URLs) which are the initial settings for the "pdfviewer" and "browser" options.
| > | 
| > | Note that it's what it say it is - R_PDFVIEWER is usually something like acroread or evince so not particularly useful for your purpose ...
| > 
| > R> getOption("pdfviewer")
| > [1] "/usr/bin/xdg-open"
| > R> 
| > 
| > We've had that as xdg-open in Debian / Ubuntu for a while now...
| > 
| 
| Yes, but that's merely a side-effect. For example on Ubuntu (R from sources) I get
| 
| gis:~$ Rscript -e 'cat(getOption("pdfviewer"),"\n")'
| /usr/bin/X11/evince 
| 
| because xdg-open is not installed by default. My point is that the setting is meant for something else, so misappropriating it, although possible, may not be wise. If you really want to go down that alley, you could use some logic like
| 
| if (identical(getOption("pdfviewer"), getOption("browser"))) { # better chance that it's something that can open things universally
| } else { ## well, bad luck ... }
| 
| That will work on Macs and possibly on OSes that have generic open commands ... (but is not guaranteed to ...).

Not a side-effect, but carefully planned by several parties :)

Kurt has this in m4/R.m4 for R's configure:

  AC_DEFUN([R_PROG_BROWSER],
  [if test -z "${R_BROWSER}"; then
    AC_PATH_PROGS(R_BROWSER, [firefox mozilla galeon opera xdg-open kfmclient gnome-moz-remote open])
  fi

and

  AC_DEFUN([R_PROG_PDFVIEWER],
  [AC_PATH_PROGS(R_PDFVIEWER,
                 [${R_PDFVIEWER} acroread acroread4 xdg-open evince xpdf gv gnome-gv ggv okular kpdf open gpdf kghostview])

so xdg-open can be use as R_BROWSER and R_PDFVIEWER. That is a 'Good Thing'
because xdg-open is itself a wrapper which finds the appropriate _installed_
binary via the desktop resources -- shifting the choice from compile-time to
run-time. 

I then ensure via a Build-Depends on the xdg-utils package ensure that
xdg-open is present when R is built (as the Debian / Ubuntu binary). (I also
set 'R_BROWSER=xdg-open' in the call to configure which may be redundant.)

So we could try to generalize this and, if on Linux, look for xdg-open and
call that.

Dirk

-- 
New Rcpp master class for R and C++ integration is scheduled for 
San Francisco (Oct 8), more details / reg.info available at
http://www.revolutionanalytics.com/products/training/public/rcpp-master-class.php



[Rd] Revision of shell.exec?
Dirk Eddelbuettel