I'm trying to enable/disable visual-fill-column when there is one window/multiple windows.
Since I don't like trying it on my own before asking, here is the solution I came up with:
(defun my-visual-fill-one-window () (global-visual-fill-column-mode -1) (if (one-window-p) (global-visual-fill-column-mode 1) (global-visual-fill-column-mode -1) ) ) (add-hook 'window-state-change-hook 'my-visual-fill-one-window)
I have three problems (maybe more but these are the three I could identify):
I need to disable the mode globally at the start of the function because if I don't and try to split one window horizontally I have the following error (strangely, I don't have it if I
M-x visual-fill-column-modemanually and split the window without having this function hooked):
split-window: Window #<window 3 on file> too small for splitting
Treemacs stops working (I can't open its window) with the following error:
treemacs--popup-window: Wrong type argument: window-live-p, nil
I'm hooking it to
window-state-changed-hookbecause it looked like the most suited one but maybe I could do better (the main problem being that if I use ivy-posframe it's considered as a second window, the mode is disabled, the text is instantly flushed to the left and as soon as the posframe is closed the mode is enabled again and the text centered)
Do you have a better solution (and possibly one that doesn't make treemacs fail miserabily)?
There's actually another question: is it possible to enable this mode if there's more than one window but they're all split vertically?