emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Prefer to split along the longest edge


From: Nicolas Desprès
Subject: Prefer to split along the longest edge
Date: Sat, 14 Dec 2024 11:05:30 +0100

Hi,

I have been enjoying using Emacs since more than 20 years now.  So,
thank you all guys for this impressive work.

It is the first time I send a patch to this list.  I am not a very
fluent lisp coder so please do apologies if the style is not very
good and feel free to tell me how to improve it.

Currently, `split-window-sensibly' prefers to split vertically,
disregarding the shape of the frame.  This is a good default when
Emacs is taller than wider.  However, when Emacs is in fullscreen
(landscape screen layout), splitting vertically is generally not the
thing to do because there is plenty of space on the right.

Typical scenario: Emacs is in fullscreen; one buffer is open in a window
covering the entire frame.  Another buffer is opened in a second
window (C-x 4 f). In this case, the split should generally be horizontal.
The attached patch changes `split-window-sensibly' to just try
spliting the longest edge first. It works well when implemented in my init.el
and installed by setting `split-window-preferred-function'.

However, when the same logic is implemented by directly modifying
`split-window-sensibly' in window.el, it does not work for one very specific
case: when the frame is 80x30 and C-x 4 f is pressed, the window is not
split and the buffer is opened in another frame. The problem seems to
come from the last eval _expression_ at the bottom of `split-window-sensibly',
but I failed to find a solution. I though better elisp coder than me will find a
solution quickly that's why I am posting here.

Apart from that, I have been using this alternate approach for a couple of
weeks now, and it works well, that's why I am submitting it for inclusion
in Emacs.

I have tested on 8d94a9ec613470b7e8e4ee0e86b643f34f8a724c with emacs built
with --with-imagemagick --with-native-compilation=yes --with-compress-install --with-mailutils --with-gnutls --with-tree-sitter --with-xwidgets --disable-gc-mark-trace --no-create --no-recursion on macOS 15.2.

Best regards,
Nico

--
Nicolas Desprès

Attachment: 0001-Split-along-the-longest-edge-by-default.patch
Description: Binary data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]