我没有观察到您使用 Emacs 24.3.50.3 描述的行为:
(lexical-let ((countdown 3) timer)
(defun countdown ()
(message "countdown %d" countdown)
(when (zerop (decf countdown))
(cancel-timer timer)
(error "BOOM")))
(setq timer (run-with-timer 1 1 'countdown)))
我在回声区域和中看到*Messages*
:
countdown 3
countdown 2
countdown 1
Entering debugger...
然后在*Backtrace*
:
Debugger entered--Lisp error: (error "BOOM")
signal(error ("BOOM"))
error("BOOM")
(progn (cancel-timer (symbol-value G66502)) (error "BOOM"))
(if (zerop (let* ((v G66503)) (set v (1- (symbol-value G66503))))) (progn (cancel-timer (symbol-value G66502)) (error "BOOM")))
(lambda (G66502 G66503) (message "countdown %d" (symbol-value G66503)) (if (zerop (let* ((v G66503)) (set v (1- (symbol-value G66503))))) (progn (cancel-timer (symbol-value G66502)) (error "BOOM"))))(--timer-- --countdown--)
apply((lambda (G66502 G66503) (message "countdown %d" (symbol-value G66503)) (if (zerop (let* ((v G66503)) (set v (1- (symbol-value G66503))))) (progn (cancel-timer (symbol-value G66502)) (error "BOOM")))) --timer-- --countdown-- nil)
countdown()
apply(countdown nil)
byte-code("r\301\302H\303H\"\210)\301\207" [timer apply 5 6] 4)
timer-event-handler([t 20941 51022 556644 1 countdown nil nil 176000])