[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 2410219 284/399: swiper.el (swiper-isearch-highlight-delay
From: |
Oleh Krehel |
Subject: |
[elpa] master 2410219 284/399: swiper.el (swiper-isearch-highlight-delay): New defcustom |
Date: |
Sat, 20 Jul 2019 14:57:41 -0400 (EDT) |
branch: master
commit 2410219b7b29a10e3f352f1726da96434c7fa15b
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
swiper.el (swiper-isearch-highlight-delay): New defcustom
---
swiper.el | 33 +++++++++++++++++++++++++++++++--
1 file changed, 31 insertions(+), 2 deletions(-)
diff --git a/swiper.el b/swiper.el
index a2694bb..2349488 100644
--- a/swiper.el
+++ b/swiper.el
@@ -766,6 +766,9 @@ Matched candidates should have `swiper-invocation-face'."
(defvar swiper--overlays nil
"Store overlays.")
+(defvar swiper--isearch-highlight-timer nil
+ "This timer used by `swiper--delayed-add-overlays'.")
+
(defun swiper--cleanup ()
"Clean up the overlays."
(while swiper--overlays
@@ -775,7 +778,10 @@ Matched candidates should have `swiper-invocation-face'."
(if (eq ivy-exit 'done) lazy-highlight-cleanup t))
(save-excursion
(goto-char (point-min))
- (isearch-clean-overlays)))
+ (isearch-clean-overlays))
+ (when (timerp swiper--isearch-highlight-timer)
+ (cancel-timer swiper--isearch-highlight-timer)
+ (setq swiper--isearch-highlight-timer nil)))
(defun swiper--add-cursor-overlay (wnd)
(let ((ov (make-overlay (point) (if (eolp) (point) (1+ (point))))))
@@ -1279,6 +1285,29 @@ come back to the same place as when \"a\" was initially
entered.")
(ivy-set-index idx-found))
(setq ivy--old-cands (nreverse cands))))))
+(defcustom swiper-isearch-highlight-delay '(2 0.2)
+ "When `ivy-text' is too short, delay showing the overlay.
+
+The default value will delay showing the overlay by 0.2 seconds
+if `ivy-text' is shorter than 2 characters.
+
+The aim is to reduce the visual clutter, since it's very rare
+that we search only for one character."
+ :type '(list
+ (integer :tag "Text length")
+ (float :tag "Delay in seconds")))
+
+(defun swiper--delayed-add-overlays ()
+ (if (and swiper-isearch-highlight-delay
+ (< (length ivy-text) (car swiper-isearch-highlight-delay)))
+ (setq swiper--isearch-highlight-timer
+ (run-with-idle-timer
+ (cadr swiper-isearch-highlight-delay) nil
+ (lambda ()
+ (with-ivy-window
+ (swiper--add-overlays (ivy--regex ivy-text))))))
+ (swiper--add-overlays (ivy--regex ivy-text))))
+
(defun swiper-isearch-action (x)
"Move to X for `swiper-isearch'."
(if (or (numberp x)
@@ -1290,7 +1319,7 @@ come back to the same place as when \"a\" was initially
entered.")
(line-end-position))
(unless (eq ivy-exit 'done)
(swiper--cleanup)
- (swiper--add-overlays (ivy--regex ivy-text))
+ (swiper--delayed-add-overlays)
(swiper--add-cursor-overlay
(ivy-state-window ivy-last))))
(swiper--cleanup)))
- [elpa] master c6977eb 266/399: ivy.el (ivy-read): Add :multi-action arg, (continued)
- [elpa] master c6977eb 266/399: ivy.el (ivy-read): Add :multi-action arg, Oleh Krehel, 2019/07/20
- [elpa] master df0d980 267/399: Modify counsel-unicode-char's copy action to use actual result, Oleh Krehel, 2019/07/20
- [elpa] master 19ff7cf 270/399: counsel.el (counsel-register-action): Tweak error, Oleh Krehel, 2019/07/20
- [elpa] master 4898a5e 272/399: counsel.el (counsel-compile): better handling for counsel--get-build-subdirs, Oleh Krehel, 2019/07/20
- [elpa] master e95a16b 275/399: Shrink ivy window after read action., Oleh Krehel, 2019/07/20
- [elpa] master 226171b 268/399: ivy.el (ivy--occur-insert-lines): Don't highlight the file name part, Oleh Krehel, 2019/07/20
- [elpa] master e8f9370 273/399: counsel.el (counsel-compile): nreverse recent history, Oleh Krehel, 2019/07/20
- [elpa] master b65cdb5 274/399: counsel.el (counsel-compile): track build dir for the benefit of M-i, Oleh Krehel, 2019/07/20
- [elpa] master a18de2f 269/399: counsel.el (counsel-register): Add, Oleh Krehel, 2019/07/20
- [elpa] master fbf654c 276/399: counsel.el (counsel-company): Rely on company-prefix if company-common is nil, Oleh Krehel, 2019/07/20
- [elpa] master 2410219 284/399: swiper.el (swiper-isearch-highlight-delay): New defcustom,
Oleh Krehel <=
- [elpa] master bc2dcbe 279/399: counsel.el (counsel--find-build-subdir): Simplify, Oleh Krehel, 2019/07/20
- [elpa] master 13da38a 287/399: ivy.el (ivy-help): Hide Org markup buffer-locally, Oleh Krehel, 2019/07/20
- [elpa] master 0134255 281/399: ivy.el (ivy--highlight-default): Use single face for adjacent groups, Oleh Krehel, 2019/07/20
- [elpa] master b7e9dfd 277/399: counsel.el: Fix a couple of typos, Oleh Krehel, 2019/07/20
- [elpa] master 92d5335 291/399: Add counsel-up-level command, Oleh Krehel, 2019/07/20
- [elpa] master 7e8622f 286/399: ivy.el (ivy-read-action): Fix, Oleh Krehel, 2019/07/20
- [elpa] master 0a26144 280/399: ivy.el (ivy--highlight-default): Handle unmatched groups, Oleh Krehel, 2019/07/20
- [elpa] master 8905b8b 278/399: counsel.el: Pacify byte-compiler, Oleh Krehel, 2019/07/20
- [elpa] master af5b594 283/399: ivy.el (ivy--occur-insert-lines): Fix typo bug, Oleh Krehel, 2019/07/20
- [elpa] master 04f56ca 282/399: ivy.el (ivy--recompute-index): Use configured flx candidate limit, Oleh Krehel, 2019/07/20