Closed smoeding closed 3 years ago
Thanks for the PR and the explanation. Sounds plausible. Once question before I merge. Do you experience the issue with the GitHub version of guess-language or the version from ELPA? The latter is outdated (need to fix that).
I'm using MELPA. The package is in a directory guess-language-20210131.1100
so I guess it should be a pretty recent version.
Thanks. Will test later and then merge.
Merged, thank you!
Thx for pushing to MELPA!
I experience freezing buffers after switching to
guess-language
. Unfortunately I can't present a simple reproducible example. But I think it might be related to what was discussed in #26.Sometimes loading a file using a mode that enables
guess-language
andflyspell
just hangs. I have to "C-g" and then the buffer appears as it should be. I believe it is caused by some other code (e.g. font-lock) or packages (e.g. yasnippet) in combination with theguess-language
code. Obviously this makes it difficult for you to find the issue.One of the things I tried was replacing the
run-at-time
call withrun-with-idle-timer
. Indeed it seemed to have solved my problem!I tried to find out the difference and someone on the Emacs Help mailing list helped to create an example explaining the difference of these two functions. Run the following code and look at the Messages buffer:
The "running at time" message will appear before the "after redisplay" message while "running at idle time" will appear later.
redisplay
will cause therun-at-time
timer to run!My explanation for my problem: your code currently uses the
run-at-time
function to trigger flycheck. At least one of the packages I use has a call toredisplay
or a similar function which causes the timer to execute the lambda. Unfortunately the buffer or thehunspell
process is not ready at this point and that somehow causes the freeze for me.Switching to
run-with-idle-timer
would only run the timer if Emacs becomes idle (meaning: waiting for user input). As I understand this is what you are trying to do here.