Closed jakanakaevangeli closed 3 years ago
Ah, that's where all these aspell processes are coming from.
the problem was an idle timer from guess-language, accidentally hijacking itself into ispell's sit-for.
I'm afraid I don't understand the internals of ispell enough to work with this description. Do you by any chance have an idea of what needs to be fixed?
How about something like the following patch. The idea is that post-command-hook is more predictable and well behaved than an idle timer, which can fire during any call to sit-for.
diff --git a/guess-language.el b/guess-language.el
index 0fecc2a..d390e42 100644
--- a/guess-language.el
+++ b/guess-language.el
@@ -232,6 +232,8 @@ (defun guess-language-function (_beginning _end _doublon)
;; words:
nil)
+(defalias 'guess-language--post-command-h #'ignore)
+
(defun guess-language-switch-flyspell-function (lang beginning end)
"Switch the Flyspell dictionary and recheck the current paragraph.
@@ -249,14 +251,15 @@ (defun guess-language-switch-flyspell-function (lang beginning end)
;; from flyspell-incorrect-hook that called us. Otherwise, the
;; word at point is highlighted as incorrect even if it is
;; correct according to the new dictionary.
- (run-with-idle-timer 0 nil
- (lambda ()
- (let ((flyspell-issue-welcome-flag nil)
- (flyspell-issue-message-flag nil)
- (flyspell-incorrect-hook nil)
- (flyspell-large-region 1))
- (with-local-quit
- (flyspell-region beginning end))))))))
+ (fset 'guess-language--post-command-h
+ (lambda ()
+ (fset 'guess-language--post-command-h #'ignore)
+ (let ((flyspell-issue-welcome-flag nil)
+ (flyspell-issue-message-flag nil)
+ (flyspell-incorrect-hook nil)
+ (flyspell-large-region 1))
+ (with-local-quit
+ (flyspell-region beginning end))))))))
(defun guess-language-switch-typo-mode-function (lang _beginning _end)
"Switch the language used by typo-mode.
@@ -299,8 +302,10 @@ (define-minor-mode guess-language-mode
(if guess-language-mode
(progn
(add-hook 'flyspell-incorrect-hook #'guess-language-function nil t)
+ (add-hook 'post-command-hook #'guess-language--post-command-h 'append t)
(advice-add 'flyspell-buffer :around #'guess-language-flyspell-buffer-wrapper))
(remove-hook 'flyspell-incorrect-hook #'guess-language-function t)
+ (remove-hook 'post-command-hook #'guess-language--post-command-h t)
(advice-remove 'flyspell-buffer #'guess-language-flyspell-buffer-wrapper)))
(defun guess-language-mark-lines (&optional highlight)
Edit: with-local-quit
is required after all.
Emacs -Q:
Each
M-x magit-commit-create
will leave an extra aspell process. (A bit more info can be found on http://debbugs.gnu.org/cgi/bugreport.cgi?bug=48379 )