[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 74d83ab 216/348: Sort virtual buffers after open buffers.
From: |
Oleh Krehel |
Subject: |
[elpa] master 74d83ab 216/348: Sort virtual buffers after open buffers. |
Date: |
Sat, 8 Apr 2017 11:03:59 -0400 (EDT) |
branch: master
commit 74d83ab7ac5c7adafaeeedfb3d9f0afca3d2f296
Author: Wilfred Hughes <address@hidden>
Commit: Oleh Krehel <address@hidden>
Sort virtual buffers after open buffers.
Fixes #706.
Fixes #743.
---
ivy.el | 25 ++++++++++++++++++-------
1 file changed, 18 insertions(+), 7 deletions(-)
diff --git a/ivy.el b/ivy.el
index 23ce80b..bc00f5b 100644
--- a/ivy.el
+++ b/ivy.el
@@ -2491,24 +2491,35 @@ Prefix matches to NAME are put ahead of the list."
(nreverse res-noprefix)))))
(defun ivy-sort-function-buffer (name candidates)
- "Re-sort CANDIDATES.
-Prefer first \"^*NAME\", then \"^NAME\"."
+ "Re-sort CANDIDATES, a list of buffer names that contain NAME.
+Sort open buffers before virtual buffers, and prefix matches
+before substring matches."
(if (or (string-match "^\\^" name) (string= name ""))
candidates
(let* ((base-re (funcall ivy--regex-function name))
(base-re (if (consp base-re) (caar base-re) base-re))
(re-prefix (concat "^\\*" base-re))
res-prefix
- res-noprefix)
+ res-noprefix
+ res-virtual-prefix
+ res-virtual-noprefix)
(unless (cl-find-if (lambda (s) (string-match re-prefix s)) candidates)
(setq re-prefix (concat "^" base-re)))
(dolist (s candidates)
- (if (string-match re-prefix s)
- (push s res-prefix)
- (push s res-noprefix)))
+ (cond
+ ((and (assoc s ivy--virtual-buffers) (string-match re-prefix s))
+ (push s res-virtual-prefix))
+ ((assoc s ivy--virtual-buffers)
+ (push s res-virtual-noprefix))
+ ((string-match re-prefix s)
+ (push s res-prefix))
+ (t
+ (push s res-noprefix))))
(nconc
(nreverse res-prefix)
- (nreverse res-noprefix)))))
+ (nreverse res-noprefix)
+ (nreverse res-virtual-prefix)
+ (nreverse res-virtual-noprefix)))))
(defun ivy--recompute-index (name re-str cands)
(let* ((caller (ivy-state-caller ivy-last))
- [elpa] master 04c2160 151/348: Replace references to evil-jumper with evil-jumps, (continued)
- [elpa] master 04c2160 151/348: Replace references to evil-jumper with evil-jumps, Oleh Krehel, 2017/04/08
- [elpa] master c2974a5 154/348: Depend on Emacs 24.3, since user-error is used, Oleh Krehel, 2017/04/08
- [elpa] master e9db958 145/348: Rename ivy-recentf -> counsel-recentf, Oleh Krehel, 2017/04/08
- [elpa] master 78be161 165/348: Fix alist and :predicate interaction, Oleh Krehel, 2017/04/08
- [elpa] master 1c09e99 156/348: ivy.el (ivy-call): Use select-window, not with-ivy-window, Oleh Krehel, 2017/04/08
- [elpa] master ec42e8a 177/348: swiper.el (swiper-multi-action-1): Fix regression, Oleh Krehel, 2017/04/08
- [elpa] master 778c325 183/348: ivy.el (ivy-call): Don't switch windows for 'identity action, Oleh Krehel, 2017/04/08
- [elpa] master 1e96d20 201/348: ivy-overlay.el (ivy-display-function-overlay): Fix up, Oleh Krehel, 2017/04/08
- [elpa] master f5276b0 180/348: Add char-fold-to-regexp option to swiper, Oleh Krehel, 2017/04/08
- [elpa] master 9f5f6e0 202/348: ivy-overlay.el (ivy-overlay-cleanup): Fixup, Oleh Krehel, 2017/04/08
- [elpa] master 74d83ab 216/348: Sort virtual buffers after open buffers.,
Oleh Krehel <=
- [elpa] master 17f8fb3 219/348: ivy.el (ivy-switch-buffer-other-window): Obey ivy-ignore-buffers, Oleh Krehel, 2017/04/08
- [elpa] master 07388d0 226/348: Shrink ivy to suitable height when reading actions., Oleh Krehel, 2017/04/08
- [elpa] master 2237916 223/348: ivy.el (ivy-call): setq default-directory instead of let, Oleh Krehel, 2017/04/08
- [elpa] master 1d97984 227/348: Ensure that ivy--regex-ignore-order always returns legal regexps, Oleh Krehel, 2017/04/08
- [elpa] master 7e02815 235/348: Fix counsel-rg to follow matching candidate, Oleh Krehel, 2017/04/08
- [elpa] master 530b7de 246/348: ivy.el: Use predicate when reading file names, Oleh Krehel, 2017/04/08
- [elpa] master 1c801a0 243/348: Ignore TAGS buffers in swiper-all, Oleh Krehel, 2017/04/08
- [elpa] master 6519ecc 248/348: ivy.el (ivy-call): Don't mess with default-directory, Oleh Krehel, 2017/04/08
- [elpa] master 721db4c 244/348: counsel.el (counsel-grep-post-action-hook): New hook for counsel-ag/grep/pt, Oleh Krehel, 2017/04/08
- [elpa] master 49acd4c 242/348: Remap scroll-up/down-command instead of assigning C-v/M-v so page up/down works, Oleh Krehel, 2017/04/08