-
Notifications
You must be signed in to change notification settings - Fork 14
Fix window configurations not getting restored due to broken split-window call #47
Conversation
95e0beb
to
72ed9d2
Compare
I notice you also pass I can't find anything in the Elisp manual about the rationale of not passing the BTW, the better fix would probably be to use the |
You are absolutely right! I did some more digging: Adding Otherwise I could not think of a non-hacky way to prevent a conflict here. When Until the better fix with
(defadvice! fix/reset-split-window-param-maybe-a
(&optional window _size _side pixelwise)
:before #'split-window
(and pixelwise
(eq (window-parameter window 'split-window)
#'visual-fill-column-split-window)
(set-window-parameter window 'split-window nil))) With this, manual splitting works for me, as well as EDIT: looking at this, I guess one could also create a version of ;; EDIT: the pixelwise paramter got removed from `visual-fill-column-split-window' recently.
;; For this hack to work `visual-fill-column' has to be pinned in packages.el
;;
;; (package! visual-fill-column :pin "598bc992f050575c48db6fb9ea50794a5ce5d065")
;;
;; Dont forget to run
;; $ doom sync -u
;; after pinning.
;;
;; * sorry for the doomisms
(defadvice! fix/visual-fill-column-split-window-dispatch-a
(&optional window _size _side pixelwise)
"Fixes custom split function bound to window parameter not being able to
pass the value of `pixelwise' back to the `split-window' function."
:before #'split-window
(and (eq (window-parameter window 'split-window)
#'visual-fill-column-split-window)
(set-window-parameter window 'split-window
(lambda (win size side)
(visual-fill-column-split-window
win size side pixelwise))))) In that case, the function signature has to keep |
This function makes splitting possible with wide margins. It gets called by split-window with 3 args but has a fourth arg in its signature that gets passed back to split-window as nil Thus, window sizes are not calculated correctly and "Window too small to split" errors occur that block window configurations from getting restored with window-state-put. See: joostkremers#47
1961dee
to
7defeb3
Compare
Reverted the changes, only updating the docstring for now. |
This function makes splitting possible with wide margins. It gets called by split-window with 3 args but has a fourth arg in its signature that gets passed back to split-window as nil Thus, window sizes are not calculated correctly and "Window too small to split" errors occur that block window configurations from getting restored with window-state-put. See: joostkremers#47
7defeb3
to
82cbdef
Compare
Yes, but the addition of the argument Besides, Martin said that the solution with
[...]
I guess that still doesn't guarantee there won't be edge cases, though. 😞
Yes, that looks like it would work. Still, I plan to implement the |
The fix has been include into Emacs 27 here. I assume it'll be included in Emacs 27.2. With that fix and an updated |
Great! Thanks for looking into that. 27.2. should be around the corner I guess & I'll just use the workaround till then. PR can be closed :) |
- Set `split-window-preferred-function` for every supported Emacs version. - Properly inhibit using the `split-window` window parameter in Emacs >= 27.2. There are two separate cases of vertical window splitting: manually with `split-window` and friends (specifically `split-window-right`), and automatically, when `display-buffer` is invoked. Both are by default impossible if the margins are too wide, but the way to handle them differs. Manual splitting is controlled by the window parameters `split-window` (Emacs 25 and up) and `min-margins` (also Emacs 25 and up, but a bug prevented it from working until Emacs 27.2; see Emacs bug 44483). The use of these two window parameters should be dependent on the Emacs version (see Github issue #47). Automatic splitting by `display-buffer` is controlled by `split-window-preferred-function`. It is set to `visual-fill-column-split-window-sensibly`, which should not be dependent on the Emacs version. Unfortunately, I had mixed them up and made it dependent of the version anyway. This should be fixed now.
visual-fill-column-split-window
was added as a window parameter to make splitting possible with wide margins.It gets called by
split-window
with 3 argsbut has an excess arg in its signature that gets passed back to
split-window
asnil
Thus, window sizes are not calculated correctly and “Window too small to split” errors occur that block window configurations from getting restored with
window-state-put
. It also messes with the window dimensions around the split-window call. The problem is masked by a(condition-case nil... (error nil))
.This affects switching doom emacs workspaces /
persp-mode
perspectives when the selected window hasvisual-fill-column mode
turned on.Fixes:
Bad-ptr/persp-mode.el#114
Bad-ptr/persp-mode.el#110
joostkremers/writeroom-mode#54