Emacs Lisp 函数中的(交互式)是什么意思? [英] What does (interactive) mean in an Emacs Lisp function?
问题描述
Emacs Lisp 函数通常是这样启动的:
Emacs Lisp function often start like this:
(lambda () (interactive) ...
(交互式)"有什么作用?
What does "(interactive)" do?
推荐答案
只是为了澄清(它在引用的文档中 查理引用的) (interactive)
不仅适用于键绑定函数,还适用于任何函数.如果没有 (interactive)
,它只能以编程方式调用,不能从 M-x
(或通过键绑定)调用.
Just to clarify (it is in the quoted docs that Charlie cites) (interactive)
is not just for key-bound functions, but for any function. Without (interactive)
, it can only be called programmatically, not from M-x
(or via key-binding).
请注意,仅向函数添加(交互式)"也不一定会使其以这种方式工作 - 函数不具有交互性的原因可能有很多.范围、依赖、参数等
Note that just adding "(interactive)" to a function won't necessarily make it work that way, either -- there could be many reasons functions are not interactive. Scoping, dependencies, parameters, etc.
这篇关于Emacs Lisp 函数中的(交互式)是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!