emacs-diffs
[Top][All Lists]
Advanced

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

master 528e157: More accurate highlighting of mis-spellings in Flyspell


From: Eli Zaretskii
Subject: master 528e157: More accurate highlighting of mis-spellings in Flyspell
Date: Thu, 3 Jun 2021 08:58:23 -0400 (EDT)

branch: master
commit 528e15775e1fa52f591681340f9d7772aa38b97e
Author: Eli Zaretskii <eliz@gnu.org>
Commit: Eli Zaretskii <eliz@gnu.org>

    More accurate highlighting of mis-spellings in Flyspell
    
    * lisp/textmodes/flyspell.el (flyspell-word): Highlight only the
    misspelled word, not any extra characters after it.  (Bug#5575)
---
 lisp/textmodes/flyspell.el | 27 ++++++++++++++++++++-------
 1 file changed, 20 insertions(+), 7 deletions(-)

diff --git a/lisp/textmodes/flyspell.el b/lisp/textmodes/flyspell.el
index 8d2715f..ba48e5d 100644
--- a/lisp/textmodes/flyspell.el
+++ b/lisp/textmodes/flyspell.el
@@ -1263,14 +1263,27 @@ spell-check."
                             (t
                              (setq flyspell-word-cache-result nil)
                              ;; Highlight the location as incorrect,
-                             ;; including offset specified in POSS.
+                             ;; including offset specified in POSS
+                             ;; and only for the length of the
+                             ;; misspelled word specified by POSS.
                              (if flyspell-highlight-flag
-                                 (flyspell-highlight-incorrect-region
-                                  (if (and (consp poss)
-                                           (integerp (nth 1 poss)))
-                                      (+ start (nth 1 poss) -1)
-                                    start)
-                                  end poss)
+                                  (let ((hstart start)
+                                        (hend end)
+                                        offset misspelled)
+                                    (when (consp poss)
+                                      (setq misspelled (car poss)
+                                            offset (nth 1 poss))
+                                      (if (integerp offset)
+                                          (setq hstart (+ start offset -1)))
+                                      ;; POSS includes the misspelled
+                                      ;; word; use that to figure out
+                                      ;; how many characters to highlight.
+                                      (if (stringp misspelled)
+                                          (setq hend
+                                                (+ hstart
+                                                   (length misspelled)))))
+                                   (flyspell-highlight-incorrect-region
+                                     hstart hend poss))
                                (flyspell-notify-misspell word poss))
                              nil))))
              ;; return to original location



reply via email to

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