Not 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-...
This is a representation of the character whose code is 367 in octal. This "general escape representation" is described in the elisp manual.
You can use the function text-char-description as:
M-: (text-char-description ?\367)
or M-x describe-char with point on the char
to see this is the character DIVISION SIGN.
Now the question is what does it stand ...
(mapcar (lambda (entry) (+ entry 2)) x)
(mapcar (apply-partially #'+ 2) x)
And if you need to update x, then setq it to the result of one of the above forms, e.g.:
(setq x (mapcar (apply-partially #'+ 2) x))
If you assign a function to an uninterned symbol, then naturally you won't find that function on the interned symbol of that name -- they are two completely independent objects.
Your void-defun is returning that uninterned symbol, and in your successful test you are capturing that symbol, so naturally you can successfully call its function.
In your ...
I'll give you an hint:
(defun apply-r-func-at-point (func)
"Apply R FUNC at point, FUNC should be a string."
(let ((sym (ess-symbol-at-point)))
(ess-send-string (get-buffer-process "*R*")
(concat func "(" (symbol-name sym) ")\n") t)
(message "No valid R symbol at point"))))
VARIABLE is a variable, that is, a symbol.
Instead of passing a symbol as the first argument, you passed its value.
set-variable is a function, not a macro or special form. It first evaluates each of its arguments, then acts on their values. The first argument you passed is org-pomodoro-length. That is, because the args get evaluated, you passed the value ...
A simple way to differentiate between value nil and a missing optional argument is to use &rest instead of &optional.
I demonstrate that with the following test function:
(defun testfun (arg &rest optArgs)
"Do something with ARG, OPT1, and OPT2.
OPT1 and OPT2 can be nil, 1, and 2.
The default of OPT1 is 1 and the default of 2 is 2.
\(fn ARG &...
You can use func-arity added in 26.1. C-h f func-arity:
func-arity is a built-in function in `C source code'.
Return minimum and maximum number of args allowed for FUNCTION.
FUNCTION must be a function of some kind.
The returned value is a cons
cell (MIN . MAX).
MIN is the minimum number of args.
MAX is the
I did C-h f C-h f and got a *Help* buffer describing
describe-function as a "Lisp function" defined in help-fns.el.
I clicked on the file name and searched for "Lisp function" which lead
me to the function help-fns-function-description-header whose code
indicated that what we want is subrp.
(subrp (symbol-function 'car))
A bit more consideration ...
If you've just typed or modified the function and you want to (re)define it, press C-M-x (eval-defun) with the cursor anywhere in the definition.
To run the function, use M-: (eval-expression) and type (count-words-buffer) then RET. If the function needed arguments, you'd need to add them after the function name, e.g. (my-function "first argument" 'second-...
Not exactly. Function buffer-substring requires two arguments. Function - will accept a single argument, but in that case it just returns the negative of that numeric argument. What you want to do is, in effect, apply such functions to a list of arguments. You can use higher-order function apply to do that.
What you can do, if you want, is have a macro or ...
You need to distinguish between
interactive command. The latter is also a function, but with the addition of (interactive) to its body.
You can run the latter, but not the former, by binding commands to
keys or calling them by name via M-x. See the elisp manual
links above more more details.
funcall takes a function as its first argument, so you need
if to return a function symbol. You can do that by
sharp-quoting its return value:
(defun a-plus-abs-b (a b)
(funcall (if (> b 0) #'+ #'-) a b))
(a-plus-abs-b 9 4) ; => 13
Elisp is a Lisp-2, which means each symbol can have a function
value and a variable value. When ...
I think you need to access the property values that narrow to region needs.
(defun outer-paren ()
"Move point to the outermost parenthesis."
(defun func ()
(let ((start (outer-paren))
You are trying to use the values returned by functions outer-paren and sp-forward-sexp, instead of the positions they move to.
The error message tells you that narrow-to-region expects buffer positions - numbers or markers. So clearly your values of start and end aren't such. They aren't numbers or markers because functions outer-paren and sp-forward-sexp ...
Emacs is a “Lisp-2”: functions and values have separate namespaces. A function definition (defun foo …) and a function call (foo …) use the function slot of the symbol foo. A variable assignment (setq foo …), a variable binding (let ((foo …)) …), and a variable reference x use the value slot of the symbol foo.
To call a function which is stored in the value ...
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.
set is a built-in function writen in C, setq a special form which don't evaluate all its argument like functions does.
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 ...
`funcall' is not supposed to be called with a macro as the FUNCTION argument. The Elisp manual says:
The argument FUNCTION must be either a Lisp function or a primitive function. Special forms and macros are not allowed, because they make sense only when given the unevaluated argument expressions. ‘funcall’ cannot provide these because, as we saw above, ...
In addition to C-h f which gives you information about functions as you found out, the C-h prefix key leads to all sorts of other documentation as well: variables, keys, log messages, modes, the Info manuals and much more - type C-h ? to get the list.
((lambda ...) ...) is a special case, and IIRC the only such special case.
Lots of elisp functions return functions, and apply-partially is no different to any of the others in this regard.
source of the function shows that it actually returns a lambda
Most functions are (ultimately) lambdas. See C-hig (elisp)What Is a Function for details.
cl-defun from cl-macs.el allows you to specify default values (beside much other mind-blowing stuff).
(cl-defun testfun (arg &optional (opt1 1) (opt2 2))
"Process normal ARG and optional args OPT1 and OPT2 with defaults 1 and 2, respectively."
(list arg opt1 opt2))
Test 1: Set opt2 explicitly to nil:
(testfun 1 'a nil)
(1 a nil)
Test 2: Setting ...
The cleanest way IMO is to define an additional variable in the argument list that indicates if the argument was supplied by the caller. This can be done using cl-defun since it supports Common Lisp style argument lists. For example,
(cl-defun test (&optional (x nil supplied-p))
(list x supplied-p))
(test) => (nil nil)
Your C-h f is not the standard C-h f (M-x describe-function), describe-function doesn't provide "References ..." information at all. To find the source of apply, use C-h f apply, it will say
apply is a built-in function in `src/eval.c'.
src/eval.c will be clickable, then click it to go to the source. If you didn't install Emacs from the source code by ...
You can force entering the debugger when a function is called,
Any calls to myf triggers the debugger. A (myf 2 3) call, for example, would result in
Debugger entered--entering a function:
* (myf 2 3)
Remove it when you're done,