[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master c4b9e25 249/272: Add much faster scrolling to counsel-grep
From: |
Oleh Krehel |
Subject: |
[elpa] master c4b9e25 249/272: Add much faster scrolling to counsel-grep |
Date: |
Mon, 25 Apr 2016 10:13:28 +0000 |
branch: master
commit c4b9e2576b527109e8c09b29d6e102edb5c5492f
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
Add much faster scrolling to counsel-grep
* counsel.el (counsel-grep-last-line): New defvar.
(counsel-grep): Set `counsel-grep-last-line' to nil.
(counsel-grep-action): Instead of going to `point-min' and
`forward-line' with a huge arg (e.g. to scroll 50K lines). Scroll
relative to the last position stored in `counsel-grep-last-line'.
This change resulted in a much smoother scrolling in a 50K line file
with 22K matches.
---
counsel.el | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/counsel.el b/counsel.el
index 864340a..745d054 100644
--- a/counsel.el
+++ b/counsel.el
@@ -1411,6 +1411,8 @@ the command."
(format counsel-grep-base-command regex counsel--git-grep-dir))
nil)))
+(defvar counsel-grep-last-line nil)
+
(defun counsel-grep-action (x)
(with-ivy-window
(swiper--cleanup)
@@ -1424,8 +1426,13 @@ the command."
(setq line-number (match-string-no-properties 2 x)))
(t nil))
(find-file file-name)
- (goto-char (point-min))
- (forward-line (1- (string-to-number line-number)))
+ (setq line-number (string-to-number line-number))
+ (if (null counsel-grep-last-line)
+ (progn
+ (goto-char (point-min))
+ (forward-line (1- (setq counsel-grep-last-line line-number))))
+ (forward-line (- line-number counsel-grep-last-line))
+ (setq counsel-grep-last-line line-number))
(re-search-forward (ivy--regex ivy-text t) (line-end-position) t)
(if (eq ivy-exit 'done)
(swiper--ensure-visible)
@@ -1465,6 +1472,7 @@ the command."
(defun counsel-grep ()
"Grep for a string in the current file."
(interactive)
+ (setq counsel-grep-last-line nil)
(setq counsel--git-grep-dir (buffer-file-name))
(let ((init-point (point))
res)
- [elpa] master 119a151 242/272: Make "j"/"k" feedback more solid in ivy-occur buffers, (continued)
- [elpa] master 119a151 242/272: Make "j"/"k" feedback more solid in ivy-occur buffers, Oleh Krehel, 2016/04/25
- [elpa] master 6a00275 187/272: ivy.el (ivy-switch-buffer-occur): Add, Oleh Krehel, 2016/04/25
- [elpa] master 181cd43 154/272: Add counsel-mode, Oleh Krehel, 2016/04/25
- [elpa] master 92b802f 176/272: counsel.el (counsel-ag): Add dir prompt for "C-u", Oleh Krehel, 2016/04/25
- [elpa] master 4998ba8 208/272: ivy.el (ivy-completing-read): Use the "t" key of ivy-sort-functions-alist, Oleh Krehel, 2016/04/25
- [elpa] master 4ac3736 243/272: New feature: virtual views in ivy-switch-buffer, Oleh Krehel, 2016/04/25
- [elpa] master 46a00dc 227/272: Modified ivy to pass predicate when selecting buffers, Oleh Krehel, 2016/04/25
- [elpa] master b48a09d 245/272: Use Ivy to browse eshell and shell history entries, Oleh Krehel, 2016/04/25
- [elpa] master e7f41bb 236/272: swiper.el (swiper-mc): Remove interactive, Oleh Krehel, 2016/04/25
- [elpa] master 147ae80 096/272: Fix an extra action being called for `completing-read', Oleh Krehel, 2016/04/25
- [elpa] master c4b9e25 249/272: Add much faster scrolling to counsel-grep,
Oleh Krehel <=
- [elpa] master 7f6d39f 193/272: counsel.el (counsel-linux-app-action-file): New action on "M-o f", Oleh Krehel, 2016/04/25
- [elpa] master ac4bedf 175/272: counsel.el (counsel-find-file): Bind "M-o f" to find-file-other-window, Oleh Krehel, 2016/04/25
- [elpa] master 41e2e41 246/272: Clean-up previous change, Oleh Krehel, 2016/04/25
- [elpa] master 90a09fa 086/272: doc/ivy.org: CUSTOM_ID should not end in "?", Oleh Krehel, 2016/04/25
- [elpa] master 6254e88 244/272: Allow a sexp node in ivy-views, Oleh Krehel, 2016/04/25
- [elpa] master e224847 179/272: ivy.el (ivy--reset-state): Fix prompt / require-match issue, Oleh Krehel, 2016/04/25
- [elpa] master 5229ebe 173/272: counsel.el (counsel-prompt-function-dir): Fix format, Oleh Krehel, 2016/04/25
- [elpa] master 8de2930 221/272: ivy.el: Improve "M-n", Oleh Krehel, 2016/04/25
- [elpa] master 6823518 196/272: swiper.el (swiper--candidates): Always remove '(field), Oleh Krehel, 2016/04/25
- [elpa] master d45ee54 258/272: Make the slash more magic during file name completion, Oleh Krehel, 2016/04/25