From f8f6a42dbfd1d3021993b727039d3545c21a2e3e Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Fri, 11 Dec 2020 18:23:16 -0600 Subject: Split windows more sensibly --- config.org | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/config.org b/config.org index 32635d9..459c179 100644 --- a/config.org +++ b/config.org @@ -247,6 +247,43 @@ This still doesn’t work under Windows – I have to manually download the [[ht (cuss indicate-empty-lines t) #+end_src +** Windows + +*** Split windows /more/ sensibly + +from [[https://stackoverflow.com/questions/23659909/reverse-evaluation-order-of-split-height-threshold-and-split-width-threshold-in][Stack Overflow]]. + +#+begin_src emacs-lisp + (defun my-split-window-sensibly (&optional window) + (let ((window (or window (selected-window)))) + (or (and (window-splittable-p window t) + ;; Split window horizontally. + (with-selected-window window + (split-window-right))) + (and (window-splittable-p window) + ;; Split window vertically. + (with-selected-window window + (split-window-below))) + (and (eq window (frame-root-window (window-frame window))) + (not (window-minibuffer-p window)) + ;; If WINDOW is the only window on its frame and is not the + ;; minibuffer window, try to split it horizontally disregarding + ;; the value of `split-width-threshold'. + (let ((split-width-threshold 0)) + (when (window-splittable-p window t) + (with-selected-window window + (split-window-right)))))))) + + (setq split-window-preferred-function #'my-split-window-sensibly) +#+end_src + +*** Winner mode + +#+begin_src emacs-lisp + (when (fboundp 'winner-mode) + (winner-mode +1)) +#+end_src + ** Startup #+begin_src emacs-lisp -- cgit 1.4.1-21-gabe81