Function: gv-get
gv-get is an autoloaded and byte-compiled function defined in
gv.el.gz.
Signature
(gv-get PLACE DO)
Documentation
Build the code that applies DO to PLACE.
PLACE must be a valid generalized variable. DO must be a function; it will be called with 2 arguments: GETTER and SETTER, where GETTER is a (copyable) Elisp expression that returns the value of PLACE, and SETTER is a function which returns the code to set PLACE when called with a (not necessarily copyable) Elisp expression that returns the value to set it to. DO must return an Elisp expression.
Source Code
;; Defined in /usr/src/emacs/lisp/emacs-lisp/gv.el.gz
;;;###autoload
(defun gv-get (place do)
"Build the code that applies DO to PLACE.
PLACE must be a valid generalized variable.
DO must be a function; it will be called with 2 arguments: GETTER and SETTER,
where GETTER is a (copyable) Elisp expression that returns the value of PLACE,
and SETTER is a function which returns the code to set PLACE when called
with a (not necessarily copyable) Elisp expression that returns the value to
set it to.
DO must return an Elisp expression."
(cond
((symbolp place) (funcall do place (lambda (v) `(setq ,place ,v))))
((not (consp place)) (signal 'gv-invalid-place (list place)))
(t
(let* ((head (car place))
(gf (function-get head 'gv-expander 'autoload)))
(if gf (apply gf do (cdr place))
(let ((me (macroexpand-1 place
;; (append macroexpand-all-environment
;; gv--macro-environment)
macroexpand-all-environment)))
(if (and (eq me place) (get head 'compiler-macro))
;; Expand compiler macros: this takes care of all the accessors
;; defined via cl-defsubst, such as cXXXr and defstruct slots.
(setq me (apply (get head 'compiler-macro) place (cdr place))))
(if (and (eq me place) (fboundp head)
(symbolp (symbol-function head)))
;; Follow aliases.
(setq me (cons (symbol-function head) (cdr place))))
(if (eq me place)
(if (and (symbolp head) (get head 'setf-method))
(error "Incompatible place needs recompilation: %S" head)
(let* ((setter (gv-setter head)))
(gv--defsetter head (lambda (&rest args) `(,setter ,@args))
do (cdr place))))
(gv-get me do))))))))