* sleep-for does not work as expected - or perhaps my expection is incorrect
@ 2011-07-12 14:42 C K Kashyap
2011-07-12 17:24 ` Deniz Dogan
2011-07-12 17:39 ` PJ Weisberg
0 siblings, 2 replies; 5+ messages in thread
From: C K Kashyap @ 2011-07-12 14:42 UTC (permalink / raw)
To: help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 391 bytes --]
Hi,
(defun somefun ()
(insert "Hello ")
(sleep-for 1)
(insert "world\n"))
When I invoke "somefun" by doign - M-: (somefun) <return>
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
[-- Attachment #2: Type: text/html, Size: 576 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: sleep-for does not work as expected - or perhaps my expection is incorrect
2011-07-12 14:42 sleep-for does not work as expected - or perhaps my expection is incorrect C K Kashyap
@ 2011-07-12 17:24 ` Deniz Dogan
2011-07-12 18:55 ` Perry Smith
2011-07-12 17:39 ` PJ Weisberg
1 sibling, 1 reply; 5+ messages in thread
From: Deniz Dogan @ 2011-07-12 17:24 UTC (permalink / raw)
To: help-gnu-emacs
On 2011-07-12 16:42, C K Kashyap wrote:
> (defun somefun ()
> (insert "Hello ")
> (sleep-for 1)
> (insert "world\n"))
The docstring for `sleep-for' says: "Pause, without updating display,
for SECONDS seconds."
Throw a (redisplay t) after the first insertion and it should work.
Deniz
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: sleep-for does not work as expected - or perhaps my expection is incorrect
2011-07-12 17:24 ` Deniz Dogan
@ 2011-07-12 18:55 ` Perry Smith
0 siblings, 0 replies; 5+ messages in thread
From: Perry Smith @ 2011-07-12 18:55 UTC (permalink / raw)
To: Deniz Dogan; +Cc: help-gnu-emacs
On Jul 12, 2011, at 12:24 PM, Deniz Dogan wrote:
> On 2011-07-12 16:42, C K Kashyap wrote:
>> (defun somefun ()
>> (insert "Hello ")
>> (sleep-for 1)
>> (insert "world\n"))
>
> The docstring for `sleep-for' says: "Pause, without updating display, for SECONDS seconds."
>
> Throw a (redisplay t) after the first insertion and it should work.
I'm use to 'sit-for' ... i.e.
(defun somefun ()
(insert "Hello ")
(sit-for 1)
(insert "world\n"))
With that you see the Hello... one second pause, then world.
HTH,
pedz
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: sleep-for does not work as expected - or perhaps my expection is incorrect
2011-07-12 14:42 sleep-for does not work as expected - or perhaps my expection is incorrect C K Kashyap
2011-07-12 17:24 ` Deniz Dogan
@ 2011-07-12 17:39 ` PJ Weisberg
2011-07-12 17:44 ` suvayu ali
1 sibling, 1 reply; 5+ messages in thread
From: PJ Weisberg @ 2011-07-12 17:39 UTC (permalink / raw)
To: C K Kashyap; +Cc: help-gnu-emacs
On Tue, Jul 12, 2011 at 7:42 AM, C K Kashyap <ckkashyap@gmail.com> wrote:
> Hi,
> (defun somefun ()
> (insert "Hello ")
> (sleep-for 1)
> (insert "world\n"))
>
> When I invoke "somefun" by doign - M-: (somefun) <return>
>
> 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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: sleep-for does not work as expected - or perhaps my expection is incorrect
2011-07-12 17:39 ` PJ Weisberg
@ 2011-07-12 17:44 ` suvayu ali
0 siblings, 0 replies; 5+ messages in thread
From: suvayu ali @ 2011-07-12 17:44 UTC (permalink / raw)
To: PJ Weisberg; +Cc: help-gnu-emacs
On Tue, Jul 12, 2011 at 7:39 PM, PJ Weisberg
<pj@irregularexpressions.net> wrote:
> 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. :-)
>
(progn (message "Hello")(sleep-for 1)(message "world"))
This, for example, clearly shows that emacs is waiting.
--
Suvayu
Open source is the future. It sets us free.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2011-07-12 18:55 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-12 14:42 sleep-for does not work as expected - or perhaps my expection is incorrect C K Kashyap
2011-07-12 17:24 ` Deniz Dogan
2011-07-12 18:55 ` Perry Smith
2011-07-12 17:39 ` PJ Weisberg
2011-07-12 17:44 ` suvayu ali
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.