From d4ad14b75d090649c0783c41082ebc4d745b76a8 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sun, 18 Aug 2024 16:26:08 -0400 Subject: [PATCH] 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 --- modules/emacs/dired/config.el | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/modules/emacs/dired/config.el b/modules/emacs/dired/config.el index 0b68f9211..e237b0c7d 100644 --- a/modules/emacs/dired/config.el +++ b/modules/emacs/dired/config.el @@ -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)