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

restrict buffers only to frame/window with vertico/consult #125

Open
fab6 opened this issue Nov 4, 2021 · 8 comments
Open

restrict buffers only to frame/window with vertico/consult #125

fab6 opened this issue Nov 4, 2021 · 8 comments

Comments

@fab6
Copy link

fab6 commented Nov 4, 2021

Hi,
coming from spacemacs I am used to have only buffers in each frame/window (sorry, I do not understand the difference yet in terms of persp).

With a plain vanilla evil-vertico-consult installation of persp I am having a complete sharing of all buffers and sometimes the open buffer in another window/frame changes when I active in a new frame/window.

Does anyone have a hint how I can get a restriction of the buffers only to the frames/windows? I have the feeling that this might be due to vertico/consult...

Thank you in advance!

@Bad-ptr
Copy link
Owner

Bad-ptr commented Nov 5, 2021

Emacs Frame -- is a "System(OS) Window".
Emacs Window -- is a "pane" displaying a part of a buffer inside Emacs Frame.
Emacs Buffer -- is a buffer with text lines of a file.
Perspective -- is a collection of buffers.

So you want your buffer list to be "isolated" between Emacs Frames?
Or you want your perspectives list to be different between Emacs Frames?

@fab6
Copy link
Author

fab6 commented Nov 5, 2021

thank you for the quick overview!

I want an isolated buffer list for each perspective. At the moment I have all buffers in each perspective when using switch-to-buffer or consult-buffer.

... and when I am writing this, I assume that this is normal and I have to use persp-switch-to-buffer to have isolation and that spacemacs does something in addition to use it in combination with e.g. consult-buffer. Is this right?
Thank you very much!

@fab6
Copy link
Author

fab6 commented Nov 5, 2021

(defun compleseus/pre-init-persp-mode ()
  (spacemacs|use-package-add-hook persp-mode
    :post-config
    (setq
     spacemacs--persp-display-buffers-func 'spacemacs/compleseus-switch-to-buffer
     spacemacs--persp-display-perspectives-func 'spacemacs/compleseus-spacemacs-layout-layouts)))

I assume it is this spacemacs part which does it

@fab6
Copy link
Author

fab6 commented Nov 5, 2021

with

(defun spacemacs/compleseus-switch-to-buffer ()
  "`consult-buffer' with buffers provided by persp."
  (interactive)
  (with-persp-buffer-list ()
                          (consult-buffer)))

and

(defvar spacemacs--persp-display-buffers-func 'ignore
  "Function to display buffers in the perspective.")
(defun spacemacs/persp-buffers ()
  "Call the function defined in `spacemacs--persp-display-buffers-func'"
  (interactive)
  (call-interactively spacemacs--persp-display-buffers-func))

@Bad-ptr
Copy link
Owner

Bad-ptr commented Nov 5, 2021

Yes, spacemacs/compleseus-switch-to-buffer looks like it will work for you.
Other pieces of code seems to be spacemacs specific.

You may wish to bind this function to C-x b or other keys you like.
Something like:

(with-eval-after-load "persp-mode-autoloads"
  (with-eval-after-load "consult")
     (defun my/consult-switch-to-buffer ()
         "`consult-buffer' with buffers provided by persp."
         (interactive)
         (with-persp-buffer-list () (consult-buffer))
      (global-set-key (kbd "C-x b") #'my/consult-switch-to-buffer)))

There is also consult-buffer-filter as I see which you can customize if above function will not work.

@fab6
Copy link
Author

fab6 commented Nov 5, 2021

I think this works quite well for me, thank you very much!

@thecashewtrader
Copy link

It works with consult, but I wonder if there's a way to get it working with just Vertico - i.e. the raw switch-to-buffer and kill-buffer commands.

@breadsander
Copy link

Yes, spacemacs/compleseus-switch-to-buffer looks like it will work for you. Other pieces of code seems to be spacemacs specific.

You may wish to bind this function to C-x b or other keys you like. Something like:

(with-eval-after-load "persp-mode-autoloads"
  (with-eval-after-load "consult")
     (defun my/consult-switch-to-buffer ()
         "`consult-buffer' with buffers provided by persp."
         (interactive)
         (with-persp-buffer-list () (consult-buffer))
      (global-set-key (kbd "C-x b") #'my/consult-switch-to-buffer)))

There is also consult-buffer-filter as I see which you can customize if above function will not work.

Thank you! This works perfectly.

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

4 participants