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

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

[nongnu] elpa/evil-anzu 35a636341a 10/27: Simplify implementation


From: ELPA Syncer
Subject: [nongnu] elpa/evil-anzu 35a636341a 10/27: Simplify implementation
Date: Thu, 6 Jan 2022 03:59:30 -0500 (EST)

branch: elpa/evil-anzu
commit 35a636341ad0513fbe0dc794f5e1c31e98505cfe
Author: Fredrik Bergroth <fbergroth@gmail.com>
Commit: Fredrik Bergroth <fbergroth@gmail.com>

    Simplify implementation
    
    Fixes flickering and supports evil-search-word-* and
    evil-search-unbounded-word-* search functions.
---
 evil-anzu.el | 85 ++++++------------------------------------------------------
 1 file changed, 8 insertions(+), 77 deletions(-)

diff --git a/evil-anzu.el b/evil-anzu.el
index 7273949eed..9f3ac9edea 100644
--- a/evil-anzu.el
+++ b/evil-anzu.el
@@ -3,6 +3,7 @@
 ;; Copyright (C) 2015 by Syohei YOSHIDA
 
 ;; Author: Syohei YOSHIDA <syohex@gmail.com>
+;;         Fredrik Bergroth <fbergroth@gmail.com>
 ;; URL: https://github.com/syohex/emacs-evil-anzu
 ;; Version: 0.01
 ;; Package-Requires: ((evil "1.0.0") (anzu "0.46"))
@@ -27,86 +28,16 @@
 (require 'evil)
 (require 'anzu)
 
-(defgroup evil-anzu nil
-  "anzu for evil-mode"
-  :group '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)))
 
-(defvar evil-anzu--displayed nil)
-
-(defconst evil-anzu--search-commands
-  '(evil-anzu-search-next evil-anzu-search-previous))
-
-(defun evil-anzu--update ()
-  (anzu--cons-mode-line 'search)
-  (let ((query (if evil-regexp-search
-                   (car-safe regexp-search-ring)
-                 (car-safe search-ring))))
-    (anzu--update query))
-  (setq evil-anzu--displayed t))
-
-(evil-define-motion evil-anzu-search-next (count)
-  "Repeat the last search."
-  :jump t
-  :type exclusive
-  (dotimes (var (or count 1))
-    (evil-search (if evil-regexp-search
-                     (car-safe regexp-search-ring)
-                   (car-safe search-ring))
-                 isearch-forward evil-regexp-search))
-  (evil-anzu--update))
-
-(evil-define-motion evil-anzu-search-previous (count)
-  "Repeat the last search in the opposite direction."
-  :jump t
-  :type exclusive
-  (dotimes (var (or count 1))
-    (evil-search (if evil-regexp-search
-                     (car-safe regexp-search-ring)
-                   (car-safe search-ring))
-                 (not isearch-forward) evil-regexp-search))
-  (evil-anzu--update))
-
-(defun evil-anzu--pre-command-hook ()
-  (when (and evil-anzu--displayed (not (memq this-command 
evil-anzu--search-commands)))
-    (anzu--reset-mode-line)
-    (setq evil-anzu--displayed nil)))
-
-(defun evil-anzu--reset-mode-line ()
-  (when (and anzu-cons-mode-line-p (anzu--mode-line-not-set-p))
-    (setq mode-line-format (delete anzu--mode-line-format mode-line-format))))
-
-(define-minor-mode evil-anzu-mode
-  "anzu for evil-mode."
-  :group      'evil-anzu
-  :init-value nil
-  :global     nil
-  :lighter    anzu-mode-lighter
-  (if evil-anzu-mode
-      (progn
-        (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 'evil-anzu--reset-mode-line nil t)
-        (add-hook 'pre-command-hook 'evil-anzu--pre-command-hook nil 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)
-    (remove-hook 'pre-command-hook 'evil-anzu--pre-command-hook t)
+(defadvice evil-flash-hook (after evil-anzu-compat activate)
+  ;; Prevent flickering, only run if timer is not active
+  (unless (memq evil-flash-timer timer-list)
     (anzu--reset-mode-line)))
 
-(defun evil-anzu--turn-on ()
-  (unless (minibufferp)
-    (evil-anzu-mode +1)))
-
-;;;###autoload
-(define-globalized-minor-mode global-evil-anzu-mode evil-anzu-mode 
evil-anzu--turn-on
-  :group 'evil-anzu)
-
-(defadvice evil-flash-hook (after reset-anzu-information activate)
-  (anzu--reset-status))
-
-(defadvice evil-search (before reset-anzu-information activate)
-  (anzu--reset-status))
-
 (provide 'evil-anzu)
 
 ;;; evil-anzu.el ends here



reply via email to

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