How do I detect that an Emacs window has already been split?
In my .emacs
file, I have:
(when (display-graphic-p)
(set-frame-size (selected-frame) 166 85)
(split-window-horizontally))
which allows me to have two buffers side-by-side, each exactly 80 chars wide.
Every once in a while I change my .emacs file and want to reload it in place, so I run M-x load-file
on my .emacs file and that window I'm in gets re-split.
Is there some sort of command I can call to check if the frame has already been split and only call (split-window-horizontally)
if it hasn't? Something like:
(when (window-is-root)
(split-window-horizontally))
or
(when (not (window-is-already-split))
(split-window-horizontally))
window-list
will return you a list of the windows (for the current frame), so you should be able to do:
(when (= (length (window-list)) 1)
(split-window-horizontally))
Check out the relevant documentation for windows.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With