Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

opening file from virtual buffer leads to empty buffer #839

Closed
kermorgant opened this issue Dec 26, 2016 · 10 comments
Closed

opening file from virtual buffer leads to empty buffer #839

kermorgant opened this issue Dec 26, 2016 · 10 comments

Comments

@kermorgant
Copy link

I've just installed ivy, wanting especially the virtual buffers (fast access to recent files).

Unfortunately, although C-x C-b lists recently opened files, hitting RET on them opens an empty buffer.
I've tried removing big parts of my config file to narrow the issue but got no success.

Here is my config :

`
(use-package counsel
:ensure t
:init
(ivy-mode 1)
:config
(setq ivy-use-virtual-buffers t)
(setq ivy-count-format "(%d/%d) ")
(global-set-key (kbd "C-s") 'swiper)
(global-set-key (kbd "M-x") 'counsel-M-x)
(global-set-key (kbd "C-x C-f") 'counsel-find-file)
(global-set-key (kbd " f") 'counsel-describe-function)
(global-set-key (kbd " v") 'counsel-describe-variable)
(global-set-key (kbd " l") 'counsel-find-library)
(global-set-key (kbd " i") 'counsel-info-lookup-symbol)
(global-set-key (kbd " u") 'counsel-unicode-char)
(global-set-key (kbd "C-c C-r") 'ivy-resume)
(setq ivy-re-builders-alist
'((read-file-name-internal . ivy--regex-fuzzy)
(t . ivy--regex-plus)))

`

I've installed and activated recentf (although the list was correctly populated without) but nothing got better.

The variable ivy--virtual-buffers seems correct :

`
ivy--virtual-buffers is a variable defined in ‘ivy.el’.
Its value is shown below.

Documentation:
Store the virtual buffers alist.

Value:
((#("configuration.org" 0 17
(face ivy-virtual))
. "/home/mikael/.emacs.d/configuration.org")

`

Any idea about what could be wrong or how to debug this further ?

Thanks
Mikael

@kermorgant
Copy link
Author

Hello,

Just noticed it works when I use "C-x b" instead of "C-x C-b" !

@kermorgant
Copy link
Author

Although I found my way out of this issue, it may still be something to fix as my observed behaviour should imho not occur : if a virtual buffer appears in the list, it should be handled normally.

@abo-abo
Copy link
Owner

abo-abo commented Dec 27, 2016

C-x C-b calls list-buffers which is not at all related to ivy.
C-x b calls ivy-switch-buffer, which should work properly.

@bmag
Copy link

bmag commented Mar 2, 2017

Found a similar bug, not sure if I should open a new report:
With ivy-mode enabled and virtual buffers enabled, calling switch-to-buffer interactively shows virtual buffers (e.g. recent files), but selecting a virtual buffer opens an empty buffer.

In one of my packages there is some code (not critical, can live without it) that wraps C-x b and calls switch-to-buffer or other commands interactively, so it's affected by this.

Original report: bmag/ivy-purpose#1

@abo-abo
Copy link
Owner

abo-abo commented Mar 2, 2017

With ivy-mode enabled and virtual buffers enabled

Virtual buffers work properly only for ivy-switch-buffer, not for switch-buffer. There's no good way to make them work for switch-buffer.

ivy-mode remaps switch-buffer key binding to ivy-switch-buffer; it can't remap the cases where switch-buffer is called not from a key binding.

@bmag
Copy link

bmag commented Mar 2, 2017

I realize that. What I find weird is that the candidates for switch-to-buffer contain virtual buffers. (granted, I'm not very familiar with the virtual buffers concept)

@basil-conto
Copy link
Collaborator

basil-conto commented Feb 10, 2018

What I find weird is that the candidates for switch-to-buffer contain virtual buffers.

This is caused by the following lines in ivy-read:

swiper/ivy.el

Lines 1845 to 1846 in dfabc02

((eq collection 'internal-complete-buffer)
(setq coll (ivy--buffer-list "" ivy-use-virtual-buffers predicate)))

Because ivy-read often overrides all minibuffer completion, even switch-to-buffer passes through iyy-read and this gets detected as the internal-complete-buffer collection.

So this is definitely a bug in Ivy; question is, is it OK to reuse this issue or should I open a new one?

@abo-abo
Copy link
Owner

abo-abo commented Feb 11, 2018

@basil-conto Let's keep this issue. I agree that this looks like a bug.

@codesuki
Copy link

I had the same problem and reading this issue I figured out that purpose mode replaces my binds and calls switch-buffer directly. I thought it should work but #839 (comment) explains why it doesn't. In case some of you use purpose mode that might be it.

@abo-abo abo-abo closed this as completed in a9e81f8 May 8, 2019
@abo-abo
Copy link
Owner

abo-abo commented May 8, 2019

Thanks, please test.

astoff pushed a commit to astoff/swiper that referenced this issue Jan 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants