From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: David Kastrup Newsgroups: gmane.emacs.devel Subject: Re: Minor fix for life.el. Date: Wed, 06 Sep 2006 20:34:02 +0200 Message-ID: <85r6yoc09x.fsf@lola.goethe.zz> References: <87ejup0vth.fsf@lrde.org> <858xkwdg92.fsf@lola.goethe.zz> <877j0gq2vn.fsf@lrde.org> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: sea.gmane.org 1157567771 10181 80.91.229.2 (6 Sep 2006 18:36:11 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 6 Sep 2006 18:36:11 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Sep 06 20:36:10 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1GL2FM-0002GZ-IQ for ged-emacs-devel@m.gmane.org; Wed, 06 Sep 2006 20:35:37 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GL2FL-0007JP-Vi for ged-emacs-devel@m.gmane.org; Wed, 06 Sep 2006 14:35:36 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GL2Ez-00073M-Dr for emacs-devel@gnu.org; Wed, 06 Sep 2006 14:35:13 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GL2Ey-00070q-6R for emacs-devel@gnu.org; Wed, 06 Sep 2006 14:35:12 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GL2Ex-000701-QO for emacs-devel@gnu.org; Wed, 06 Sep 2006 14:35:11 -0400 Original-Received: from [199.232.76.164] (helo=fencepost.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.52) id 1GL2FA-0000Z1-AY for emacs-devel@gnu.org; Wed, 06 Sep 2006 14:35:24 -0400 Original-Received: from localhost ([127.0.0.1] helo=lola.goethe.zz) by fencepost.gnu.org with esmtp (Exim 4.34) id 1GL2Ex-0008RG-4B; Wed, 06 Sep 2006 14:35:11 -0400 Original-Received: by lola.goethe.zz (Postfix, from userid 1002) id 8F72F1C4D3A4; Wed, 6 Sep 2006 20:34:02 +0200 (CEST) Original-To: michael.cadilhac@lrde.org (=?iso-8859-1?Q?Micha=EBl?= Cadilhac) In-Reply-To: <877j0gq2vn.fsf@lrde.org> (=?iso-8859-1?Q?Micha=EBl?= Cadilhac's message of "Wed, 06 Sep 2006 20:14:04 +0200") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:59461 Archived-At: michael.cadilhac@lrde.org (Micha=EBl Cadilhac) writes: > David Kastrup writes: > >> michael.cadilhac@lrde.org (Micha=EBl 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 >>> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D >>> 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) >>>=20=20=20 >>> ;; Redisplay; if the user has hit a key, exit the loop. >>> ! (or (eq t (sit-for sleeptime)) >>> (throw 'life-exit nil))) >>>=20=20=20 >>> (defun life-extinct-quit () >>> --- 269,276 ---- >>> (recenter 0) >>>=20=20=20 >>> ;; 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. --=20 David Kastrup, Kriemhildstr. 15, 44793 Bochum