branch: elpa/dirvish
commit 5a3cf2b0a655c841a492f59fd1af4bbb1e6857f5
Author: Alex Lu <[email protected]>
Commit: Alex Lu <[email protected]>
refactor: set `window-size-fixed` during redisplay (#317 #329)
This patch prevents *zoom-mode* from altering the initial width of
the *dirvish-side* window.
However, enabling `zoom-mode` currently disrupts the window layout (defined
by
`dirvish-default-layout` and `dirvish-layout-recipes`) in a full-frame
Dirvish. There is no simple solution to this because `zoom--update`
unconditionally calls `balance-windows`.
Ref: https://github.com/cyrus-and/zoom/issues/40
Ref: https://github.com/cyrus-and/zoom/issues/45
closes: #317
closes: #329
---
dirvish.el | 9 ++++-----
extensions/dirvish-side.el | 23 +++++++++++------------
2 files changed, 15 insertions(+), 17 deletions(-)
diff --git a/dirvish.el b/dirvish.el
index 9bdee60bd4..641c8b58b4 100644
--- a/dirvish.el
+++ b/dirvish.el
@@ -1108,7 +1108,9 @@ Optionally, use CURSOR as the enabled cursor type."
(defun dirvish-pre-redisplay-h (window)
"Record root WINDOW and redisplay sessions in selected frame."
(setq dirvish--selected-window (frame-selected-window))
- (when-let* ((dv (dirvish-curr))) (setf (dv-root-window dv) window))
+ (let* ((dv (dirvish-curr)) (lyt (dv-curr-layout dv)) (sf (dv-size-fixed dv)))
+ (setf (dv-root-window dv) window)
+ (when (and (not lyt) sf) (setq window-size-fixed sf)))
(dirvish--redisplay))
(defun dirvish-post-command-h ()
@@ -1377,14 +1379,11 @@ Dirvish sets `revert-buffer-function' to this function."
(lh (line-pixel-height)) (gui? (display-graphic-p))
(mh (dirvish--mode-line-height t)) (hh (dirvish--mode-line-height t
t)))
(setf (dv-index dv) (cons (dirvish-prop :root) (current-buffer)))
- ;; only record window config before creating fullframe layout
+ ;; only refresh window config before creating fullframe layout
(setf (dv-winconf dv) (when layout (or conf
(current-window-configuration))))
- ;; `dired' and `dired-jump' delete the old root window, so reset it
- (setf (dv-root-window dv) (selected-window))
(when layout (dirvish--init-special-buffers dv))
(dirvish--setup-mode-line dv)
(when w-order (let ((ignore-window-parameters t)) (delete-other-windows)))
- (when-let* ((fixed (dv-size-fixed dv))) (setq window-size-fixed fixed))
(when (or (dv-curr-layout dv) (dv-dedicated dv))
(set-window-dedicated-p nil t))
;; ensure a positive fringe on both sides for `dirvish-subtree' (#311)
diff --git a/extensions/dirvish-side.el b/extensions/dirvish-side.el
index 7c8c5d10dd..0b6e65c33d 100644
--- a/extensions/dirvish-side.el
+++ b/extensions/dirvish-side.el
@@ -70,6 +70,7 @@ filename until the project root when opening a side session."
"Create root window of DV according to `dirvish-side-display-alist'."
(let* ((buf (with-current-buffer (get-buffer-create " *dirvish-temp*")
;; set the :dv prop for `dirvish-curr'
+ (setq window-size-fixed 'width)
(dirvish-prop :dv (dv-id dv))
(current-buffer)))
(win (display-buffer-in-side-window
@@ -136,18 +137,16 @@ filename until the project root when opening a side
session."
(defun dirvish-side--new (path)
"Open a side session in PATH."
- (let* ((bname buffer-file-name)
- (dv (or (dirvish--get-session 'type 'side)
- (dirvish--new
- :type 'side
- :size-fixed 'width
- :dedicated t
- :root-conf #'dirvish-side-root-conf
- :root-window-fn #'dirvish-side-root-window-fn
- :open-file #'dirvish-side-open-file)))
- (r-win (dv-root-window dv)))
- (setq r-win (dirvish--create-root-window dv))
- (with-selected-window r-win
+ (let ((bname buffer-file-name)
+ (dv (or (dirvish--get-session 'type 'side)
+ (dirvish--new
+ :type 'side
+ :size-fixed 'width
+ :dedicated t
+ :root-conf #'dirvish-side-root-conf
+ :root-window-fn #'dirvish-side-root-window-fn
+ :open-file #'dirvish-side-open-file))))
+ (with-selected-window (dirvish--create-root-window dv)
(dirvish--find-entry 'find-alternate-file path)
(cond ((not bname) nil)
(dirvish-side-auto-expand