Path: csiph.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!eternal-september.org!.POSTED!not-for-mail From: Aidan Hall Newsgroups: comp.emacs Subject: Re: Sharing my split-window-preferred-function that splits at (pixel-wise) longer window-edge Date: Wed, 17 Dec 2025 19:16:10 +0000 Organization: Black Mesa Lines: 33 Message-ID: <87ecosvs05.fsf@gmail.com> References: <871pmjqaxq.fsf@posteo.de> MIME-Version: 1.0 Content-Type: text/plain Injection-Date: Wed, 17 Dec 2025 19:16:11 +0000 (UTC) Injection-Info: dont-email.me; posting-host="2afe9a7fd670954ad77f3137928debb2"; logging-data="3950769"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX181Un7TkNgHAOCoKlnOAlvD+pg6CCMJqYk=" User-Agent: Gnus/5.13 (Gnus v5.13) Cancel-Lock: sha1:g+/7sm0QPhyrlItOPyxqvjDZRQg= sha1:qDlUTQ5Ij8OTtMttoDkhHzA+hL8= Xref: csiph.com comp.emacs:2509 Mekeor Melire writes: > (defun split-window-rationally (&optional window) > "Split window at its pixelwise longer edge." > (interactive) > (let ((window (or window (selected-window))) > (split-height-threshold 0) > (split-width-threshold 0) > (ratio (>= (window-pixel-width) (window-pixel-height)))) > (with-selected-window window > (cond ((and ratio (window-splittable-p window t)) > (split-window-right)) > ((and (not ratio) (window-splittable-p window)) > (split-window-below)) > ((window-splittable-p window t) > (split-window-right)) > ((window-splittable-p window) > (split-window-below)))))) I like the general idea of splitting based on pixel widths, since it makes the logic independent of a given window's text scale. One issue with this function is that it doesn't account for characters generally being taller than they are wide. You could do something similar using "scale independent window width/height in characters", computed like so: (/ (window-pixel-width) (frame-char-width)) Both your approach and this degrade (somewhat) gracefully to character counts in terminal frames, where: (window-pixel-width) = (window-width) (frame-char-width) = 1