Dedicated window troubles

From:

Tassilo Horn

Subject:

Dedicated window troubles

Date:

Thu, 19 Feb 2015 11:06:45 +0100

Hi all,
I have a wide screen, so I use
(setq split-width-threshold 152
split-height-threshold nil)
so that Emacs favors splitting horizontally so that I end up with two
side-by-side windows. That works ok, but I run into troubles when I
decide to make one of the side-by-side windows dedicated to its buffer.
For example, now I have a buffer for editing a latex document shown in
the left window, and the right window displays the resulting PDF file
and is dedicated to that buffer.
+------------------------------+---------------------------------+
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| latex-file | PDF <dedicated> |
+------------------------------+---------------------------------+
What I'd like to have now when doing, e.g., `C-h f defun RET' is that
the left window is split vertically, and the *Help* buffer is now shown
in the new, lower-left window. What actually happens is that the left
window's buffer switches to *Help*.
That might be reasonable but other functions exhibit even stranger
behavior:
(switch-to-buffer-other-window "*Help*") ;; Pops up a new *frame*
(pop-to-buffer "*Help*") ;; Swiches buffer in the current window
Especially that `switch-to-buffer-other-window' pops up a new frame (and
I have `pop-up-frames' set to nil) is really annoying. And I'd usually
expect from `pop-to-buffer' that it creates a new window if there's
enough space (and here the left window is more than 80 lines tall) but
it doesn't.
I think the reason for that inconvenience is that by setting
`split-height-threshold' to nil, I have effectively forbidden
`split-window-sensibly' to perform a vertical split in case there are
more than one window. Well, that's properly documented, but what
configuration am I supposed to use so that Emacs prefers horizontal
splits if the window to be split is wide enough and falls back to
vertical splitting otherwise?
Currently, the only way I see is to have my own
`split-window-preferred-function' which is exactly like
`split-window-sensibly' but tries horizontal splits first, then vertical
splits, and then the fallback case. Then I could go with
`split-width-threshold' set to 152 as its now and
`split-height-threshold' set to something like 60 or so.
But since wide displays are so common nowadays, there must be an easy
way to achieve what I'm looking for, no?
Bye,
Tassilo