branch: elpa/dirvish
commit 15e2cd192591e2d01d58bca08be6fe5e4c664b82
Author: Alex Lu <hellosimon1...@hotmail.com>
Commit: Alex Lu <hellosimon1...@hotmail.com>

    fix(core): crashes when preview directory w/ the `.dir-local` entry
    
    Reported-by: Henrik Lissner <cont...@henrik.io>
---
 dirvish.el | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/dirvish.el b/dirvish.el
index ca11586491..14be5a7d10 100644
--- a/dirvish.el
+++ b/dirvish.el
@@ -862,12 +862,17 @@ When FORCE, ensure the preview get refreshed."
   (when-let* ((attrs (ignore-errors (file-attributes file)))
               (size (file-attribute-size attrs)))
     (cond ((file-directory-p file) ; default directory previewer
-           (let* ((script `(with-current-buffer
-                               (progn (setq insert-directory-program
-                                            ,insert-directory-program)
-                                      (dired-noselect ,file "-AlGh"))
-                             (buffer-string)))
-                  (cmd (format "%S" `(message "\n%s" ,script))))
+           (let* ((script
+                   `(with-current-buffer
+                        (let ((non-essential t)
+                              (delay-mode-hooks t)
+                              (enable-local-variables :safe)
+                              enable-dir-local-variables)
+                          (setq insert-directory-program
+                                ,insert-directory-program)
+                          (dired-noselect ,file "-AlGh"))
+                      (buffer-string)))
+                  (cmd (prin1-to-string `(message "\n%s" ,script))))
              `(dired . (,dirvish-emacs-bin "-Q" "-batch" "--eval" ,cmd))))
           ((> size (or large-file-warning-threshold 10000000))
            `(info . ,(format "File %s is too big for literal preview." file)))

Reply via email to