X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Ffunctions.lisp;h=b1dfb4c271eb9db5ced80ca3c3ef197f8675bf74;hb=e8b227cbde3cf3eeb9b28f347f9ff78acb0cf0a8;hp=803a3f29522d486d0a200ebef097d523ca91ae83;hpb=9635bd8a9ea703c1ea60feb8c16984692a6af6c0;p=cl-mock.git diff --git a/src/functions.lisp b/src/functions.lisp index 803a3f2..b1dfb4c 100644 --- a/src/functions.lisp +++ b/src/functions.lisp @@ -18,14 +18,16 @@ it completely." (if value (set-fdefinition name value) (fmakunbound name))) (defun call-with-function-bindings (functions values function - &optional (previous (mapcar #'maybe-fdefinition functions))) - "Calls FUNCTION while temporarily binding all FUNCTIONS to VALUES. -See PROGF and PROGV." - (unwind-protect - (progn - (mapc #'set-fdefinition functions values) - (funcall function)) - (mapc #'set-or-unbind-fdefinition functions previous))) + &optional previous) + "Calls FUNCTION while temporarily binding all FUNCTIONS with the given +names to VALUES. See PROGF and PROGV. If PREVIOUS is set, it has to +be the list of original values for each function." + (let ((previous (or previous (mapcar #'maybe-fdefinition functions)))) + (unwind-protect + (progn + (mapc #'set-fdefinition functions values) + (funcall function)) + (mapc #'set-or-unbind-fdefinition functions previous)))) (defmacro progf (functions values &body body) "Like PROGV, but for FUNCTIONS."