tags:

views:

93

answers:

3

I have the following code in ~/.emacs for running scheme (gosh and mit-scheme).

;(setq scheme-program-name "gosh -i")
(setq scheme-program-name "mit-scheme")
(autoload 'scheme-mode "cmuscheme" "Major mode for scheme." t)
(autoload 'run-scheme "cmuscheme" "Run an inferior scheme process." t)

(defun scheme-other-window ()
 "Run scheme on other window"
 (interactive)
 (switch-to-buffer-other-window
  (get-buffer-create "*scheme*"))
 (run-scheme scheme-program-name))

(define-key global-map
  "\C-cs" 'scheme-other-window)

C-c s starts the scheme in REPL way specified at 'scheme-program-name', and I select the scheme to use by commenting out one or the other.

Is there better way than this? I mean, can I select which scheme to use with 'M-x' or something?

+4  A: 

If you invoke run-scheme with a prefix argument, it will ask you which scheme you want to run -- you can fake that by running it with

(let ((current-prefix-arg 1)) (call-interactively 'run-scheme))
Eli Barzilay
@Eli : I put your code in the .emacs, but it doesn't work.
prosseek
@prosseek: "doesn't work" is not enough information to know what goes wrong. It should work on GNU Emacs -- I'm using 23.1.1, but it should work on older versions too.
Eli Barzilay
@Eli : I got something wrong, following Jared's code, it works. Thanks.
prosseek
+1  A: 

Look at quack.el- it has a better Scheme mode and queries for what Scheme you wish to run.

Greg
+2  A: 

quack.el is probably the better solution, but should you want to keep using run-scheme this version of the function includes Eli's suggestion and does work.

(defun scheme-other-window ()
  "Run scheme on another window"
  (interactive)
  (switch-to-buffer-other-window
   (get-buffer-create "*scheme*"))
  ;; This causes run-scheme to act as if C-u had been entered before it was called.
  (let ((current-prefix-arg 1)) 
    (call-interactively 'run-scheme)))
Jared
@Jared : Thanks!
prosseek