1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-01-03 10:31:37 -08:00

Avoid unwind-protect without unwind forms in cl-letf

* lisp/emacs-lisp/cl-macs.el (cl--letf): Use unwind-protect only if
necessary, avoiding a warning.
This commit is contained in:
Mattias Engdegård 2023-03-29 17:03:31 +02:00
parent 9c31ee4686
commit e324060369

View file

@ -2758,13 +2758,8 @@ Each PLACE may be a symbol, or any generalized variable allowed by `setf'.
;; Common-Lisp's `psetf' does the first, so we'll do the same.
(if (null bindings)
(if (and (null binds) (null simplebinds)) (macroexp-progn body)
`(let* (,@(mapcar (lambda (x)
(pcase-let ((`(,vold ,getter ,_setter ,_vnew) x))
(list vold getter)))
binds)
,@simplebinds)
(unwind-protect
,(macroexp-progn
(let ((body-form
(macroexp-progn
(append
(delq nil
(mapcar (lambda (x)
@ -2773,11 +2768,19 @@ Each PLACE may be a symbol, or any generalized variable allowed by `setf'.
(`(,_vold ,_getter ,setter ,vnew)
(funcall setter vnew))))
binds))
body))
body))))
`(let* (,@(mapcar (lambda (x)
(pcase-let ((`(,vold ,getter ,_setter ,_vnew) x))
(list vold getter)))
binds)
,@simplebinds)
,(if binds
`(unwind-protect ,body-form
,@(mapcar (lambda (x)
(pcase-let ((`(,vold ,_getter ,setter ,_vnew) x))
(funcall setter vold)))
binds))))
binds))
body-form))))
(let* ((binding (car bindings))
(place (car binding)))
(gv-letplace (getter setter) place