emacs: External Lisp

 
 27.11 Running an External Lisp
 ==============================
 
 Lisp mode is the major mode for editing programs written in
 general-purpose Lisp dialects, such as Common Lisp.  Its mode command is
 ‘M-x lisp-mode’.  Emacs uses Lisp mode automatically for files whose
 names end in ‘.l’, ‘.lsp’, or ‘.lisp’.
 
    You can run an external Lisp session as a subprocess or “inferior
 process” of Emacs, and pass expressions to it to be evaluated.  To begin
 an external Lisp session, type ‘M-x run-lisp’.  This runs the program
 named ‘lisp’, and sets it up so that both input and output go through an
 Emacs buffer named ‘*inferior-lisp*’.  To change the name of the Lisp
 program run by ‘M-x run-lisp’, change the variable
 ‘inferior-lisp-program’.
 
    The major mode for the ‘*lisp*’ buffer is Inferior Lisp mode, which
 combines the characteristics of Lisp mode and Shell mode (SeeShell
 Mode).  To send input to the Lisp session, go to the end of the
 ‘*lisp*’ buffer and type the input, followed by <RET>.  Terminal output
 from the Lisp session is automatically inserted in the buffer.
 
    When you edit a Lisp program in Lisp mode, you can type ‘C-M-x’
 (‘lisp-eval-defun’) to send an expression from the Lisp mode buffer to a
 Lisp session that you had started with ‘M-x run-lisp’.  The expression
 sent is the top-level Lisp expression at or following point.  The
 resulting value goes as usual into the ‘*inferior-lisp*’ buffer.  Note
 that the effect of ‘C-M-x’ in Lisp mode is thus very similar to its
 effect in Emacs Lisp mode (SeeLisp Eval), except that the
 expression is sent to a different Lisp environment instead of being
 evaluated in Emacs.
 
    The facilities for editing Scheme code, and for sending expressions
 to a Scheme subprocess, are very similar.  Scheme source files are
 edited in Scheme mode, which can be explicitly enabled with ‘M-x
 scheme-mode’.  You can initiate a Scheme session by typing ‘M-x
 run-scheme’ (the buffer for interacting with Scheme is named
 ‘*scheme*’), and send expressions to it by typing ‘C-M-x’.