branch: elpa/anzu
commit 10bc7c5fbdb94058e172d1659dfda9780485eff1
Merge: 9064fc7892 cf3370967b
Author: Syohei YOSHIDA <[email protected]>
Commit: Syohei YOSHIDA <[email protected]>
Merge pull request #41 from syohex/refactoring
Refactoring for evil-anzu
---
anzu.el | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/anzu.el b/anzu.el
index 88e90175ae..dc0d64384c 100644
--- a/anzu.el
+++ b/anzu.el
@@ -203,19 +203,22 @@
(eq isearch-regexp (cdr anzu--last-search-state))
(string= input anzu--last-isearch-string)))
-(defun anzu--update ()
- (when (>= (length isearch-string) anzu-minimum-input-length)
- (let ((result (if (anzu--use-result-cache-p isearch-string)
+(defun anzu--update (query)
+ (when (>= (length query) anzu-minimum-input-length)
+ (let ((result (if (anzu--use-result-cache-p query)
anzu--cached-positions
- (anzu--search-all-position isearch-string))))
+ (anzu--search-all-position query))))
(let ((curpos (anzu--where-is-here (plist-get result :positions)
(point))))
(setq anzu--total-matched (plist-get result :count)
anzu--overflow-p (plist-get result :overflow)
anzu--current-position curpos
anzu--last-search-state (cons isearch-word isearch-regexp)
- anzu--last-isearch-string isearch-string)
+ anzu--last-isearch-string query)
(force-mode-line-update)))))
+(defun anzu--update-post-hook ()
+ (anzu--update isearch-string))
+
(defconst anzu--mode-line-format '(:eval (anzu--update-mode-line)))
(defsubst anzu--mode-line-not-set-p ()
@@ -272,10 +275,10 @@
:lighter anzu-mode-lighter
(if anzu-mode
(progn
- (add-hook 'isearch-update-post-hook 'anzu--update nil t)
+ (add-hook 'isearch-update-post-hook 'anzu--update-post-hook nil t)
(add-hook 'isearch-mode-hook 'anzu--cons-mode-line-search nil t)
(add-hook 'isearch-mode-end-hook 'anzu--reset-mode-line nil t))
- (remove-hook 'isearch-update-post-hook 'anzu--update t)
+ (remove-hook 'isearch-update-post-hook 'anzu--update-post-hook t)
(remove-hook 'isearch-mode-hook 'anzu--cons-mode-line t)
(remove-hook 'isearch-mode-end-hook 'anzu--reset-mode-line t)
(anzu--reset-mode-line)))