Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Splitting windows vertically doesn't work #12

Open
sondr3 opened this issue Mar 10, 2016 · 15 comments
Open

Splitting windows vertically doesn't work #12

sondr3 opened this issue Mar 10, 2016 · 15 comments
Assignees

Comments

@sondr3
Copy link

sondr3 commented Mar 10, 2016

Hello, this does everything I want for my purposes, however, it refuses to split up windows. I use Evil so I do C-w v to split my window vertically but get the following error message: split-window: Window #<window 3 on emacs.org> too small for splitting (2) [2 times]. However splitting horizontally works just fine. Any ideas why?

I'm using the Emacs 25.1 on OS X El Capitan.

@anler anler self-assigned this Mar 10, 2016
@anler
Copy link
Owner

anler commented Mar 10, 2016

I'll take a look asap.

@wagk
Copy link

wagk commented Mar 21, 2017

I'm facing the same problem, however, it appears that the issue does not affect M-x split-windows-horizontally

My current workaround until this is fixed is to put (evil-ex-define-cmd "vsp[lit]" 'split-window-horizontally) inside the evil config

An issue with this solution is that now the split windows are both centered. Toggling centered-window-mode does not fix this, but oddly does if the toggling is done in a frame where there are no splits.

@anler
Copy link
Owner

anler commented Apr 2, 2017

Hi, I pushed a new version that hopefully will fix this issue.

@xiongtx
Copy link
Collaborator

xiongtx commented Apr 27, 2017

Issue doesn't seem to be fixed with latest build.

Backtrace

When calling split-window-right:

Debugger entered--Lisp error: (error "Window #<window 369 on centered-window-mode.el> too small for splitting")
  signal(error ("Window #<window 369 on centered-window-mode.el> too small for splitting"))
  error("Window %s too small for splitting" #<window 369 on centered-window-mode.el>)
  split-window(nil nil t)
  split-window-right(nil)
  funcall-interactively(split-window-right nil)
  call-interactively(split-window-right nil nil)
  command-execute(split-window-right)

Environment

  • Emacs: 25.1.50.1
  • OS: Darwin C02RW05YFVH6 15.6.0

@anler
Copy link
Owner

anler commented Apr 27, 2017

I'm working on it, thanks for reporting it!

@xiongtx
Copy link
Collaborator

xiongtx commented May 11, 2017

@wagk Are you sure you've having problems splitting windows vertically and not horizontally?

split-window-horizontally:

+---------------+     +-------+-------+
|               |     |       |       |
|               | --> |       |       |
|               |     |       |       |
+---------------+     +-------+-------+

split-window-vertically:

+---------------+     +---------------+
|               |     |               |
|               | --> +---------------+
|               |     |               |
+---------------+     +---------------+

Fringes are on the left and right, so the trouble should be with splitting horizontally, not vertically. That's what I'm experiencing.

@wagk
Copy link

wagk commented May 11, 2017

@xiongtx Yes I believe split-window-horizontal was the one causing the issue. Apologies

@xiongtx
Copy link
Collaborator

xiongtx commented May 11, 2017

@anler It may be worth taking a look at writeroom-mode /visual-fill-column, which also center the window but don't have this splitting problem, for ideas on how to deal with this issue.

I haven't dug too deeply into how they do things, but one thing I see is that they use margins instead of fringes to center the window.

@anler
Copy link
Owner

anler commented May 23, 2017

Hi all, I haven't forgotten about this, but I'm going to merge #21 first, I'm using it and haven't had this issue since, but still is not a definitive solution. Thanks!

@wyuenho
Copy link
Contributor

wyuenho commented May 27, 2017

I just tried out #21, I had to set cwm-frame-internal-border to 0 to avoid having the mode line and the minibuffer being rendered off screen. My window were also only able to be split horizontally once. C-x 3 C-x 1 C-x 3 will still get me the window too small warning.

@wyuenho
Copy link
Contributor

wyuenho commented Nov 26, 2017

@anler I think this is due to https://debbugs.gnu.org/cgi/bugreport.cgi?bug=24193,

Olivetti had the same problem and they hacked around it. Maybe you can do something similar? I love this mode since this is the only lightroom mode clone that works with linum.

@anler
Copy link
Owner

anler commented Nov 27, 2017

I'll take a look later today, thanks!

@wyuenho
Copy link
Contributor

wyuenho commented Nov 28, 2017

So, using https://github.com/railwaycat/homebrew-emacsmacport, setting fullscreen frame parameter to maximized with (set-frame-parameter nil 'fullscreen 'maximized), C-x 3 RET C-x 1 RET C-x 3 doesn't work. But if I maximize the frame with (toggle-max-frame 'both), splitting windows now works. This is just weird.

@cnngimenez
Copy link

Hi!

It seems that the error is triggered at Line 5544 on window.el file. It seems that split-window make some calculations to check if the splitting is possible. If I understand the code right, it calculates the new window minimum size (it considers the frame divider size too) , and if this size is not available, it triggers the error message. Maybe the frame divider value is too high? 🤔

As a temporary solution I tried to advise the split-window function to disable and re-enable the centered-window-mode.

(defun my-cwm-turn-off (fnc &optional window size side pixelwise)
  "Deactivate the centered-window-mode before splitting."
  (if centered-window-mode
      (progn
        (centered-window-mode -1)
        (apply fnc window size side pixelwise)
        (centered-window-mode t))
    (apply fnc window size side pixelwise)))

(advice-add 'split-window :around #'my-cwm-turn-off)

This works in my Emacs... but maybe there is a better solution for this? 🤔

@krisbalintona
Copy link

krisbalintona commented Sep 19, 2024

As an FYI I think this is a more universal solution (i.e. one that works regardless of what function/command is doing the splitting):

(defun kb/window-splittable-p (window &optional horizontal)
    "Override for `window-splittable-p'.
Determine if WINDOW is splittable."
    (when (and (window-live-p window)
               (not (window-parameter window 'window-side)))
      (with-current-buffer (window-buffer window)
        (if horizontal
            (and (memq window-size-fixed '(nil height))
                 (numberp split-width-threshold)
                 (>= (if (bound-and-true-p centered-window-mode)
                         ;; Added this. Not sure if this is foolproof, since all
                         ;; it does is take into consideration the margins and
                         ;; fringes, but for now it's a sufficient approximation
                         (window-total-width window)
                       (window-width window))
                     (max split-width-threshold
                          (* 2 (max window-min-width 2)))))
          (and (memq window-size-fixed '(nil width))
               (numberp split-height-threshold)
               (>= (window-height window)
                   (max split-height-threshold
                        (* 2 (max window-min-height
                                  (if mode-line-format 2 1))))))))))
(advice-add 'window-splittable-p :override #'kb/window-splittable-p)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants