TIL that I can use display-buffer-alist to define a custom placement behaviour for specific buffers.
I started using claude-code-ide.el for AI pair programming in Emacs, but the default buffer layout doesn't work for me. My Emacs setup has three tall frames side by side, filling the screen. By default claude-code-ide uses a side window for the claude-code CLI which results in an unusable layout in the active frame.
This layout only seems appropriate for a wide frame, if I had a single frame full-screen for example. Thankfully claude-code-ide has a setting to change its behaviour:
(setopt claude-code-ide-use-side-window nil)
This makes claude-code-ide use the default (other-window)
behaviour, splitting the window
vertically, which is still less than awesome. What I'd like to happen is for the claude-code CLI
buffer to be placed in one of the other open frames, and it turns out that I can configure this
exact behaviour with display-buffer-alist
:
(setopt
display-buffer-alist
'((".*claude-code.*"
(display-buffer-use-some-frame
display-buffer-pop-up-frame)
(reusable-frames . visible))))
This instructs display-buffer
to use an existing visible frame or to pop up a new frame if I
only have a single visible frame.
Along the way, I reminded myself about next-window-any-frame which I'd forgotten is bound to
s-'
. I prefer to use ace-window which is like a window power tool.
The Zen of Buffer Display has more examples and explains the related behavioural considerations.