Skip to content

Commit 52cac9c

Browse files
committed
Adjust around advice to work in Emacs < 30
The implementation added in the previous commit requires Emacs 30. This commit adds a kludge that is necessary to make it work in older versions. Also see bug#61179.
1 parent 51c68c8 commit 52cac9c

1 file changed

Lines changed: 31 additions & 26 deletions

File tree

lisp/transient.el

Lines changed: 31 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2194,32 +2194,37 @@ value. Otherwise return CHILDREN as is."
21942194
,@body)))
21952195

21962196
(defun transient--wrap-command ()
2197-
(letrec ((prefix transient--prefix)
2198-
(suffix this-command)
2199-
(advice (lambda (fn &rest args)
2200-
(interactive
2201-
(lambda (spec)
2202-
(let ((abort t))
2203-
(unwind-protect
2204-
(prog1 (advice-eval-interactive-spec spec)
2205-
(setq abort nil))
2206-
(when abort
2207-
(when-let ((unwind (oref prefix unwind-suffix)))
2208-
(transient--debug 'unwind-interactive)
2209-
(funcall unwind suffix))
2210-
(if (symbolp suffix)
2211-
(advice-remove suffix advice)
2212-
(remove-function suffix advice))
2213-
(oset prefix unwind-suffix nil))))))
2214-
(unwind-protect
2215-
(apply fn args)
2216-
(when-let ((unwind (oref prefix unwind-suffix)))
2217-
(transient--debug 'unwind-command)
2218-
(funcall unwind suffix))
2219-
(if (symbolp suffix)
2220-
(advice-remove suffix advice)
2221-
(remove-function suffix advice))
2222-
(oset prefix unwind-suffix nil)))))
2197+
(let* ((prefix transient--prefix)
2198+
(suffix this-command)
2199+
(advice nil)
2200+
(advice-interactive
2201+
(lambda (spec)
2202+
(let ((abort t))
2203+
(unwind-protect
2204+
(prog1 (advice-eval-interactive-spec spec)
2205+
(setq abort nil))
2206+
(when abort
2207+
(when-let ((unwind (oref prefix unwind-suffix)))
2208+
(transient--debug 'unwind-interactive)
2209+
(funcall unwind suffix))
2210+
(if (symbolp suffix)
2211+
(advice-remove suffix advice)
2212+
(remove-function suffix advice))
2213+
(oset prefix unwind-suffix nil))))))
2214+
(advice-body
2215+
(lambda (fn &rest args)
2216+
(unwind-protect
2217+
(apply fn args)
2218+
(when-let ((unwind (oref prefix unwind-suffix)))
2219+
(transient--debug 'unwind-command)
2220+
(funcall unwind suffix))
2221+
(if (symbolp suffix)
2222+
(advice-remove suffix advice)
2223+
(remove-function suffix advice))
2224+
(oset prefix unwind-suffix nil)))))
2225+
(setq advice `(lambda (fn &rest args)
2226+
(interactive ,advice-interactive)
2227+
(apply ',advice-body fn args)))
22232228
(if (symbolp suffix)
22242229
(advice-add suffix :around advice '((depth . -99)))
22252230
(add-function :around (var suffix) advice '((depth . -99))))))

0 commit comments

Comments
 (0)