[ESS] Windows suggestion: ask registry for location of Rterm.exe

Rodney Sparapani rsparapa at mcw.edu
Fri Jun 15 19:06:46 CEST 2012


On 06/15/2012 11:43 AM, Paul Johnson wrote:
> 1. batchfiles
>
> I learned of an R for Windows project called "batchfiles" which has
> various idioms to find R by asking the registry.
>
> https://code.google.com/p/batchfiles
>
> I think it should be on the front of "runemacs" or such. It would run
> every time Emacs-ESS starts, it would respect R_HOME in the user's
> init.el file, but check registry optionally..
>
> The batchfiles are written in the Windows Command language (which I
> knew in 1994 or so:)). Here's what they do to find the R HOME. This
> idiom is used in several of their script files:
>
> :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
> :: use environment variable R_HOME if defined
> :: else current folder if bin\rcmd.exe exists
> :: else most current R as determined by registry entry
> :: else error
> :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
>
> if not defined R_HOME if exist bin\r.exe set R_HOME=%CD%
> if not defined R_HOME for /f "tokens=2*" %%a in (
>   'reg query hklm\software\R-core\R /v InstallPath 2^>NUL ^| findstr InstallPath'
>    ) do set R_HOME=%%~b
> if not defined R_HOME for /f "tokens=2*" %%a in (
>   'reg query hklm\software\wow6432Node\r-core\r /v InstallPath 2^>NUL
> ^| findstr InstallPath'
>    ) do set R_HOME=%%~b
> if not defined R_HOME echo "Error: R not found"&  goto:eof
>
> In rterm.bat, you see they have a routine to guess the arch subfolder
> and then it pieces together a command.
>
> Can we launch Command scripts from inside LISP?

Hi Paul:

Very nice thoughts.  I'm just going to react to this part which seems
to be the most straightforward.  I think you can call this from elisp.
But, the problem with this code is that it doesn't work, does it? 
Here's what I get on Windows XP:

H:\>reg query hklm\software\R-core\R /v InstallPath

Error:  The system was unable to find the specified registry key or value

H:\>reg query hklm\software\wow6432Node\r-core\r /v InstallPath

Error:  The system was unable to find the specified registry key or value

What do you see?

Rodney



More information about the ESS-help mailing list