Macros for Getting Emacs to Interact with GNU Common LISP

by Thomas R. Ioerger, 6/28/99


Facilities for interacting with processes like shells or LISP interpreters are already built into Emacs. This makes it easy to develop programs because you can interactively switch back and forth between editing your code and running/testing it. GNU Common LISP (GCL) is a freely available, complete (vis-a-vis Common Lisp 2 standard), and reasonably robust implementation of LISP that runs on most Unix-based systems. The goal of this page is to describe how to get Emacs to interact with GCL. Primarily, this involves setting up some internal functions and key bindings that tell Emacs what commands start and stop GCL, how to evaluate expressions, how to pop out of the debugger, etc.


Usage: Once Emacs is loaded, perhaps with a LISP program in a buffer, here are the things you can do. These are all done by pressing control-t (\C-t) followed by a letter (without the control key).


Caveats:


Put these commands at the end of the file ".emacs" in your home directory.

; Functions and key bindings for getting Emacs to interact with GCL.
; Thomas R. Ioerger, Dept of Computer Science, Texas A&M University
; see http://www.cs.tamu.edu/faculty/ioerger/emacs-gcl.html for more details

(global-set-key "\C-t" (make-keymap))

(defun run-gcl ()
  (interactive)
  (split-window)
  (other-window 1)
  (inferior-lisp "gcl")
)

(defun gcl-debug-quit ()
  (interactive)
  (comint-send-string "*inferior-lisp*" ":q\C-M"))

(defun gcl-quit ()
  (interactive)
  (comint-send-string "*inferior-lisp*" "(bye)\C-M"))

(defun gcl-eval-buffer ()
  (interactive)
  (set-mark 0)
  (end-of-buffer)
  (lisp-eval-region 1 (point))
  (exchange-point-and-mark)
)

(global-set-key "\C-tl" 'run-gcl)
(global-set-key "\C-te" 'lisp-eval-defun)
(global-set-key "\C-tw" 'switch-to-lisp) ; split screen!
(global-set-key "\C-tq" 'gcl-debug-quit)
(global-set-key "\C-tb" 'gcl-eval-buffer)
(global-set-key "\C-tx" 'gcl-quit)

; commands (after prefix of control-t)
; l = start lisp
; e = eval current expression
; w = switch to lisp buffer
; q = quit from debugger back to top-level
; b = eval buffer
; x = kill lisp process