aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2023-06-12 13:25:08 -0400
committerStefan Monnier2023-06-12 13:25:31 -0400
commit410aac81832daf028f162aa00d42ffd2f15beb99 (patch)
tree5bf75c6ca236686116a47e84dfba77f55e9215c5
parent560c15a04f9578d607c68e63a04901dce924b227 (diff)
downloademacs-410aac81832daf028f162aa00d42ffd2f15beb99.tar.gz
emacs-410aac81832daf028f162aa00d42ffd2f15beb99.zip
* lisp/transient.el (transient--wrap-command): Use `letrec` and a closure
-rw-r--r--lisp/transient.el52
1 files changed, 24 insertions, 28 deletions
diff --git a/lisp/transient.el b/lisp/transient.el
index 048554eee13..78496843284 100644
--- a/lisp/transient.el
+++ b/lisp/transient.el
@@ -2190,39 +2190,35 @@ value. Otherwise return CHILDREN as is."
2190 2190
2191(defun transient--wrap-command () 2191(defun transient--wrap-command ()
2192 (let* ((prefix transient--prefix) 2192 (let* ((prefix transient--prefix)
2193 (suffix this-command) 2193 (suffix this-command))
2194 (advice nil) 2194 (letrec ((advice
2195 (advice-interactive 2195 (lambda (fn &rest args)
2196 (lambda (spec) 2196 (interactive
2197 (let ((abort t)) 2197 (lambda (spec)
2198 (unwind-protect 2198 (let ((abort t))
2199 (prog1 (advice-eval-interactive-spec spec) 2199 (unwind-protect
2200 (setq abort nil)) 2200 (prog1 (advice-eval-interactive-spec spec)
2201 (when abort 2201 (setq abort nil))
2202 (when abort
2203 (when-let ((unwind (oref prefix unwind-suffix)))
2204 (transient--debug 'unwind-interactive)
2205 (funcall unwind suffix))
2206 (if (symbolp suffix)
2207 (advice-remove suffix advice)
2208 (remove-function suffix advice))
2209 (oset prefix unwind-suffix nil))))))
2210 (unwind-protect
2211 (apply fn args)
2202 (when-let ((unwind (oref prefix unwind-suffix))) 2212 (when-let ((unwind (oref prefix unwind-suffix)))
2203 (transient--debug 'unwind-interactive) 2213 (transient--debug 'unwind-command)
2204 (funcall unwind suffix)) 2214 (funcall unwind suffix))
2205 (if (symbolp suffix) 2215 (if (symbolp suffix)
2206 (advice-remove suffix advice) 2216 (advice-remove suffix advice)
2207 (remove-function suffix advice)) 2217 (remove-function suffix advice))
2208 (oset prefix unwind-suffix nil)))))) 2218 (oset prefix unwind-suffix nil)))))
2209 (advice-body 2219 (if (symbolp suffix)
2210 (lambda (fn &rest args) 2220 (advice-add suffix :around advice '((depth . -99)))
2211 (unwind-protect 2221 (add-function :around (var suffix) advice '((depth . -99)))))))
2212 (apply fn args)
2213 (when-let ((unwind (oref prefix unwind-suffix)))
2214 (transient--debug 'unwind-command)
2215 (funcall unwind suffix))
2216 (if (symbolp suffix)
2217 (advice-remove suffix advice)
2218 (remove-function suffix advice))
2219 (oset prefix unwind-suffix nil)))))
2220 (setq advice `(lambda (fn &rest args)
2221 (interactive ,advice-interactive)
2222 (apply ',advice-body fn args)))
2223 (if (symbolp suffix)
2224 (advice-add suffix :around advice '((depth . -99)))
2225 (add-function :around (var suffix) advice '((depth . -99))))))
2226 2222
2227(defun transient--premature-post-command () 2223(defun transient--premature-post-command ()
2228 (and (equal (this-command-keys-vector) []) 2224 (and (equal (this-command-keys-vector) [])