Using Emacs with Clojure
The Emacs editor can be integrated with Clojure to make
Clojure more convenient and interactive. Make a directory/folder
cs378 for your CS 378 files.
Emacs Command Summary
- Copy the file z.emacsclj from the class directory
to your cs378 directory; then do mv z.emacsclj .emacs .
(If you already have a .emacs, you can name the file something
else and load it manually as described below.)
- Start Emacs. On the Linux workstations, it is under Applications -
Accessories - Gnu Emacs (GUI).
- If you renamed your file to be .emacs, it will load
automatically. Otherwise, within Emacs, enter M-x load file
followed by Return, then complete the file path with
cs378/z.emacsclj and Return.
M-x or Meta-x is Alt while typing
x or Esc followed by x .
- Enter M-x lisp mode followed by Return.
- Enter M-x run lisp followed by Return.
Now you are running Clojure as a sub-process of Emacs.
- You can use Emacs commands to help edit your input to Clojure:
- Emacs will help indent using Tab at the start of a line, and it will
show where parentheses balance.
- You can copy-paste a function definition and edit it before
entering Return with the pointer at the end of the function definition
to send the definition to Clojure.
- You can re-execute previous lines of input to Clojure by putting
the pointer at the end of a line and entering Return.