Function: cl-defun
cl-defun is an autoloaded macro defined in cl-macs.el.gz.
Signature
(cl-defun NAME ARGLIST [DOCSTRING] BODY...)
Documentation
Define NAME as a function.
Like normal defun, except ARGLIST allows full Common Lisp conventions,
and BODY is implicitly surrounded by (cl-block NAME ...).
The full form of a Common Lisp function argument list is
(VAR...
[&optional (VAR [INITFORM [SVAR]])...]
[&rest|&body VAR]
[&key (([KEYWORD] VAR) [INITFORM [SVAR]])... [&allow-other-keys]]
[&aux (VAR [INITFORM])...])
VAR may be replaced recursively with an argument list for
destructuring, &whole is supported within these sublists. If
SVAR, INITFORM, and KEYWORD are all omitted, then (VAR) may be
written simply VAR. See the Info node (cl)Argument Lists for
more details.
Aliases
defun* (obsolete since 27.1)
Source Code
;; Defined in /usr/src/emacs/lisp/emacs-lisp/cl-macs.el.gz
;;;###autoload
(defmacro cl-defun (name args &rest body)
"Define NAME as a function.
Like normal `defun', except ARGLIST allows full Common Lisp conventions,
and BODY is implicitly surrounded by (cl-block NAME ...).
The full form of a Common Lisp function argument list is
(VAR...
[&optional (VAR [INITFORM [SVAR]])...]
[&rest|&body VAR]
[&key (([KEYWORD] VAR) [INITFORM [SVAR]])... [&allow-other-keys]]
[&aux (VAR [INITFORM])...])
VAR may be replaced recursively with an argument list for
destructuring, `&whole' is supported within these sublists. If
SVAR, INITFORM, and KEYWORD are all omitted, then `(VAR)' may be
written simply `VAR'. See the Info node `(cl)Argument Lists' for
more details.
\(fn NAME ARGLIST [DOCSTRING] BODY...)"
(declare (debug
;; Same as defun but use cl-lambda-list.
(&define [&name sexp] ;Allow (setf ...) additionally to symbols.
cl-lambda-list
cl-declarations-or-string
[&optional ("interactive" interactive)]
def-body))
(doc-string 3)
(indent 2))
`(defun ,name ,@(cl--transform-lambda (cons args body) name)))