[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/evil e324f8daf1: Skip overlays-in in evil-next-flyspell-er
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/evil e324f8daf1: Skip overlays-in in evil-next-flyspell-error |
Date: |
Sun, 8 Jan 2023 04:59:10 -0500 (EST) |
branch: elpa/evil
commit e324f8daf152301fd59b045da2331da7497aaec4
Author: Axel Forsman <axelsfor@gmail.com>
Commit: Axel Forsman <axelsfor@gmail.com>
Skip overlays-in in evil-next-flyspell-error
Searching through the results of overlays-in, in addition to looping
with next-overlay-change/overlays-at, is essentially doing the same work
twice. This commit opts for only doing the latter.
In addition, some other fixes are
* Avoid requiring flyspell.
* Fail immediately if no spelling error was found regardless of count,
and signal error in that case so that macros are aborted like in Vim.
* Echo a notice when search wrapped around.
* Make "[s" and "s]" push the previous position onto the jump list.
* Run tests when suitable spell checker other than aspell is available.
---
evil-commands.el | 85 +++++++++++++++-----------------------------------------
evil-tests.el | 12 ++++----
2 files changed, 28 insertions(+), 69 deletions(-)
diff --git a/evil-commands.el b/evil-commands.el
index d624717cde..6ad86d0a09 100644
--- a/evil-commands.el
+++ b/evil-commands.el
@@ -33,10 +33,10 @@
(require 'evil-command-window)
(require 'evil-jumps)
(require 'evil-vars)
-(require 'flyspell)
(require 'cl-lib)
(require 'reveal)
+(declare-function flyspell-overlay-p "flyspell")
(declare-function imenu--in-alist "imenu")
;;; Motions
@@ -576,72 +576,33 @@ and jump to the corresponding one."
((< open close) (goto-char open-pair))
(t (goto-char close-pair)))))))
-(defun evil--flyspell-overlays-in-p (beg end)
- (let ((ovs (overlays-in beg end))
- done)
- (while (and ovs (not done))
- (when (flyspell-overlay-p (car ovs))
- (setq done t))
- (setq ovs (cdr ovs)))
- done))
-
-(defun evil--flyspell-overlay-at (pos forwardp)
- (when (not forwardp)
- (setq pos (max (1- pos) (point-min))))
- (let ((ovs (overlays-at pos))
- done)
- (while (and ovs (not done))
- (if (flyspell-overlay-p (car ovs))
- (setq done t)
- (setq ovs (cdr ovs))))
- (when done
- (car ovs))))
-
-(defun evil--flyspell-overlay-after (pos limit forwardp)
- (let (done)
- (while (and (if forwardp
- (< pos limit)
- (> pos limit))
- (not done))
- (let ((ov (evil--flyspell-overlay-at pos forwardp)))
- (when ov
- (setq done ov)))
- (setq pos (if forwardp
- (next-overlay-change pos)
- (previous-overlay-change pos))))
- done))
-
-(defun evil--next-flyspell-error (forwardp)
- (when (evil--flyspell-overlays-in-p (point-min) (point-max))
- (let ((pos (point))
- limit
- ov)
- (when (evil--flyspell-overlay-at pos forwardp)
- (setq pos (save-excursion (goto-char pos)
- (forward-word (if forwardp 1 -1))
- (point))))
- (setq limit (if forwardp (point-max) (point-min))
- ov (evil--flyspell-overlay-after pos limit forwardp))
- (if ov
- (goto-char (overlay-start ov))
- (when evil-search-wrap
- (setq limit pos
- pos (if forwardp (point-min) (point-max))
- ov (evil--flyspell-overlay-after pos limit forwardp))
- (when ov
- (goto-char (overlay-start ov))))))))
-
(evil-define-motion evil-next-flyspell-error (count)
"Go to the COUNT'th spelling mistake after point."
- (interactive "p")
- (dotimes (_ count)
- (evil--next-flyspell-error t)))
+ :jump t
+ (unless (bound-and-true-p flyspell-mode) (signal 'search-failed nil))
+ (let ((fwd (> (or count 1) 0)) (start (point)) (pos (point)) ov)
+ (dotimes (_ (abs (or count 1)))
+ (let ((limit (if fwd (point-max) (point-min))) wrappedp)
+ (when fwd (setq pos (save-excursion (goto-char pos)
+ (skip-syntax-forward "w")
(point))))
+ (while (progn (if (if fwd (>= pos limit) (<= pos limit))
+ (if (or wrappedp (not evil-search-wrap))
+ (signal 'search-failed nil)
+ (setq wrappedp t
+ limit start
+ pos (if fwd (point-min)
+ (previous-overlay-change
(point-max)))))
+ (setq pos (if fwd (next-overlay-change pos)
+ (previous-overlay-change pos))))
+ (not (setq ov (seq-find #'flyspell-overlay-p
+ (overlays-at pos))))))
+ (when wrappedp (let (message-log-max) (message "Search wrapped")))))
+ (goto-char (overlay-start ov))))
(evil-define-motion evil-prev-flyspell-error (count)
"Go to the COUNT'th spelling mistake preceding point."
- (interactive "p")
- (dotimes (_ count)
- (evil--next-flyspell-error nil)))
+ :jump t
+ (evil-next-flyspell-error (- (or count 1))))
(evil-define-motion evil-previous-open-paren (count)
"Go to [count] previous unmatched '('."
diff --git a/evil-tests.el b/evil-tests.el
index f84d0db4a6..a79a7751e9 100644
--- a/evil-tests.el
+++ b/evil-tests.el
@@ -68,6 +68,7 @@
(require 'ert)
(require 'evil)
(require 'evil-test-helpers)
+(require 'ispell)
;;; Code:
@@ -5915,7 +5916,7 @@ Line 2"))
(ert-deftest evil-test-flyspell-motions ()
"Test flyspell motions"
:tags '(evil motion)
- (skip-unless (executable-find "aspell"))
+ (skip-unless (condition-case _ (progn (ispell-check-version) t) (error)))
(ert-info ("Simple")
(evil-test-buffer
"[I] cannt tpye for lyfe"
@@ -5968,8 +5969,7 @@ Line 2"))
"I cannt [t]pye for lyfe"
("]s")
"I cannt tpye for [l]yfe"
- ("]s")
- "I cannt tpye for [l]yfe")))
+ (error search-failed "]s"))))
(ert-info ("One mistake")
(evil-test-buffer
"[I]'m almst there..."
@@ -5984,10 +5984,8 @@ Line 2"))
"[I]'ve learned to type!"
(flyspell-mode)
(flyspell-buffer)
- ("]s")
- "[I]'ve learned to type!"
- ("[s")
- "[I]'ve learned to type!")))
+ (error search-failed "]s")
+ (error search-failed "[s"))))
;;; Text objects
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [nongnu] elpa/evil e324f8daf1: Skip overlays-in in evil-next-flyspell-error,
ELPA Syncer <=