unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Bug in new sit-for?
@ 2006-07-16 20:26 Lennart Borgman
  2006-07-16 22:18 ` Chong Yidong
  0 siblings, 1 reply; 5+ messages in thread
From: Lennart Borgman @ 2006-07-16 20:26 UTC (permalink / raw)


Create a file sit-for-bug.el:

  (message "calling (sit-for 0)")(sit-for 0)
  (message "calling (sit-for 1)")(sit-for 1)
  (message "after sit-for")

Evaluate this inside Emacs with eval-buffer. Works fine. Now try instead

  emacs.exe -batch -Q -l sit-for-bug.el

This hangs after the displaying "calling (sit-for 1)". The first 
(sit-for 0) does not hang.

This is with Emacs from today on w32. Unfortunately this is a slightly 
patched version, will check with an unpatched version later.

Using Emacs from 2006-07-02 the batch call works fine.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Bug in new sit-for?
  2006-07-16 20:26 Bug in new sit-for? Lennart Borgman
@ 2006-07-16 22:18 ` Chong Yidong
  2006-07-16 22:48   ` Lennart Borgman
  0 siblings, 1 reply; 5+ messages in thread
From: Chong Yidong @ 2006-07-16 22:18 UTC (permalink / raw)
  Cc: Emacs Devel

Lennart Borgman <lennart.borgman.073@student.lu.se> writes:

> Create a file sit-for-bug.el:
>
>  (message "calling (sit-for 0)")(sit-for 0)
>  (message "calling (sit-for 1)")(sit-for 1)
>  (message "after sit-for")
>
> Evaluate this inside Emacs with eval-buffer. Works fine. Now try instead
>
>  emacs.exe -batch -Q -l sit-for-bug.el
>
> This hangs after the displaying "calling (sit-for 1)". The first
> (sit-for 0) does not hang.

(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).

Anyway, the situation is a little more complicated than that, because
the old sit-for also doesn't work properly.

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.

With the new sit-for, the sit-for sits forever.  However, typing in
something + enter (to send the input to Emacs) interrupts it.

Neither behavior is completely satisfactory, and I don't know if
there's a way to do this properly.  I can probably make the new
sit-for mimic the old behavior by not calling read-event in batch
mode.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Bug in new sit-for?
  2006-07-16 22:18 ` Chong Yidong
@ 2006-07-16 22:48   ` Lennart Borgman
  2006-07-17  4:25     ` Chong Yidong
  0 siblings, 1 reply; 5+ messages in thread
From: Lennart Borgman @ 2006-07-16 22:48 UTC (permalink / raw)
  Cc: Emacs Devel

Chong Yidong wrote:
>>  emacs.exe -batch -Q -l sit-for-bug.el
>>
>> This hangs after the displaying "calling (sit-for 1)". The first
>> (sit-for 0) does not hang.
>>     
>
> (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?

> Anyway, the situation is a little more complicated than that, because
> the old sit-for also doesn't work properly.
>
> 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.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Bug in new sit-for?
  2006-07-16 22:48   ` Lennart Borgman
@ 2006-07-17  4:25     ` Chong Yidong
  2006-07-17  4:28       ` Chong Yidong
  0 siblings, 1 reply; 5+ messages in thread
From: Chong Yidong @ 2006-07-17  4:25 UTC (permalink / raw)
  Cc: Emacs Devel

Lennart Borgman <lennart.borgman.073@student.lu.se> 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)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Bug in new sit-for?
  2006-07-17  4:25     ` Chong Yidong
@ 2006-07-17  4:28       ` Chong Yidong
  0 siblings, 0 replies; 5+ messages in thread
From: Chong Yidong @ 2006-07-17  4:28 UTC (permalink / raw)
  Cc: Emacs Devel

> 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.

I take that back; a cleaner thing to do is to simply make sit-for call
sleep-for when noninteractive.  I'll check in a fix to that effect
soon (and update the documentation accordingly).

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2006-07-17  4:28 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-07-16 20:26 Bug in new sit-for? Lennart Borgman
2006-07-16 22:18 ` Chong Yidong
2006-07-16 22:48   ` Lennart Borgman
2006-07-17  4:25     ` Chong Yidong
2006-07-17  4:28       ` Chong Yidong

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).