* Proposal for a new mechanism for delayed stuff
@ 2012-12-25 13:20 Lars Ingebrigtsen
2012-12-25 13:52 ` Xue Fuqiao
` (4 more replies)
0 siblings, 5 replies; 14+ messages in thread
From: Lars Ingebrigtsen @ 2012-12-25 13:20 UTC (permalink / raw)
To: emacs-devel
Gnus does a lot of stuff that it doesn't really know how long it'll take
to do. For instance, connecting to a mail server, and rendering
complex HTML.
If Gnus were to output "Connecting to foo", "sending retrieval
commands", "waiting for foo to finish outputting" (which are usually
done asynchronously, intermingled between many servers), Gnus would spew
an inordinate number of messages.
And sometimes the user should know what's taking so long, so that the
user can decide what to do about it.
So the ideal would be if we could say "display a message if things take
too long".
The idea I had yesterday was to make this totally general:
(with-timeout-forms
(progn
(bla)
(bla))
(1.5 (message "This is sure taking a lot of time..."))
(10 (message "This is sure taking forever!")))
A la condition-case and stuff, although here we have forms that are
run if the main form takes too long. So after 1.5 seconds we trigger
the first, and after 10 we trigger the second.
And perhaps it would also be possible to have a special thing in the
timeout forms that would conclude the entire main form? Like `return'
or something.
So it's like `with-timeout', only that it doesn't end executing the
body. And it would hopefully be possible to implement it such a way
that a looping body form would also be "pre-emptible".
--
(domestic pets only, the antidote for overdose, milk.)
http://lars.ingebrigtsen.no * Lars Magne Ingebrigtsen
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Proposal for a new mechanism for delayed stuff
2012-12-25 13:20 Proposal for a new mechanism for delayed stuff Lars Ingebrigtsen
@ 2012-12-25 13:52 ` Xue Fuqiao
2012-12-25 19:57 ` Karl Fogel
` (3 subsequent siblings)
4 siblings, 0 replies; 14+ messages in thread
From: Xue Fuqiao @ 2012-12-25 13:52 UTC (permalink / raw)
To: Lars Ingebrigtsen; +Cc: emacs-devel
On Tue, 25 Dec 2012 14:20:31 +0100
Lars Ingebrigtsen <larsi@gnus.org> wrote:
> So the ideal would be if we could say "display a message if things take
> too long".
That's good for many packages and features, such as ispell-buffer, nxml, some TeX-related packages, replace+, ERC, W3 and so on.
--
Best regards, Xue Fuqiao.
http://www.emacswiki.org/emacs/XueFuqiao
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Proposal for a new mechanism for delayed stuff
2012-12-25 13:20 Proposal for a new mechanism for delayed stuff Lars Ingebrigtsen
2012-12-25 13:52 ` Xue Fuqiao
@ 2012-12-25 19:57 ` Karl Fogel
2012-12-26 14:08 ` Ted Zlatanov
` (2 subsequent siblings)
4 siblings, 0 replies; 14+ messages in thread
From: Karl Fogel @ 2012-12-25 19:57 UTC (permalink / raw)
To: emacs-devel
Lars Ingebrigtsen <larsi@gnus.org> writes:
>Gnus does a lot of stuff that it doesn't really know how long it'll take
>to do. For instance, connecting to a mail server, and rendering
>complex HTML.
>
>If Gnus were to output "Connecting to foo", "sending retrieval
>commands", "waiting for foo to finish outputting" (which are usually
>done asynchronously, intermingled between many servers), Gnus would spew
>an inordinate number of messages.
>
>And sometimes the user should know what's taking so long, so that the
>user can decide what to do about it.
>
>So the ideal would be if we could say "display a message if things take
>too long".
>
>The idea I had yesterday was to make this totally general:
>
>(with-timeout-forms
> (progn
> (bla)
> (bla))
> (1.5 (message "This is sure taking a lot of time..."))
> (10 (message "This is sure taking forever!")))
>
>A la condition-case and stuff, although here we have forms that are
>run if the main form takes too long. So after 1.5 seconds we trigger
>the first, and after 10 we trigger the second.
>
>And perhaps it would also be possible to have a special thing in the
>timeout forms that would conclude the entire main form? Like `return'
>or something.
>
>So it's like `with-timeout', only that it doesn't end executing the
>body. And it would hopefully be possible to implement it such a way
>that a looping body form would also be "pre-emptible".
I think that's a great generalization idea. And `with-timeout' could
then be (re)implemented using `with-timeout-forms', presumably.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Proposal for a new mechanism for delayed stuff
2012-12-25 13:20 Proposal for a new mechanism for delayed stuff Lars Ingebrigtsen
2012-12-25 13:52 ` Xue Fuqiao
2012-12-25 19:57 ` Karl Fogel
@ 2012-12-26 14:08 ` Ted Zlatanov
2012-12-27 4:08 ` Stephen J. Turnbull
2012-12-27 9:40 ` Vitalie Spinu
2012-12-29 6:30 ` Stefan Monnier
4 siblings, 1 reply; 14+ messages in thread
From: Ted Zlatanov @ 2012-12-26 14:08 UTC (permalink / raw)
To: emacs-devel
On Tue, 25 Dec 2012 14:20:31 +0100 Lars Ingebrigtsen <larsi@gnus.org> wrote:
LI> The idea I had yesterday was to make this totally general:
(with-timeout-forms
(progn
(bla)
(bla))
(1.5 (message "This is sure taking a lot of time..."))
(10 (message "This is sure taking forever!")))
LI> A la condition-case and stuff, although here we have forms that are
LI> run if the main form takes too long. So after 1.5 seconds we trigger
LI> the first, and after 10 we trigger the second.
I like it.
LI> And perhaps it would also be possible to have a special thing in the
LI> timeout forms that would conclude the entire main form? Like `return'
LI> or something.
You could use 'finally?
Ted
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Proposal for a new mechanism for delayed stuff
2012-12-26 14:08 ` Ted Zlatanov
@ 2012-12-27 4:08 ` Stephen J. Turnbull
2012-12-27 10:49 ` Achim Gratz
0 siblings, 1 reply; 14+ messages in thread
From: Stephen J. Turnbull @ 2012-12-27 4:08 UTC (permalink / raw)
To: emacs-devel
Ted Zlatanov writes:
> You could use 'finally?
In Python, "finally" has a different meaning, basically the same as
`unwind-protect' in Emacs. Python usage is merely suggestive, but I
think that's more intuitive for "finally".
"break" seems to be the obvious choice of inline syntactic keyword.
Since this is Lisp, I guess its semantics would need to be extended to
"break and return value".
Alternatively, Emacs could adopt the Scheme call/cc convention and
have an "exit function", which if called would exit the
with-timeout-forms form and return the argument of the exit function.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Proposal for a new mechanism for delayed stuff
2012-12-27 4:08 ` Stephen J. Turnbull
@ 2012-12-27 10:49 ` Achim Gratz
2012-12-27 14:43 ` Stephen J. Turnbull
0 siblings, 1 reply; 14+ messages in thread
From: Achim Gratz @ 2012-12-27 10:49 UTC (permalink / raw)
To: emacs-devel
Am 27.12.2012 05:08, schrieb Stephen J. Turnbull:
> "break" seems to be the obvious choice of inline syntactic keyword.
> Since this is Lisp, I guess its semantics would need to be extended to
> "break and return value".
All languages I know that have a syntactic "break" use it to modify
local control flow. Unless I missed some vital part of the discussion,
we'd want to terminate an async process that has used up the time budget
alotted to it. So I don't see "break" as an obvious nor appropriate choice.
--
Achim.
(on the road :-)
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Proposal for a new mechanism for delayed stuff
2012-12-27 10:49 ` Achim Gratz
@ 2012-12-27 14:43 ` Stephen J. Turnbull
0 siblings, 0 replies; 14+ messages in thread
From: Stephen J. Turnbull @ 2012-12-27 14:43 UTC (permalink / raw)
To: Achim Gratz; +Cc: emacs-devel
Achim Gratz writes:
> All languages I know that have a syntactic "break" use it to modify
> local control flow.
Point taken. This is really more like a throw (but I don't trust my
intuition enough to suggest anything right now :-P )..
> Unless I missed some vital part of the discussion, we'd want to
> terminate an async process that has used up the time budget alotted
> to it.
No, it's because Emacs is blocking that this timeout mechanism has
been suggested. If the task were asynchronous there wouldn't be a
need for a separate timeout. We would just sleep a bit and check a
buffer from Lisp code, and repeat a fixed number of times or until
success, whichever comes first. It could used for any potentially
long-running synchronous task, whether I/O or a user-specified
Lisp computation.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Proposal for a new mechanism for delayed stuff
2012-12-25 13:20 Proposal for a new mechanism for delayed stuff Lars Ingebrigtsen
` (2 preceding siblings ...)
2012-12-26 14:08 ` Ted Zlatanov
@ 2012-12-27 9:40 ` Vitalie Spinu
2012-12-27 14:01 ` Lars Ingebrigtsen
2012-12-29 6:30 ` Stefan Monnier
4 siblings, 1 reply; 14+ messages in thread
From: Vitalie Spinu @ 2012-12-27 9:40 UTC (permalink / raw)
To: emacs-devel
>> Lars Ingebrigtsen <larsi@gnus.org>
>> on Tue, 25 Dec 2012 14:20:31 +0100 wrote:
[...]
> (with-timeout-forms
> (progn
> (bla)
> (bla))
> (1.5 (message "This is sure taking a lot of time..."))
> (10 (message "This is sure taking forever!")))
(bla) (bla) are asynchronous forms, right? I am probably missing
something, but there should be a callback, otherwise how do you know
when (bla) is finished?
Should negative numbers signify a repeated task?
(with-timeout-forms
(progn ...
)
(-1 (do-something-every-second))
)
Then you can pass an explicit callback:
(with-timeout-forms
(progn ...
(bla bla)
)
(-.1 (if-job-is-finished-break-timeout-loop))
)
Vitalie
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Proposal for a new mechanism for delayed stuff
2012-12-25 13:20 Proposal for a new mechanism for delayed stuff Lars Ingebrigtsen
` (3 preceding siblings ...)
2012-12-27 9:40 ` Vitalie Spinu
@ 2012-12-29 6:30 ` Stefan Monnier
2012-12-31 14:09 ` Lars Magne Ingebrigtsen
4 siblings, 1 reply; 14+ messages in thread
From: Stefan Monnier @ 2012-12-29 6:30 UTC (permalink / raw)
To: emacs-devel
> (with-timeout-forms
> (progn
> (bla)
> (bla))
> (1.5 (message "This is sure taking a lot of time..."))
> (10 (message "This is sure taking forever!")))
Maybe an alternative would be a `current-state-message' global variable,
which is then displayed once per second that Emacs is busy.
Stefan
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Proposal for a new mechanism for delayed stuff
2012-12-29 6:30 ` Stefan Monnier
@ 2012-12-31 14:09 ` Lars Magne Ingebrigtsen
2013-01-03 16:47 ` Stefan Monnier
0 siblings, 1 reply; 14+ messages in thread
From: Lars Magne Ingebrigtsen @ 2012-12-31 14:09 UTC (permalink / raw)
To: Stefan Monnier; +Cc: emacs-devel
Stefan Monnier <monnier@IRO.UMontreal.CA> writes:
>> (with-timeout-forms
>> (progn
>> (bla)
>> (bla))
>> (1.5 (message "This is sure taking a lot of time..."))
>> (10 (message "This is sure taking forever!")))
>
> Maybe an alternative would be a `current-state-message' global variable,
> which is then displayed once per second that Emacs is busy.
Sure, that would also handle the "tell the user what's going on" use
case, and we could have a convenience macro `with-current-state-message'
that would simply be an `unwind-protect' to clear out the state message.
But `with-timeout-form' would be kinda generally useful, I think. :-)
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog http://lars.ingebrigtsen.no/
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Proposal for a new mechanism for delayed stuff
2012-12-31 14:09 ` Lars Magne Ingebrigtsen
@ 2013-01-03 16:47 ` Stefan Monnier
2013-01-03 23:34 ` Lars Magne Ingebrigtsen
0 siblings, 1 reply; 14+ messages in thread
From: Stefan Monnier @ 2013-01-03 16:47 UTC (permalink / raw)
To: Lars Magne Ingebrigtsen; +Cc: emacs-devel
> Sure, that would also handle the "tell the user what's going on" use
> case, and we could have a convenience macro `with-current-state-message'
> that would simply be an `unwind-protect' to clear out the state message.
Yes, the advantage is that the message can be displayed even if we're in
the middle of uninterruptible Elisp code.
> But `with-timeout-form' would be kinda generally useful, I think. :-)
IIUC you can implement that in Elisp, right?
Stefan
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Proposal for a new mechanism for delayed stuff
2013-01-03 16:47 ` Stefan Monnier
@ 2013-01-03 23:34 ` Lars Magne Ingebrigtsen
2013-01-04 1:56 ` Stefan Monnier
0 siblings, 1 reply; 14+ messages in thread
From: Lars Magne Ingebrigtsen @ 2013-01-03 23:34 UTC (permalink / raw)
To: Stefan Monnier; +Cc: emacs-devel
Stefan Monnier <monnier@iro.umontreal.ca> writes:
>> Sure, that would also handle the "tell the user what's going on" use
>> case, and we could have a convenience macro `with-current-state-message'
>> that would simply be an `unwind-protect' to clear out the state message.
>
> Yes, the advantage is that the message can be displayed even if we're in
> the middle of uninterruptible Elisp code.
Well, presumably if we can display `current-state-message' in
uninterruptible Elisp code, we could also do the `with-timeout-forms'
things in the uninterruptible Elisp code?
Or is that too difficult?
Anyway, if `current-state-message' is easy to implement, I'm all for
getting that. :-)
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog http://lars.ingebrigtsen.no/
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Proposal for a new mechanism for delayed stuff
2013-01-03 23:34 ` Lars Magne Ingebrigtsen
@ 2013-01-04 1:56 ` Stefan Monnier
0 siblings, 0 replies; 14+ messages in thread
From: Stefan Monnier @ 2013-01-04 1:56 UTC (permalink / raw)
To: Lars Magne Ingebrigtsen; +Cc: emacs-devel
>>> Sure, that would also handle the "tell the user what's going on" use
>>> case, and we could have a convenience macro `with-current-state-message'
>>> that would simply be an `unwind-protect' to clear out the state message.
>> Yes, the advantage is that the message can be displayed even if we're in
>> the middle of uninterruptible Elisp code.
> Well, presumably if we can display `current-state-message' in
> uninterruptible Elisp code, we could also do the `with-timeout-forms'
> things in the uninterruptible Elisp code?
No, because that would mean running arbitrary code in the middle of
"uninterruptible Elisp code", which is contrary to the idea of
"uninterruptible".
> Anyway, if `current-state-message' is easy to implement, I'm all for
> getting that. :-)
I don't know if it is.
Stefan
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2013-01-04 1:56 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-25 13:20 Proposal for a new mechanism for delayed stuff Lars Ingebrigtsen
2012-12-25 13:52 ` Xue Fuqiao
2012-12-25 19:57 ` Karl Fogel
2012-12-26 14:08 ` Ted Zlatanov
2012-12-27 4:08 ` Stephen J. Turnbull
2012-12-27 10:49 ` Achim Gratz
2012-12-27 14:43 ` Stephen J. Turnbull
2012-12-27 9:40 ` Vitalie Spinu
2012-12-27 14:01 ` Lars Ingebrigtsen
2012-12-29 6:30 ` Stefan Monnier
2012-12-31 14:09 ` Lars Magne Ingebrigtsen
2013-01-03 16:47 ` Stefan Monnier
2013-01-03 23:34 ` Lars Magne Ingebrigtsen
2013-01-04 1:56 ` Stefan Monnier
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).