2013-06-28 53 views
2

在emacs lisp中,可以通过run-with-timerrun-with-async-timer命令实现伪同步的一种形式。考虑例如以下简单倒数计时器的:Emacs lisp:调试定时器?

(defun -c (i) 
(cond 
    ((= i 0) (error "TESTERROR")) 
    (t 
    (message "Countdown at %d" i) 
    (run-with-timer 1 nil '-c (1- i))))) 

(-c 3)运行将显示用信号误差将静默被忽略消息

Countdown at 3 
Countdown at 2 
Countdown at 1 

emacs lisp是否有某种方式可以获得此类定时器的错误报告,最好使用完整的堆栈跟踪?

+2

正如sds指出的,这是一个错误(在我看来),我在几个月前在Em中修正了它acs的后备箱。 – Stefan

回答

0

我不遵守你使用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]) 
+0

谢谢...我现在从源代码编译emacs并且现在可以工作。尽管如此,为了获得堆栈跟踪,我还必须执行'M-x toggle-debug-on-error'。你有默认情况下启用'debug-on-error'吗? – kdb

+0

是的,我确实默认启用'debug-on-error'。 – sds