SRansom
SRansom

Reputation: 357

emacs scheme racket auto reload file

I am new to scheme, but was able to get it running in emacs. I like having the file open in one buffer in emacs, and having the racket interpreter open in another so that I can test as I'm writing etc. The problem is that every time I want to test something I have to save the file (not a big deal) and then reload it in the interpreter using (enter! "programname").

Is there anyway to have it auto reload every time I save the file? It gets to be really tedious having to reload the file manually every time I change something, especially because I'm still learning scheme so I have to go back and forth to make changes a LOT. Any help is greatly appreciated, thanks!

Upvotes: 5

Views: 594

Answers (2)

Greg Hendershott
Greg Hendershott

Reputation: 16260

Geiser and/or Quack are very nice modes for Emacs. Using DrRacket is also a great option.

But to more-literally answer your question:

You could add the following to your .emacs and bind it to the F5 key for a rough approximation of DrRacket's Run command:

(defun run-roughly-like-dr-racket ()
  (interactive)
  (let ((w (selected-window)))
    (set-buffer-modified-p t)           ;force save buffer so that enter! ...
    (save-buffer)                       ;...will re-evaluate

    (other-window -1)
    (run-scheme)
    (select-window w)

    (comint-send-string (get-buffer-process "*scheme*")
                        (format "(enter! \"%s\")\n" (buffer-file-name)))

    (pop-to-buffer (get-buffer-process "*scheme*") t)
    (select-window w)))

Upvotes: 3

molbdnilo
molbdnilo

Reputation: 66371

The most useful option is probably Geiser.

It lets you, among other splendid things, compile the current file with a keystroke, or only evaluate the definition at point. It's well documented and is the closest to a SLIME for Scheme you can get, I think.

If you can live without Emacs, DrRacket is also an excellent environment to work in.

Upvotes: 3

Related Questions