Emacs for Erlang 具有类似 vi 的键绑定和方便的简短引用?

发布于 2024-10-16 21:29:36 字数 227 浏览 3 评论 0原文

我已经接触过 Emacs 的 vi 风格按键绑定,但我过去在 .emacs 文件中混合基于 Lisp 的配置以启用各种模式等的经验到目前为止还不是很愉快。

阅读了几篇关于 Emacs + Erlang 的文章,但是对于那些主要熟悉 vi 的人(以及不熟悉 Lisp 的人)来说,有什么东西可能稍微容易一些吗?

整套可能性(键绑定)是相当压倒性的。是否有专门与 Erlang 开发相关的简明键映射/快捷键参考?

I have come accross vi-style keybindings for Emacs, but my past experience in mixing Lisp based config in .emacs file for enabling various modes etc., hasn't been very pleasant so far.

Read several articles on Emacs + Erlang, but is there something that might be slightly easier for folks familiar mostly with vi (and who are unfamiliar with Lisp)?

The entire set of possibilities (keybindings) is quite overwhelming. Is there a condensed key-map/shortcuts reference specially relevant for Erlang development?

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

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

发布评论

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

评论(2

汹涌人海 2024-10-23 21:29:36

只需使用 vi 和命令行即可。有很多人这样做,而且似乎对他们来说效果很好。尽管我使用 Emacs,但它不是我使用的 Emacs-erlang 交互。相反,我通常只拥有一个单独的 Erlang shell,然后使用 l() 命令在该 shell 中加载模块进行交互。


一一回答你的问题:

  • 在 Erlang 中调试很有趣。首先,如果你的程序保持功能正常,你会发现你需要更少的调试来找出程序的错误行为,因为你可以简单地为众多函数中的每个函数编写小测试来测试其正确性。您可以将它们添加到单元测试框架中。

    一旦您将多个进程添加到混合中,您就会发现传统的调试无论如何都不再起作用。诀窍是跟踪和断言,您将需要学习一种在不运行程序的情况下读取程序的方法,并使用调试器查看它们的去向。

    也就是说,尝试在 Erlang shell 中执行 debugger:start() :) 还有跟踪系统和构建于其之上的第 3 方工具 redbug其中(eper 套件的一部分)。

  • 可以使用 3-4 个分析器之一来完成分析:cprofeproffprof 在范围和功能上都略有不同。它们对您的程序有多大影响以及它们是否可以在生产系统上运行。我倾向于使用 eprof,并且我的程序中有一个旋钮,它将生成一个 eprof,然后在程序启动时将其附加。

  • 在 shell 中尝试 appmon:start()

  • 浏览大型代码库的标准 vi-方式是创建标签文件,以便您可以跳转到光标下事物的定义点。 Emacs 也可以做同样的事情。我有一个 make Tags 目标来创建这些文件,这样我就可以轻松地在源代码中进行跳转。跳转时,您有一堆之前的跳转,因此您可以返回到稍后跳转的点。

  • 最后还有像xref这样的工具,可以用来创建调用图并在代码中查找奇怪的东西。它需要您进行一些编码,但它确实为您提供了必要的工具。

Just use vi and a command line. There are numerous people doing that and it seems to work just fine for them. Even though I use Emacs, it is not the Emacs-erlang interaction I use. Rather I usually just have a separate Erlang shell and then I load modules in that shell with the l() command for interaction.


Answering your questions one by one:

  • Debugging in Erlang is funny. Firstly, if your program is kept functional you will find that you need much less debugging to figure out what the program does incorrectly because you can simply write small tests for each of the numerous functions to test its correctness. And you can add those into unit-test frameworks.

    As soon as you add multiple processes to the mix you will find that traditional debugging doesn't work anymore anyway. The trick is then to trace and assert, and you will need to learn a way to read programs without running them and see where they go with a debugger.

    That said, try to execute debugger:start() in an Erlang shell :) There are also the tracing systems and redbug, a 3rd party tool built on top of them (part of the eper suite).

  • Profiling can be done with one of the 3-4 profilers: cprof, eprof and fprof are all slightly different in scope and in how much impact they have on your program and if they can be run on a production system or not. I tend to use eprof and I have a knob in my program which will spawn an eprof and then attach it at program start.

  • Try appmon:start() in a shell.

  • The standard vi-way of browsing large code bases is to create tags-files so you can jump to the definition point of the thing-under-the-cursor. Emacs can do the same. I have a make tags target to create these files so I can easily make jumps around in the source code. When jumping you have a stack of the former jumps so you can return to the point you jumped from later on.

  • Finally there are tools like xref which can be worked to create call graphs and find odd things in the code. It will require some coding on your part, but it does provide you with the necessary tooling.

╭ゆ眷念 2024-10-23 21:29:36

Viper 模式 提供 Vi 风格的键绑定。这可能是最简单的开始方法。在 .emacs 中启用新模式是使用 Emacs 的一个非常基本的部分,因此这是一个最好尽早清除的学习障碍!

Emacs 手册包含有关以下内容的更多详细信息:对您的键绑定进行单独更改。

您可能会发现 Xah 的按键绑定教程很有帮助,因为它提供了许多示例。

Viper mode provides Vi-style keybindings. That's probably the easiest way to start. Enabling a new mode in your .emacs is a pretty fundamental part of using Emacs, so it's a learning hurdle best cleared early!

The Emacs manual contains more detailed information about making individual changes to your keybindings.

You may find Xah's keybinding tutorial helpful, as it provides many examples.

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