fix(dired): fallback to default if dirvish-use-mode-line == nil

Currently, setting `dirvish-use-mode-line` to nil blanks out the
mode-line, and setting it to `t` makes Dirvish use its own mode-line. To
get the default mode-line, `dirvish-mode-line-format` needs to be set to
nil, but even then Dirvish will prepend a bar to the default-mode-line
so it can control its height, which I think is a confusing chain of
causes and effects.

This changes the behavior such that `dirvish-use-mode-line` controls
whether `dirvish-mode-line-format` will be used or not. I'll upstream
this to hlissner/dirvish later.

Fix: #8000
This commit is contained in:
Henrik Lissner 2024-08-18 16:26:08 -04:00
parent 967586fcae
commit d4ad14b75d
No known key found for this signature in database
GPG key ID: B60957CA074D39A3

View file

@ -87,7 +87,7 @@ Fixes #3939: unsortable dired entries on Windows."
'(:left (sort file-time symlink) :right (omit yank index)))
(setq dirvish-attributes nil
dirvish-use-header-line nil
dirvish-mode-line-format nil))
dirvish-use-mode-line nil))
;; Match the height of `doom-modeline', if it's being used.
;; TODO: Make this respect user changes to these variables.
@ -156,6 +156,20 @@ Fixes #3939: unsortable dired entries on Windows."
:n "S" #'dirvish-relative-symlink
:n "h" #'dirvish-hardlink))
;; HACK: Modifies Dirvish to fall back to default `mode-line-format' if
;; `dirvish-use-mode-line' is nil, instead of when
;; `dirvish-mode-line-format' is nil (since the latter *still* prepends to
;; the default `mode-line-format'), and is overall less intuitive.
;; REVIEW: Upstream this behavior later.
(defadvice! +dired--dirvish-use-modeline-a (fn &rest args)
"Change how `dirvish-use-mode-line' and `dirvish-mode-line-format' operate."
:around #'dirvish--setup-mode-line
(when dirvish-use-mode-line
(let ((dirvish--mode-line-fmt
(if dirvish-mode-line-format
dirvish--mode-line-fmt)))
(apply fn args))))
;; HACK: Kill Dirvish session before switching projects/workspaces, otherwise
;; it errors out on trying to delete/change dedicated windows.
(add-hook! '(persp-before-kill-functions projectile-before-switch-project-hook)