Hello everyone :-)
When ‘delete-selection-mode’ and ‘transient-mark-mode’ are enabled,
there’s an active region and I type a character, the region is
immediately deactivated. In Flyspell mode, though, the unhighlighting
of the deactivated region is delayed by the function
‘flyspell-check-word-p’. The region is deactivated but the overlay is
not updated to reflect that.
If I understand correctly the delay (indicated by ‘<---’ below) is
used by Flyspell to give the user some time for typing before
highlighting a word as mispelled, but in this case it ends up
delaying also the refresh of the region overlay.
(defun flyspell-check-word-p ()
"Return t when the word at `point' has to be checked.
The answer depends of several criteria.
Mostly we check word delimiters."
(let ((ispell-otherchars (ispell-get-otherchars)))
(cond
((<= (- (point-max) 1) (point-min))
;; The buffer is not filled enough.
nil)
((and (and (> (current-column) 0)
(not (eq (current-column) flyspell-pre-column)))
(save-excursion
(backward-char 1)
(and (looking-at (flyspell-get-not-casechars))
(or (string= "" ispell-otherchars)
(not (looking-at ispell-otherchars)))
(or flyspell-consider-dash-as-word-delimiter-flag
(not (looking-at "-"))))))
;; Yes because we have reached or typed a word delimiter.
t)
((symbolp this-command)
(cond
((get this-command 'flyspell-deplacement)
(not (eq flyspell-previous-command this-command)))
((get this-command 'flyspell-delayed)
;; The current command is not delayed, that
;; is that we must check the word now.
(and (not unread-command-events)
(sit-for flyspell-delay))) ; <---
(t t)))
(t t))))