在 sbcl 中启用自动完成

发布于 2024-10-25 01:03:44 字数 424 浏览 8 评论 0原文

最近开始学习lisp,主要是bin使用clisp和vim。我也想尝试 sbcl,因为它经常被推荐为最好的免费 lisp 编译器之一。不过,有一件事让 sbcl 对我来说更难使用:我无法在 REPL 中获得自动完成功能,而我在 clisp 中有自动完成功能。也就是说,当我启动 sbcl 并键入以下内容(作为示例)时,

* (requi<tab>

其中 是文本制表符,我没有得到补全列表,而是得到详细的制表符。在 clisp 中, 会将上一行补全为 * (require)。

由于我对 lisp 相当陌生,所以 clisp 中的自动补全功能非常方便,所以它如果有人能解释如何在 sbcl 中获取它,那真的会非常方便。

I have recently started to learn lisp, and have mainly bin using clisp and vim. I wanted to try sbcl as well, since this is often recommended as one of the best, free lisp compilers. There is one thing, though, which makes sbcl more difficult to use for me: I can not get autocomplete in the REPL, which I do have in clisp. That is, when I start sbcl and type the following (as an example),

* (requi<tab>

where <tab> is the literal tab character, I do not get a list of completions, but rather a verbose tab character. In clisp, <tab> will complete the previous line to * (require.

As I am fairly new to lisp, the autocomplete functionality in clisp is really handy, so it would really be very convenient if anyone could explain how to get it in sbcl as well.

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

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

发布评论

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

评论(4

韬韬不绝 2024-11-01 01:03:44

在 SBCL 中获取自动完成 repl 的一种方法是使用 linedit,来自 http://common-lisp.net /项目/lineedit/。第二种方法是使用 rlwrap(一个 readline 包装器)和一个合适的完成文件。 (我认为可以公平地说,这些都不像 emacs 那样常用,当然 emacs 也提供了一个完整的 REPL 以及许多其他有用的功能。)

One way of getting an autocompleting repl in SBCL is to use linedit, from http://common-lisp.net/project/linedit/. A second is to use rlwrap, a readline wrapper, with a suitable completions file. (I think it's fair to say that neither of these is as commonly used as emacs, which of course also provides a completing REPL with a number of other useful features.)

淡看悲欢离合 2024-11-01 01:03:44

我不知道在 SBCL 中获得自动完成 REPL 的方法,但我发现从 SLIME 中与我的 lisp 环境交互非常方便,此时,您可以使用 Cc Ci 进行自动完成。

I don't know of a way to get an auto-completing REPL in SBCL, but I find that interfacing with my lisp environment from within SLIME is quite handy and at that point, you can use C-c C-i for auto-completion.

扮仙女 2024-11-01 01:03:44

事实上这是完全有可能的。是的,您想通过 Emacs 和 Slime 使用 Common Lisp(我更喜欢 SLY)。但这是初学者遇到的另一堵墙。

你想直接玩 REPL 吗?
以下指令允许使用 rlwrap 在 SBCL 中自动完成。

https://www.cliki.net/CMUCL%20Hints

1) 安装 rlwrap

2) 创建 shell别名,例如将文本放入

alias rs="rlwrap sbcl"

~/.bashrc (或 ~/.profile 或其他)中。
(或者您可以继续通过“rlwrap sbcl”调用 sbcl rlwrapped)

3)Edi Weitz 创建了一个完成列表文件,该文件现已从他的网站上消失,因此我链接到互联网档案馆。将此单词表保存到文件“sbcl”中
https://web.archive.org/web/20031207221537 /http://weitz.de/files/cmucl_completions

4)您可以尝试按照Cliki上的说明放置文件,这只适用于您登录的用户。我希望它适用于所有用户,因此我将“sbcl”文件放入我的 rlwrap 完成目录中,该目录位于
/usr/share/rlwrap/completions/

所以现在我有一个文件 /usr/share/rlwrap/completions/sbcl
里面有这几个字。

5)创建/调整
~/.inputrc 文件添加行

TAB: complete

5) 完成,现在在新终端中(或重新加载 .bashrc 后)
我可以通过 rlwrap 使用别名“rs”启动 SBCL
开始输入 (def (或其他)并按 TAB,然后获得自动完成建议。

初学者奖励 - 如果您想在终端中从 REPL 编辑 lisp,例如,带有 parinfer 的 vim,尝试 magic-ed,它允许您从 repl 编辑文件,这可以为您解决这个问题。
https://github.com/sanel/magic-ed
借助 Tab 自动完成功能以及从终端编辑 Lisp 的便捷方式,人们可以在终端中开始学习 Common Lisp。

Actually it's completely possible. Yes, You want to work with Common Lisp via Emacs and Slime (I prefer SLY). But it's another wall beginners hit.

You want to just play from the REPL?
The following instructions allow autocomplete in SBCL with rlwrap.

https://www.cliki.net/CMUCL%20Hints

1) install rlwrap

2) create shell alias, for example putting text like

alias rs="rlwrap sbcl"

into your ~/.bashrc (or ~/.profile or whatever).
(or you can continue calling sbcl rlwrapped via "rlwrap sbcl")

3)Edi Weitz created a completion list file that is now gone from his website, so i'm linking to the Internet Archive. save this wordlist into a file "sbcl"
https://web.archive.org/web/20031207221537/http://weitz.de/files/cmucl_completions

4)You can try putting the file according to the instructions on Cliki, this will only apply for the user you are logged in under. I wanted it to work for all users, so I put the "sbcl" file into my rlwrap completion directory, which is in
/usr/share/rlwrap/completions/

So now I have a file /usr/share/rlwrap/completions/sbcl
That contains the words.

5)Create / adjust
~/.inputrc file add the line

TAB: complete

5) Done, now in a new terminal (or after reloading .bashrc)
I can launch SBCL via rlwrap with the alias "rs"
start typing (def (or whatever) and hit TAB, and get auto-completion suggestions.

Beginner Bonus - if you want to edit lisp in the terminal, from the REPL, in say, vim with parinfer, try magic-ed, which will allow you to edit files from the repl. Configuring SBCL to use ED is esoteric. This solves that issue for You.
https://github.com/sanel/magic-ed
With tab auto-completion and convenient way to edit lisp from the terminal, one can start learning Common Lisp in the terminal.

踏月而来 2024-11-01 01:03:44

If you want to use sbcl, emacs and slime, follow this Modern Common Lisp on Linux tutorial. The tutorial mentions installing quicklisp and especially (ql:quickload "quicklisp-slime-helper"), an elispscript which getting slime to do autocomplete and more.

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