Bad-ptr / persp-mode.el

named perspectives(set of buffers/window configs) for emacs
394 stars 44 forks source link

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

Open fab6 opened 2 years ago

fab6 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago
(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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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

thecashewtrader commented 2 years ago

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 commented 1 month ago

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.