[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 83f89d8 003/272: Improve swiper for multiple occurrences o
From: |
Oleh Krehel |
Subject: |
[elpa] master 83f89d8 003/272: Improve swiper for multiple occurrences on one line |
Date: |
Mon, 25 Apr 2016 10:13:13 +0000 |
branch: master
commit 83f89d8c3160b968a422127d14d245f3f4a2c733
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
Improve swiper for multiple occurrences on one line
* swiper.el (swiper--current-line):
(swiper--current-match-start): New defvar.
(swiper--init): Update.
(swiper--update-input-ivy): Don't move to line NUM if
`swiper--current-line' is equal to NUM. Later, store NUM in
`swiper--current-line' to avoid calling `line-number-at-pos'.
Additionally store `swiper--current-match-start' - it's necessary to
move there before searching for the regexp, since the point currently is
after the old regexp.
Fixes #314
---
swiper.el | 24 ++++++++++++++++++------
1 file changed, 18 insertions(+), 6 deletions(-)
diff --git a/swiper.el b/swiper.el
index d9bf724..bb20ab4 100644
--- a/swiper.el
+++ b/swiper.el
@@ -315,8 +315,13 @@ When non-nil, INITIAL-INPUT is the initial search pattern."
(declare-function evil-jumper--set-jump "ext:evil-jumper")
+(defvar swiper--current-line nil)
+(defvar swiper--current-match-start nil)
+
(defun swiper--init ()
"Perform initialization common to both completion methods."
+ (setq swiper--current-line nil)
+ (setq swiper--current-match-start nil)
(setq swiper--opoint (point))
(when (bound-and-true-p evil-jumper-mode)
(evil-jumper--set-jump)))
@@ -440,17 +445,24 @@ Matched candidates should have `swiper-invocation-face'."
(string-to-number (match-string 0 str))
0)))
(unless (eq this-command 'ivy-yank-word)
- (goto-char (point-min))
(when (cl-plusp num)
- (goto-char (point-min))
- (if swiper-use-visual-line
- (line-move (1- num))
- (forward-line (1- num)))
+ (unless (if swiper--current-line
+ (eq swiper--current-line num)
+ (eq (line-number-at-pos) num))
+ (goto-char (point-min))
+ (if swiper-use-visual-line
+ (line-move (1- num))
+ (forward-line (1- num))))
(if (and (equal ivy-text "")
(>= swiper--opoint (line-beginning-position))
(<= swiper--opoint (line-end-position)))
(goto-char swiper--opoint)
- (re-search-forward re (line-end-position) t))
+ (if (eq swiper--current-line num)
+ (when swiper--current-match-start
+ (goto-char swiper--current-match-start))
+ (setq swiper--current-line num))
+ (re-search-forward re (line-end-position) t)
+ (setq swiper--current-match-start (match-beginning 0)))
(isearch-range-invisible (line-beginning-position)
(line-end-position))
(unless (and (>= (point) (window-start))
- [elpa] master updated (03d2b00 -> 39a458e), Oleh Krehel, 2016/04/25
- [elpa] master 8306be1 006/272: Fix compilation warnings, Oleh Krehel, 2016/04/25
- [elpa] master a4317f9 002/272: ivy.el (ivy--get-window): Return a valid window, Oleh Krehel, 2016/04/25
- [elpa] master 83f89d8 003/272: Improve swiper for multiple occurrences on one line,
Oleh Krehel <=
- [elpa] master db283d3 005/272: Fix recursive minibuffer exit with "C-g", Oleh Krehel, 2016/04/25
- [elpa] master cabab4b 012/272: swiper.el (swiper-font-lock-ensure): Add bongo-library-mode, Oleh Krehel, 2016/04/25
- [elpa] master 2c50031 004/272: Fix ivy-reverse-i-search broken by recursive update, Oleh Krehel, 2016/04/25
- [elpa] master 6951eba 001/272: Make ivy--regex-plus recognize ! at the beginning of the str, Oleh Krehel, 2016/04/25
- [elpa] master d74fab4 010/272: counsel.el (counsel-M-x): Let-bind this-command, Oleh Krehel, 2016/04/25
- [elpa] master fd27465 014/272: counsel.el (counsel-git): Fix window selection, Oleh Krehel, 2016/04/25
- [elpa] master 6bf72fd 008/272: counsel.el (counsel-imenu): Work when given positions are overlays, Oleh Krehel, 2016/04/25
- [elpa] master 63be079 009/272: ivy.el (ivy-re-builders-alist): Allow this-command to be a key, Oleh Krehel, 2016/04/25
- [elpa] master 09848ca 013/272: Add cousel-ag-base-command var, Oleh Krehel, 2016/04/25
- [elpa] master adfad96 007/272: support imenu, Oleh Krehel, 2016/04/25