[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 8f08f38 155/184: counsel.el (counsel--grep-last-pos): Refa
From: |
Oleh Krehel |
Subject: |
[elpa] master 8f08f38 155/184: counsel.el (counsel--grep-last-pos): Refactor from counsel-grep-last-line |
Date: |
Wed, 16 Oct 2019 13:15:13 -0400 (EDT) |
branch: master
commit 8f08f38990ebaa8af945237264ce0e19150282e7
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
counsel.el (counsel--grep-last-pos): Refactor from counsel-grep-last-line
It's only used in `counsel-grep-action' now, instead of 2 other places.
---
counsel.el | 16 +++++++++-------
ivy.el | 2 --
2 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/counsel.el b/counsel.el
index 1b7dc5b..28575a0 100644
--- a/counsel.el
+++ b/counsel.el
@@ -215,8 +215,6 @@ respectively."
(set-process-filter proc (or filter #'counsel--async-filter))
proc))
-(defvar counsel-grep-last-line nil)
-
(defun counsel--split-string (&optional str)
(split-string
(or str (buffer-string))
@@ -232,7 +230,6 @@ respectively."
(ivy--sort-maybe
(with-current-buffer (process-buffer process)
(counsel--split-string))))
- (setq counsel-grep-last-line nil)
(when counsel--async-start
(setq counsel--async-duration
(time-to-seconds (time-since counsel--async-start))))
@@ -3017,6 +3014,12 @@ substituted by the search regexp and file, respectively.
Neither
(format counsel-grep-command (shell-quote-argument regex)))
nil)))
+(defvar counsel--grep-last-pos nil
+ "Store the last point and line that `counsel-grep-action' scrolled to.
+This speeds up scrolling: 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 here.")
+
(defun counsel-grep-action (x)
"Go to candidate X."
(with-ivy-window
@@ -3037,11 +3040,11 @@ substituted by the search regexp and file,
respectively. Neither
(with-current-buffer (or (get-file-buffer file-name)
(find-file file-name))
(setq line-number (string-to-number line-number))
- (if counsel-grep-last-line
- (forward-line (- line-number counsel-grep-last-line))
+ (if (and counsel--grep-last-pos (= (point) (car
counsel--grep-last-pos)))
+ (forward-line (- line-number (cdr counsel--grep-last-pos)))
(goto-char (point-min))
(forward-line (1- line-number)))
- (setq counsel-grep-last-line line-number)
+ (setq counsel--grep-last-pos (cons (point) line-number))
(when (re-search-forward (ivy--regex ivy-text t) (line-end-position)
t)
(when swiper-goto-start-of-match
(goto-char (match-beginning 0))))
@@ -3075,7 +3078,6 @@ When non-nil, INITIAL-INPUT is the initial search
pattern."
(unless buffer-file-name
(user-error "Current buffer is not visiting a file"))
(counsel-require-program counsel-grep-base-command)
- (setq counsel-grep-last-line nil)
(setq counsel-grep-command
(format counsel-grep-base-command
"%s" (shell-quote-argument
diff --git a/ivy.el b/ivy.el
index b78c001..1c44f22 100644
--- a/ivy.el
+++ b/ivy.el
@@ -4877,7 +4877,6 @@ EVENT gives the mouse position."
(declare-function swiper--cleanup "swiper")
(declare-function swiper--add-overlays "swiper")
(defvar ivy-occur-timer nil)
-(defvar counsel-grep-last-line)
(defun ivy--occur-press-update-window ()
(cl-case (ivy-state-caller ivy-occur-last)
@@ -4922,7 +4921,6 @@ EVENT gives the mouse position."
(action (ivy--get-action ivy-last))
(ivy-exit 'done))
(with-ivy-window
- (setq counsel-grep-last-line nil)
(with-current-buffer (ivy--occur-press-buffer)
(save-restriction
(widen)
- [elpa] master ec1ed07 171/184: counsel.el (counsel--find-file-1): Use dired-current-directory for dired, (continued)
- [elpa] master ec1ed07 171/184: counsel.el (counsel--find-file-1): Use dired-current-directory for dired, Oleh Krehel, 2019/10/16
- [elpa] master 1d8803e 181/184: Ensure that ripgrep on windows uses '/' as the path-separator, Oleh Krehel, 2019/10/16
- [elpa] master 7854d03 129/184: counsel.el (counsel-google): Add, Oleh Krehel, 2019/10/16
- [elpa] master cd634c6 183/184: doc/Changelog.org: Release 0.13.0, Oleh Krehel, 2019/10/16
- [elpa] master 0dfd70d 135/184: counsel.el (counsel-google-function): Require json, Oleh Krehel, 2019/10/16
- [elpa] master eed1f06 138/184: counsel.el (counsel--py-action): Don't auto-insert parens, Oleh Krehel, 2019/10/16
- [elpa] master 52295c4 137/184: swiper.el (swiper-isearch): Fix searching for "$^", Oleh Krehel, 2019/10/16
- [elpa] master 80c2669 142/184: ivy.el (ivy--alist-set): Work-around emacs-24.3 not having alist-get, Oleh Krehel, 2019/10/16
- [elpa] master 8b07572 149/184: ivy.el (ivy-configure): Add :display-transformer-fn, Oleh Krehel, 2019/10/16
- [elpa] master 9da8003 158/184: counsel.el (counsel-M-x): Don't sort by default, Oleh Krehel, 2019/10/16
- [elpa] master 8f08f38 155/184: counsel.el (counsel--grep-last-pos): Refactor from counsel-grep-last-line,
Oleh Krehel <=
- [elpa] master 6b40d40 156/184: ivy.el (ivy--occur-press-update-window): Re-use ivy-highlight-grep-commands, Oleh Krehel, 2019/10/16
- [elpa] master 2ed4416 165/184: ivy.el (ivy-configure): Add :exit-codes, Oleh Krehel, 2019/10/16
- [elpa] master 2ce5450 177/184: counsel.el (counsel-find-file): Bind "M-o R" to find-file-read-only, Oleh Krehel, 2019/10/16
- [elpa] master c82b852 174/184: ivy.el (ivy-occur-revert-buffer): Simplify, Oleh Krehel, 2019/10/16
- [elpa] master 8bc23e6 104/184: counsel.el (counsel-compile): delete duplicates, Oleh Krehel, 2019/10/16
- [elpa] master 966525c 118/184: counsel.el (counsel-cd): Fix for counsel-ag, Oleh Krehel, 2019/10/16
- [elpa] master f628569 127/184: Make ivy--magic-file-slash less aggressive, Oleh Krehel, 2019/10/16
- [elpa] master efdee7a 172/184: swiper.el (swiper--occur-insert-lines): Extract, Oleh Krehel, 2019/10/16