Function: cl-letf
cl-letf is an autoloaded macro defined in cl-macs.el.gz.
Signature
(cl-letf ((PLACE VALUE) ...) BODY...)
Documentation
Temporarily bind to PLACEs.
This is the analogue of let, but with generalized variables (in the
sense of setf) for the PLACEs. Each PLACE is set to the corresponding
VALUE, then the BODY forms are executed. On exit, either normally or
because of a throw or error, the PLACEs are set back to their original
values. Note that this macro is *not* available in Common Lisp.
As a special case, if (PLACE) is used instead of (PLACE VALUE),
the PLACE is not modified before executing BODY.
See info node (cl) Modify Macros for details.
Probably introduced at or before Emacs version 24.3.
Aliases
letf (obsolete since 27.1)
Source Code
;; Defined in /usr/src/emacs/lisp/emacs-lisp/cl-macs.el.gz
;;;###autoload
(defmacro cl-letf (bindings &rest body)
"Temporarily bind to PLACEs.
This is the analogue of `let', but with generalized variables (in the
sense of `setf') for the PLACEs. Each PLACE is set to the corresponding
VALUE, then the BODY forms are executed. On exit, either normally or
because of a `throw' or error, the PLACEs are set back to their original
values. Note that this macro is *not* available in Common Lisp.
As a special case, if `(PLACE)' is used instead of `(PLACE VALUE)',
the PLACE is not modified before executing BODY.
See info node `(cl) Modify Macros' for details.
\(fn ((PLACE VALUE) ...) BODY...)"
(declare (indent 1) (debug ((&rest [&or (symbolp form)
(gate gv-place &optional form)])
body)))
(if (and (not (cdr bindings)) (cdar bindings) (symbolp (caar bindings))
(not (assq (caar bindings)
(alist-get :cl-symbol-macros macroexpand-all-environment))))
`(let ,bindings ,@body)
(cl--letf bindings () () body)))