From: "Stefan Möding" <s.moeding@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: run-with-idle-timer vs. run-at-time
Date: Mon, 15 Feb 2021 20:12:09 +0100 [thread overview]
Message-ID: <m24kid87sm.fsf@athena.moeding.net> (raw)
Hi!
I'm trying to understand the difference between these two timers:
(run-with-idle-timer 0 nil (lambda () (...)))
(run-at-time 0 nil (lambda () (...)))
I suspect there is a difference (see below) but I'm unable to come up with
an example where it actually makes a difference. Does anybody have an idea
what condition could cause a different behavior?
I can see from the documentation that `run-with-idle-timer' runs when
Emacs is waiting for input. But that also seems to be the case for
`run-at-time'. Is there a way that `run-at-time' might run at a time
(earlier) when `run-with-idle-timer' would not?
Background:
I'm trying to use the `guess-language' package from MELPA (also see
https://github.com/tmalsburg/guess-language.el). The package integrates
with flyspell to guess the language of the current paragraph and set the
spelling dictionary according to the language. The package maintainer has
implemented this asynchronously using the `run-at-time` function as
illustrated above.
In my setup certain buffers now cause a freeze and I have to C-g to get
back to work. It's reproducible but due to my setup it's too complicated
to expect the package author to have a look (e.g. using
`gnus-dired-attach' to create a message buffer to send a file as
attachment will cause the freeze; flyspell is enabled for message-mode).
I suspect the timer triggers the code to early and Emacs hangs while
trying to talk to the `hunspell' process.
There doesn't seem to be any more blocking if I replace `run-at-time` with
`run-with-idle-timer' in the package code. So there seems to be
a difference. Now I'm trying to come up with an example that might help
the package maintainer to understand why `run-with-idle-timer' might be
a better alternative (if it is that way).
Thanks for any pointers!
--
Stefan
next reply other threads:[~2021-02-15 19:12 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-15 19:12 Stefan Möding [this message]
2021-02-15 19:33 ` run-with-idle-timer vs. run-at-time Óscar Fuentes
2021-02-16 6:50 ` Stefan Möding
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m24kid87sm.fsf@athena.moeding.net \
--to=s.moeding@gmail.com \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).