XEmacs and ESS on MS Windows
If you don't know what ESS is then you probably don't need to read any further.
Absolutely anyone is welcome to edit this page and/or move it to its rightful place as appropriate. It is quite out of place in a home brew wiki.
I draw your attention to the "I'm feeling lucky" method, it worked for me, it may or may not work for you.
Contents
Background
First of all I need to say I am emacs challenged. I edit init.el with vi.
I run R on MS Windows XP and have XEmacs installed. I had previously had ESS partially working with XEmacs, at least to the point where I could feed R code to the ESS process and get output. I didn't get the noweb and SWeave stuff working and the icons on the XEmacs toolbar all went weird.
I joined the ESS mailing list because I thought I had nearly got it working and so why not finish the job.
I noticed a post with updated instructions so I gave it a go and got into a little strife. What follows is a running commentary on starting from scratch again.
References
Starting with a clean slate
This step is probably completely unecessary but I did it anyway. Please don't attempt this at home unless you are sure you want to blow away your complete XEmacs installation.
- Using XP "control panel|remove programs" I removed XEmacs.
- Then I deleted the XEmacs directory.
Base XEmacs
Next I downloaded a fresh copy of XEmacs from XEmacs downloads, I happened to use the Australian mirror. The file I downloaded in this case was XEmacs Setup 21.4.18-1.exe.
Then I double clicked on the downloaded exe file and installed to the default directory of C:\XEmacs and clicked the option for "create desktop icon".
Running XEmacs showed that I had forgotten to delete my init.el file from a previous install so I deleted that and XEmacs started normally (with no errors). So far so good.
I added the path to XEmacs.exe (C:\XEmacs\XEmacs-21.4.18\i586-pc-win32) to the windows PATH. This way I can run XEmacs from the command line.
Apparently sometimes you can end up with an error message Searching for program: No such file or directory, xargs. If you see that, follow the instructions in intro note 11, page 11. I didn't see this problem.
Install ESS (the easy way)
I downloaded ESS from http://ess.r-project.org/downloads/ess/ess-5.2.11.zip.
As per intro sect 3 I unzipped this into c:\XEmacs. With windows explorer I confirmed that there was now a reasonable looking directory structure under C:\XEmacs\ess-5.2.11
I downloaded init.el and copied it to C:\Documents and Settings\pms\.xemacs.
The key thing here (which I missed in a previous attempt at this) is that the references to ess-site and the icons directory in init.el are pointing to the place you just copied them too, ie:
;; Edit to reflect the location of ESS (load "C:/XEmacs/ess-5.2.11/lisp/ess-site") ;; Edit to reflect the location of the ESS icons (setq ess-icon-directory "C:/XEmacs/ess-5.2.11/etc/icons")the version I downloaded has these set consistently with the rest of the instructions. In my earlier attempt I had screwed up my init.el file.
- Optionally byte compile the .el files:
dired C:/XEmacs/ess-5.2.11/lisp
mark .el files: %m \.el$ RET they should all now look marked.
Hit B to byte compile files.
Installing ESS (the harder way)
The first time I tried the easy way, I screwed up the paths in init.el and so I tried installing the ESS package using the supplied Makefile. This approach requires cygwin.
- I make a fresh, unzipped copy of ess-5.2.11.zip in c:\tmp.
I edited some definition lines in the Makeconf file like so:
PREFIX=C:/XEmacs/Packages/xemacs-packages # alternative location: #PREFIX=C:/XEmacs/Packages/site-packages # ## XEmacs EMACS=xemacs LISPDIR=$(PREFIX)/lisp/ess INFODIR=$(PREFIX)/info ETCDIR =$(PREFIX)/etc/ess ... # This invokes bash for me. SHELL = sh
I have cygwin installed so the other stuff in the makefile appears to work ok. Download Makeconf.
Then I invoke make. After 30 seconds or so of mostly compiling el files I strike an error relating to creating the documentation. I cheat and remove the doc target from the makefile as per
@for D in lisp doc etc; do cd $$D; $(MAKE) $@; cd ..; done
to
@for D in lisp etc; do cd $$D; $(MAKE) $@; cd ..; done
. Download Makefile.
I then run make clean followed by make.
I don't think this actually installs anything so then I ran make install.
Then I run XEmacs again and see the following
(1) (initialization/error) An error has occurred while loading c:\Documents and Settings\pms\.xemacs\init.el: Cannot open load file: C:/XEmacs/Packages/xemacs-packages/lisp/ess-site
A bit of work with windows explorer shows that the path is not quite right. So I edit init.el:
;; Edit to reflect the location of ESS (load "C:/XEmacs/Packages/xemacs-packages/lisp/ess/ess-site") ;; Edit to reflect the location of the ESS icons (setq ess-icon-directory "C:/XEmacs/Packages/xemacs-packages/etc/ess/icons")changing the icon directory also. R/Rterm for me is already in the windows path so I don't need to set the path explicitly in init.el. It turns out that after installing with make into xemacs-packages or site-packages, there is magic in XEmacs to find the files you need so init.el requires only:
(require 'ess-site)
After fixing those, I try XEmacs again and see this error:
(1) (initialization/error) An error has occurred while loading c:\Documents and Settings\pms\.xemacs\init.el: Cannot open load file: essd-sp6w
At this point I just manually copied essd-sp6w.el into C:\XEmacs\Packages\xemacs-packages\lisp\ess and that particular problem went away. Don't ask me what the file is for, probably something to do with S-Plus 6 for Windows. Also don't ask me why the make process didn't copy the file.
Running XEmacs again, it seems I am making headway:
(1) (initialization/error) An error has occurred while loading c:\Documents and Settings\pms\.xemacs\init.el: Searching for program: No such file or directory, Rterm
Now I thought having Rterm in my path meant that XEmacs would find it. As it turns out, in my windows environment I had defined "R_HOME" and then added "%R_HOME%/bin" to the path. XEmacs didn't like this, when I removed the R_HOME reference in the path I saw this message after firing up XEmacs:
Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for a HTML browser interface to help. Type 'q()' to quit R. > options(chmhelp=FALSE) > options(htmlhelp=TRUE) > options(STERM='iESS', editor='winclient.exe')
When I then loaded an R source file, it was all syntax highlighted for me and some R buttons appeared in the tool bar.
Installing ESS (I'm Feeling Lucky)
After having a crack at the methods above, I decided some automation would be in order so I created this inno setup script that creates a setup-ess.exe. A link to this file is below, please read the comments in the installer script before running it. If you have an existing init.el file you might want to make a backup copy (although it shouldn't overwrite newer files).
Note that the changes to Makeconf and Makefile noted above are irrelevant to this approach.
Download the script source.
This script is for reference only, I have prebuilt an installer.
A precompiled installer: setup-ess.exe. You should take the usual precautions with exe files you download.
Note that this init.el is modified as per the note in the setup script. You should probably grab the latest one from ESS and XEmacs for Windows Users of R and adjust the ess-site line as noted above.
What Next
- Get SWeave etc working.
init.el
Refer to the two lines I changed above.
