[comp.lang.lisp] Another EMACS to lisp interface

ccm@warhol.ads.com (Chris McConnell) (06/14/90)

Has been posted to gnu.emacs.  A short description follows:

MAJOR FEATURES in lisp-mode, scheme-mode or ilisp-mode:

+Provides dialect specific support so that less customization is
required to take advantage of the features provided.  Currently
supported dialects include common LISP, allegro, lucid, kcl, cmulisp,
scheme and oaklisp.

+Multiple inferior LISPs can be active at the same time.

+Input history ala comint-mode including next/previous and partial
matching. 

+Smart about movement, entry, editing and input of LISP expressions.

+Eval/compile/load of defuns/regions/sexps with errors and results
shown in pop-up windows, inserted in buffers or ignored.  

+A crude eval/compile changed definitions mechanism.

+Handles Common LISP packages correctly.

+Completion of filenames and LISP symbols.

+No communication through a file system is required.

+Arglist, documentation, describe, macroexpansion.

+Find unbalanced parentheses.

+ESC-Q will justify blocks of code, or paragraphs in strings and
comments.

+Super bracket will close the containing defun adding or deleting
parentheses as required.

+Find source queries the LISP world first and if that fails uses the
tags facility.

+Edit/list callers of a function.

I have not written a manual or info node.  If someone else wants to
do so, let me know!

MODE DOCUMENTATION:

ILISP Mode:
Major mode for interacting with an inferior LISP process.  Runs a
LISP interpreter as a subprocess of Emacs, with Lisp I/O through an
Emacs buffer.

To start a LISP use M-x run-ilisp, or a specific dialect like
M-x allegro.  If called with a prefix you will be prompted for a
buffer name and a program to run.  If there are multiple LISP's, use
the dialect name or M-x select-ilisp to select the current ILISP
buffer.

Currently supported LISP dialects include: 
 clisp
   allegro
   lucid
   kcl
   cmulisp
 scheme
   oaklisp

Customization: Entry to this mode runs the hooks on comint-mode-hook and
ilisp-mode-hook and then DIALECT-hooks specific to LISP
dialects in the nesting order above.  For more information on creating
a new dialect see ilisp.el

Most of these key bindings work in both Lisp Mode and ILISP mode.
There are a few additional and-go bindings found in Lisp Mode.

C-x             Prefix Command
]               lisp-close-all
TAB             lisp-indent-line
DEL             backward-delete-char-untabify
C-c             Prefix Command
C-a             comint-bol
C-d             comint-delchar-or-maybe-eof
RET             lisp-return
ESC             Prefix Command

C-c k           lisp-compile-file
C-c l           lisp-load-file
C-c z           switch-to-lisp
C-c b           switch-to-lisp
C-c SPC         lisp-mark-change
C-c C-p         lisp-eval-prev-sexp-and-go
C-c C-n         lisp-eval-next-sexp-and-go
C-c C-e         lisp-eval-defun-and-go
C-c c           lisp-compile-defun
C-c w           lisp-compile-region
C-c p           lisp-eval-prev-sexp
C-c n           lisp-eval-next-sexp
C-c e           lisp-eval-defun
C-c M           lisp-macroexpand-1
C-c m           lisp-macroexpand
C-c d           lisp-documentation
C-c a           lisp-arglist
C-c i           lisp-describe
C-c ;           comment-region
C-c R           comint-msearch-input-matching
C-c C-r         lisp-eval-region-and-go
C-c r           lisp-eval-region
C-c C-o         comint-kill-output
C-c C-\         comint-quit-subjob
C-c C-z         comint-stop-subjob
C-c C-c         comint-interrupt-subjob
C-c C-w         lisp-compile-region-and-go
C-c C-u         comint-kill-input

C-x C-f         lisp-find-file

ESC C-x         lisp-eval-defun
ESC TAB         lisp-complete
ESC ,           edit-next-caller
ESC .           lisp-find-source
ESC C-r         lisp-reposition-window
ESC C-e         lisp-end-of-defun
ESC C-a         lisp-beginning-of-defun
ESC q           lisp-reindent
ESC C-q         indent-sexp
ESC N           comint-psearch-input
ESC P           comint-msearch-input
ESC s           comint-previous-similar-input
ESC n           comint-next-input
ESC p           comint-previous-input


comint-previous-input (ESC p) and
comint-next-input (ESC n) cycle through the input
history.  comint-previous-similar-input
(ESC s) cycles through input that has the
string typed so far as a prefix.

comint-interrupt-subjob (C-c C-c) interrupts a
running LISP. 

When you send something to LISP, you will see progress messages in the
minibuffer.  If you do not want to see progress messages, set
comint-show-progress to nil.

See comint-mode documentation for more information on comint commands.

A number of commands refer to "defun".  A "defun" is a list that
starts at the left margin in a LISP buffer, or after a prompt in the
ILISP buffer.  So the commands refer to the "defun" that contains
point.

RET knows about prompts and sexps.  If an sexp is not
complete, it will indent properly.  When an entire sexp is complete,
it is sent to the inferior LISP.  If you edit old input, the input
will be copied to the end of the buffer first.

TAB indents for LISP.  With prefix, shifts rest of
expression rigidly with the current line.

ESC C-q will indent each line in the next sexp.

DEL converts tabs to spaces as it moves
back.

switch-to-lisp (C-c z) will pop to the current ILISP
buffer or if already in an ILISP buffer, it will return to the buffer
that last switched to an ILISP buffer.  With a prefix, it will also go
to the end of the buffer.  If you do not want it to pop, set
pop-up-windows to nil.

lisp-reposition-window (ESC C-r) will put the
start of the current defun at the top of the current window.

lisp-previous-buffer (ESC C-l) will switch to the
last visited buffer in the current window.

find-unbalanced (M-x find-unbalanced) and find-unbalanced-region
(M-x find-unbalanced-region) will find unbalanced parentheses in a
buffer.

lisp-close-all (]) will close all outstanding parentheses
back to the containing form, or a previous left bracket which will be
converted to a left paren.  If there are too many parentheses, they
will be deleted.

lisp-reindent (ESC q) will reindent the current paragraph
if in a comment or string.  Otherwise it will close the containing
defun and reindent it.

comment-region (C-c ;) will put prefix copies of
comment-start before and comment-end's after the lines in region.  To
uncomment a region, use a minus prefix.

The very first inferior LISP command executed may send some forms to
initialize the inferior LISP.  

Each time an inferior LISP command is executed, the last form sent can be
seen in the *ilisp-send* buffer.

The first time an inferior LISP mode command is executed in a Lisp
Mode buffer, the package will be determined by looking for a string of
the form (in-package "package" or 'package).  A buffers package
will be displayed in the mode line. reparse-attribute-list
(M-x reparse-attribute-list) will cause the current package to
change.  If a buffer has no specification, forms will be evaluated in
the current inferior LISP package.

lisp-describe (C-c i), lisp-arglist (C-c a) and
lisp-documentation (C-c d) and lisp-find-source
(ESC .) will switch whether they prompt for a response or
use the previous symbol when called with a negative prefix.  If they
are prompting, symbol completion works although you must have at least
some prefix or the default will be accepted.

lisp-macroexpand (C-c m) and lisp-macroexpand-1
(C-c M) will be applied to the next sexp unless they
are called with a negative prefix in which case they will prompt for
an expression to expand.

lisp-describe (C-c i) will describe the previous sexp.
If called with a negative prefix, it will prompt for an expression to
evaluate and describe.  If there is no previous-sexp and you are in an
ILISP buffer, the previous result will be described.

lisp-arglist (C-c a), lisp-macroexpand
(C-c m), and lisp-macroexpand-1
(C-c M) will insert their result in the buffer if
called with a positive prefix.

lisp-documentation (C-c d) infers whether function or
variable documentation is desired.  With a negative prefix, you can
specify the type of documentation as well.

lisp-find-source (ESC .) will find the source for a
supplied definition by using information stored in the inferior LISP.
If a definition is not found, the normal tags facility will be used.

lisp-complete (ESC TAB) will try to complete the previous
symbol in the current inferior LISP.  The first time you try to
complete it will generate the longest common substring.  If you
immediately try to complete again, you can see the possible
completions.  If you are in a string, then filename completion will be
done instead.

edit-callers (M-x edit-callers) will generate a list of all of the
callers of a function in the current inferior LISP using list-callers
(M-x list-callers).  Each successive call to edit-next-caller
(ESC ,) will edit the next caller.  The list is stored
in the buffer *All-Callers*.

The eval/compile commands verify that their expressions are balanced
and then send the form to the inferior LISP.  If called with a
positive prefix, the result of the operation will be inserted into the
buffer after the form that was just sent.  If lisp-wait-p is t (the
default), then EMACS will display the result of the command in the
minibuffer or a pop-up window.  If lisp-wait-p is nil, the command
will be sent but Emacs will not wait for the results and they will be
left in the ILISP buffer.  If called with a negative prefix, the sense
of lisp-wait-p will be inverted for the next command.  The and-go
versions will perform the operation and then immediately switch to the
ILISP buffer where you will see the results of executing your form.

The compile commands will only compile functions that are defined
using defun, other expressions will be evaluated.  If you want to
compile other forms, you need to wrap a function around it first and
then compile and execute that function or just compile the file and
load it.

lisp-mark-change (C-c SPC) marks the current defun as
being changed.  A prefix causes it to be unmarked.  clear-all-changes
(M-x clear-all-changes) will clear all of the changes.  list-changes
(M-x list-changes) will show the forms currently marked. eval-changes
(M-x eval-changes), or compile-changes (M-x compile-changes) will
evaluate or compile these changes as appropriate.  If called with a
positive prefix, the changes will be kept.  If called with a negative
prefix, the commands will be sent to the inferior LISP without
waiting. If there is an error, the process will stop and show the
error and all remaining changes will remain in the list.  All of the
results will be kept in the buffer *Last-Changes*.

File commands in lisp-source-mode buffers keep track of the last used
directory and file.  If the point is on a string, that will be the
default.  If the buffer is one of lisp-source-modes, the buffer file
will be the default.  Otherwise, the last file used in a
lisp-source-mode will be used.

lisp-load-file (C-c l) will load a file into the inferior
LISP.  You will be given the opportunity to save the buffer if it has
changed and to compile the file if the compiled version is older than
the current version.