[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 6d4f2b3 34/57: Fix the error switching to non-existent buf
From: |
Oleh Krehel |
Subject: |
[elpa] master 6d4f2b3 34/57: Fix the error switching to non-existent buffers |
Date: |
Tue, 19 May 2015 14:21:34 +0000 |
branch: master
commit 6d4f2b321636515582ec6fb234d261c031462a11
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
Fix the error switching to non-existent buffers
* ivy.el (ivy-read): Use `ivy-add-virtual-buffers'.
(ivy-buffer-list): Remove.
(ivy-add-virtual-buffers): New defun.
(ivy--switch-buffer-action): New defun, consider `ivy--current' being
zero length.
(ivy-switch-buffer): Use `ivy--switch-buffer-action'.
Fixes #101
---
ivy.el | 60 +++++++++++++++++++++++++++++-------------------------------
1 files changed, 29 insertions(+), 31 deletions(-)
diff --git a/ivy.el b/ivy.el
index feed8c3..b9fbf0b 100644
--- a/ivy.el
+++ b/ivy.el
@@ -637,13 +637,15 @@ RE-BUILDER is a lambda that transforms text into a regex."
(setq initial-input nil)))
((eq collection 'internal-complete-buffer)
(setq coll
- (mapcar (lambda (x)
- (if (with-current-buffer x
- (file-remote-p
- (abbreviate-file-name default-directory)))
- (propertize x 'face 'ivy-remote)
- x))
- (all-completions "" collection predicate))))
+ (ivy-add-virtual-buffers
+ (mapcar
+ (lambda (x)
+ (if (with-current-buffer x
+ (file-remote-p
+ (abbreviate-file-name default-directory)))
+ (propertize x 'face 'ivy-remote)
+ x))
+ (all-completions "" collection predicate)))))
((or (functionp collection)
(vectorp collection)
(listp (car collection)))
@@ -1134,9 +1136,6 @@ CANDS is a list of strings."
(defvar recentf-list)
(defvar ido-use-faces)
-(defvar ido-process-ignore-lists)
-(defvar ido-ignored-list)
-(declare-function ido-make-buffer-list "ido")
(defun ivy--virtual-buffers ()
"Adapted from `ido-add-virtual-buffers-to-list'."
@@ -1169,33 +1168,32 @@ CANDS is a list of strings."
(setq ivy--virtual-buffers (nreverse virtual-buffers))
(mapcar #'car ivy--virtual-buffers))))
-(defun ivy-buffer-list ()
- "Return the current list of buffers.
-See `ido-make-buffer-list'."
- (require 'ido)
- (setq ivy--virtual-buffers nil)
- (let ((ido-process-ignore-lists t)
- ido-ignored-list)
- (delete-dups
- (append (ido-make-buffer-list nil)
- (and
- ivy-use-virtual-buffers
- (ivy--virtual-buffers))))))
+(defun ivy-add-virtual-buffers (buffer-list)
+ "Add virtual buffers to BUFFER-LIST."
+ (delete-dups
+ (append
+ buffer-list
+ (and ivy-use-virtual-buffers
+ (ivy--virtual-buffers)))))
+
+(defun ivy--switch-buffer-action ()
+ "Finalizer for `ivy-switch-buffer'."
+ (if (zerop (length ivy--current))
+ (switch-to-buffer
+ ivy-text nil 'force-same-window)
+ (let ((virtual (assoc ivy--current ivy--virtual-buffers)))
+ (if virtual
+ (find-file (cdr virtual))
+ (switch-to-buffer
+ ivy--current nil 'force-same-window)))))
(defun ivy-switch-buffer ()
"Switch to another buffer."
(interactive)
(if (not ivy-mode)
(call-interactively 'switch-to-buffer)
- (let ((bl (ivy-buffer-list)))
- (ivy-read "Switch to buffer: " bl
- :action
- (lambda ()
- (let ((virtual (assoc ivy--current ivy--virtual-buffers)))
- (if virtual
- (find-file (cdr virtual))
- (switch-to-buffer
- ivy--current nil 'force-same-window))))))))
+ (ivy-read "Switch to buffer: " 'internal-complete-buffer
+ :action #'ivy--switch-buffer-action)))
(provide 'ivy)
- [elpa] master 056614d 22/57: Rename avy-swiper to swiper-avy, (continued)
- [elpa] master 056614d 22/57: Rename avy-swiper to swiper-avy, Oleh Krehel, 2015/05/19
- [elpa] master cf292da 23/57: Declare swiper-map, Oleh Krehel, 2015/05/19
- [elpa] master a953af0 19/57: Simplify ivy-partial-or-done, Oleh Krehel, 2015/05/19
- [elpa] master fe34d2c 10/57: ivy.el (ivy-partial-or-done): Handle empty input, Oleh Krehel, 2015/05/19
- [elpa] master 77abf00 25/57: ivy.el (ivy-backward-kill-word): Add and bind to "M-DEL", Oleh Krehel, 2015/05/19
- [elpa] master 8c936bc 21/57: ivy.el (ivy-use-virtual-buffers): New defcustom, Oleh Krehel, 2015/05/19
- [elpa] master 9b9885d 33/57: ivy.el (ivy-partial-or-done): Fixup, Oleh Krehel, 2015/05/19
- [elpa] master d841418 24/57: Fix the transition from a bad regex to good one, Oleh Krehel, 2015/05/19
- [elpa] master 2ad5fb1 20/57: Add support for virtual buffers, Oleh Krehel, 2015/05/19
- [elpa] master f97622d 30/57: swiper.el (swiper-font-lock-ensure): Ignore fundamental-mode, Oleh Krehel, 2015/05/19
- [elpa] master 6d4f2b3 34/57: Fix the error switching to non-existent buffers,
Oleh Krehel <=
- [elpa] master 16eb4a2 31/57: When completing file names, defer to `minibuffer-complete' for "TAB", Oleh Krehel, 2015/05/19
- [elpa] master b63c358 35/57: Properly update virtual buffers for "^ " interaction, Oleh Krehel, 2015/05/19
- [elpa] master d8f79fa 43/57: ivy.el (ivy-partial-or-done): Update doc, Oleh Krehel, 2015/05/19
- [elpa] master ce0efb3 29/57: Allow to customize the minibuffer formatter, Oleh Krehel, 2015/05/19
- [elpa] master 9a2083a 27/57: Swiper should use the :re-builder argument, Oleh Krehel, 2015/05/19
- [elpa] master d8c2ef3 45/57: ivy.el (ivy-partial-or-done): More predictability, Oleh Krehel, 2015/05/19
- [elpa] master e05e3b7 39/57: ivy.el (ivy-read): Keep the last ivy--index for :dynamic-collection, Oleh Krehel, 2015/05/19
- [elpa] master 1cdb6ed 32/57: ivy.el (ivy-partial-or-done): Fixup, Oleh Krehel, 2015/05/19
- [elpa] master 5f2cf0c 28/57: Update test, Oleh Krehel, 2015/05/19
- [elpa] master 6405cb3 42/57: ivy.el (ivy-partial-or-done): Always forward to `ivy-alt-done', Oleh Krehel, 2015/05/19