emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/evil-anzu 8c80e184f9 24/27: only activate evil-anzu when a


From: ELPA Syncer
Subject: [nongnu] elpa/evil-anzu 8c80e184f9 24/27: only activate evil-anzu when anzu-mode is active
Date: Thu, 6 Jan 2022 03:59:32 -0500 (EST)

branch: elpa/evil-anzu
commit 8c80e184f9905975f92021fd6d79a997b862e9a9
Author: CeleritasCelery <t.macman@gmail.com>
Commit: CeleritasCelery <t.macman@gmail.com>

    only activate evil-anzu when anzu-mode is active
---
 evil-anzu.el | 42 +++++++++++++++++++++++++-----------------
 1 file changed, 25 insertions(+), 17 deletions(-)

diff --git a/evil-anzu.el b/evil-anzu.el
index 194e918049..da040e4d7d 100644
--- a/evil-anzu.el
+++ b/evil-anzu.el
@@ -28,30 +28,38 @@
 (require 'evil)
 (require 'anzu)
 
-(defadvice evil-search (after evil-anzu-compat (string forward &optional 
regexp-p start) activate)
-  (anzu--cons-mode-line-search)
-  (let ((isearch-regexp regexp-p))
-    (anzu--update string)))
+(defun evil-anzu-start-search (string forward &optional regexp-p start)
+  (when anzu-mode (anzu--cons-mode-line-search)
+        (let ((isearch-regexp regexp-p))
+          (anzu--update string))))
 
-(defadvice evil-ex-find-next (after evil-anzu-compat (&optional pattern 
direction nowrap) activate)
+(defun evil-anzu-search-next (&optional pattern direction nowrap)
   "Make anzu work with the 'evil-search search module.
 If PATTERN is not specified the current global pattern 
`evil-ex-search-pattern' is used."
-  (anzu--cons-mode-line-search)
-  (let* ((isearch-regexp t)      ; all evil-ex searches are regexp searches
-         (current-pattern (or pattern evil-ex-search-pattern))
-         (regexp (evil-ex-pattern-regex current-pattern)))
-    (save-match-data            ; don't let anzu's searching mess up evil
-      (anzu--update regexp))))
-
-(defadvice evil-flash-hook (after evil-anzu-compat activate)
+  (when anzu-mode
+    (anzu--cons-mode-line-search)
+    (let* ((isearch-regexp t) ; all evil-ex searches are regexp searches
+           (current-pattern (or pattern evil-ex-search-pattern))
+           (regexp (evil-ex-pattern-regex current-pattern)))
+      (save-match-data       ; don't let anzu's searching mess up evil
+        (anzu--update regexp)))))
+
+(defun evil-anzu-prevent-flicker (&optional force)
   ;; Prevent flickering, only run if timer is not active
-  (unless (memq evil-flash-timer timer-list)
-    (anzu--reset-mode-line)))
+  (when anzu-mode
+    (unless (memq evil-flash-timer timer-list)
+      (anzu--reset-mode-line))))
 
-(defadvice evil-ex-delete-hl (after evil-anzu-compat (name) activate)
-  (when (eq name 'evil-ex-search)
+(defun evil-anzu-reset (name)
+  (when (and anzu-mode
+             (eq name 'evil-ex-search))
     (anzu--reset-mode-line)))
 
+(advice-add 'evil-search       :after #'evil-anzu-start-search)
+(advice-add 'evil-ex-find-next :after #'evil-anzu-search-next)
+(advice-add 'evil-flash-hook   :after #'evil-anzu-prevent-flicker)
+(advice-add 'evil-ex-delete-hl :after #'evil-anzu-reset)
+
 (provide 'evil-anzu)
 
 ;;; evil-anzu.el ends here



reply via email to

[Prev in Thread] Current Thread [Next in Thread]