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

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

[elpa] externals/guess-language ec7c0f6 07/10: Make guess-language-backw


From: Stefan Monnier
Subject: [elpa] externals/guess-language ec7c0f6 07/10: Make guess-language-backward-paragraph always go to word boundary
Date: Wed, 17 Apr 2019 08:12:40 -0400 (EDT)

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

    Make guess-language-backward-paragraph always go to word boundary
    
    This fixes the problem of marking the last word from previous
    paragraph as incorrect if the current paragraph is in different
    language.
    
    This is caused by the following: When a change of language is
    detected, the whole paragraph is flyspelled by calling flyspell-region
    on the paragraph. guess-language-backward-paragraph finds the start of
    the paragraph to check and in many cases (e.g. in text-mode), the
    found point is on the empty line separating two paragraphs.
    flyspell-region start spelling from that point by calling
    flyspell-word. This function checks the word under the point or if the
    point is in between words, the previous word. Since the start of the
    paragraph is between words, the last word of the previous paragraph is
    checked against dictionary of current paragraph.
    
    This is fixed by ensuring that guess-language-backward-paragraph
    always goes to the first non-whitespace character of the paragraph.
    This causes flyspell-word to check the first word in the paragraph and
    not that last word on the previous paragraph.
---
 guess-language.el | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/guess-language.el b/guess-language.el
index ae68069..b42b71e 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



reply via email to

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