EMACS setup notes

by Mortimer B. Cladwell III

Installation instructions for the various programs I use with EMACS



Download and install R from Cran. I am using version 2.11.1. Sequence manipulation algorithms require the seqinr package v2.0-9 to be installed in R. Launch the gui and select Packages/Install Packages... Select a Cran mirror, then select the package "seqinr". Packages can also be installed from the command line, once you have R running in EMACS. Use the comand:



Install EMACS. I am using version 23.2


Install ESS. I am using version 5.8. Unzip the files as a subdirectory to c:/emacs-23.2/site-lisp. You must include in your .emacs file:

(require 'ess-site)

Start EMACS. If ESS and R have been properly installed and configured, you should see:

"Finding all versions of R on your system..."

in the minibuffer during startup. Launch R with the command "M-x R". You should be able to enter R commands at the > prompt and see the output.

To make working with R more convenient, I include the following in my .emacs file:

;;;; R  Setup
(require 'ess-site)

(defun my-ess-mode ()
  (cond ((string= "R" ess-dialect)
	 (message "my-r-mode")
	 ;; customization for ESS[R] here
	 (define-key ess-mode-map '[f5] 'ess-eval-region-and-go))))

;and then hook this into the appropriate place:

(add-hook 'ess-mode-hook 'my-ess-mode)    

;;;;    Programming - Elisp

(add-hook 'emacs-lisp-mode-hook
	  '(lambda ()
	     (require 'eldoc)
	     (define-key emacs-lisp-mode-map [f5] 'eval-region)
	     (define-key emacs-lisp-mode-map [f4] 'eval-buffer)))

This allows me to use F5 to evaluate a region whether I am in R or Lisp. I also define the following function key shortcuts to streamline the loading of different files of interest. If you decide not to define these keys, you will need to load the files manually using the command "M-x my-favorite-file".

(global-set-key (kbd "<F6>") 'load-and-run-fave-file)
(global-set-key (kbd "<F10>") 'exe-my-fave-method)

(defun load-and-run-fave-file()
  (load "my-favorite-file.el"))

If ess is not finding R, check your PATH variable and make sure the R executable is listed.


Install clustalw2 which performs the sequence alignments. Download the clustalw-2.0.11-win.msi file and allow it to install in c:\Program Files\.


Download and unzip SQLITE into a directory. I used c:\program files\sqlite3. This path will need to be referred to as c:\progra~1\sqlite3 in your lisp code and any batch files. Be sure to also download the associated executable file, which provides about 27 "dot" utility commands. Test that the systems works by creating a table and populating with data. To get started, create a batch file that starts SQLITE with the database name of interest, which is passed to the executable as a parameter. To create the database named "mydb", the contents of sqlite.bat would be:

c:\progra~1\sqlite\sqlite3.exe mydb

At the sqlite prompt both dot and SQL commands can be submitted. To retain a record of the commands used to create your database, place them in a plain text file and then use the .read command to read that file into SQLITE. Here are the contents of my "create-tables.txt" file:

	names varchar(20),
	antigen_species char(20),
	host char(20),
	supplier varchar(20),
	catnum varchar(20),
	isotype char(20),
	specificity varchar(20),
	application varchar(20),
	epitope varchar(20));
To execute, read in create-tables.txt at the sqlite prompt:
sqlite> .read "create-tables.txt"

You can check that the table was created with the .schema command. Next insert a value. Either type it directly at the sqlite prompt, or read it from a file.

INSERT INTO ab VALUES ( NULL,'Tau 46', 'human', 'mouse', 'Santa Cruz', 'sc-32274', 'IgG1', 'hu;mu;rat', 'western;ip;if','unknown');

And query it out:

sqlite> SELECT * FROM ab;

If you retrieve your row, you are all set to move on. Note that the assigned value of ab_id is NULL. Let the database assign the autoincrement field.

Last modified: 10 October 2010