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

Extra buffers popping up all over the place when switch-to-buffer-obey-display-actions is non-nil #337

Open
Stewmath opened this issue Jun 2, 2024 · 0 comments

Comments

@Stewmath
Copy link

Stewmath commented Jun 2, 2024

The switch-to-buffer-obey-display-actions variable makes switch-to-buffer behave like display-buffer. I've been experimenting with this setting to make my window management more consistent. However this makes poly-mode misbehave.

When using ChatGPT.el which uses poly-mode, I found that whenever I put the cursor onto a new span (ie. moving from english text to a C# code region), a separate window would pop up for that region, instead of replacing the current buffer.

The following configuration is what caused the issue to occur:

;; Make switch-buffer obey rules set below
(setq switch-to-buffer-obey-display-actions t)

;; Number of sidebars allowed on left, top, right, bottom
(setq window-sides-slots '(nil nil 1 nil))

(add-to-list 'display-buffer-alist
             '("\\*ChatGPT\\*$"
               (display-buffer-reuse-window
                display-buffer-reuse-mode-window
                display-buffer-in-side-window)
               (side . right)
               (slot . 0)
               (window-parameters . ((no-delete-other-windows . t)))
               (window-width . 0.45)))

I used the following code to fix the issue in my config - presumably a similar fix could be applied to this repository:

(after! polymode
  (defun polymode-switch-to-buffer-fix (oldfun &rest args)
    (let ((switch-to-buffer-obey-display-actions nil))
      (apply oldfun args)
      ))

  (advice-add #'pm--select-existing-buffer-visibly :around #'polymode-switch-to-buffer-fix)
  (advice-add #'polymode-after-change-major-mode-cleanup :around #'polymode-switch-to-buffer-fix)
  )
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

1 participant