Elisp 编程 - 最好的设置是什么?

发布于 2024-10-20 19:30:20 字数 204 浏览 1 评论 0原文

Emacs 中有各种很酷的编程语言模式,都是用 elisp 编写的,但显然对 elisp 本身没有特殊支持。

由于 slime 不适用于 elisp,我问自己是否所有 elisp 代码都只是在 scratch 缓冲区中被黑了? 编写 elisp 时是否不需要像 slime 这样的东西,或者根本就没有?有人在更大的 elisp 项目中使用 ECB 和语义吗?

There are all kind of cool programming language modes in Emacs, written in elisp, but apparently no special support for elisp itself.

Since slime is not working for elisp, I ask myself if all that elisp code is just hacked in the scratch buffer?
Is there no need for something like slime when writing elisp, or is it simply not there? Is anybody using ECB and semantic for bigger elisp projects?

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

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

发布评论

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

评论(7

活泼老夫 2024-10-27 19:30:20

ielm 是 Emacs Lisp REPL:交互式 Emacs Lisp 模式。

Mx ielm 带您到达那里。

ielm is the Emacs Lisp REPL: Interactive Emacs Lisp Mode.

M-x ielm gets you there.

旧人哭 2024-10-27 19:30:20

Emacs 本身带有 Emacs Lisp 支持。基础到中级的内容,例如补全 (M-TAB)、库搜索 (Mx apropos)、文档 (Ch fCh vCh S),即时运行代码(CMxM-:)直接在运行 Emacs。

Slime 的主要目的是与外部进程交互。对于 Emacs Lisp,您不需要它(除非您正在为不同版本的 Emacs 进行开发,但这是一个罕见的问题)。

ECB 和语义的功能对于大型项目(由多个源文件组成)最有用。人们不倾向于用 Emacs Lisp 编写大型项目。

Emacs itself comes with Emacs Lisp support. Basic-to-intermediate things like completion (M-TAB), library search (M-x apropos), documentation (C-h f, C-h v, C-h S), running code on-the-fly (C-M-x, M-:) operate directly in the running Emacs.

Slime's primary purpose is interaction with an external process. You don't need that for Emacs Lisp (unless you're developing for a different version of Emacs, but that's a rare concern).

The features of ECB and semantic are mostly useful for large projects (consisting of more than a handful of source files). People don't tend to write large projects in Emacs Lisp.

清欢 2024-10-27 19:30:20

总是有 emacs-lisp-mode,它(至少在 Emacs 23 中)会在任何时候自动加载您编辑 .el 文件。这似乎是许多 emacs lisp 黑客用来编写程序的方法。它有一些不错的功能(例如编译或评估缓冲区、一些调试工具、分析)。默认情况下,*scratch* 缓冲区是从 lisp-interaction-mode 编辑的,这有点不同。

它不像 slime 那样功能齐全(elisp 的社区比 common lisp 小得多),但它确实有效。您必须查阅文档并尝试该模式才能了解可以使用哪些功能。

There's always emacs-lisp-mode, which (at least in Emacs 23) is automatically loaded whenever you edit a .el file. This appears to be what many emacs lisp hackers use to write their programs. It has a few nice features (like compiling or evaluating a buffer, some debugging tools, profiling). The *scratch* buffer is by default edited from lisp-interaction-mode, which is a bit different.

It's not quite as full featured as, say, slime (elisp has a much smaller community than common lisp), but it definitely works. You'd have to poke around the documentation and experiment with the mode to see what kind of features you can use.

心的憧憬 2024-10-27 19:30:20

如前所述,Emacs 已经是权威的 elisp 开发环境,并且在内部为您提供了您可能需要的大部分功能。

如果您想跳转到尚未加载(并且缺少自动加载声明)的函数定义,您也可能使用 ctags/etags 为您的 elisp 代码库生成外部索引。 Mx find-function RET 否则处理此问题。 (我将其绑定到 ChCf

“apropos”函数是查找一般内容的关键。我使用以下绑定来轻松访问:

(define-prefix-command 'Apropos-Prefix nil "Apropos (a,c,d,i,l,v,C-v)")
(global-set-key (kbd "C-h C-a") 'Apropos-Prefix)
(define-key Apropos-Prefix (kbd "a")   'apropos)
(define-key Apropos-Prefix (kbd "C-a") 'apropos)
(define-key Apropos-Prefix (kbd "c")   'apropos-command)
(define-key Apropos-Prefix (kbd "d")   'apropos-documentation)
(define-key Apropos-Prefix (kbd "i")   'info-apropos)
(define-key Apropos-Prefix (kbd "l")   'apropos-library)
(define-key Apropos-Prefix (kbd "v")   'apropos-variable)
(define-key Apropos-Prefix (kbd "C-v") 'apropos-value)

;; Use prefix arg (C-u) to see more results for a call,
;; or uncomment the next line to do this by default:
;; (setq apropos-do-all t)
;; See C-h v apropos-do-all RET for details.

我还启用了 eldoc-mode 并绑定了 imenu-ido-goto-symbol(但很少使用)。

还有其他可能有用的库。例如,我知道有些人非常信赖 ParEdit。诚然,定位搜索对于编写 elisp 有用的 elisp 库有点困难。我不确定 Emacs Wiki 是否有这方面的类别?

As indicated, Emacs is already the definitive elisp development environment, and internally provides you with most of the functionality you are likely to want.

You might potentially also use ctags/etags to generate an external index for your elisp code base, if you were wanting to jump to function definitions which were not already loaded (and lacked autoload declarations). M-x find-function RET handles this otherwise. (I bind that to C-hC-f)

The "apropos" functions are key to finding things in general. I use the following bindings for easy access:

(define-prefix-command 'Apropos-Prefix nil "Apropos (a,c,d,i,l,v,C-v)")
(global-set-key (kbd "C-h C-a") 'Apropos-Prefix)
(define-key Apropos-Prefix (kbd "a")   'apropos)
(define-key Apropos-Prefix (kbd "C-a") 'apropos)
(define-key Apropos-Prefix (kbd "c")   'apropos-command)
(define-key Apropos-Prefix (kbd "d")   'apropos-documentation)
(define-key Apropos-Prefix (kbd "i")   'info-apropos)
(define-key Apropos-Prefix (kbd "l")   'apropos-library)
(define-key Apropos-Prefix (kbd "v")   'apropos-variable)
(define-key Apropos-Prefix (kbd "C-v") 'apropos-value)

;; Use prefix arg (C-u) to see more results for a call,
;; or uncomment the next line to do this by default:
;; (setq apropos-do-all t)
;; See C-h v apropos-do-all RET for details.

I also enable eldoc-mode and I have imenu-ido-goto-symbol bound (but very rarely utilised).

There are other libraries that may prove useful. I know that some people swear by ParEdit, for example. Admittedly, it's a bit difficult to target a search for elisp libraries which are useful for writing elisp. I'm not sure if the Emacs Wiki has a category for this?

小傻瓜 2024-10-27 19:30:20
  • 我通常使用 emacs-lisp-mode 而不是 *scratch* 的默认模式。 99% 的时间我都想保存一次性的交互式测试(至少暂时保存),因此我更常使用 *.el 文件而不是 *scratch* .

  • Icicles 在与 Emacs Lisp 交互时可以提供很大帮助。方法太多,这里就不一一列举了。以下两个概述可以提供一些想法:

http://www.emacswiki.org/emacs/EmacsNewbieWithIcicles

http://www.emacswiki.org/emacs/Icicles_-_Nutshell_View

  • I generally use emacs-lisp-mode in preference to the default mode for *scratch*. 99% of the time I want to save even throw-away, interactive tests (at least temporarily), so I more often use a *.el file than *scratch*.

  • Icicles can help a lot when interacting with Emacs Lisp. The ways are too numerous to list here. Here are two overviews that can give an idea:

http://www.emacswiki.org/emacs/EmacsNewbieWithIcicles

http://www.emacswiki.org/emacs/Icicles_-_Nutshell_View

雅心素梦 2024-10-27 19:30:20

我认为将这个添加到您的 .emacs

(define-key emacs-lisp-mode-map (kbd "M-.") 'find-function-at-point)

将会非常有帮助。

I think add this to you .emacs

(define-key emacs-lisp-mode-map (kbd "M-.") 'find-function-at-point)

will be very helpful.

人事已非 2024-10-27 19:30:20
M-x edebug-defun 

调试功能
我认为这些是 elisp 最好的调试工具。

M-x edebug-defun 

to debug the function
I think these is the best debug tools for elisp.

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