如何使用Emacs运行方案?

发布于 2024-10-03 16:42:56 字数 457 浏览 3 评论 0原文

我按照这个教程并成功安装了Emacs、STk、Quack。

问题是我怎样才能像在 Racket 中那样加载我的程序?

在 Racket 中,我可以在上方窗口中编辑代码,输入一些代码,保存并运行。然后下面的窗口就会自动加载我刚刚写的代码。然后我就可以玩它了。

我尝试过 Mx 运行方案。它只会让我进入类型麻省理工学院计划。然后它说不存在这样的文件或目录。然后我尝试了F5(该网站的作者编写了一个.emacs文件使我可以按F5)。然后 STk 打开。我可以在 STk 中加载我的方案文件。但这会让我和埃德温一起回到麻省理工学院的计划。

我想在 Racket 中拥有同样的东西(Write/REPL)。但按键移动更加灵活。在 Racket 中,您没有 Cf Cn Ca...等。

有人可以教我怎么做吗?

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 code in the upper window, type some codes, save and run. Then the lower window will automatically loaded the code I just wrote. Then I can play with it.

I've tried M-x run-scheme. It only brings me into type mit-scheme. Then it says No such file or directory exists. Then I tried F5 (The author from the site wrote a .emacs file enables me to press F5). Then the STk opens up. I can load my scheme file in STk. But it will brings me back to MIT Scheme with edwin.

I want to have the same thing in Racket (Write/REPL). But more flexibility with the key movement. In Racket you don't have C-f C-n C-a...etc.

Could anyone teach me how to do so?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

拥抱没勇气 2024-10-10 16:42:56

我实际上只是在我的 Macbook 上设置了这个。既然你没有指定你所在的系统,我希望你使用一些 Unix 风格...我真的不熟悉 STk,但这可能会帮助你解决你遇到的任何问题,这听起来确实与我遇到的问题类似。

如果你安装一个Scheme实现(我正在使用MIT的Scheme,编辑后添加它也适用于Racket,使用mzscheme),它可能带有一个名为“scheme”的符号链接 - 我认为这就是Emacs所寻找的。

如果没有(MIT Scheme 在 OS X 上似乎没有),您可以编辑 Emacs 配置,在 Emacs 中输入 Mxcustomize-group,然后输入 scheme。向下滚动一点并找到 Scheme 程序名称 字段。将其更改为您的Scheme实现命令,例如mit-schememzscheme。您还可以在 PATH 中创建一个指向正确二进制文件的符号链接:

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

对于 MIT Scheme,您还需要设置 MITSCHEME-LIBRARY-PATH 变量,因此将其添加到您的 .emacs 中。

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

然后您应该能够使用Mx run-scheme启动一个较差的Scheme缓冲区。并使用 Cx Ce 将代码传递给 REPL,该 REPL 会计算该点之前的表达式。

如果这不起作用(对我来说不起作用),您可能需要确保 Emacs 用于执行 shell 命令的路径包含 scheme 符号链接或包含用于实现的二进制文件的任何目录。经过一些实验,我通过将其添加到我的 .emacs 文件中解决了这个问题:

Emacs 在运行编译命令时忽略我的路径

作为参考,我用来设置它的另一个 SO 问题:

如何让方案解释器在 Emacs 中工作?

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?

月竹挽风 2024-10-10 16:42:56

从 GNU 下载的 64 位版本现在的 .app 名为“MIT:GNU Scheme.app”。我尝试了 @spacemanaki 的说明,但我不断收到:

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

最终我意识到分号充当了路径分隔符。因此,只需确保您重命名它:

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

然后上述说明将正常工作 - 尽管您可能必须使用 Finder 来进行重命名,因为当我在 shell 上执行此操作时,我的 Resources 文件夹消失了。

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.

层林尽染 2024-10-10 16:42:56

如果您使用的是 Mac,我建议使用 Homebrew 通过简单的命令 brew install mit-scheme 安装 mit-scheme。找到您的 ~/.emacs 文件,如果不存在则创建一个,将其附加到文件末尾:

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

使用 which mit-scheme 命令找出您的已安装 mit-scheme。
以我的 MacOS X 为例:

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

保存并退出。
然后重新启动 Emacs 并输入 M+x,您就进入了 mit-sheme。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文