How to run scheme with Emacs?

后端 未结 3 1099
太阳男子
太阳男子 2021-01-31 18:35

I followed this tutorial and successfully installed Emacs, STk, Quack.

The question is how can I load my program like I do in Racket?

In Racket I can edit my cod

相关标签:
3条回答
  • 2021-01-31 19:14

    I literally just set this up on my Macbook. Since you didn't specify what system you are on, I will hope you're using some Unix flavor... I'm not familiar with STk really, but this might help you sort out whatever issues you are having, which sound really similar to the problems I faced.

    If you install a Scheme implementation (I am using MIT Scheme, edited to add that this also works with Racket, using mzscheme) it may come with a symlink named "scheme" - this is what Emacs looks for, I think.

    If it doesn't (MIT Scheme doesn't seem to on OS X) you can edit your Emacs configuration, in Emacs type M-x customize-group then type scheme. Scroll down a bit and find the Scheme program name field. Change it to your Scheme implementation command, like mit-scheme or mzscheme. You can also just create a symlink in your PATH which points to the right binary:

    sudo ln -s /Applications/mit-scheme.app/Contents/Resources/mit-scheme
        /usr/local/bin/scheme
    

    For MIT Scheme, you also need to set the MITSCHEME-LIBRARY-PATH variable, so add this to your .emacs.

    (setenv "MITSCHEME_LIBRARY_PATH"
        "/Applications/mit-scheme.app/Contents/Resources")
    

    Then you should be able to start an inferior Scheme buffer with M-x run-scheme. And pass code to the REPL with C-x C-e, which evaluates the expression before the point.

    If this doesn't work (it didn't for me) you may need to make sure that the path Emacs uses for executing shell commands includes the scheme symlink or whatever directory contains the binary for your implementation. With some experimentation, I fixed this by adding this to my .emacs file:

    Emacs is ignoring my path when it runs a compile command

    For references, the other SO question which I used to set this up:

    How do I get a scheme interpreter working inside Emacs?

    0 讨论(0)
  • 2021-01-31 19:32

    I would recommend to use Homebrew to install the mit-scheme with simple command brew install mit-scheme if your are on a Mac. Find your ~/.emacs file, if it not exists then create one, append this to the end of the file:

    (setq scheme-program-name  "your/mit-scheme/path")
    

    Use which mit-scheme command to find out where your mit-scheme was installed. Take my MacOS X as an example:

    (seq scheme-program-name   "/usr/local/bin/mit-scheme")
    

    Save it and quit. Then restart your Emacs and type M+x and you are in the mit-sheme.

    0 讨论(0)
  • 2021-01-31 19:34

    The 64-bit download from GNU now has the .app named as "MIT:GNU Scheme.app." I tried @spacemanaki's instructions but I kept getting:

    bash-3.2$ export MITSCHEME_LIBRARY_PATH=/Applications/MIT:GNU\ Scheme.app/Contents/Resources
    bash-3.2$ scheme
        scheme: can't find a readable default for option --band.
        searched for file all.com in these directories:
        /Applications/MIT
        /Applications/MIT:GNU Scheme.app/Contents/Resources/GNU Scheme.app/Contents/Resources
    

    Eventually I realized the semicolon was acting as a path separator. So just make sure you rename it:

    mv MIT:GNU\ Scheme.app/ mit-scheme.app
    

    Then the above instructions will work fine - although you may have to use Finder to do the rename, because when I did it on the shell my Resources folder disappeared.

    0 讨论(0)
提交回复
热议问题