[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master ee5dacf 385/399: Add swiper-backward command
From: |
Oleh Krehel |
Subject: |
[elpa] master ee5dacf 385/399: Add swiper-backward command |
Date: |
Sat, 20 Jul 2019 14:58:05 -0400 (EDT) |
branch: master
commit ee5dacf23cbb82b1557aa00d648aae681f6c6db7
Author: Joel Rosdahl <address@hidden>
Commit: Oleh Krehel <address@hidden>
Add swiper-backward command
Fixes #1172.
---
ivy.el | 13 ++++++++++++-
swiper.el | 11 ++++++++++-
2 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/ivy.el b/ivy.el
index 4f5a1c2..22ff77c 100644
--- a/ivy.el
+++ b/ivy.el
@@ -3221,7 +3221,8 @@ CANDIDATES are assumed to be static."
(if (memq (cdr (assq (ivy-state-caller ivy-last)
ivy-index-functions-alist))
'(ivy-recompute-index-swiper
- ivy-recompute-index-swiper-async))
+ ivy-recompute-index-swiper-async
+ ivy-recompute-index-swiper-backward))
(progn
(ivy--recompute-index name re-str cands)
(setq ivy--old-cands (ivy--sort name cands)))
@@ -3444,6 +3445,16 @@ CANDS are the current candidates."
res))))
(error 0)))
+(defun ivy-recompute-index-swiper-backward (re-str cands)
+ "Recompute index of selected candidate when using `swiper-backward'.
+CANDS are the current candidates."
+ (let ((idx (ivy-recompute-index-swiper re-str cands)))
+ (if (or (= idx -1)
+ (<= (read (get-text-property 0 'swiper-line-number (nth idx
cands)))
+ (line-number-at-pos)))
+ idx
+ (- idx 1))))
+
(defun ivy-recompute-index-swiper-async (_re-str cands)
"Recompute index of selected candidate when using `swiper' asynchronously.
CANDS are the current candidates."
diff --git a/swiper.el b/swiper.el
index 75f8181..6524fd0 100644
--- a/swiper.el
+++ b/swiper.el
@@ -538,12 +538,21 @@ numbers; replaces calculating the width from buffer line
count."
;;;###autoload
(defun swiper (&optional initial-input)
- "`isearch' with an overview.
+ "`isearch-forward' with an overview.
When non-nil, INITIAL-INPUT is the initial search pattern."
(interactive)
(swiper--ivy (swiper--candidates) initial-input))
;;;###autoload
+(defun swiper-backward (&optional initial-input)
+ "`isearch-backward' with an overview.
+When non-nil, INITIAL-INPUT is the initial search pattern."
+ (interactive)
+ (let ((ivy-index-functions-alist
+ '((swiper . ivy-recompute-index-swiper-backward))))
+ (swiper initial-input)))
+
+;;;###autoload
(defun swiper-thing-at-point ()
"`swiper' with `ivy-thing-at-point'."
(interactive)
- [elpa] master 75f4146 377/399: ivy.el (ivy-occur-revert-buffer): Stay on the same line, (continued)
- [elpa] master 75f4146 377/399: ivy.el (ivy-occur-revert-buffer): Stay on the same line, Oleh Krehel, 2019/07/20
- [elpa] master 3ec81dc 369/399: ivy-test.el (swiper--re-builder-char-fold): Split away, Oleh Krehel, 2019/07/20
- [elpa] master 98127be 375/399: ivy.el (ivy-format-functions-alist): Fix defcustom type, Oleh Krehel, 2019/07/20
- [elpa] master 1bb48ae 376/399: swiper.el: Add :group for faces, Oleh Krehel, 2019/07/20
- [elpa] master 3380b6f 382/399: swiper.el (swiper--avy-goto): Works for swiper-isearch, Oleh Krehel, 2019/07/20
- [elpa] master bd53ada 379/399: counsel.el (counsel-async-split-string-re-alist): Extract, Oleh Krehel, 2019/07/20
- [elpa] master 0703a70 380/399: counsel.el (counsel-async-ignore-re-alist): Extract, Oleh Krehel, 2019/07/20
- [elpa] master 59603df 383/399: swiper.el (swiper--avy-goto): Fix for a small amount of cands, Oleh Krehel, 2019/07/20
- [elpa] master 5f030d5 381/399: counsel.el (counsel--git-log-format-function): Add, Oleh Krehel, 2019/07/20
- [elpa] master c4c6068 384/399: doc/ivy.org: Fix RET -> C-j, Oleh Krehel, 2019/07/20
- [elpa] master ee5dacf 385/399: Add swiper-backward command,
Oleh Krehel <=
- [elpa] master 3c6790f 387/399: ivy.el (ivy-immediate-done): Improve make-directory, Oleh Krehel, 2019/07/20
- [elpa] master 6e50ab6 391/399: ivy-test.el (swiper-isearch-backward): Goto old match on DEL, Oleh Krehel, 2019/07/20
- [elpa] master 714911b 389/399: ivy.el (ivy--sort): Higher priority for ivy-sort-matches-functions-alist, Oleh Krehel, 2019/07/20
- [elpa] master 56a1f7d 386/399: Add counsel-grep-backward and counsel-grep-or-swiper-backward commands, Oleh Krehel, 2019/07/20
- [elpa] master 79de883 388/399: ivy.el (ivy--sort): Simplify, Oleh Krehel, 2019/07/20
- [elpa] master f5508e5 390/399: swiper.el (swiper-isearch-backward): Add backward search, Oleh Krehel, 2019/07/20
- [elpa] master af0799a 393/399: counsel.el (counsel-git-log-show-commit-action): Fix match end., Oleh Krehel, 2019/07/20
- [elpa] master 54d1b19 392/399: swiper.el (swiper-isearch-action): Use swiper-action-recenter, Oleh Krehel, 2019/07/20
- [elpa] master 16486d5 394/399: ivy.el (ivy--shorter-matches-first): Add and use for ivy-completion-in-region, Oleh Krehel, 2019/07/20
- [elpa] master f99f13a 396/399: Increase swiper-isearch cursor overlay priority, Oleh Krehel, 2019/07/20