2

M-x eval-buffer evaluates lisp code in a buffer. How do I evaluate mit-scheme code written in a buffer?

Kshitiz Sharma
  • 17,947
  • 26
  • 98
  • 169
  • See official documentation [here](http://www.gnu.org/software/mit-scheme/documentation/mit-scheme-user/GNU-Emacs-Interface.html) and [here](http://www.emacswiki.org/emacs/ExScheme). – Kshitiz Sharma Feb 04 '14 at 04:28
  • Have a look at (http://www.nongnu.org/geiser/). It's got support for Racket and Guile already. It should be relatively easy to add support for mit-scheme. – abo-abo Feb 12 '14 at 15:15

1 Answers1

3

In vanilla emacs you can do run-scheme, to start a scheme repl. Then you can use the different functions available for evaluating the scheme code in the repl.

For example given you are in scheme-mode, suppose you have following code in the scheme buffer

(define (test a b)
  (+ a b))

After starting the repl with run-scheme, you can go to the end of function definition and do C-x C-e, to evaluate it in the repl. Now you have the test function defined in the repl, to test this type the following in the buffer

(test 1 3)

Go to the end of the sexp and do C-x C-e again, this will print 4 in the repl. Also you can use C-c C-l to load the entire file at once.

Do C-h m to find out the different keybindings for evaluating scheme code. You can also use the menu to discover the different functions available.

Other option is to use slime as far as I know you will need some extra setup to use mit-scheme with slime, the instructions are present in the contrib/swank-mit-scheme.scm file in slime's main folder.