My reputation is not sufficient to "Add a comment", so writing in a full answer...
This is a copy-paste from ideasman42 for reference answer with flyspell-visible--overlay-refresh-from-timer
function wrapped into with-local-quit
macro. It should solve Blocking call to accept-process-output with quit inhibited!!
messages problem.
Also, I replaced (flyspell-region sta end)
invocation with (let ((flyspell-issue-message-flag nil)) (flyspell-small-region start end))
:
(defvar-local flyspell-visible-last-window-range nil)
(defun flyspell-visible--overlay-refresh-from-timer ()
(with-local-quit
(when (equal flyspell-visible--delay-buffer (current-buffer))
(let* ((start (window-start))
(end (window-end))
(range (list start end)))
(when (not (equal range flyspell-visible-last-window-range))
(setq inhibit-redisplay t)
(let ((flyspell-issue-message-flag nil))
(flyspell-small-region start end))
(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 ()
(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))
Another small improvement could be adding flyspell
derived mode that runs flyspell-visible--delay-timer
by default:
(define-minor-mode flyspell-visible-mode
"Flyspell visible mode."
:lighter " FlyV"
:parent flyspell-mode
(if flyspell-visible-mode
(progn
(flyspell-mode 1)
(flyspell-visible-turn-on)
(message "Flyspell visible mode enabled"))
(flyspell-mode -1)
(flyspell-visible-turn-on)
(message "Flyspell visible mode disabled")))
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+.Blocking call to accept-process-output with quit inhibited!!
messages).flyspell-mode
?