25
A
回答
18
我的意思是说,当你将某个函数绑定到一个键时,你需要包含一些你需要的函数的可调用代码 - 比如从CTRL-u获得参数。
看一看CTRL-h f interactive
的详细信息:
interactive is a special form in `C source code'. (interactive args) Specify a way of parsing arguments for interactive use of a function. For example, write (defun foo (arg) "Doc string" (interactive "p") ...use arg...) to make ARG be the prefix argument when `foo' is called as a command. The "call" to `interactive' is actually a declaration rather than a function; it tells `call-interactively' how to read arguments to pass to the function. When actually called, `interactive' just returns nil. The argument of `interactive' is usually a string containing a code letter followed by a prompt. (Some code letters do not use I/O to get the argument and do not need prompts.) To prompt for multiple arguments, give a code letter, its prompt, a newline, and another code letter, etc. Prompts are passed to format, and may use % escapes to print the arguments that have already been read.
23
只是为了澄清(它是在引用文档that Charlie cites)(interactive)
不仅仅是键绑定功能,但对于任何功能。没有(interactive)
,它只能以编程方式调用,而不是从M-x
(或通过键绑定)调用。
编辑:注意,只是加入“(互动)”的功能不一定会使其工作方式,无论是 - 可能有许多原因,功能都没有互动。范围,依赖关系,参数等。
12
更值得一提的是,interactive
在交互式上下文中的主要目的(例如,当用户使用键绑定调用函数时)让用户指定函数参数,否则该函数参数只能以编程方式给出。
例如,考虑函数sum
返回两个数字的和。
(defun sum (a b)
(+ a b))
您可以通过(sum 1 2)
调用它,但你只能在一个Lisp程序做(或在REPL)。如果在函数中使用interactive
特殊形式,则可以向用户询问参数。
(defun sum (a b)
(interactive
(list
(read-number "First num: ")
(read-number "Second num: ")))
(+ a b))
现在M-x sum
会让你在minibuffer输入两个数字,你仍然可以做(sum 1 2)
为好。
interactive
应该返回将用作参数列表,如果所谓的交互功能的列表。
2
(交互式)用于通过M-x或键盘绑定与用户交互的功能。
的Mx描述功能RET互动RET关于如何使用它,包括参数搭上弦,整数,缓冲名称的详细信息等
相关问题
- 1. #[...]在emacs-lisp中意味着什么?
- 2. “+”在+函数($)中意味着什么?
- 3. 在php中函数意味着什么?
- 4. 什么是!在这个Ruby函数中意味着什么
- 5. 在AngularJS中结尾意味着什么double意味着
- 6. 什么===在PHP意味着
- 7. 溢出意味着什么?
- 8. 在numpy代码中意味着什么?
- 9. 用交互式Emacs Lisp函数替换文本帮助
- 10. 双参数化函数在scala中意味着什么?
- 11. '\'在JavaScript函数参数中意味着什么?
- 12. 什么呢JDBC:HSQLDB:hsqlTempFiles意味着
- 13. * | *这意味着什么CSS?
- 14. 如何从另一个Emacs Lisp函数调用具有前缀参数的交互式Emacs Lisp函数?
- 15. 〜=是什么。在Stata意味着什么?
- 16. matlab中的参数意味着什么?
- 17. 互动的Emacs Lisp函数交换两个词互相
- 18. 什么是“不可变变量”意味着函数式编程
- 19. 函数(i)在这个jQuery代码中意味着什么?
- 20. 在Python中,函数是“全部”意味着什么?
- 21. 这个函数声明在C++中意味着什么
- 22. “:”在dart的类构造函数中意味着什么?
- 23. 'f'在OpenGL函数(如glRotatef)中意味着什么?
- 24. PREEMPTIVE_XE_DISPATCHER这意味着什么?
- 25. 奎因意味着什么?
- 26. Field.Index.NOT_ANALYZED_NO_NORMS意味着什么
- 27. $这意味着什么PHP?
- 28. MYSQLI_NUM意味着什么?
- 29. HttpServletResponse.SC_BAD_REQUEST意味着什么?
- 30. 什么是点在以下emacs的命令意味着
Török,如果我要问另一个之前测试的参数值题? http://stackoverflow.com/questions/25447312/emacs-lisp-how-to-use-interactive-for-conditional-arguments – yPhil 2014-08-22 12:52:31