(defun func2 (arg)
(if (listp arg)
(mapcar #'func2 arg)
Emacs Lisp is a lisp-2 (like Common Lisp), not lisp-1 (unlike, say, Scheme).
I.e., every symbol in ELisp has a
- "value cell": accessed by
symbol-value, tested by
boundp, and used by the compiler when the symbol is in the "variable" position, i.e., not as the first element of a list to be evaluated - like your use of
- "function cell": accessed by
symbol-function, tested by
fboundp, and used by the compiler when the symbol is in the "function" position, i.e., the first element of a list to be evaluated - like your use of
func2 is in variable position and it has a function binding and not a variable binding, you are getting the
void variable error. You need to tell the compiler to use the function value instead of the variable value, and this is accomplished by prefixing it with
#' (you can use the ordinary quote
' instead too, but it is a bad idea because it makes code less readable and self-documenting).
See also Why use #' before function arguments in emacs-lisp?