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

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

[nongnu] elpa/evil-visualstar aafece5bc2 10/19: Commit 2015-05-08 19:00


From: ELPA Syncer
Subject: [nongnu] elpa/evil-visualstar aafece5bc2 10/19: Commit 2015-05-08 19:00
Date: Thu, 6 Jan 2022 04:00:22 -0500 (EST)

branch: elpa/evil-visualstar
commit aafece5bc213ca4c34a5c559d027b1eb381bea2e
Merge: 6e9f2349ad a18dfe7612
Author: Guido Van Hoecke <guivho@gmail.com>
Commit: Guido Van Hoecke <guivho@gmail.com>

    Commit 2015-05-08 19:00
---
 README.md          |  6 ++++++
 evil-visualstar.el | 16 ++++++++++++----
 2 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/README.md b/README.md
index 0c0fe6c97a..6cb854549e 100644
--- a/README.md
+++ b/README.md
@@ -15,4 +15,10 @@ Add `(global-evil-visualstar-mode)` to your configuration.
 
 Make a visual selection with `v` or `V`, and then hit `*` to search that 
selection forward, or `#` to search that selection backward.
 
+If the `evil-visualstar/persistent` option is not nil, visual-state will
+remain in effect, allowing for repeated `*` or #`.
+
+Note that you than have to exit visualstar-mode before hitting a
+direction key to avoid extending the selection.
+
 [1]: http://melpa.org
diff --git a/evil-visualstar.el b/evil-visualstar.el
index df596b41d3..3aa9568f85 100644
--- a/evil-visualstar.el
+++ b/evil-visualstar.el
@@ -45,6 +45,11 @@
 
 (require 'evil)
 
+(defvar evil-visualstar/persistent nil
+  "Set to t if * or # should keep visual-mode.
+This allows for repeated use of * in # but keeps vusual mode.
+You'd need to hit escape to leave visual-mode.")
+
 (defun evil-visualstar/begin-search (beg end direction)
   (when (evil-visual-state-p)
     (evil-exit-visual-state)
@@ -59,11 +64,14 @@
           (setq evil-ex-search-direction direction)
           (setq evil-ex-search-pattern pattern)
           (evil-ex-search-activate-highlight pattern)
+          ;; update search history unless this pattern equals the
+          ;; previous pattern
+          (unless (equal (car-safe evil-ex-search-history) selection)
+            (push selection evil-ex-search-history))
+          (evil-push-search-history selection (eq direction 'forward))
           (setq found (evil-ex-search-next))))
-      (when found
-        (push-mark (- (+ end (point)) beg) t)
-        (exchange-point-and-mark)
-        (exchange-point-and-mark)))))
+      (when (and evil-visualstar/persistent found)
+        (push-mark (+ (point) (- end beg)) nil t)))))
 
 (defun evil-visualstar/begin-search-forward (beg end)
   "Search for the visual selection forwards."



reply via email to

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