For reference: The example below runs the spell checker on a timer, however it gives many messages:
Blocking call to accept-process-output with quit inhibited!!
.. Which I worked around by temporarily disabling logging, however this is far from ideal.
On the other hand, in practice I've found this to be usable.
(defvar-local flyspell-visible-last-window-range nil)
(defun flyspell-visible--overlay-refresh-from-timer ()
(when (equal flyspell-visible--delay-buffer (current-buffer))
(let*
(
(sta (window-start))
(end (window-end))
(range (list sta end))
)
(when (not (equal range flyspell-visible-last-window-range))
(setq inhibit-redisplay t)
(let
((log-max message-log-max))
;; don't log
(setq message-log-max nil)
(flyspell-region sta end)
(setq message-log-max log-max)
(message nil)
)
(setq-local flyspell-visible-last-window-range range)
(setq inhibit-redisplay nil)
)
)
)
)
;; Timer
(defvar flyspell-visible--delay-timer nil)
(defvar flyspell-visible--delay-buffer nil)
(defun flyspell-visible-turn-on ()
"Enable spell checking on a timer"
(when (timerp flyspell-visible--delay-timer)
(cancel-timer flyspell-visible--delay-timer))
;; Delay for spelling - should be ok, only runs when scroll changes.
(setq flyspell-visible--delay-buffer (current-buffer))
(setq flyspell-visible--delay-timer
(run-with-idle-timer 1.0 t 'flyspell-visible--overlay-refresh-from-timer))
)
(defun flyspell-visible-turn-off ()
(when (timerp flyspell-visible--delay-timer)
(cancel-timer flyspell-visible--delay-timer))
(setq flyspell-visible--delay-timer nil)
(setq flyspell-visible--delay-buffer nil)
(setq flyspell-visible-last-window-range nil)
)
window-scroll-functions
hook because there are exceptions, which took me quite a bit of time to finally semi-understand [after pestering Eli and Stefan with a few bug reports ...]; and, I combined it with thepost-command-hook
to try and come up with something for all situations .... Eventually, I took the plunge and started learning C and am now pestering Eli and Stefan on the Emacs devel mailing list instead ... :) To see how this can work in Lisp, have a look at thelinum.el
library that has been deprecated in favor of built-in line number in Emacs 26+. – lawlist May 24 '19 at 0:19Blocking call to accept-process-output with quit inhibited!!
messages). – ideasman42 May 24 '19 at 3:00flyspell-mode
? – scribe Jun 21 '20 at 22:13