[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Dedicated window troubles
From: |
Tassilo Horn |
Subject: |
Re: Dedicated window troubles |
Date: |
Thu, 19 Feb 2015 14:26:09 +0100 |
User-agent: |
Gnus/5.130012 (Ma Gnus v0.12) Emacs/25.0.50 (gnu/linux) |
Alexis <flexibeast@gmail.com> writes:
> TH> But since wide displays are so common nowadays, there must be an TH> easy
> way to achieve what I'm looking for, no?
>
> Given my own workflow and preferences, i too am very interested in how
> to achieve this!
FWIW, since nobody replied within 10 minutes, that's what I'm using now:
--8<---------------cut here---------------start------------->8---
(setq split-width-threshold 152
split-height-threshold 60)
(defun th/split-window-sensibly (&optional window)
"Split WINDOW in a way suitable for `display-buffer'.
Like `split-window-sensibly' but first try horizontal splits,
then vertical splits, and also try not to split dedicated
windows."
(let ((window (or (and window (not (window-dedicated-p 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 vertically disregarding
;; the value of `split-height-threshold'.
(let ((split-height-threshold 0))
(when (window-splittable-p window)
(with-selected-window window
(split-window-below))))))))
(setq split-window-preferred-function #'th/split-window-sensibly)
--8<---------------cut here---------------end--------------->8---
That works fine so far. I also modified it so that it is less likely to
split dedicated windows.
Bye,
Tassilo