[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/spell-fu 41a133d119 52/86: Fix #16: Fails to spellcheck wh
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/spell-fu 41a133d119 52/86: Fix #16: Fails to spellcheck when whitespace-mode splits a word |
Date: |
Thu, 7 Jul 2022 12:03:43 -0400 (EDT) |
branch: elpa/spell-fu
commit 41a133d1195bd9b8a1523fb2de7c4d46ecc4565f
Author: Campbell Barton <ideasman42@gmail.com>
Commit: Campbell Barton <ideasman42@gmail.com>
Fix #16: Fails to spellcheck when whitespace-mode splits a word
Faces no longer split words when neither face is ignored.
---
spell-fu.el | 76 ++++++++++++++++++++++++++++++++++++++++++-------------------
1 file changed, 52 insertions(+), 24 deletions(-)
diff --git a/spell-fu.el b/spell-fu.el
index c9719fefd3..7b52c21dfa 100644
--- a/spell-fu.el
+++ b/spell-fu.el
@@ -600,30 +600,58 @@ Argument POINT-END the end position of WORD."
(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 (spell-fu--next-faces-prop-change
point-start point-end)))
- ;; No need to check faces of each word
- ;; as face-changes are being stepped over.
- (when (spell-fu--check-faces-at-point point-start)
- ;; 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)))
- (spell-fu-check-word
- word-start
- word-end
- (buffer-substring-no-properties word-start word-end))))
- (widen))
-
- (setq point-start point-end-iter))))))))
+ ;; Avoid duplicate calls that check if `point-start' passes the face
test.
+ (let ((ok-start (spell-fu--check-faces-at-point point-start)))
+ ;; 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*
+ ( ;; Assign to `ok-start' next iteration to avoid duplicate
checks.
+ (point-end-iter (spell-fu--next-faces-prop-change
point-start point-end))
+ (ok-end-iter
+ (and
+ (< point-end-iter point-end)
+ (spell-fu--check-faces-at-point point-end-iter))))
+
+ ;; No need to check faces of each word
+ ;; as face-changes are being stepped over.
+ (when ok-start
+
+ ;; Extend `point-end-iter' out for as long as the face isn't
being ignored,
+ ;; needed when `whitespace-mode' sets a margin,
+ ;; splitting words in this case isn't desirable, see: #16.
+ ;;
+ ;; This may also have some advantage
+ ;; in reducing the number of narrowing calls.
+ ;;
+ ;; NOTE: this could be made into an option.
+ ;; Currently there doesn't seem much need for this at the
moment.
+ (while ok-end-iter
+ (setq point-end-iter
+ (spell-fu--next-faces-prop-change point-end-iter
point-end))
+ (setq ok-end-iter
+ (and
+ (< point-end-iter point-end)
+ (spell-fu--check-faces-at-point point-end-iter))))
+
+ ;; 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)))
+ (spell-fu-check-word
+ word-start
+ word-end
+ (buffer-substring-no-properties word-start word-end))))
+ (widen))
+
+ (setq point-start point-end-iter)
+ (setq ok-start ok-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 1f3e5b8f05 72/86: readme: Fix typos, (continued)
- [nongnu] elpa/spell-fu 1f3e5b8f05 72/86: readme: Fix typos, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 2f2fd6de00 83/86: Change URL to codeberg, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 00b75e5741 25/86: Cleanup: docstring, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 1bc18879b6 27/86: Add license file, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu d0700095ea 28/86: Add header to cache loading & error checking for cache content, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu f6c849f860 30/86: Fix disabling spell-fu when used without a timer, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 502d523b46 31/86: Fix unintended modification of the standard syntax table, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu e62cfc4f08 34/86: Add support for personal dictionary management, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 86d46cf63e 37/86: fix: encode word to utf8, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 9180a77865 48/86: Fix #15: don't enable (when used globally) for application buffers, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 41a133d119 52/86: Fix #16: Fails to spellcheck when whitespace-mode splits a word,
ELPA Syncer <=
- [nongnu] elpa/spell-fu 7c2542e109 73/86: Merge branch 'multiple-dictionaries' into 'master', ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 50be652a6e 77/86: Fix overlay faces masking other faces (when checking faces-at-point), ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu cbe5cd84c3 86/86: Correct URL, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 41a7ebcbab 23/86: Cleanup: replace cl-letf with advice macro, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 251e63eacc 29/86: readme: update, clarify TODO, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu ad139f6fac 40/86: Cleanup: quiet checkdoc warning, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 2caa9fc6f0 44/86: Update changelog, ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu f38bebefea 62/86: Cleanup: replace 'if' with 'cond', ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 9587fa4b99 17/86: Add missing args (quiet checkdoc warnings), ELPA Syncer, 2022/07/07
- [nongnu] elpa/spell-fu 484b6bdf04 53/86: Fix disabling spell-fu-mode stopping the idle timer in other buffers, ELPA Syncer, 2022/07/07