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

Virtual buffers? #9

Closed
fintelkai opened this issue Jan 25, 2020 · 17 comments
Closed

Virtual buffers? #9

fintelkai opened this issue Jan 25, 2020 · 17 comments

Comments

@fintelkai
Copy link

One thing I like about ivy is the injection of recent files into the switch buffer list. Is that in your plans for selectrum/prescient?

@raxod502
Copy link
Member

Not as an option to modify the behavior of switch-to-buffer. But you could implement such a command yourself using selectrum-completing-read, and use it instead of switch-to-buffer. What do you think of that?

@raxod502 raxod502 added the waiting on response Needs more info or follow-up, will be closed after 90 days if no response label Jan 26, 2020
@fintelkai
Copy link
Author

Thanks. Here's a proof of concept:

(defun kvf/recentf-find-file ()
  "Find a recent file using selectrum."
  (interactive)
  (let ((file (selectrum-completing-read "Choose recent file: "
                                         (mapcar 'abbreviate-file-name recentf-list)
                                         nil t)))
    (when file
      (find-file file))))

@raxod502
Copy link
Member

If it's important to you to show both files and buffers at the same time, I would suggest checking the source code of selectrum-read-buffer and modifying it to augment the list with files from recentf.

@fintelkai
Copy link
Author

Thanks. I'll close this issue and will continue experimenting when I have time.

@raxod502 raxod502 removed the waiting on response Needs more info or follow-up, will be closed after 90 days if no response label Jan 27, 2020
@andyleejordan
Copy link
Contributor

andyleejordan commented Apr 5, 2020

Hey @fintelkai, I'm looking for the same functionality (easy access to recentf, which I'm also used to via virtual buffers). What have you come up with since January? Or a broader question, what are folks using to access recently opened files if not through counsel/ivy's virtual buffers? I am struggling to find a function or package that even just lists recently opened files: everyone seems to do it through ido/ivy/helm.

Edit: Honestly what you've posted does like 90% of what I want, bound to C-x C-r like I had counsel-recentf. It's actually kind of nice that my buffer list is longer littered with a million files.

@fintelkai
Copy link
Author

@andschwa I'm currently experimenting with Doom, which has a recent file function, using ivy or helm and processing the recentf list.

@sewkokot
Copy link

sewkokot commented May 19, 2020

It seem that adding virtual buffers from recentf-list is not that easy as merely appending filenames from the recentf-list to the list of buffer names.

Looking at the virtual buffer implementations in ido and ivy (adapted from ido), the candidates from recentf-list are in the form of a list of alist '((name1 . path1) (name2 . path2)). The names serve for sorting, filtering and displaying results in the minibuffer and paths are for visiting the files (e.g. find-file-nonselect). Therefore the combined list of buffers and virtual buffers is passed to either switch-to-buffer or find-file.

In the current selectrum implementation, selectrum-read-buffer is set as read-buffer-function which at most serves for switching to buffer and not visiting files. Am I understanding it correctly?

@clemera
Copy link
Collaborator

clemera commented May 20, 2020

I added a command for that in the wiki

@andyleejordan
Copy link
Contributor

Oo a wiki...thanks @clemera!

@clemera
Copy link
Collaborator

clemera commented May 20, 2020

@andschwa Thanks for adding another one. I adjusted it to use completing-read. Whenever possible we should try to avoid to depend on selectrum.

@andyleejordan
Copy link
Contributor

@clemera That's hilarious, I just noticed that when I was looking at in my init.el and fixed it at the same time. Thanks! I borrowed the yank-pop replacement too 😄

@clemera
Copy link
Collaborator

clemera commented May 20, 2020

@andschwa Hehe, I think mine shouldn't depend on selectrum either, but I kind of like the narrowing by prefix.

@sewkokot
Copy link

sewkokot commented May 20, 2020

@clemera, thank you for selectrum-switch-buffer+
I appended my own list of frequently edited files to recentf-list, this way I use only one command instead of three or four to edit the buffer/file I need.

@raxod502
Copy link
Member

I have linked to the wiki from the README.

@haji-ali
Copy link
Contributor

Does selectrum-switch-buffer+ still work on the latest version of selectrum? I am getting

Error in post-command-hook (selectrum--minibuffer-post-command-hook): (void-variable cb)

@clemera
Copy link
Collaborator

clemera commented Aug 26, 2020

You have to enable lexical binding, by putting a

;; -*- lexical-binding: t -*-

at the top of the file.

@raxod502
Copy link
Member

I added this information also to the top of the wiki page. I cannot wait until lexical binding becomes the global default; in Emacs 27 it was changed for interactive evaluation but file buffers still use dynamic binding by default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

6 participants