[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/jinx aa0a82e9fe 1/8: Refactoring of internals
From: |
ELPA Syncer |
Subject: |
[elpa] externals/jinx aa0a82e9fe 1/8: Refactoring of internals |
Date: |
Wed, 29 Mar 2023 22:58:45 -0400 (EDT) |
branch: externals/jinx
commit aa0a82e9fe9deb07cabf7c7d57e0e48d906c47c9
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>
Refactoring of internals
---
jinx.el | 46 ++++++++++++++++++++++++++--------------------
1 file changed, 26 insertions(+), 20 deletions(-)
diff --git a/jinx.el b/jinx.el
index 495a7cdac8..dbefcbe001 100644
--- a/jinx.el
+++ b/jinx.el
@@ -337,12 +337,19 @@ FLAG must be t or nil."
(let* ((from (jinx--find-visible-pending pos end t))
(to (jinx--find-visible-pending from end nil)))
(if (< from to)
- (setq pos (cdr (jinx--check-region from to)))
+ (setq pos (jinx--check-region from to))
(setq pos to))))))
+(defun jinx--force-check-region (start end)
+ "Enforce spell-check of region between START and END."
+ (with-delayed-message (1 "Fontifying...")
+ (jit-lock-fontify-now))
+ (with-delayed-message (1 "Checking...")
+ (jinx--check-region start end)))
+
(defun jinx--check-region (start end)
"Check region between START and END.
-Returns a pair of updated (START END) bounds."
+Return updated END position."
(let ((jinx--mode-syntax-table (syntax-table)))
(unwind-protect
(with-silent-modifications
@@ -376,12 +383,15 @@ Returns a pair of updated (START END) bounds."
('nil (overlay-put (make-overlay word-start word-end)
'category 'jinx))))))
(remove-list-of-text-properties start end '(jinx--pending)))
(set-syntax-table jinx--mode-syntax-table)))))
- (cons start end))
+ end)
-(defun jinx--get-overlays (start end)
- "Return misspelled words overlays between START and END."
+(defun jinx--get-overlays (start end &optional visible)
+ "Return misspelled word overlays between START and END.
+If VISIBLE is non-nil, only include visible overlays."
(sort (cl-loop for ov in (overlays-in start end)
- if (eq (overlay-get ov 'category) 'jinx) collect ov)
+ if (and (eq (overlay-get ov 'category) 'jinx)
+ (not (and visible (invisible-p (overlay-start ov)))))
+ collect ov)
(lambda (a b) (< (overlay-start a) (overlay-start b)))))
(defun jinx--delete-overlays (start end)
@@ -474,16 +484,6 @@ Returns a pair of updated (START END) bounds."
(error msg)))))))
(module-load (expand-file-name module)))))
-(defun jinx--force-overlays (start end)
- "Enforce spell-check of region between START and END.
-Return list of overlays, see `jinx--get-overlays'."
- (with-delayed-message (1 "Fontifying...")
- (jit-lock-fontify-now))
- (with-delayed-message (1 "Checking...")
- (setq start (jinx--check-region start end)
- end (cdr start) start (car start)))
- (jinx--get-overlays start end))
-
(defun jinx--annotate-suggestion (word)
"Annotate WORD during completion."
(get-text-property 0 'jinx--annotation word))
@@ -653,8 +653,12 @@ If prefix argument ALL non-nil correct all misspellings."
(old-point (and (not all) (point-marker))))
(unwind-protect
(if all
- (let* ((overlays (or (jinx--force-overlays (point-min) (point-max))
- (user-error "No misspellings in whole
buffer")))
+ (let* ((overlays
+ (progn
+ (jinx--force-check-region (point-min) (point-max))
+ (or
+ (jinx--get-overlays (point-min) (point-max))
+ (user-error "No misspellings in whole buffer"))))
(nearest (jinx--nearest-overlay overlays))
(count (length overlays))
before after)
@@ -672,8 +676,10 @@ If prefix argument ALL non-nil correct all misspellings."
(jinx--correct
(or
(jinx--nearest-overlay
- (or (jinx--get-overlays (window-start) (window-end))
- (jinx--force-overlays (window-start) (window-end))))
+ (or (jinx--get-overlays (window-start) (window-end) 'visible)
+ (progn
+ (jinx--force-check-region (window-start) (window-end))
+ (jinx--get-overlays (window-start) (window-end) 'visible))))
(user-error "No misspelling in visible text"))))
(when old-point (goto-char old-point))
(jit-lock-refontify))))
- [elpa] externals/jinx updated (72d7a1ad9d -> 397112434c), ELPA Syncer, 2023/03/29
- [elpa] externals/jinx aa0a82e9fe 1/8: Refactoring of internals,
ELPA Syncer <=
- [elpa] externals/jinx 6ea7a861c4 6/8: editorial changes to readme (#26), ELPA Syncer, 2023/03/29
- [elpa] externals/jinx 27177e33d9 5/8: Fix compilation warning, ELPA Syncer, 2023/03/29
- [elpa] externals/jinx 397112434c 8/8: Improve readme and commentary, ELPA Syncer, 2023/03/29
- [elpa] externals/jinx f966592133 2/8: Reset syntax table correctly, ELPA Syncer, 2023/03/29
- [elpa] externals/jinx 06d801f595 3/8: Simplify jinx--recheck-overlays, ELPA Syncer, 2023/03/29
- [elpa] externals/jinx 983ffa2862 4/8: Simplify overlay reordering, ELPA Syncer, 2023/03/29
- [elpa] externals/jinx 524711ef85 7/8: Improve readme, ELPA Syncer, 2023/03/29