Function: define-setf-expander

define-setf-expander is a macro defined in cl.el.gz.

Signature

(define-setf-expander NAME ARGLIST &rest BODY)

Documentation

Define a setf method.

This method shows how to handle setfs to places of the form
(NAME ARGS...). The argument forms ARGS are bound according to
ARGLIST, as if NAME were going to be expanded as a macro, then the BODY forms are executed and must return a list of five elements: a temporary-variables list, a value-forms list, a store-variables list
(of length one), a store-form, and an access-form.

See gv-define-expander, and gv-define-setter for better and simpler ways to define setf-methods.

Probably introduced at or before Emacs version 24.3.

Aliases

define-setf-method (obsolete since 27.1)

Source Code

;; Defined in /usr/src/emacs/lisp/obsolete/cl.el.gz
(defmacro define-setf-expander (name arglist &rest body)
  "Define a `setf' method.
This method shows how to handle `setf's to places of the form
\(NAME ARGS...).  The argument forms ARGS are bound according to
ARGLIST, as if NAME were going to be expanded as a macro, then
the BODY forms are executed and must return a list of five elements:
a temporary-variables list, a value-forms list, a store-variables list
\(of length one), a store-form, and an access-form.

See `gv-define-expander', and `gv-define-setter' for better and
simpler ways to define setf-methods."
  (declare (debug
            (&define name cl-lambda-list cl-declarations-or-string def-body))
           (indent defun))
  `(progn
     ,@(if (stringp (car body))
           (list `(put ',name 'setf-documentation ,(pop body))))
     (gv-define-expander ,name
       (cl-function
        (lambda (do ,@arglist)
          (cl--gv-adapt (progn ,@body) do))))))