2013-06-28 52 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