简体   繁体   中英

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?

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.

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM