[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: sleep-for documentation and how to pause reliably
From: |
Thierry Volpiatto |
Subject: |
Re: sleep-for documentation and how to pause reliably |
Date: |
Fri, 15 Feb 2013 11:19:27 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.2.93 (gnu/linux) |
Hi Eli,
Eli Zaretskii <address@hidden> writes:
> Am I missing something, or is our current docs of sleep-for misleading?
>
> The doc string says:
>
> (sleep-for SECONDS &optional MILLISECONDS)
>
> Pause, without updating display, for SECONDS seconds.
>
> The only way I can interpret this is that sleep-for _always_ pauses
> for that number of seconds.
>
> The ELisp manual goes even further:
>
> -- Function: sleep-for seconds &optional millisec
> This function simply pauses for SECONDS seconds without updating
> the display. It pays no attention to available input. It returns
> `nil'. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
> [...]
>
> Use `sleep-for' when you wish to guarantee a delay.
> ^^^^^^^^^^^^^^^^^
>
> "Guarantee a delay". No "buts".
>
> However, in fact, sleep-for will return as soon as any input from any
> subprocess arrives. E.g., try this in *scratch*:
>
> (progn (setq proc (start-process-shell-command "ls" nil "ls"))
> (sleep-for 20)
> (message "hi"))
>
> You will see no delay at all before the message is displayed.
>
> Am I missing something? If not, apart of fixing the docs, _is_ there
> any way to wait reliably when async subprocesses are running and
> producing output?
What about using a sentinel?
(progn
(let ((proc (start-process-shell-command "ls" nil "ls")))
(set-process-sentinel proc #'(lambda (process event)
(when (string= event "finished\n"))
(sleep-for 20)
(message "hi after 20s sleeping"))))
(message "Hi now sleeping 20s"))
--
Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997
- sleep-for documentation and how to pause reliably, Eli Zaretskii, 2013/02/15
- Re: sleep-for documentation and how to pause reliably,
Thierry Volpiatto <=
- Re: sleep-for documentation and how to pause reliably, Eli Zaretskii, 2013/02/15
- Re: sleep-for documentation and how to pause reliably, Thierry Volpiatto, 2013/02/15
- Re: sleep-for documentation and how to pause reliably, Eli Zaretskii, 2013/02/16
- Re: sleep-for documentation and how to pause reliably, Xue Fuqiao, 2013/02/17
- Re: sleep-for documentation and how to pause reliably, Eli Zaretskii, 2013/02/17
- Re: sleep-for documentation and how to pause reliably, Xue Fuqiao, 2013/02/17
Re: sleep-for documentation and how to pause reliably, Stefan Monnier, 2013/02/15