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

Add multiple buffers at once #54

Open
alphapapa opened this issue Oct 17, 2015 · 7 comments
Open

Add multiple buffers at once #54

alphapapa opened this issue Oct 17, 2015 · 7 comments

Comments

@alphapapa
Copy link

I use Helm, so when I tried persp-add-buffer, I selected several buffers with Helm, but only the first one was added. It would be very helpful if you could add multiple buffers at once. I was going to add all my org-mode buffers to an org-mode perspective, but doing it one-at-a-time...

@zenspider
Copy link
Collaborator

I don't use helm, but patches are welcome.

Since nobody seems to be clamoring for this, it might be considered out of scope.

@gcv
Copy link
Collaborator

gcv commented Nov 27, 2019

Let's keep this one open for now. I actually ran into a situation yesterday when I wanted this feature and remembered this ticket.

@gcv
Copy link
Collaborator

gcv commented Jan 27, 2020

@alphapapa: I'm looking into this, and... I guess I'm not as proficient with Helm as I thought (which wasn't very).

How do I select a series of files in Helm and feed them to an arbitrary command, e.g., persp-add-buffer? I usually just end up in Helm's projectile integration browser, and I know how to mark several files, but hitting Tab gives me a canned list of commands. I don't see a way to invoke a command on the selection. I read on the wiki something about making eshell aliases, but though I can pick an alias somewhere in the command tree, it doesn't seem to do anything at all (or maybe I didn't define one correctly).

@gcv
Copy link
Collaborator

gcv commented Aug 19, 2021

With commit 0b693bd, helm-buffers-list now lists buffers in all perspectives when called with a prefix argument. It now has actions to add to the current perspective, and to remove buffers from the current perspective. It supports both actions with multiple marked buffers. If anyone has ideas about how to make Helm work directly from persp-add-buffer, let me know (either reopen this ticket or make a new one).

@gcv gcv closed this as completed Aug 19, 2021
@meliache
Copy link

meliache commented Sep 8, 2021

I'd like to be able to add multiple buffers at once without helm, just using the generic completing-read-multiple (which I use via selectrum).

I was thinking about creating a new issue, but searched the closed issues first and found this. The issue title doesn't mention helm explicitly, so I think a more generic solution could be discussed.

Now that I think about it, it would be also useful to batch-remove buffers from a perspective. I haven't created my own completing-read-multiple-functions, but whenever packages use that out of the box (e.g. for tagging), I found it incredibly useful.

Instead of via completing-read-multiple, it is also convenient to add/remove marked buffers from ibuffer. Here's what I came up with:

  (defun meliache/persp-ibuffer-remove-marked-buffers ()
    (interactive)
    (dolist (buffer (ibuffer-get-marked-buffers))
      (persp-remove-buffer buffer)))

  (defun meliache/persp-ibuffer-add-marked-buffers ()
    (interactive)
    (dolist (buffer (ibuffer-get-marked-buffers))
      (persp-add-buffer buffer)))

It might be useful to have some similar functions built in or at least documented somewhere.

@gcv
Copy link
Collaborator

gcv commented Sep 9, 2021

Re: completing-read-multiple: I like that. I think persp-add-buffer and persp-remove-buffer can be modified to use completing-read-multiple. There might be minor complications with persp-interactive-completion-function.

Re: ibuffer. Your functions look fine, I can add them (feel free to open a PR [and don’t forget the needed declare-function calls], or I’ll just do it later). What’s the right way to integrate them with ibuffer? Is there a keymap they should be added to? Or just let users run them with M-x?

@gcv gcv reopened this Sep 9, 2021
@meliache
Copy link

meliache commented Sep 9, 2021

Re: ibuffer. Thanks, I might do the PR. I came up with the functions rather on the fly, while writing the comment I wanted to write that such functions would be useful, but then I thought this should be easy to do myself if there's a way to get the marked buffers and it was. I didn't think much about keymaps yet, after all we don't have a special "persp-ibuffer" mode, so the only way would be to add keybindings to ibuffer-mode-map (or create a new keymap). So far I just used the commands interactively via M-x. Maybe it would be useful to shadow the keybindings for persp-add-buffer and persp-remove-buffer with their ibuffer-versions while in ibuffer-mode, though this than makes it difficult to add/remove the ibuffer-buffer, so I'm not sure if that's good UX design.

When I run persp-ibuffer and then meliache/persp-ibuffer-remove-marked-buffers, this doesn't remove the removed buffers from the ibuffer view, so sometimes I call persp-ibuffer again to update the view. It would be nice to have this update done automatically, though that shouldn't be done when run withing a normal ibuffer showing all perspectives.

Also I didn't think yet whether I should unmark the files after executing one of the above commands.

I think we could continue such discussions in the PR.

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

No branches or pull requests

4 participants