From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: storm@cua.dk (Kim F. Storm) Newsgroups: gmane.emacs.devel Subject: Broken sit-for [was: Re: Minor fix for life.el.] Date: Thu, 07 Sep 2006 16:27:52 +0200 Message-ID: References: <87ejup0vth.fsf@lrde.org> <858xkwdg92.fsf@lola.goethe.zz> <877j0gq2vn.fsf@lrde.org> <85r6yoc09x.fsf@lola.goethe.zz> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1157639507 5562 80.91.229.2 (7 Sep 2006 14:31:47 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 7 Sep 2006 14:31:47 +0000 (UTC) Cc: =?utf-8?Q?Micha=C3=ABl?= Cadilhac , emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Sep 07 16:31:41 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 1GLKtV-00055z-6v for ged-emacs-devel@m.gmane.org; Thu, 07 Sep 2006 16:30:17 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GLKtU-00021W-Jr for ged-emacs-devel@m.gmane.org; Thu, 07 Sep 2006 10:30:16 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GLKsQ-0001Lv-Tj for emacs-devel@gnu.org; Thu, 07 Sep 2006 10:29:11 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GLKsP-0001KV-ON for emacs-devel@gnu.org; Thu, 07 Sep 2006 10:29:10 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GLKsP-0001KQ-LJ for emacs-devel@gnu.org; Thu, 07 Sep 2006 10:29:09 -0400 Original-Received: from [195.41.46.237] (helo=pfepc.post.tele.dk) by monty-python.gnu.org with esmtp (Exim 4.52) id 1GLKsk-0007lw-8O; Thu, 07 Sep 2006 10:29:30 -0400 Original-Received: from kfs-l.imdomain.dk.cua.dk (unknown [80.165.4.124]) by pfepc.post.tele.dk (Postfix) with SMTP id BB7388A0013; Thu, 7 Sep 2006 16:28:59 +0200 (CEST) Original-To: David Kastrup In-Reply-To: <85r6yoc09x.fsf@lola.goethe.zz> (David Kastrup's message of "Wed\, 06 Sep 2006 20\:34\:02 +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:59511 Archived-At: David Kastrup 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)))))) ;;; 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)))))) ;;; Atomic change groups. -- Kim F. Storm http://www.cua.dk