[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/spell-fu 103d3a19ce 49/86: Fix checking words that spanned
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/spell-fu 103d3a19ce 49/86: Fix checking words that spanned different faces |
Date: |
Thu, 7 Jul 2022 12:03:42 -0400 (EDT) |
branch: elpa/spell-fu
commit 103d3a19ce4190f4171d449d018a513a15112260
Author: Campbell Barton <ideasman42@gmail.com>
Commit: Campbell Barton <ideasman42@gmail.com>
Fix checking words that spanned different faces
---
changelog.rst | 3 +++
spell-fu.el | 41 +++++++++++++++++++++++++++--------------
2 files changed, 30 insertions(+), 14 deletions(-)
diff --git a/changelog.rst b/changelog.rst
index f0e50bb759..07252c50cd 100644
--- a/changelog.rst
+++ b/changelog.rst
@@ -4,7 +4,10 @@ Change Log
##########
- In development.
+ - Changes to the face are now treated as word separators.
+ This fixes spell checking in situations where characters are escaped for
example ``"test\nterm"``,
+ will use the ``\n`` as a divider when escape characters use a different
face.
- ``global-spell-fu-mode`` no longer enables spell-fu for modes derived from
``special-mode``
such as package list for example (fixes ``#15``).
- Support conditionally disabling ``global-spell-fu-mode`` via
diff --git a/spell-fu.el b/spell-fu.el
index 8100e231cf..da1c2d6006 100644
--- a/spell-fu.el
+++ b/spell-fu.el
@@ -592,20 +592,33 @@ Argument FACES-EXCLUDE faces to check POS excludes or
ignored when nil."
"Check spelling for POINT-START & POINT-END, checking text matching face
rules."
(spell-fu--remove-overlays point-start point-end)
(with-syntax-table spell-fu-syntax-table
- (save-match-data
- (save-excursion
- (goto-char point-start)
- (while (re-search-forward spell-fu-word-regexp point-end t)
- (let
- (
- (word-start (match-beginning 0))
- (word-end (match-end 0)))
- (when
- (spell-fu--check-faces-at-point
- word-start
- spell-fu-faces-include
- spell-fu-faces-exclude)
- (spell-fu-check-word word-start word-end
(match-string-no-properties 0)))))))))
+ (save-match-data ;; For regex search.
+ (save-excursion ;; For moving the point.
+ (save-restriction ;; For narrowing.
+ ;; It's possible the face changes part way through the word.
+ ;; In practice this is likely caused by escape characters, e.g.
+ ;; "test\nthe text" where "\n" may have separate highlighting.
+ (while (< point-start point-end)
+ (let ((point-end-iter (next-single-property-change point-start
'face nil point-end)))
+ ;; Use narrowing so the regex correctly handles boundaries
+ ;; that happen to fall on face changes.
+ (narrow-to-region point-start point-end-iter)
+ (goto-char point-start)
+ (while (re-search-forward spell-fu-word-regexp point-end-iter t)
+ (let
+ (
+ (word-start (match-beginning 0))
+ (word-end (match-end 0)))
+ (when
+ (spell-fu--check-faces-at-point
+ word-start
+ spell-fu-faces-include
+ spell-fu-faces-exclude)
+ (spell-fu-check-word
+ word-start
+ word-end
+ (buffer-substring-no-properties word-start word-end)))))
+ (setq point-start point-end-iter))))))))
(defun spell-fu--check-range-without-faces (point-start point-end)
"Check spelling for POINT-START & POINT-END, checking all text."
- [nongnu] elpa/spell-fu b7e5cf3d73 11/86: Fix missing checks that ispell variables are bound before use, (continued)
- [nongnu] elpa/spell-fu b7e5cf3d73 11/86: Fix missing checks that ispell variables are bound before use, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 30be3683b2 12/86: readme: update settings docs, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 18724c2e53 14/86: Avoid potentially accessing the same files time multiple times, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 8e8711f1fa 22/86: Add TODO's to the readme, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 88d803e994 26/86: Cleanup: use updated auto-formatting results, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu db0eef27ab 33/86: Add: spell-fu-goto-next-error, spell-fu-goto-previous-error, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu a7db587471 36/86: Remove redundant escaping, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu c58be13845 39/86: Fix #3 default word regex now excludes trailing apostrophes, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 98424adbea 42/86: adds helper routine to get lang from dict, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 143233734a 46/86: Allow global-spell-fu to be ignored per mode or using a function, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 103d3a19ce 49/86: Fix checking words that spanned different faces,
ELPA Syncer <=
- [nongnu] elpa/spell-fu 1c0424b4c9 55/86: Cleanup: minor tweak to docstring, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu fd27978614 57/86: Update readme.rst, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu a7879fe9e7 59/86: Cleanup: over-wide docstrings, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu a2a0e3b786 60/86: Cleanup: remove redundant group properties, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 570ccd84ed 64/86: Fix spell-fu-goto-{next/prev}-error silently failing, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu b2da2874f3 67/86: Cleanup: use shorter variable names, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 00af362af3 71/86: Add multiple dictionary support, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 2ba65de269 74/86: Cleanup: include all arguments in doc-strings, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 4782667d7b 76/86: Fail gracefully with a message when aspell can't be found, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 3a19836c69 78/86: Cleanup: use brief SPDX license, ELPA Syncer, 2022/07/07