I grabbed "Practical Common Lisp" off my bookshelf, after reading too much programming.reddit.com, and decided to learn lisp. *gasp*
I quickly realized that emacs is the de facto lisp editor and that I needed to learn a bit of emacs to go with the lisp flow and avoid many headaches. This brief tutorial is a result of my effort and I hope it saves someone else a bit of time in learning just enough emacs to play around with lisp.

Let's start with the basics. Emacs makes heavy use of the Control and Alt keys as we'll see right away. The most important thing to know about any command line editor is how to save and exit. To exit emacs hold down the control key and hit the 'x' key then hit control and the 'c' key. These types of key sequences are abbreviated as C-x C-c. Now the basics

exit emacs: C-x C-c
open a file: C-x C-f (then type the file name)
save the file: C-x C-s
undo: C-x u

Another concept that needs to be addressed immediately are "buffers". Emacs can have many things open/running at once and each of these is called a buffer. For example, you can open multiple files use C-x C-f and each open file is it's own buffer. Also, many emacs commands will create a new window inside emacs for displaying information; each of these is also a buffer. There are 3 essential commands for dealing with buffers; viewing all existing buffers, switching to a particular buffer, and returning the view to a single window (i.e. after a command like C-x C-b splits the window).

listing buffers: C-x C-b
go to a buffer: C-x b (then type the name of the buffer and save some time with tab completion)
return to single window: C-x 1

The next thing any coder will want to know is how to search. Basic search is done with C-s for forward search and C-r for backwards search. Once you hit C-s it will prompt for the string to search for and highlight all matches. Hit C-s again to move forward to the next match or C-r to move backwards.

search forward: C-s
search back: C-r

Another important command is C-g. This will cancel any command that you have started. For example, if you start a search you can stop the search with C-g.

cancel: C-g

This should be just enough emacs to get started using it for lisp. I'll add more to this article as a learn more from my lisp experience.
Below is a list of some other useful emacs commands, some specifically for lisp and slime, and a list of other resources on emacs.

killing (i.e. cut)
killing word before: M-<backspace>
killing word after: M-d
killing rest of line before: C-k
killing rest of line after: M-k

yanking (i.e. paste)
paste the last kill: C-y
past previous kills: M-y

LISP RELATED
start slime: M-x slime
slime compile defun: C-c C-c
slime compile and load file: C-c C-k
slime quit: C-c M-g
slime clear repl: C-c C-t
slime prev command: M-p
slime next command: M-n
slime search prev commands: M-r
slime search next commands: M-s
go to lisp buffer: C-c C-z
close parens: C-c C-q

Good Resources
http://www.gnu.org/software/emacs/tour/
http://xahlee.org/emacs/emacs.html



New commenting closed as post is too old. Why?