image University of Washington Computer Science & Engineering
  CSE 341Sp '06:  Emacs Hints
  CSE Home   About Us    Search    Contact Info 

Here are some useful emacs commands.  This is not an introduction to emacs, see the Unix and Emacs tutorial for that.

Useful key commands

Note: C-xo means hit the control key and x at the same time, then hit o (without the control key); C-xC-f means hit control - x and then control - f.   M-x is Meta - x, Meta is usually the Alt key on the lab machines.

Emacs Setup

Emacs gets its defaults from the .emacs file in your home directory. This file is just an emacs Lisp program that gets run on startup. Emacs Lisp is very similar to the Scheme language that we will study later on this quarter. After making a change to your .emacs file, to get the change to apply you can put the point in the thing you just typed, then do CM-x, which sends the current function to emacs (much like C-cC-f sends a function to SML). In addition to the changes mentioned in the Unix and Emacs Tutorial, put in the following. Note that ; is used to start a comment; the rest of the line is ignored.

;; Set up C-cC-f.  
(add-hook 'sml-mode-hook (lambda () (local-set-key "\C-c\C-f" 
                                      'sml-send-function-and-go)))

;; I don't know why this isn't standard in emacs: M-g lets you type a
line number to goto in.  Handy for moving to errors that SML reports
(global-set-key "\M-g" 'goto-line)

;; bind M-` (the backtick key, a backwards single quote) to
;; next-error, which sometimes can go to compile error messages.  It
;; seems to be somewhat flakey with SML, but if you put the point on
;; an error message and then hit M-`, you'll jump to the error in the
;; source file.  Sometimes you have to hit it twice, and sometimes it
;; doesn't work.
(global-set-key "\M-`" 'next-error)




Matt Cary, March 2005

CSE logo Computer Science & Engineering
University of Washington
Box 352350
Seattle, WA  98195-2350
(206) 543-1695 voice, (206) 543-2969 FAX
[comments to cary at cs.washington.edu]