Function: gv-define-simple-setter
gv-define-simple-setter is an autoloaded macro defined in gv.el.gz.
Signature
(gv-define-simple-setter NAME SETTER &optional FIX-RETURN)
Documentation
Define a simple setter method for generalized variable NAME.
This macro is an easy-to-use substitute for gv-define-expander that works
well for simple place forms. Assignments of VAL to (NAME ARGS...) are
turned into calls of the form (SETTER ARGS... VAL).
If FIX-RETURN is non-nil, then SETTER is not assumed to return VAL and
instead the assignment is turned into something equivalent to
(let ((temp VAL))
(SETTER ARGS... temp)
temp)
so as to preserve the semantics of setf.
Probably introduced at or before Emacs version 24.3.
Source Code
;; Defined in /usr/src/emacs/lisp/emacs-lisp/gv.el.gz
;;;###autoload
(defmacro gv-define-simple-setter (name setter &optional fix-return)
"Define a simple setter method for generalized variable NAME.
This macro is an easy-to-use substitute for `gv-define-expander' that works
well for simple place forms. Assignments of VAL to (NAME ARGS...) are
turned into calls of the form (SETTER ARGS... VAL).
If FIX-RETURN is non-nil, then SETTER is not assumed to return VAL and
instead the assignment is turned into something equivalent to
(let ((temp VAL))
(SETTER ARGS... temp)
temp)
so as to preserve the semantics of `setf'."
(declare (debug (sexp [&or symbolp lambda-expr] &optional sexp)))
(when (eq 'lambda (car-safe setter))
(message "Use `gv-define-setter' or name %s's setter function" name))
`(gv-define-setter ,name (val &rest args)
,(if fix-return
`(macroexp-let2 nil v val
`(progn
(,',setter ,@args ,v)
,v))
``(,',setter ,@args ,val))))