emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/guess-language 9a49c94 08/10: Make the word under point


From: Stefan Monnier
Subject: [elpa] externals/guess-language 9a49c94 08/10: Make the word under point correctly highlighted after change of dictionary
Date: Wed, 17 Apr 2019 08:12:40 -0400 (EDT)

branch: externals/guess-language
commit 9a49c94cfd095a97e9b96c19f3c254a59600d454
Author: Michal Sojka <address@hidden>
Commit: Michal Sojka <address@hidden>

    Make the word under point correctly highlighted after change of dictionary
    
    When the dictionary is switched as a result of detecting different
    language, the word under point remains highlighted as
    incorrect (according to the previously used dictionary) until the word
    is flyspelled again, for example by moving the point out of the word
    and back. This is annoying.
    
    This commit fixes that by ensuring that flyspelling the current
    paragraph with the new dictionary happens after the return from
    flyspell-incorrect-hook, which highlights the word under point
    according to the old dictionary.
---
 guess-language.el | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/guess-language.el b/guess-language.el
index b42b71e..3f79e62 100644
--- a/guess-language.el
+++ b/guess-language.el
@@ -240,11 +240,17 @@ which LANG was detected."
          (new-dictionary (cadr (assq lang guess-language-langcodes))))
     (unless (string= old-dictionary new-dictionary)
       (ispell-change-dictionary new-dictionary)
-      (let ((flyspell-issue-welcome-flag nil)
-            (flyspell-issue-message-flag nil)
-            (flyspell-incorrect-hook nil)
-            (flyspell-large-region 1))
-        (flyspell-region beginning end)))))
+      ;; Flyspell the region with the new dictionary after we return
+      ;; 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-at-time 0 nil
+                   (lambda ()
+                     (let ((flyspell-issue-welcome-flag nil)
+                           (flyspell-issue-message-flag nil)
+                           (flyspell-incorrect-hook nil)
+                           (flyspell-large-region 1))
+                       (flyspell-region beginning end)))))))
 
 (defun guess-language-switch-typo-mode-function (lang _beginning _end)
   "Switch the language used by typo-mode.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]