[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/guess-language bee93967f6 29/35: Use post-command-hook
From: |
ELPA Syncer |
Subject: |
[elpa] externals/guess-language bee93967f6 29/35: Use post-command-hook to trigger flyspell |
Date: |
Tue, 28 May 2024 18:58:25 -0400 (EDT) |
branch: externals/guess-language
commit bee93967f6f3858811370e6f979600bba9572f07
Author: Miha Rihtaršič <miha@kamnitnik.top>
Commit: Miha Rihtaršič <miha@kamnitnik.top>
Use post-command-hook to trigger flyspell
---
guess-language.el | 30 ++++++++++++++++++++++--------
1 file changed, 22 insertions(+), 8 deletions(-)
diff --git a/guess-language.el b/guess-language.el
index 0fecc2a507..ff7b05b48a 100644
--- a/guess-language.el
+++ b/guess-language.el
@@ -138,6 +138,9 @@ By default it's the same directory where this module is
installed."
Uses ISO 639-1 to identify languages.")
(make-variable-buffer-local 'guess-language-current-language)
+(defvar-local guess-language--post-command-h #'ignore
+ "Function called by `guess-language--post-command-h'.")
+
(defun guess-language-load-trigrams ()
"Load language statistics."
(cl-loop
@@ -232,6 +235,13 @@ provides three arguments that we don't need."
;; words:
nil)
+(defun guess-language--post-command-h ()
+ "The `post-command-hook' used by guess-language.
+
+Used by `guess-language-switch-flyspell-function' to recheck the
+spelling of the current paragraph after switching dictionary."
+ (funcall guess-language--post-command-h))
+
(defun guess-language-switch-flyspell-function (lang beginning end)
"Switch the Flyspell dictionary and recheck the current paragraph.
@@ -249,14 +259,15 @@ which LANG was detected."
;; from flyspell-incorrect-hook that called us. Otherwise, the
;; word at point is highlighted as incorrect even if it is
;; correct according to the new dictionary.
- (run-with-idle-timer 0 nil
- (lambda ()
- (let ((flyspell-issue-welcome-flag nil)
- (flyspell-issue-message-flag nil)
- (flyspell-incorrect-hook nil)
- (flyspell-large-region 1))
- (with-local-quit
- (flyspell-region beginning end))))))))
+ (setq guess-language--post-command-h
+ (lambda ()
+ (setq guess-language--post-command-h #'ignore)
+ (let ((flyspell-issue-welcome-flag nil)
+ (flyspell-issue-message-flag nil)
+ (flyspell-incorrect-hook nil)
+ (flyspell-large-region 1))
+ (with-local-quit
+ (flyspell-region beginning end))))))))
(defun guess-language-switch-typo-mode-function (lang _beginning _end)
"Switch the language used by typo-mode.
@@ -299,8 +310,11 @@ correctly."
(if guess-language-mode
(progn
(add-hook 'flyspell-incorrect-hook #'guess-language-function nil t)
+ ;; Depth of 92 to ensure placement after flyspell's PCH
+ (add-hook 'post-command-hook #'guess-language--post-command-h 92 t)
(advice-add 'flyspell-buffer :around
#'guess-language-flyspell-buffer-wrapper))
(remove-hook 'flyspell-incorrect-hook #'guess-language-function t)
+ (remove-hook 'post-command-hook #'guess-language--post-command-h t)
(advice-remove 'flyspell-buffer #'guess-language-flyspell-buffer-wrapper)))
(defun guess-language-mark-lines (&optional highlight)
- [elpa] externals/guess-language 867f13b3a5 05/35: Merge pull request #27 from andersjohansson/regexp-opt, (continued)
- [elpa] externals/guess-language 867f13b3a5 05/35: Merge pull request #27 from andersjohansson/regexp-opt, ELPA Syncer, 2024/05/28
- [elpa] externals/guess-language 6aa88cf267 16/35: README: Section on changing thesaurus language, ELPA Syncer, 2024/05/28
- [elpa] externals/guess-language bbafdeaf38 07/35: Added Serbian, ELPA Syncer, 2024/05/28
- [elpa] externals/guess-language cb4f2043e3 08/35: Added explanation of how to add new languages, ELPA Syncer, 2024/05/28
- [elpa] externals/guess-language 166618eb79 18/35: Add Esperanto language support, ELPA Syncer, 2024/05/28
- [elpa] externals/guess-language d532e6217c 19/35: Merge pull request #31 from hendursaga/eo-support, ELPA Syncer, 2024/05/28
- [elpa] externals/guess-language 699aa8e44f 20/35: README: minor fixes, ELPA Syncer, 2024/05/28
- [elpa] externals/guess-language 836018bd30 24/35: Use idle-timer to trigger flyspell, ELPA Syncer, 2024/05/28
- [elpa] externals/guess-language e423be90a4 23/35: README: markup once again, ELPA Syncer, 2024/05/28
- [elpa] externals/guess-language 2dfff77173 27/35: Add more documents about Vietnamese support., ELPA Syncer, 2024/05/28
- [elpa] externals/guess-language bee93967f6 29/35: Use post-command-hook to trigger flyspell,
ELPA Syncer <=
- [elpa] externals/guess-language e6b78ed2a3 30/35: Merge pull request #35 from jakanakaevangeli/PCH, ELPA Syncer, 2024/05/28
- [elpa] externals/guess-language 5e46229daa 09/35: Add Serbian Latin trigram., ELPA Syncer, 2024/05/28
- [elpa] externals/guess-language e743b14281 04/35: Use destructuring in cl-loop variable assignments, ELPA Syncer, 2024/05/28
- [elpa] externals/guess-language d69f811de1 12/35: README: Add Serbian Latin, ELPA Syncer, 2024/05/28
- [elpa] externals/guess-language 987561e185 13/35: README: Added a note on Latin Serbian, ELPA Syncer, 2024/05/28
- [elpa] externals/guess-language 5bff301337 03/35: Use regexp-opt for compiling regexps, ELPA Syncer, 2024/05/28
- [elpa] externals/guess-language f4ce91eba3 06/35: Merge pull request #28 from andersjohansson/cl-loop-destructuring, ELPA Syncer, 2024/05/28
- [elpa] externals/guess-language afbc3456eb 17/35: Minor documentation fixes, ELPA Syncer, 2024/05/28
- [elpa] externals/guess-language e7decda098 25/35: Merge pull request #32 from smoeding/feature/fix-timer, ELPA Syncer, 2024/05/28
- [elpa] externals/guess-language 82b5cb598e 32/35: resolve merge conflict, ELPA Syncer, 2024/05/28