unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Minor fix for life.el.
@ 2006-09-06 17:05 Michaël Cadilhac
  2006-09-06 18:03 ` David Kastrup
  0 siblings, 1 reply; 12+ messages in thread
From: Michaël Cadilhac @ 2006-09-06 17:05 UTC (permalink / raw)



[-- Attachment #1.1.1: Type: text/plain, Size: 301 bytes --]


I usually use M-x life with zero as numerical prefix (it's lot of fun).
M-0 M-x life RET

There's a little bug: when I hit a key, life goes into an infinite
loop (not MY life) and I have to C-g to stop this.

The following patch fixes this bug (sit-for is still called because he
causes redisplay).


[-- Attachment #1.1.2: life.patch --]
[-- Type: text/x-patch, Size: 1301 bytes --]

Index: lisp/play/life.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/play/life.el,v
retrieving revision 1.25
diff -c -r1.25 life.el
*** lisp/play/life.el	5 Feb 2006 14:10:44 -0000	1.25
--- lisp/play/life.el	6 Sep 2006 16:58:35 -0000
***************
*** 269,275 ****
    (recenter 0)
  
    ;; Redisplay; if the user has hit a key, exit the loop.
!   (or (eq t (sit-for sleeptime))
        (throw 'life-exit nil)))
  
  (defun life-extinct-quit ()
--- 269,276 ----
    (recenter 0)
  
    ;; Redisplay; if the user has hit a key, exit the loop.
!   (or (and (sit-for sleeptime) (< 0 sleeptime))
!       (not (input-pending-p))
        (throw 'life-exit nil)))
  
  (defun life-extinct-quit ()
Index: lisp/ChangeLog
===================================================================
RCS file: /sources/emacs/emacs/lisp/ChangeLog,v
retrieving revision 1.10003
diff -c -0 -r1.10003 ChangeLog
*** lisp/ChangeLog	6 Sep 2006 02:43:00 -0000	1.10003
--- lisp/ChangeLog	6 Sep 2006 16:58:48 -0000
***************
*** 0 ****
--- 1,5 ----
+ 2006-09-06  Michaël Cadilhac  <michael.cadilhac@lrde.org>
+ 
+ 	* play/life.el (life-display-generation): Test for input manually if
+ 	`sleeptime' is negative or null.
+ 

[-- Attachment #1.1.3: Type: text/plain, Size: 330 bytes --]


TIA

-- 
 |      Michaël `Micha' Cadilhac   |  Si les religions etaient aussi tole-  |
 |         Epita/LRDE Promo 2007   |  rantes qu'elles le pretendent, il y   |
 | http://www.lrde.org/~cadilh_m   |  a longtemps qu'il n'y en aurait plus  |
 `--  -   JID: micha@amessage.be --'           -- Moustic              -  --'

[-- Attachment #1.2: Type: application/pgp-signature, Size: 188 bytes --]

[-- Attachment #2: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

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

* Re: Minor fix for life.el.
  2006-09-06 17:05 Minor fix for life.el Michaël Cadilhac
@ 2006-09-06 18:03 ` David Kastrup
  2006-09-06 18:14   ` Michaël Cadilhac
  0 siblings, 1 reply; 12+ messages in thread
From: David Kastrup @ 2006-09-06 18:03 UTC (permalink / raw)
  Cc: emacs-devel

michael.cadilhac@lrde.org (Michaël Cadilhac) writes:

> I usually use M-x life with zero as numerical prefix (it's lot of fun).
> M-0 M-x life RET
>
> There's a little bug: when I hit a key, life goes into an infinite
> loop (not MY life) and I have to C-g to stop this.
>
> The following patch fixes this bug (sit-for is still called because he
> causes redisplay).
>
> Index: lisp/play/life.el
> ===================================================================
> RCS file: /sources/emacs/emacs/lisp/play/life.el,v
> retrieving revision 1.25
> diff -c -r1.25 life.el
> *** lisp/play/life.el	5 Feb 2006 14:10:44 -0000	1.25
> --- lisp/play/life.el	6 Sep 2006 16:58:35 -0000
> ***************
> *** 269,275 ****
>     (recenter 0)
>   
>     ;; Redisplay; if the user has hit a key, exit the loop.
> !   (or (eq t (sit-for sleeptime))
>         (throw 'life-exit nil)))
>   
>   (defun life-extinct-quit ()
> --- 269,276 ----
>     (recenter 0)
>   
>     ;; Redisplay; if the user has hit a key, exit the loop.
> !   (or (and (sit-for sleeptime) (< 0 sleeptime))
> !       (not (input-pending-p))

That looks like the wrong fix.

How about

      (or (eq t (sit-for (max sleeptime 0)))
          (throw 'life-exit nil))

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

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

* Re: Minor fix for life.el.
  2006-09-06 18:03 ` David Kastrup
@ 2006-09-06 18:14   ` Michaël Cadilhac
  2006-09-06 18:34     ` David Kastrup
  0 siblings, 1 reply; 12+ messages in thread
From: Michaël Cadilhac @ 2006-09-06 18:14 UTC (permalink / raw)
  Cc: emacs-devel


[-- Attachment #1.1: Type: text/plain, Size: 1904 bytes --]

David Kastrup <dak@gnu.org> writes:

> michael.cadilhac@lrde.org (Michaël Cadilhac) writes:
>
>> I usually use M-x life with zero as numerical prefix (it's lot of fun).
>> M-0 M-x life RET
>>
>> There's a little bug: when I hit a key, life goes into an infinite
>> loop (not MY life) and I have to C-g to stop this.
>>
>> The following patch fixes this bug (sit-for is still called because he
>> causes redisplay).
>>
>> Index: lisp/play/life.el
>> ===================================================================
>> RCS file: /sources/emacs/emacs/lisp/play/life.el,v
>> retrieving revision 1.25
>> diff -c -r1.25 life.el
>> *** lisp/play/life.el	5 Feb 2006 14:10:44 -0000	1.25
>> --- lisp/play/life.el	6 Sep 2006 16:58:35 -0000
>> ***************
>> *** 269,275 ****
>>     (recenter 0)
>>   
>>     ;; Redisplay; if the user has hit a key, exit the loop.
>> !   (or (eq t (sit-for sleeptime))
>>         (throw 'life-exit nil)))
>>   
>>   (defun life-extinct-quit ()
>> --- 269,276 ----
>>     (recenter 0)
>>   
>>     ;; Redisplay; if the user has hit a key, exit the loop.
>> !   (or (and (sit-for sleeptime) (< 0 sleeptime))
>> !       (not (input-pending-p))
>
> That looks like the wrong fix.

Damn!

> How about
>
>       (or (eq t (sit-for (max sleeptime 0)))

I don't think the (eq t)  is needed. However, the problem is not fixed
by this  as sit-for  returns immediately `t'  if its argument  is zero
(AFAICT). That's why  I thought the check for input  should be done by
hand.

>           (throw 'life-exit nil))

-- 
 |      Michaël `Micha' Cadilhac   |  Isn't vi that text editor with        |
 |         Epita/LRDE Promo 2007   |   two modes... One that beeps and      |
 | http://www.lrde.org/~cadilh_m   |     one that corrupts your file?       |
 `--  -   JID: micha@amessage.be --'           -- Dan Jacobson         -  --'

[-- Attachment #1.2: Type: application/pgp-signature, Size: 188 bytes --]

[-- Attachment #2: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

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

* Re: Minor fix for life.el.
  2006-09-06 18:14   ` Michaël Cadilhac
@ 2006-09-06 18:34     ` David Kastrup
  2006-09-07 14:27       ` Broken sit-for [was: Re: Minor fix for life.el.] Kim F. Storm
  0 siblings, 1 reply; 12+ messages in thread
From: David Kastrup @ 2006-09-06 18:34 UTC (permalink / raw)
  Cc: emacs-devel

michael.cadilhac@lrde.org (Michaël Cadilhac) writes:

> David Kastrup <dak@gnu.org> writes:
>
>> michael.cadilhac@lrde.org (Michaël Cadilhac) writes:
>>
>>> I usually use M-x life with zero as numerical prefix (it's lot of fun).
>>> M-0 M-x life RET
>>>
>>> There's a little bug: when I hit a key, life goes into an infinite
>>> loop (not MY life) and I have to C-g to stop this.
>>>
>>> The following patch fixes this bug (sit-for is still called because he
>>> causes redisplay).
>>>
>>> Index: lisp/play/life.el
>>> ===================================================================
>>> RCS file: /sources/emacs/emacs/lisp/play/life.el,v
>>> retrieving revision 1.25
>>> diff -c -r1.25 life.el
>>> *** lisp/play/life.el	5 Feb 2006 14:10:44 -0000	1.25
>>> --- lisp/play/life.el	6 Sep 2006 16:58:35 -0000
>>> ***************
>>> *** 269,275 ****
>>>     (recenter 0)
>>>   
>>>     ;; Redisplay; if the user has hit a key, exit the loop.
>>> !   (or (eq t (sit-for sleeptime))
>>>         (throw 'life-exit nil)))
>>>   
>>>   (defun life-extinct-quit ()
>>> --- 269,276 ----
>>>     (recenter 0)
>>>   
>>>     ;; Redisplay; if the user has hit a key, exit the loop.
>>> !   (or (and (sit-for sleeptime) (< 0 sleeptime))
>>> !       (not (input-pending-p))
>>
>> That looks like the wrong fix.
>
> Damn!
>
>> How about
>>
>>       (or (eq t (sit-for (max sleeptime 0)))
>
> I don't think the (eq t)  is needed.

Right.

> However, the problem is not fixed by this as sit-for returns
> immediately `t' if its argument is zero (AFAICT).

Testing turns out that you are right.  I am surprised.  Further
testing showed that
(sit-for 1e-6)
returns t even if a key is pressed, while
(sit-for 1e-3)
returns nil when a key is pressed.

I think this behavior is not consistent enough to be fun.

> That's why I thought the check for input should be done by hand.

Probably the option least likely to require any changes even if
sit-for is about to change.

Kim, any idea whether this sit-for return value is turning out the way
you intended it?  At least the documentation says "t if waited for
whole time" and this does not imply that the keyboard needs to be
checked at all if the time has expired before it would have been worth
checking the keyboard.  But since pending keyboard is supposed to
inhibit redisplay for (sit-for 0), we can't avoid checking it anyway,
right?

And supposedly the return value of t from sit-for should at least
imply that a redisplay has occured and completed.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

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

* Broken sit-for [was: Re: Minor fix for life.el.]
  2006-09-06 18:34     ` David Kastrup
@ 2006-09-07 14:27       ` Kim F. Storm
  2006-09-08  9:16         ` Broken sit-for Michaël Cadilhac
  2006-09-09 23:02         ` Broken sit-for [was: Re: Minor fix for life.el.] Kim F. Storm
  0 siblings, 2 replies; 12+ messages in thread
From: Kim F. Storm @ 2006-09-07 14:27 UTC (permalink / raw)
  Cc: Michaël Cadilhac, emacs-devel

David Kastrup <dak@gnu.org> writes:

>> However, the problem is not fixed by this as sit-for returns
>> immediately `t' if its argument is zero (AFAICT).
>
> Probably the option least likely to require any changes even if
> sit-for is about to change.
>
> Kim, any idea whether this sit-for return value is turning out the way
> you intended it?  At least the documentation says "t if waited for
> whole time" and this does not imply that the keyboard needs to be
> checked at all if the time has expired before it would have been worth
> checking the keyboard.  But since pending keyboard is supposed to
> inhibit redisplay for (sit-for 0), we can't avoid checking it anyway,
> right?
>
> And supposedly the return value of t from sit-for should at least
> imply that a redisplay has occured and completed.

I agree that (sit-for 0) should return nil if input is pending on entry.

Can you try the following version of sit-for?

[It assumes that `redisplay' returns t if display completed, nil if
there is pending input.  The code does that, but the doc string
doesn't say so explicitly...  so its doc string should be fixed.]


(defun sit-for (seconds &optional nodisp obsolete)
  "Perform redisplay, then wait for SECONDS seconds or until input is available.
SECONDS may be a floating-point value.
\(On operating systems that do not support waiting for fractions of a
second, floating-point values are rounded down to the nearest integer.)

If optional arg NODISP is t, don't redisplay, just wait for input.
Redisplay does not happen if input is available before it starts.

Value is t if waited the full time with no input arriving, and nil otherwise.

An obsolete, but still supported form is
\(sit-for SECONDS &optional MILLISECONDS NODISP)
where the optional arg MILLISECONDS specifies an additional wait period,
in milliseconds; this was useful when Emacs was built without
floating point support.

\(fn SECONDS &optional NODISP)"
  (when (or obsolete (numberp nodisp))
    (setq seconds (+ seconds (* 1e-3 nodisp)))
    (setq nodisp obsolete))
  (cond
   (noninteractive
    (sleep-for seconds)
    t)
   ((input-pending-p)
    nil)
   ((<= seconds 0)
    (or nodisp (redisplay)))
   (t
    (or nodisp (redisplay))
    (let ((read (read-event nil nil seconds)))
      (or (null read)
	  (progn (push read unread-command-events) nil))))))


Patch:

*** subr.el	29 Jul 2006 00:53:10 +0200	1.523
--- subr.el	07 Sep 2006 16:22:40 +0200	
***************
*** 1733,1745 ****
    (when (or obsolete (numberp nodisp))
      (setq seconds (+ seconds (* 1e-3 nodisp)))
      (setq nodisp obsolete))
!   (if noninteractive
!       (progn (sleep-for seconds) t)
!     (unless nodisp (redisplay))
!     (or (<= seconds 0)
! 	(let ((read (read-event nil nil seconds)))
! 	  (or (null read)
! 	      (progn (push read unread-command-events) nil))))))
  \f
  ;;; Atomic change groups.
  
--- 1733,1751 ----
    (when (or obsolete (numberp nodisp))
      (setq seconds (+ seconds (* 1e-3 nodisp)))
      (setq nodisp obsolete))
!   (cond
!    (noninteractive
!     (sleep-for seconds)
!     t)
!    ((input-pending-p)
!     nil)
!    ((<= seconds 0)
!     (or nodisp (redisplay)))
!    (t
!     (or nodisp (redisplay))
!     (let ((read (read-event nil nil seconds)))
!       (or (null read)
! 	  (progn (push read unread-command-events) nil))))))
  \f
  ;;; Atomic change groups.
  

-- 
Kim F. Storm <storm@cua.dk> http://www.cua.dk

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

* Re: Broken sit-for
  2006-09-07 14:27       ` Broken sit-for [was: Re: Minor fix for life.el.] Kim F. Storm
@ 2006-09-08  9:16         ` Michaël Cadilhac
  2006-09-09 23:02         ` Broken sit-for [was: Re: Minor fix for life.el.] Kim F. Storm
  1 sibling, 0 replies; 12+ messages in thread
From: Michaël Cadilhac @ 2006-09-08  9:16 UTC (permalink / raw)
  Cc: emacs-devel


[-- Attachment #1.1: Type: text/plain, Size: 1522 bytes --]

storm@cua.dk (Kim F. Storm) writes:

> I agree that (sit-for 0) should return nil if input is pending on entry.
>
> Can you try the following version of sit-for?

I did, and indeed it fixes the bug for life.el, thanks !

> [It assumes that `redisplay' returns t if display completed, nil if
> there is pending input.  The code does that, but the doc string
> doesn't say so explicitly...  so its doc string should be fixed.]
>
> (defun sit-for (seconds &optional nodisp obsolete)
>   "Perform redisplay, then wait for SECONDS seconds or until input is available.
> SECONDS may be a floating-point value.
> \(On operating systems that do not support waiting for fractions of a
> second, floating-point values are rounded down to the nearest integer.)
>
> If optional arg NODISP is t, don't redisplay, just wait for input.
> Redisplay does not happen if input is available before it starts.
>
> Value is t if waited the full time with no input arriving, and nil otherwise.

Maybe this  part of  the docstring should  be slightly changed  to say
that a negative or null value of SECONDS is not considered to be fully
waited if an input was pending before the call to sit-for.

-- 
 |      Michaël `Micha' Cadilhac   |  Mieux vaut se taire                   |
 |         Epita/LRDE Promo 2007   |   Que de parler trop fort.             |
 | http://www.lrde.org/~cadilh_m   |           -- As de trèfle              |
 `--  -   JID: micha@amessage.be --'                                   -  --'

[-- Attachment #1.2: Type: application/pgp-signature, Size: 188 bytes --]

[-- Attachment #2: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

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

* Re: Broken sit-for [was: Re: Minor fix for life.el.]
  2006-09-07 14:27       ` Broken sit-for [was: Re: Minor fix for life.el.] Kim F. Storm
  2006-09-08  9:16         ` Broken sit-for Michaël Cadilhac
@ 2006-09-09 23:02         ` Kim F. Storm
  2006-09-10  0:28           ` Broken sit-for David Kastrup
  1 sibling, 1 reply; 12+ messages in thread
From: Kim F. Storm @ 2006-09-09 23:02 UTC (permalink / raw)


storm@cua.dk (Kim F. Storm) writes:

> I agree that (sit-for 0) should return nil if input is pending on entry.

Are there any objections to installing the version of sit-for below:


(defun sit-for (seconds &optional nodisp obsolete)
  "Perform redisplay, then wait for SECONDS seconds or until input is available.
SECONDS may be a floating-point value.
\(On operating systems that do not support waiting for fractions of a
second, floating-point values are rounded down to the nearest integer.)

If optional arg NODISP is t, don't redisplay, just wait for input.
Redisplay does not happen if input is available before it starts.

Value is t if waited the full time with no input arriving, and nil otherwise.

An obsolete, but still supported form is
\(sit-for SECONDS &optional MILLISECONDS NODISP)
where the optional arg MILLISECONDS specifies an additional wait period,
in milliseconds; this was useful when Emacs was built without
floating point support.

\(fn SECONDS &optional NODISP)"
  (when (or obsolete (numberp nodisp))
    (setq seconds (+ seconds (* 1e-3 nodisp)))
    (setq nodisp obsolete))
  (cond
   (noninteractive
    (sleep-for seconds)
    t)
   ((input-pending-p)
    nil)
   ((<= seconds 0)
    (or nodisp (redisplay)))
   (t
    (or nodisp (redisplay))
    (let ((read (read-event nil nil seconds)))
      (or (null read)
	  (progn (push read unread-command-events) nil))))))


Patch:

*** subr.el	29 Jul 2006 00:53:10 +0200	1.523
--- subr.el	07 Sep 2006 16:22:40 +0200	
***************
*** 1733,1745 ****
    (when (or obsolete (numberp nodisp))
      (setq seconds (+ seconds (* 1e-3 nodisp)))
      (setq nodisp obsolete))
!   (if noninteractive
!	(progn (sleep-for seconds) t)
!     (unless nodisp (redisplay))
!     (or (<= seconds 0)
!	(let ((read (read-event nil nil seconds)))
!	  (or (null read)
!	      (progn (push read unread-command-events) nil))))))
  \f
  ;;; Atomic change groups.
  
--- 1733,1751 ----
    (when (or obsolete (numberp nodisp))
      (setq seconds (+ seconds (* 1e-3 nodisp)))
      (setq nodisp obsolete))
!   (cond
!    (noninteractive
!     (sleep-for seconds)
!     t)
!    ((input-pending-p)
!     nil)
!    ((<= seconds 0)
!     (or nodisp (redisplay)))
!    (t
!     (or nodisp (redisplay))
!     (let ((read (read-event nil nil seconds)))
!	(or (null read)
!	  (progn (push read unread-command-events) nil))))))
  \f
  ;;; Atomic change groups.
  

-- 
Kim F. Storm <storm@cua.dk> http://www.cua.dk

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

* Re: Broken sit-for
  2006-09-09 23:02         ` Broken sit-for [was: Re: Minor fix for life.el.] Kim F. Storm
@ 2006-09-10  0:28           ` David Kastrup
  2006-09-10  9:18             ` Michaël Cadilhac
  2006-09-10 21:06             ` Kim F. Storm
  0 siblings, 2 replies; 12+ messages in thread
From: David Kastrup @ 2006-09-10  0:28 UTC (permalink / raw)
  Cc: emacs-devel

storm@cua.dk (Kim F. Storm) writes:

> storm@cua.dk (Kim F. Storm) writes:
>
>> I agree that (sit-for 0) should return nil if input is pending on entry.
>
> Are there any objections to installing the version of sit-for below:

[...]

> Value is t if waited the full time with no input arriving, and nil otherwise.

>     (sleep-for seconds)
>     t)
>    ((input-pending-p)
>     nil)
>    ((<= seconds 0)
>     (or nodisp (redisplay)))

The doc string for "redisplay" does not specify a return value, so
maybe you should write

     ((<= seconds 0)
      (unless nodisp (redisplay) t))

instead.

>    (t
>     (or nodisp (redisplay))
>     (let ((read (read-event nil nil seconds)))
>       (or (null read)
> 	  (progn (push read unread-command-events) nil))))))

This does not interfere with the myriad of other
unread-command-events like variables we have?  They are sure to be
unused at this point of time?

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

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

* Re: Broken sit-for
  2006-09-10  0:28           ` Broken sit-for David Kastrup
@ 2006-09-10  9:18             ` Michaël Cadilhac
  2006-09-10 21:26               ` Kim F. Storm
  2006-09-10 21:06             ` Kim F. Storm
  1 sibling, 1 reply; 12+ messages in thread
From: Michaël Cadilhac @ 2006-09-10  9:18 UTC (permalink / raw)
  Cc: emacs-devel, Kim F. Storm


[-- Attachment #1.1: Type: text/plain, Size: 1254 bytes --]

David Kastrup <dak@gnu.org> writes:

> storm@cua.dk (Kim F. Storm) writes:
>
>> storm@cua.dk (Kim F. Storm) writes:
>>
>>> I agree that (sit-for 0) should return nil if input is pending on entry.
>>
>> Are there any objections to installing the version of sit-for below:
>
> [...]
>
>> Value is t if waited the full time with no input arriving, and nil otherwise.

I still think this line should be slightly changed to say something
about zero (and negative) values of SECONDS.

>>    (t
>>     (or nodisp (redisplay))
>>     (let ((read (read-event nil nil seconds)))
>>       (or (null read)
>> 	  (progn (push read unread-command-events) nil))))))
>
> This does not interfere with the myriad of other
> unread-command-events like variables we have?  They are sure to be
> unused at this point of time?

Well, it actually triggers a problem.  See the thread « The order input
events are processed. »

-- 
 |      Michaël `Micha' Cadilhac   |  La culture c'est comme la confiture,  |
 |         Epita/LRDE Promo 2007   |      c'est meilleur avec du pain.      |
 | http://www.lrde.org/~cadilh_m   |           -- MOI59                     |
 `--  -   JID: micha@amessage.be --'                                   -  --'

[-- Attachment #1.2: Type: application/pgp-signature, Size: 188 bytes --]

[-- Attachment #2: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

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

* Re: Broken sit-for
  2006-09-10  0:28           ` Broken sit-for David Kastrup
  2006-09-10  9:18             ` Michaël Cadilhac
@ 2006-09-10 21:06             ` Kim F. Storm
  1 sibling, 0 replies; 12+ messages in thread
From: Kim F. Storm @ 2006-09-10 21:06 UTC (permalink / raw)
  Cc: emacs-devel

David Kastrup <dak@gnu.org> writes:

> storm@cua.dk (Kim F. Storm) writes:
>
>> storm@cua.dk (Kim F. Storm) writes:
>>
>>> I agree that (sit-for 0) should return nil if input is pending on entry.
>>
>> Are there any objections to installing the version of sit-for below:
>
> [...]
>
>> Value is t if waited the full time with no input arriving, and nil otherwise.
>
>>     (sleep-for seconds)
>>     t)
>>    ((input-pending-p)
>>     nil)
>>    ((<= seconds 0)
>>     (or nodisp (redisplay)))
>
> The doc string for "redisplay" does not specify a return value, 

I have fixed that.

>
>>    (t
>>     (or nodisp (redisplay))
>>     (let ((read (read-event nil nil seconds)))
>>       (or (null read)
>> 	  (progn (push read unread-command-events) nil))))))
>
> This does not interfere with the myriad of other
> unread-command-events like variables we have?  They are sure to be
> unused at this point of time?

It does (but that's how the code looks now).

Perhaps it should simply use unread-post-input-method-events instead
of unread-command-events.

-- 
Kim F. Storm <storm@cua.dk> http://www.cua.dk

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

* Re: Broken sit-for
  2006-09-10  9:18             ` Michaël Cadilhac
@ 2006-09-10 21:26               ` Kim F. Storm
  2006-09-11 14:22                 ` Michaël Cadilhac
  0 siblings, 1 reply; 12+ messages in thread
From: Kim F. Storm @ 2006-09-10 21:26 UTC (permalink / raw)
  Cc: emacs-devel

michael.cadilhac@lrde.org (Michaël Cadilhac) writes:

> I still think this line should be slightly changed to say something
> about zero (and negative) values of SECONDS.

To me it seems quite obvious that "seconds <= 0" implies "waited the full time".

But if you can suggest something better, please do.

>
>>>    (t
>>>     (or nodisp (redisplay))
>>>     (let ((read (read-event nil nil seconds)))
>>>       (or (null read)
>>> 	  (progn (push read unread-command-events) nil))))))
>>
>> This does not interfere with the myriad of other
>> unread-command-events like variables we have?  They are sure to be
>> unused at this point of time?
>
> Well, it actually triggers a problem.  See the thread « The order input
> events are processed. »

See my answer to that thread.

--
Kim F. Storm <storm@cua.dk> http://www.cua.dk

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

* Re: Broken sit-for
  2006-09-10 21:26               ` Kim F. Storm
@ 2006-09-11 14:22                 ` Michaël Cadilhac
  0 siblings, 0 replies; 12+ messages in thread
From: Michaël Cadilhac @ 2006-09-11 14:22 UTC (permalink / raw)
  Cc: emacs-devel


[-- Attachment #1.1: Type: text/plain, Size: 1237 bytes --]

storm@cua.dk (Kim F. Storm) writes:

> michael.cadilhac@lrde.org (Michaël Cadilhac) writes:
>
>> I still think this line should be slightly changed to say something
>> about zero (and negative) values of SECONDS.
>
> To me it seems quite obvious that "seconds <= 0" implies "waited the
> full time".

It does to me too, and that's the problem.

The docstring says the following :

> Value is t if waited the full time with no input arriving, and nil
> otherwise.

I said earlier:

> Maybe this  part of  the docstring should  be slightly changed  to say
> that a negative or null value of SECONDS is not considered to be fully
> waited if an input was pending before the call to sit-for.

I think the  current docstring is ambiguous on  this point: if seconds
is  <=  0,  one could  think  that  _whatever  the input_  SECONDS  is
considered to be fully waited, whilst it's not the case.

-- 
 |      Michaël `Micha' Cadilhac   |  Un certain Blaise Pascal              |
 |         Epita/LRDE Promo 2007   |    etc... etc...                       |
 |  http://michael.cadilhac.name   |  -- Prévert (Les paris stupides)       |
 `--  -   JID: micha@amessage.be --'                                   -  --'

[-- Attachment #1.2: Type: application/pgp-signature, Size: 188 bytes --]

[-- Attachment #2: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

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

end of thread, other threads:[~2006-09-11 14:22 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-09-06 17:05 Minor fix for life.el Michaël Cadilhac
2006-09-06 18:03 ` David Kastrup
2006-09-06 18:14   ` Michaël Cadilhac
2006-09-06 18:34     ` David Kastrup
2006-09-07 14:27       ` Broken sit-for [was: Re: Minor fix for life.el.] Kim F. Storm
2006-09-08  9:16         ` Broken sit-for Michaël Cadilhac
2006-09-09 23:02         ` Broken sit-for [was: Re: Minor fix for life.el.] Kim F. Storm
2006-09-10  0:28           ` Broken sit-for David Kastrup
2006-09-10  9:18             ` Michaël Cadilhac
2006-09-10 21:26               ` Kim F. Storm
2006-09-11 14:22                 ` Michaël Cadilhac
2006-09-10 21:06             ` Kim F. Storm

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