[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#14820: 24.3; elisp manual: How to write good idle timer worker funct
bug#14820: 24.3; elisp manual: How to write good idle timer worker functions?
Thu, 11 Jul 2013 03:31:25 +1200 (NZST)
Stefan Monnier wrote:
> Currently, Emacs doesn't support such "background tasks" well.
> Documentation could help, but I think it's not really worth the
> trouble. Better come up with a package that provides support
> for it.
Well surely you'd agree that writing such a package is going to be
more much difficult without documentation? That is essentially the
problem I ran into here, after all.
At the absolute minimum, that page definitely needs to mention
`sit-for' / "(elisp) Waiting" and `accept-process-output' /
"(elisp) Accepting Output". After all, when specific pit-falls
are mentioned, I think that the available facilities for working
around them warrant at least a passing mention.
(Honestly, the merest mention of these two functions after the
description of the problems of blocking other timers and processes
would have saved me many hours, so it's worth it just for the
potential to save someone else from being similarly stumped. I'd
simply never had cause to use them before, so it wasn't *at all*
obvious where to look.)
Having found my way to the latter, and run some experiments with
generating output from a shell while running my idle timer code,
I've managed to answer my own question about `sit-for' (which is
that it does not solve the problem of accepting process output), but
determined that (unsurprisingly) calling `(accept-process-output)'
does provide a solution, so I believe I'm on my way to resolving my
I do still think that if there were some nice easy-to-use wrappers
around the functionality that Emacs *does* provide, we could say
something a little more positive about the situation -- that
*despite* not supporting "background tasks" well, Emacs makes
it easy to fake them!
> IIRC someone posted some packages that try to provide support
> for related issues, but I can't find the corresponding email.
Ah, that's a shame; but thank you for looking. Maybe someone
else remembers what those were?
Failing that, if I end up with something that seems useful and
generic, I'll submit it for consideration.
p.s. Although I *think* I now know what I'm doing here, I don't
want to close this issue just yet. I'm very interested in any and
all comments on this subject, if any other people wish to chip in
with their thoughts?