Emacs

A bit of history

Emacs was originally written by Richard Stallman and Guy Steele at MIT in the mid-1970s as a set of Editing macros for the TECO editor on the ITS operating system. It's written in a mix of C and Emacs Lisp (elisp) and is easily extended (if you're a programmer) using elisp. There are actually two major (and many lesser known) implementations of Emacs out there: emacs, which is the Unix port written by Richard Stallman and the Free Software Foundation, and xemacs, which is a mostly compatible fork of emacs started by Jamie Zawinski (one of the original Netscape developers). MacOS X users should also note Aquamacs, which is installed on all of the Macs in the HLP Lab. It provides a more Mac friendly GUI and supplements the standard Emacs keybindings with standard Mac keybindings (e.g. you can quit with ^X^C or Apple-Q)

Usage

If you've never used a programmer's editor before, Emacs can be somewhat intimidating. Luckily, inserting text and moving around are quite straightforward. What stymies newbies is how to do anything with your file once you've typed something.

Before going on, you need to know a couple of Unix conventions about commonly used keys: the Control key is represented by ^ (the carat) or C and the Meta key (usually Alt or Esc stand in for Meta, depending on your OS) is represented by M when discussing control key sequences. Emacs is famous for its heavy use of control keys. In fact, one teasing backronym for it is "Escape Meta Alt Control Shift".

Quiting

A helpful first thing to know with any editor is how to quit. In Emacs the key sequence is C-x C-c, i.e. hold down Control and press x, then hold down Control again and press c.

Opening a file

To open a file use C-x C-f. You will then be presented with a line at the bottom of the screen that says Find file: ~/. You have to type the path to the file you want to open. You may backspace over the ~/ part, which just means to start the path in your home directory. Once you start typing, you can hit the Tab key and Emacs will try to autocomplete the filename. If there is only one possible expansion, it will expand it, but if there are several you have to hit Tab again and it will show you the alternatives.

Another possible way to open a file is to use C-x d to put Emacs in "dired" mode, which allows you to browse the filesystem to find the file you want to open.

Saving a file

The emacs version of "Save As..." is C-x C-w and "Save" is C-x C-s.

LISP interaction

For LISP users, the SLIME package has been installed on the iMacs. Add the following to your .emacs file to be able to use it:

(setq inferior-lisp-program "/usr/local/bin/sbcl")
(add-to-list 'load-path "/usr/local/slime-2.0/")
(require 'slime)
(slime-setup)

At runtime M-x slime starts SLIME.

R interaction

You can use the R statistics package from within Emacs using an extension called Emacs Speaks Statistics (ESS), which is installed on the iMacs in the lab. Add the following line to your .emacs file to be able to use it:

(load "~/ess-config.el")

You also need to put the ess-config.el emacs lisp file in your home directory. This file configures a bunch of stuff related to ESS for you. At minimum you can add the following lines to your .emacs instead of loading the elisp file, but the elisp file is better and does much more.

(require 'ess-site)
(setq inferior-R-program-name "R")

Silly things

Over the years Emacs has accumulated many scripts to extend its capabilities, including some silly ones. M-x doctor can entertain you if ever you feel like talking to or arguing with an Eliza bot. M-x hanoi lets you watch Emacs solve the Towers of Hanoi puzzle.

Emacs (last edited 2012-11-07 16:24:01 by echidna)

MoinMoin Appliance - Powered by TurnKey Linux