aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2021-06-03 15:57:14 +0300
committerEli Zaretskii2021-06-03 15:57:14 +0300
commit528e15775e1fa52f591681340f9d7772aa38b97e (patch)
treec9af4721b48e76c2de3ab9f72d127d3a5fa7bfa8
parent089e0c4c55dcf72f9cf2f6f04b8a52fc7355499c (diff)
downloademacs-528e15775e1fa52f591681340f9d7772aa38b97e.tar.gz
emacs-528e15775e1fa52f591681340f9d7772aa38b97e.zip
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)
-rw-r--r--lisp/textmodes/flyspell.el27
1 files changed, 20 insertions, 7 deletions
diff --git a/lisp/textmodes/flyspell.el b/lisp/textmodes/flyspell.el
index 8d2715f611c..ba48e5de21a 100644
--- a/lisp/textmodes/flyspell.el
+++ b/lisp/textmodes/flyspell.el
@@ -1263,14 +1263,27 @@ spell-check."
1263 (t 1263 (t
1264 (setq flyspell-word-cache-result nil) 1264 (setq flyspell-word-cache-result nil)
1265 ;; Highlight the location as incorrect, 1265 ;; Highlight the location as incorrect,
1266 ;; including offset specified in POSS. 1266 ;; including offset specified in POSS
1267 ;; and only for the length of the
1268 ;; misspelled word specified by POSS.
1267 (if flyspell-highlight-flag 1269 (if flyspell-highlight-flag
1268 (flyspell-highlight-incorrect-region 1270 (let ((hstart start)
1269 (if (and (consp poss) 1271 (hend end)
1270 (integerp (nth 1 poss))) 1272 offset misspelled)
1271 (+ start (nth 1 poss) -1) 1273 (when (consp poss)
1272 start) 1274 (setq misspelled (car poss)
1273 end poss) 1275 offset (nth 1 poss))
1276 (if (integerp offset)
1277 (setq hstart (+ start offset -1)))
1278 ;; POSS includes the misspelled
1279 ;; word; use that to figure out
1280 ;; how many characters to highlight.
1281 (if (stringp misspelled)
1282 (setq hend
1283 (+ hstart
1284 (length misspelled)))))
1285 (flyspell-highlight-incorrect-region
1286 hstart hend poss))
1274 (flyspell-notify-misspell word poss)) 1287 (flyspell-notify-misspell word poss))
1275 nil)))) 1288 nil))))
1276 ;; return to original location 1289 ;; return to original location