I have two frames open with the following window splits:
Frame 1 Frame 2
|---+---+ |------|
|a |b | |d |
| | | | |
|---+---+ | |
|c | | |
|---+---+ |------|
Say that I am in window "a"
or "b"
. Sometimes when I call a function that needs a window, a new, tiny one "e"
will be created instead of using a current one. This new window is often too small to be of use.
Frame 1 Frame 2
|---+---+ |------|
|a |b | |d |
| | | | |
|---+---+ | |
|c |e | | |
|---+---+ |------|
How could I open new windows in one of the currently existing vertical windows, "a"
, "b"
, or "d"
?
I have experienced this issue with at least occur
and xref-find-definitions-other-window
.
The crux of the issue seems to be with the display-buffer
function. At first glance it seemed like I could use display-buffer-in-side-window
to get the behavior I want. In the case of occur
, I came up with
(setq
display-buffer-alist
`(("\\*Occur\\*"
display-buffer-in-side-window
(side . right)
(slot . 0)
(window-width . fit-window-to-buffer))))
This has two problems.
First, it turns out that a side window isn't a window like "b"
is to "a"
. Instead, it is a 'hidden' window that can be toggled. For instance, the above code does the following when in window "a"
, "b"
, or "c"
Frame 1 Frame 2
|---+---+---| |---|
|a |b |e | |d |
| | | | | |
|---+---+ | | |
|c | | | |
|---+---+---| |---|
and does the following when in "d"
Frame 1 Frame 2
|---+---+ |---|---|
|a |b | |d |e |
| | | | | |
|---+---+ | | |
|c | | | |
|---+---+ |---|---|
Unfortunately, Frame 2 lives on a vertically aligned monitor and the windows "d"
and "e"
are too narrow to be convenient. It's the same kind of problem as before!
The second problem is that it relies on an explicit buffer name. When using xref-find-definitions-other-window
, the buffer name varies.