Next: , Previous: Running Scheme48, Up: User environment


2.2 Emacs integration

Emacs is the canonical development environment for Scheme48. The scheme.el and cmuscheme.el packages provide support for editing Scheme code and running inferior Scheme processes, respectively. Also, the scheme48.el package provides more support for integrating directly with Scheme48.1 scheme.el and cmuscheme.el come with GNU Emacs; scheme48.el is available separately from

     http://www.emacswiki.org/cgi-bin/wiki/download/scheme48.el.

To load scheme48.el if it is in the directory emacs-dir, add these lines to your .emacs:

     (add-to-list 'load-path "emacs-dir/")
     (autoload 'scheme48-mode "scheme48"
       "Major mode for improved Scheme48 integration."
       t)
     (add-hook 'hack-local-variables-hook
               (lambda ()
                 (if (and (boundp 'scheme48-package)
                          scheme48-package)
                     (progn (scheme48-mode)
                            (hack-local-variables-prop-line)))))

The add-hook call sets Emacs up so that any file with a scheme48-package local variable specified in the file's -*- line or Local Variables section will be entered in Scheme48 mode. Files should use the scheme48-package variable to enable Scheme48 mode; they should not specify Scheme48 mode explicitly, since this would fail in Emacs instances without scheme48.el. That is, put this at the tops of files:

     ;;; -*- Mode: Scheme; scheme48-package: ... -*-

Avoid this at the tops of files:

     ;;; -*- Mode: Scheme48 -*-

There is also SLIME48, the Superior Lisp Interaction Mode for Emacs with Scheme48. It provides a considerably higher level of integration the other Emacs packages do, although it is less mature. It is at

     http://mumble.net/~campbell/scheme/slime48.tar.gz;

there is also a Darcs repository2 at

     http://mumble.net/~campbell/darcs/slime48/.

Finally, paredit.el implements pseudo-structural editing facilities for S-expressions: it automatically balances parentheses and provides a number of high-level operations on S-expressions. Paredit.el is available on the web at

     http://mumble.net/~campbell/emacs/paredit.el.

cmuscheme.el defines these:

— Emacs command: run-scheme [scheme-prog]

Starts an inferior Scheme process or switches to a running one. With no argument, this uses the value of scheme-program-name to run the inferior Scheme system; with a prefix argument scheme-prog, this invokes scheme-prog.

— Emacs variable: scheme-program-name

The Scheme program to invoke for inferior Scheme processes.

Under scheme48-mode with scheme.el, cmuscheme.el, and scheme48.el, these keys are defined:

C-M-fforward-sexp
C-M-bbackward-sexp
C-M-kkill-sexp
<ESC> C-<DEL> (not C-M-<DEL>) — backward-kill-sexp
C-M-qindent-sexp
C-M-@mark-sexp
C-M-<SPC>mark-sexp
S-expression manipulation commands. C-M-f moves forward by one S-expression; C-M-b moves backward by one. C-M-k kills the S-expression following the point; <ESC> C-<DEL> kills the S-expression preceding the point. C-M-q indents the S-expression following the point. C-M-@ & C-M-<SPC>, equivalent to one another, mark the S-expression following the point.
C-c zswitch-to-scheme
Switches to the inferior Scheme process buffer.
C-c C-lscheme48-load-file
Loads the file corresponding with the current buffer into Scheme48. If that file was not previously loaded into Scheme48 with C-c C-l, Scheme48 records the current interaction environment in place as it loads the file; if the file was previously recorded, it is loaded into the recorded environment. See Emacs integration commands.
C-c C-rscheme48-send-region
C-c M-rscheme48-send-region-and-go
C-c C-r sends the currently selected region to the current inferior Scheme process. The file of the current buffer is recorded as in the C-c C-l command, and code is evaluated in the recorded package. C-c M-r does similarly, but subsequently also switches to the inferior Scheme process buffer.
C-M-xscheme48-send-definition
C-c C-escheme48-send-definition
C-c M-escheme48-send-definition-and-go
C-M-x (GNU convention) and C-c C-e send the top-level definition that the current point is within to the current inferior Scheme process. C-c C-e does similarly, but subsequently also switches to the inferior Scheme process buffer. C-c c-e and C-c M-e also respect Scheme48's file/environment mapping.
C-x C-escheme48-send-last-sexp
Sends the S-expression preceding the point to the inferior Scheme process. This also respects Scheme48's file/environment mapping.

Footnotes

[1] scheme48.el is based on the older cmuscheme48.el, which is bundled with Scheme48 in the emacs/ directory. Since cmuscheme48.el is older and less developed, it is not documented here.

[2] Darcs is a revision control system; see

     http://www.darcs.net/

for more details.