How can I get sensible stack-like behavior from a bottom side-window? I've configured both Ag and Help to display their buffers using display-buffer-in-side-window
. I like to maintain a window configuration like
+-----------+ +-----------+
| | | |
| | | A | <- main workspace
| A | OR | |
| | +-----------+
| | | B | <- search/compilation/help
+-----------+ +-----------+
where A is my main work area, and B is acts as a drawer for things like search results, compilation errors, and Help buffers. In most cases, I'd like hitting q
in B to bury the buffer and delete the window. If B was displaying something else prior, I'd like q
to bury the current buffer and reveal the previous buffer. Once I've q
'd out of all the buffers that were displayed in B since it popped up, I'd like the window to be deleted. The buffer in A should not be part of this buffer stack.
For instance, say I start with my_code.rb
in A. I run a search and Ag pops up B to display the results. Hitting q
buries the Ag buffer and deletes B, leaving me with a clean view.
But say instead of q
'ing out of the search results, I ran a help command like describe-variable. A *Help* buffer supplants the search results in B. Hitting q
buries *Help* and the search results are visible again. I hit q
again, expecting it to bury the search results and delete B, but instead it displays my_code.rb
in B, leaving me with an unwanted split view.
It sounds like the quit-restore
window-parameter controls this, but I'm not sure how to manage it. I inspected its value using at various points during the above flow, and found the following:
search results displayed in B:
(window
window
#<window A on my_code.rb>
#<buffer *ag search text:my-search-term dir:~/my/path/*>)
help buffer displayed in B:
(other
(#<buffer *ag search text:my-search-term dir:~/my/path/*> 225
#<marker (moves after insertion) at 225 in *ag search text:my-search-term dir:~/my/path/*> 12)
#<window 72 on *ag search text:my-search-term dir:~/my/path/*>
#<buffer *Help*>)
search results again displayed in B after quitting the Help buffer:
nil
So it seems that quitting the Help buffer is causing the quit-restore
window parameter to be discarded wholesale?
For reference, this is my display-buffer-alist
configuration:
(setq
display-buffer-alist
`((,(rx bos
(or (and "*ag " (1+ not-newline) "*")
"*Help*")
eos)
(display-buffer-reuse-window
display-buffer-in-side-window)
(side . bottom))))