next up previous contents index
Next: Mail Mode Up: Programming Modes Previous: C Mode

Scheme Mode

This is a major mode that won't do you any good unless you have a compiler or an interpreter for the Scheme programming language on your system. Having one is not as normal as having, say, a C compiler, but it's becoming more and more common, so I'll cover it too. Much of what is true for Scheme  mode is true for Lisp mode as well, if you prefer to write in Lisp .

Well, to make matters painful, Emacs comes with two different Scheme modes, because people couldn't decide how they wanted it to work. The one I'm describing is called cmuscheme , and later on, in the section on customizing Emacs, I'll talk about how there can be two different Scheme modes and what to do about it. For now, don't worry about it if things in your Emacs don't quite match up to what I say here. A customizable editor means an unpredictable editor, and there's no way around that!

You can run an interactive Scheme process in Emacs, with the command M-x run-scheme. This creates a buffer named `` *scheme*'', which has the usual Scheme prompt in it. You can type in Scheme expressions at the prompt, hit tex2html_wrap8352 , and Scheme will evaluate them and display the answer. Thus, in order to interact with the Scheme process, you could just type all your function definitions and applications in at the prompt. Chances are you have previously-written Scheme source code in a file somewhere, and it would be easier to do your work in that file and send the definitions over to the Scheme process buffer as necessary.

If that source file ends in ``.ss'' or ``.scm'', it will automatically be brought up in Scheme mode when you find it with C-x C-f. If for some reason, it doesn't come up in Scheme mode, you can do it by hand with M-x scheme-mode. This scheme-mode is not the same thing as the buffer running the Scheme process; rather, the source code buffer's being in scheme-mode means that it has special commands for communicating with the process buffer.

If you put yourself inside a function definition in the Scheme source code buffer and type C-c C-e, then that definition will be ``sent'' to the process buffer -- exactly as if you had typed it in yourself. C-c M-e sends the definition and then brings you to the process buffer to do some interactive work. C-c C-l loads a file of Scheme code (this one works from either the process buffer or the source code buffer). And like other programming language modes, hitting tex2html_wrap8288 anywhere on a line of code correctly indents that line.

If you're at the prompt in the process buffer, you can use M-p and M-n to move through your previous commands (also known as the input history). So if you are debugging the function `rotate', and have already applied it to arguments in the process buffer, like so:

screen6671

then you can get that command back by typing M-p at the prompt later on. There should be no need to retype long expressions at the Scheme prompt -- get in the habit of using the input history and you'll save a lot of time.

Emacs knows about quite a few programming languages: C, C++, Lisp, and Scheme are just some. Generally, it knows how to indent them in intuitive ways.


next up previous contents index
Next: Mail Mode Up: Programming Modes Previous: C Mode

Converted on:
Mon Apr 1 08:59:56 EST 1996