Being more used to Vim, I know that it was correct to think "everything in Vim is a macro" but what about Emacs?
Is it fine/correct to think that everything is a function in Emacs?
Emacs Stack Exchange is a question and answer site for those using, extending or developing Emacs. It only takes a minute to sign up.
Sign up to join this communityNot everything is a function, no. For starters, Elisp (the language) has many other kinds of object besides functions.
However, I think you're specifically asking whether every interactive action from the user is invoking a function behind the scenes; and the answer is still no.
The majority of commands will be functions; but not all of them.
Quoting from C-hig (elisp)Interactive Call
:
Commands include strings and vectors (which are treated as keyboard macros), lambda expressions that contain a top-level ‘interactive’ form (*note Using Interactive::), byte-code function objects made from such lambda expressions, autoload objects that are declared as interactive (non-‘nil’ fourth argument to ‘autoload’), and some primitive functions. Also, a symbol is considered a command if it has a non-‘nil’ ‘interactive-form’ property, or if its function definition satisfies ‘commandp’.
Yes, I think so. Every key is bound to a function. Actually, a command, which is an interactive function (meaning a function the user can call during editing, not just by running elisp code). Adding a letter to a file is accomplished via the command self-insert
, which is bound to most unmodified keys by default.
I'm not sure how useful that is, but nearly every interaction you have with emacs is via a function.
In the emacs lisp sense, not everything is a function. functionp is a predicate to determine wether a symbol is bound to a function or not.
(functionp 'set)
t
(functionp 'setq)
nil
set is a built-in function writen in C, setq a special form which don't evaluate all its argument like functions does.
functionp
, for example, orfuncall
. If there is a useful, specific question here about Elisp, please rephrase to make clear what that is.functionp
? But that has an easy answer - if everything satisfied it then it would have no reason to exist. Any way you look at it, your question is too broad or unclear, even if interpretation is limited to what Elisp calls a function. And we don't know what you mean by "function" wrt Elisp, in your question.