[emacs-berlin] Open a new window splitting the frame horizontally

Christian Tietze me at christiantietze.de
Tue Nov 19 12:32:32 UTC 2024


I found the `display-buffer-alist' tricky, too, when I started to experiment. Eventually, this article helped to find a couple of use cases I absolutely wanted:
https://www.masteringemacs.org/article/demystifying-emacs-window-manager

And then with time, I managed to tweak settings to produce sidebars and the like myself, so don't give up :)

> I want to modify this behaviour so that the search results window
> containing the *rg* buffer always splits the frame horizontally.

Vertically, you mean (from the rest of your description)?

Horizontal would put two windows like this:

┌─┬─┐
│A│B│
└─┴─┘

Vertical like this:

┌─┐
│A│
├─┤
│B│
└─┘



> I've looked at the Emacs documentation[1]. I think I can accomplish this with the following snippet:
>
> (setopt
>  display-buffer-alist
>  '(("\\*rg\*"
>     (display-buffer-below-selected display-buffer-at-bottom)
>     )))

These settings work from me when I run `rg` interactively, splitting the frame's sole window in 2, showing a bottom window at ~40% height:

--8<---------------cut here---------------start------------->8---
(add-to-list 'display-buffer-alist
             '("\\*rg\\*"
              (display-buffer-in-direction
               display-buffer-select)
              (direction . down)
              (window-height . 0.4)))
--8<---------------cut here---------------end--------------->8---

Hope that helps!

Cheers,
Christian

-- 
Sent from Bielefeld, Germany ⛫
https://christiantietze.de -- Become the best developer you can be
https://zettelkasten.de    -- Create knowledge from information


More information about the emacs-berlin mailing list