[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Bug in new sit-for?
From: |
Chong Yidong |
Subject: |
Re: Bug in new sit-for? |
Date: |
Mon, 17 Jul 2006 00:25:04 -0400 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) |
Lennart Borgman <address@hidden> writes:
>> (First off, it isn't hung: press enter, and the sit-for will exit.
>> The problem is that `read-event' can't be interrupted by the timer in
>> batch mode).
>>
> Why can't it be interrupted in batch?
Because in batch mode, kbd_buffer_get_event simply calls getchar().
Normally, it does more stuff including checking timers.
>> With the old sit-for, there is no way to interrupt in batch mode: no
>> matter what key you press, including enter, the sit-for will sit for
>> the entire duration.
>>
> Yes, that was inconvenient too.
This patch should bring back the old batch mode behavior. It's a bit
of a hack, but I don't see any more elegant solution.
*** emacs/lisp/subr.el.~1.520.~ 2006-07-11 18:48:03.000000000 -0400
--- emacs/lisp/subr.el 2006-07-17 00:19:23.000000000 -0400
***************
*** 1732,1738 ****
(timer-set-function timer 'with-timeout-handler
'(sit-for-timeout))
(timer-activate timer)
! (push (read-event) unread-command-events)
nil)
t
(cancel-timer timer)
--- 1732,1741 ----
(timer-set-function timer 'with-timeout-handler
'(sit-for-timeout))
(timer-activate timer)
! ;; In batch mode, input doesn't trigger the timer.
! (if noninteractive
! (while t (redisplay))
! (push (read-event) unread-command-events))
nil)
t
(cancel-timer timer)