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

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

[elpa] externals/guess-language e64d88f 09/10: Merge pull request #25 fr


From: Stefan Monnier
Subject: [elpa] externals/guess-language e64d88f 09/10: Merge pull request #25 from wentasah/fixes
Date: Wed, 17 Apr 2019 08:12:41 -0400 (EDT)

branch: externals/guess-language
commit e64d88f287a547198e4c96e2fff543e103f2b456
Merge: 09e1a41 9a49c94
Author: Titus von der Malsburg <address@hidden>
Commit: GitHub <address@hidden>

    Merge pull request #25 from wentasah/fixes
    
    Fix incorrect highlighting of otherwise correct words when switching 
dictionary
---
 guess-language.el | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/guess-language.el b/guess-language.el
index ae68069..3f79e62 100644
--- a/guess-language.el
+++ b/guess-language.el
@@ -159,7 +159,9 @@ most appropriate given the buffer mode."
       (if (org-in-item-p) 
           (org-beginning-of-item-list)
         (org-backward-paragraph))
-    (backward-paragraph)))
+    (backward-paragraph)
+    (when (looking-at-p "[[:space:]]")
+      (forward-whitespace 1))))
 
 (defun guess-language-forward-paragraph ()
   "Uses whatever method for moving to the next paragraph is
@@ -238,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]