Reinstalling Emacs/ESS

I must say I’m not very computer savvy (compared to all those computer gurus out there). I don’t do windows update. I don’t update PERIOD………… unless the software automatically does it. Unfortunately, with use of R and Bioconductor, their packages tend to be frequently updated with new releases of the software. So when I install a new package, often I’ll get a warning saying the package was build for system XX.X – the newest release which I have NOT installed, pretty much saying that if I don’t update and my scripts does something wonky it’s not their fault.

For the sake of keeping up to date with the packages and know that I’m not running some out of date, potentially messed up scripts, I’m planning to update more frequently. I don’t update because I tend to forget how I set up the program the first time and have to learn how to fix little bugs ALL OVER AGAIN (stupid brain… shouldn’t you remember these things). So here’s another remind myself in the future type of post: HOW TO REINSTALL EMACS in Windows 7.

Sounds simple. Which it is. But it’s the little nitty details of getting it to work the way I want that is the issue. As you might be aware from my other post that I’m using Vincent Goulet’s emacs distribution. He updates this whenever new versions of ESS and Emacs are made available I believe.

Step 1) uninstall previous version of emacs and install the latest package from his website.

Next I want to associate all my .R files to GNU Emacs.

Step 2) Click START and type “set association” in the search box, then click “Change the file type associated with a file extension”. Scroll down to .R flies, select  and click [Change program…]. From here, go to the Emacs program folder, ie. C:\Program files (x86)\GNU Emacs xx.x\bin, with xx.x replaced by the Emacs version number, and select emacsclientw.exe.

When I tried to double-click any .R file, an error pops up. In order for this to work, the environment variable ALTERNATE_EDITOR needs to be set torunemacs.exe.

Step 3) Go to system PATH. Right click on [My Computer] and select [Properties] -> [Advance system settings] -> Under the |Advance| tab, select [Environment Variables…].

Step 3.1) Under “User Variables for XXX” (XXX represents your user name), look for a variable called “ALTERNATE_EDITOR”. If present, select it and click [edit], if not, click “New…”. Write “ALTERNATE_EDITOR” as Variable name; while typing in the location of the runemacs.exe file (ie. C:\Program Files (x86)\GNU Emacs 23.4\bin\runemacs.exe) for Variable value. Click OK.

Also, it would be ideal to add the emacs bin into PATH.

Step 3.2) Under “System variables”, select “Path” and click edit. This contains a list of locations for the system to look when searching for a program. The bin folder (as per above in step 2) contains all the emacs program executables (.exe files) so add this to the end of the variable value and separating it with a semicolon between the new folder and the previous will work. I would recommend, copy and paste the entire original variable value for path into notepad or something. Save it, then add “;C:\Program files (x86)\GNU Emacs xx.x\bin” to the end. Copy and paste this entire thing into the Variable value slot and giving it a try. If things start acting funny, at least you have the original path values saved and can revert it back. Click OK to save the changes.

So at this point, you should be able to click on a .R file and emacs should start. Yes you can choose emacs.exe as the default program, but unfortunately for me, a terminal also opens up when files are opened that way, taking up space in my taskbar which drives me nuts! (Never had this issue before but I don’t remember if I used to select emacs.exe or emacsclientw.exe as default program).

Also, if you want any new files to open in any existing Emacs sessions, add (server-start) to your .emacs file and that seemed to work for me.

Hopefully things will be easier next time. This is by no means an ultimate guide to reinstalling emacs. There are probably lots of redundancies and things that didn’t need to be done, but it worked for me this time and maybe it’ll help you. I gathered these information from various websites such as this and this. Thanks google and all the kind folks who leave info out there to help others. What will I do without internet and google………… lol. Happy coding everyone!

Advertisements

Tags: ,

About lucialam

attempts at organizing my thoughts and mind

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: