all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Tassilo Horn <tsdh@gnu.org>
To: Alexis <flexibeast@gmail.com>
Cc: help-gnu-emacs@gnu.org
Subject: Re: Dedicated window troubles
Date: Thu, 19 Feb 2015 14:26:09 +0100	[thread overview]
Message-ID: <87d256jamm.fsf@gnu.org> (raw)
In-Reply-To: <87d256oz82.fsf@gmail.com> (Alexis's message of "Thu, 19 Feb 2015 23:35:57 +1100")

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



  reply	other threads:[~2015-02-19 13:26 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-19 10:06 Dedicated window troubles Tassilo Horn
2015-02-19 12:35 ` Alexis
2015-02-19 13:26   ` Tassilo Horn [this message]
2015-02-19 13:32     ` Tassilo Horn

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87d256jamm.fsf@gnu.org \
    --to=tsdh@gnu.org \
    --cc=flexibeast@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.