zsxh
161
(defun advice-run-once (symbol where function &optional props)
(advice-add symbol :after (lambda (&rest _) (advice-remove symbol function)))
(advice-add symbol where function props))
;; Lazy load `dirvish' to speedup bootstrap time
(defvar dirvish-override-dired-p nil)
(defun dirvish-override-dired-mode-maybe (&rest _)
"Call `dirvish-override-dired-mode' only once."
(unless dirvish-override-dired-p
;; (message "debug: load dirvish")
(setq dirvish-override-dired-p t)
(dirvish-override-dired-mode)))
(advice-run-once 'find-file :before #'dirvish-override-dired-mode-maybe)
(use-package dired
:ensure nil
:defer t
:config
(dirvish-override-dired-mode-maybe))
(use-package dirvish
:defer t
:config
(dirvish-override-dired-mode-maybe)
;; 其它配置
)
延迟加载,我是这么处理的
1 个赞
放:config
上就会出现那个奇怪的modelline,刚试过。
dirvish 会增加 1s 启动时间吗? 为什么我这里才 0.05 秒。。
好像还是会出现那个modelline,但你这种我也不是很理解,不知道我用的对不对。
:after-call pre-command-hook 也不行?
这个没试,(dirvish-override-dired-mode)
放到:init
还是:config
.
:config 吧 好像都行。反正这个意思是第一次运行前不加载。
好像还是不行,放init对启动时间没有改善,放config, 会出现modelline问题。
没有报错,message里面只有Note: standard-indent, tab-width, evil-shift-width adjusted to 2
,可能和dirvish无关。
(use-package! dirvish
:defer 0.5
:config
(dirvish-override-dired-mode)
(dirvish-peek-mode)
(setq! dirvish-menu-bookmarks
'(("o" "~/" "Home")
("u" "~/.cache/emacs/" "Emacs cache")))
(setq! dirvish-mode-line-format
'(:left (sort file-time " " file-size symlink) :right (omit yank index)))
(setq! dirvish-header-line-format '(:left (path) :right (free-space)))
(setq! dirvish-attributes '(subtree-state all-the-icons))
:bind
(nil ; Bind `dirvish', `dirvish-dired' and `dirvish-side' as you see fit
:map dired-mode-map
("SPC" . dirvish-show-history)
("TAB" . dirvish-toggle-subtree)
("b" . dirvish-goto-bookmark)
("f" . dirvish-file-info-menu)
("M-a" . dirvish-mark-menu)
("M-s" . dirvish-setup-menu)
("M-f" . dirvish-toggle-fullscreen)
([remap dired-sort-toggle-or-edit] . dirvish-quicksort)
([remap dired-summary] . dirvish-dispatch)
([remap dired-do-copy] . dirvish-yank-menu)
([remap mode-line-other-buffer] . dirvish-other-buffer)))
这是我 doom 用来测试的配置,你原原本本复制,modeline 还是会那样吗?
那你就慢慢从这个改。用 setq! 代替 custom ,有问题再说。
Edit: 上面那个写错了两处,改了一下。
有一种场景,需要查看一个目录下多个子目录中的最新的文件,但不知道文件名,这个时候dirvish-fd
就比较方便,但打开文件关闭dired就不太方便,我试了几个打开文件的函数,都被override掉了。
那我明天找时间加一个类似 dirvish-side-open-file-window-function
的选项吧。
当鼠标没有移到屏幕顶端或者底端时,dired-next-line
不能更新左下角文件的时间和大小,只有鼠标移到屏幕边缘的时候,modeline上的文件的信息才会更新。
这是我用的配制:
(use-package! dirvish
:defer 0.5
:config
(dirvish-override-dired-mode)
;; (dirvish-peek-mode)
(setq! dirvish-menu-bookmarks
'(("h" "~/" "Home")
("d" "~/Downloads/" "Downloads")
("t" "~/.Trash/")))
(setq! dirvish-mode-line-format
'(:left (sort file-time " " file-size symlink) :right (omit yank index)))
(setq! dirvish-header-line-format '(:left (path) :right (free-space)))
(setq! dirvish-attributes '(subtree-state))
(setq! dirvish-hide-details nil)
:bind
(("C-x f" . dirvish-fd) ; Bind `dirvish', `dirvish-dired' and `dirvish-side' as you see fit
:map dired-mode-map
;; ("SPC" . dirvish-show-history)
("TAB" . dirvish-toggle-subtree)
("b" . dirvish-goto-bookmark)
("f" . dirvish-file-info-menu)
("M-a" . dirvish-mark-menu)
("M-s" . dirvish-setup-menu)
("M-f" . dirvish-toggle-fullscreen)
([remap dired-sort-toggle-or-edit] . dirvish-quicksort)
([remap dired-summary] . dirvish-dispatch)
([remap dired-do-copy] . dirvish-yank-menu)
([remap mode-line-other-buffer] . dirvish-other-buffer)))
是按着不放的时候不更新? 还是按一下之后不更新?
如果是按着不放的时候不更新那是正常的,松手才会更新。