(setq load-path (cons "~/emacs" load-path))
(autoload 'scheme-mode "iuscheme"
"Major mode for Scheme." t)
(autoload 'run-scheme "iuscheme"
"Switch to interactive Scheme buffer." t)
(autoload 'run-alt-scheme "iuscheme"
"Switch to interactive alternative Scheme buffer." t)
(setq auto-mode-alist (cons '("\\.ss$" . scheme-mode) auto-mode-alist))
If you already have some Scheme support in your .emacs file, you might want to delete it before doing the above step. Usually, the above statements are all anyone needs in their .emacs file relating to Scheme.
The above instructions are sufficient to get you started writing Scheme programs in Emacs with all sorts of support. If you want to know what you've just done and why you've done it, read on...
The file iuscheme.el serves two basic functions. The first is probably the most important, but needs a history lesson. You see, the original Emacs program started at MIT. MIT is also an active user of Scheme, so someone apparently thought that they should write a Scheme mode for Emacs. So they wrote two handy emacs-lisp files called xscheme.el and scheme.el, and got these files placed on the general distribution of Emacs (that is, every emacs in the world has these files). Unfortunately for the rest of the universe, they wrote their Scheme mode specifically for the MIT Scheme, causing (for Chez Scheme users, at least) the infamous error:
Error in open-input-file: error opening "-emacs": No such file or directory.
The folks at Carnegie Mellon, for reasons of their own, wrote a much nicer and cleaner package of Emacs Scheme support: cmuscheme.el, and after a bit, they also got their file into the Emacs distribution. So you can be sure that any emacs you use has this file available, and thus there is some way to avoid the horrible "-emacs" bug. The problem is that when you try to edit Scheme it is unclear whether you'll get MIT's (evil) or CMU's (good) support files. One way to make sure is to add the following lines to your .emacs file:
(autoload 'scheme-mode "cmuscheme" "Major mode for Scheme." t) (autoload 'run-scheme "cmuscheme" "Switch to interactive Scheme buffer." t) (autoload 'run-alt-scheme "cmuscheme" "Switch to interactive alternative Scheme buffer." t)Yet if you're at IU, you would probably be better served to use iuscheme.el instead of cmuscheme.el. Why? Well, the most important thing iuscheme does is make sure that cmuscheme is loaded. That's right, iuscheme is just an extension of cmuscheme (hooray for software reuse). So, while you can get almost the same functionality by adding the cmuscheme autoloads to your .emacs file, and never have to deal with iuscheme.el at all, iuscheme extends cmuscheme in a number of useful ways:
So there you are. A good rule of thumb might be to use iuscheme.el while you are, in fact, here at IU. But you should remember the existence of cmuscheme.el for when you fly the coop.
If you regularly work under X and want to see your scheme in nifty fonts, you might want to look at the file schemefont.el, which is just what I use to fontify my scheme buffers. If you use it, you should either just stick the contents of the file in your .emacs file, or put the file in your ~/emacs directory and add
(load-library "schemefont")somewhere late in your .emacs file.
For a (very) different Scheme editing experience, get the file balance-mode.el, place it in your ~/emacs directory, and add the statement:
(require 'balance-mode)in your .emacs file. The command Esc-x balance-mode toggles a minor mode for automatic paren and square-bracket balancing. If you want this behavior in all Scheme editing sessions, also add the expression
(add-hook 'scheme-mode-hook (function (lambda () (balance-mode t))))to your .emacs file.
iuscheme.el was written by Chris Haynes, a professor here at IU. I pattern-matched balance-mode.el from various emacs files. schemefont.el was written by me, but pattern matched off of some stuff that Jon Rossie cooked up.