Function: cl-defmacro

cl-defmacro is an autoloaded macro defined in cl-macs.el.gz.

Signature

(cl-defmacro NAME ARGLIST [DOCSTRING] BODY...)

Documentation

Define NAME as a macro.

Like normal defmacro, except ARGLIST allows full Common Lisp conventions, and BODY is implicitly surrounded by (cl-block NAME ...).

The full form of a Common Lisp macro argument list is

   (VAR...
    [&optional (VAR [INITFORM [SVAR]])...]
    [&rest|&body VAR]
    [&key (([KEYWORD] VAR) [INITFORM [SVAR]])... [&allow-other-keys]]
    [&aux (VAR [INITFORM])...]
    [&environment VAR])

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.

View in manual

Aliases

defmacro* (obsolete since 27.1)

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/cl-macs.el.gz
;;;###autoload
(defmacro cl-defmacro (name args &rest body)
  "Define NAME as a macro.
Like normal `defmacro', except ARGLIST allows full Common Lisp conventions,
and BODY is implicitly surrounded by (cl-block NAME ...).

The full form of a Common Lisp macro argument list is

   (VAR...
    [&optional (VAR [INITFORM [SVAR]])...]
    [&rest|&body VAR]
    [&key (([KEYWORD] VAR) [INITFORM [SVAR]])... [&allow-other-keys]]
    [&aux (VAR [INITFORM])...]
    [&environment VAR])

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
            (&define name cl-macro-list cl-declarations-or-string def-body))
           (doc-string 3)
           (indent 2)
           (autoload-macro expand))   ; expand to defmacro on autoload gen
  `(defmacro ,name ,@(cl--transform-lambda (cons args body) name)))