From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: PJ Weisberg Newsgroups: gmane.emacs.help Subject: Re: sleep-for does not work as expected - or perhaps my expection is incorrect Date: Tue, 12 Jul 2011 10:39:09 -0700 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1310492512 1635 80.91.229.12 (12 Jul 2011 17:41:52 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 12 Jul 2011 17:41:52 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: C K Kashyap Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Jul 12 19:41:47 2011 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Qggxt-00050T-Qz for geh-help-gnu-emacs@m.gmane.org; Tue, 12 Jul 2011 19:41:46 +0200 Original-Received: from localhost ([::1]:38122 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qggxs-0002yZ-AH for geh-help-gnu-emacs@m.gmane.org; Tue, 12 Jul 2011 13:41:44 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:37079) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qggva-0002xt-GI for help-gnu-emacs@gnu.org; Tue, 12 Jul 2011 13:39:23 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QggvW-0004fW-FK for help-gnu-emacs@gnu.org; Tue, 12 Jul 2011 13:39:22 -0400 Original-Received: from smtpauth22.prod.mesa1.secureserver.net ([64.202.165.44]:58707) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1QggvV-0004es-WA for help-gnu-emacs@gnu.org; Tue, 12 Jul 2011 13:39:18 -0400 Original-Received: (qmail 8306 invoked from network); 12 Jul 2011 17:39:14 -0000 Original-Received: from unknown (209.85.161.52) by smtpauth22.prod.mesa1.secureserver.net (64.202.165.44) with ESMTP; 12 Jul 2011 17:39:14 -0000 Original-Received: by fxd18 with SMTP id 18so1376178fxd.39 for ; Tue, 12 Jul 2011 10:39:12 -0700 (PDT) Original-Received: by 10.223.14.22 with SMTP id e22mr232546faa.93.1310492352044; Tue, 12 Jul 2011 10:39:12 -0700 (PDT) Original-Received: by 10.223.89.142 with HTTP; Tue, 12 Jul 2011 10:39:09 -0700 (PDT) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4-2.6 X-Received-From: 64.202.165.44 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:81559 Archived-At: On Tue, Jul 12, 2011 at 7:42 AM, C K Kashyap wrote: > Hi, > (defun somefun () > =A0 (insert "Hello ") > =A0 (sleep-for 1) > (insert "world\n")) > > When I invoke "somefun" by doign - =A0M-: (somefun) > > I see that "Hello world" gets printed after 1 second instead of printing > Hello and then printing world after one second. > > What can I do to get the script to write out "hello" first and then wait = for > a second and then write out world? > > Regards, > Kashyap (defun somefun () (insert "Hello ") (redisplay t) (sleep-for 1) (insert "world\n")) Your function *is* waiting one second before it writes out world--but Emacs is waiting for your function to finish before it tries to show any of the changes it's made to the buffer. :-) -PJ