Subject: Re: 23.0.60; flyspell checking is sometimes silently disabled

From: Markus Triska <[email-masked]>
Date: Thu, 21 Aug 2008 22:15:57 -0400

Chong Yidong <[email-masked]> writes:

> Have you found a way to track down the problem causing this bug?

I have set debug-on-error to t, so the next time I see this problem, I
hope to catch which function raises the error. I already know that it is
either preview-move-point (from AUCTeX) or flyspell-post-command-hook.

Thus, especially if an AUCTeX user reads this: If you want to help to
debug this problem, please add the following to your .emacs:

   (defun my-flyspell-check ()
     (when flyspell-mode
       (unless (memq 'flyspell-post-command-hook post-command-hook)
         (with-current-buffer (get-buffer-create "flywarn")
           (insert "flychecking inactive despite flyspell-mode!\n"))
         (display-buffer  "flywarn"))))

   (setq flycheck-timer (run-with-timer 0 0.5 'my-flyspell-check))

and it will warn you when Flyspell is no longer really active.

Also, as I mentioned: I find it fair enough that Flyspell is disabled
when there are errors; I only wish that there were a general mechanism
to disable it in a cleaner way in case of errors, i.e., existing
underlines should be removed, the mode line should reflect that it is no
longer active etc. In short, when flyspell-post-command-hook must be
removed from post-command-hook, also (flyspell-mode 0) or anything
equivalent should be done. Analogously for some other modes (linum.el is
another example, where errors in a custom linum-format function should
make Emacs disable the minor mode completely, thus removing it from
other hooks as well).