简体   繁体   English

如何在Emacs Lisp中理解这种形式(交互式(列表'交互式))?

[英]How to understand this form (interactive (list 'interactive)) in Emacs Lisp?

I was found some codes like this, 我找到了一些这样的代码,

 1 (require 'cl-lib)
 2 (require 'company)
 3 
 4 (defun company-sample-backend (command &optional arg &rest ignored)
 5   (interactive (list 'interactive))
    ...
   )

but how to understand line 5? 但如何理解第5行?

The argument to the interactive declaration is either a string or an elisp form which, when evaluated, returns a list of argument values for the function. interactive声明的参数是字符串或elisp表单,在计算时,它返回函数的参数值列表

In this instance the declaration uses a form returning a list. 在这种情况下,声明使用返回列表的表单。 The form is: 表格是:

(list 'interactive)

which is a form that returns a list of a single item, being the symbol interactive 这是一个返回单个项目列表的表单,是interactive符号

The argument list for the function was: 该函数的参数列表是:

(command &optional arg &rest ignored)

Therefore, when this function is called interactively, the argument command will have the value interactive 因此,当以交互方式调用此函数时,参数command将具有interactive

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在 Emacs Lisp 中以交互模式“按”输入? - How to "press" enter in interactive mode in Emacs Lisp? Emacs Lisp:如何使用REPL交互式缓冲区? - Emacs Lisp: How to, an interactive buffer with REPL? Lisp交互式Emacs乘法不正确 - Lisp interactive emacs multiplying incorrectly 如何获取Emacs lisp非交互功能列表? - How do I get a list of Emacs lisp non-interactive functions? Emacs / Emacs Lisp:我可以在交互式表单之前插入建议吗? 或如何智能地预设编译命令? - Emacs/Emacs Lisp: can I insert advice before interactive form? or how to intelligently pre-set the compile-command? 如何从另一个Emacs Lisp函数调用具有前缀参数的交互式Emacs Lisp函数? - How to call interactive Emacs Lisp function with a prefix argument, from another Emacs Lisp function? 如何在 Emacs-LISP 中将(非交互式)function 变成命令(交互式功能)? - How to turn a (non-interactive) function into a command (interactive function) in Emacs-LISP? Emacs Lisp 函数中的(交互式)是什么意思? - What does (interactive) mean in an Emacs Lisp function? 帮助使用交互式Emacs Lisp函数替换文本 - Help with an interactive Emacs Lisp function for replacing text 交互式Emacs Lisp函数可以互相交换两个单词 - Interactive Emacs Lisp function to swap two words with each other
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM