From: Eshel Yaron Date: Tue, 19 Nov 2024 18:43:09 +0000 (+0100) Subject: flyspell.el: block less X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=1c32a3ce0cbeb89458a7ca83c20f36b3b416db1a;p=emacs.git flyspell.el: block less --- diff --git a/lisp/textmodes/flyspell.el b/lisp/textmodes/flyspell.el index 7bf9cb1ae9d..2d9fe432e0a 100644 --- a/lisp/textmodes/flyspell.el +++ b/lisp/textmodes/flyspell.el @@ -810,6 +810,13 @@ Mostly we check word delimiters." (let ((pos (point))) (or (>= pos start) (<= pos stop) (= pos (1+ stop)))))))) +(defcustom flyspell-blocking-delay nil + "Whether to block Emacs while Flyspell waits after a delayed command." + :type 'boolean + :version "30.1") + +(defvar flyspell--timer nil) + ;;*---------------------------------------------------------------------*/ ;;* flyspell-check-word-p ... */ ;;*---------------------------------------------------------------------*/ @@ -844,7 +851,15 @@ Mostly we check word delimiters." ;; The current command is not delayed, that ;; is that we must check the word now. (and (not unread-command-events) - (sit-for flyspell-delay))) + (if flyspell-blocking-delay + (sit-for flyspell-delay) + (setq flyspell--timer + (run-with-idle-timer + flyspell-delay nil + (lambda (buffer) + (when (eq (current-buffer) buffer) (flyspell-word))) + (current-buffer))) + nil))) (t t))) (t t)))) @@ -955,6 +970,7 @@ Mostly we check word delimiters." (defun flyspell-post-command-hook () "The `post-command-hook' used by flyspell to check a word on-the-fly." (interactive) + (when (timerp flyspell--timer) (cl-callf cancel-timer flyspell--timer)) (when flyspell-mode (with-local-quit (let ((command this-command) @@ -1179,7 +1195,7 @@ spell-check." (set-process-query-on-exit-flag ispell-process nil) ;; Wait until ispell has processed word. (while (progn - (accept-process-output ispell-process) + (accept-process-output ispell-process 1) (not (string= "" (car ispell-filter))))) ;; (ispell-send-string "!\n") ;; back to terse mode.