From 1c6288e2b714fff541dd130f201eae2cae4b2ef1 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Mon, 19 Aug 2024 13:44:07 -0400 Subject: [PATCH] perf(dired): suppress mode hooks when previewing files Ref: #6760 --- modules/emacs/dired/config.el | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/modules/emacs/dired/config.el b/modules/emacs/dired/config.el index 744598a36..37cc5a292 100644 --- a/modules/emacs/dired/config.el +++ b/modules/emacs/dired/config.el @@ -203,6 +203,14 @@ Fixes #3939: unsortable dired entries on Windows." (car (last (cdr result)))))) result))) + ;; HACK: Suppress mode hooks when previewing files, as they may contain + ;; expensive or disruptive functionality that isn't needed just for + ;; previewing them. + ;; REVIEW: Upstream this later? + (defadvice! +dired--suppress-hooks-in-previews-a (fn &rest args) + :around #'dirvish--find-file-temporarily + (delay-mode-hooks (apply fn args))) + ;; HACK: Dirvish will complain that pdf-tools is required to preview PDFs, ;; even if the package is installed, so I advise it to try autoloading it ;; before complaining, otherwise complain if epdfinfo hasn't been built yet.