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

    fix(peek): ensure special buffers are initialized
---
 dirvish-widgets.el         | 2 +-
 dirvish.el                 | 7 +++----
 extensions/dirvish-peek.el | 8 ++++----
 3 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/dirvish-widgets.el b/dirvish-widgets.el
index 464365e2d6..41fdd0173b 100644
--- a/dirvish-widgets.el
+++ b/dirvish-widgets.el
@@ -728,7 +728,7 @@ Require: `tar' (executable)"
   :require (dirvish-zipinfo-program dirvish-tar-program)
   (cond ((equal ext "zip") `(shell . (,dirvish-zipinfo-program ,file)))
         ;; Emacs source code files, let `fallback' handles it
-        ((string-suffix-p ".el.gz" file))
+        ((string-suffix-p ".el.gz" file) nil)
         ((member ext '("tar" "zst" "bz2" "bz" "gz" "xz" "tgz"))
          `(shell . (,dirvish-tar-program "-tvf" ,file)))))
 
diff --git a/dirvish.el b/dirvish.el
index 0d862002f7..65e44d12c5 100644
--- a/dirvish.el
+++ b/dirvish.el
@@ -830,7 +830,7 @@ buffer, it defaults to filename under the cursor when it is 
nil."
   (when (>= (length (dv-preview-buffers dv)) dirvish-preview-buffers-max-count)
     (dirvish--kill-buffer (frame-parameter nil 'dv-preview-last)))
   (with-current-buffer (dirvish--util-buffer "temp")
-    (let ((text (gethash file (dv-preview-hash dv))) info)
+    (let ((text (gethash file (dv-preview-hash dv))) info jka-compr-verbose)
       (with-silent-modifications
         (setq buffer-read-only t)
         (if text (insert text)
@@ -852,8 +852,8 @@ buffer, it defaults to filename under the cursor when it is 
nil."
                    (and (bound-and-true-p so-long-detected-p)
                         (error "No preview of file with long lines"))))
         (error (setq info (error-message-string err))))
-      (set-frame-parameter nil 'dv-preview-last (current-buffer))
       (if info (prog1 `(info . ,info) (dirvish--kill-buffer (current-buffer)))
+        (set-frame-parameter nil 'dv-preview-last (current-buffer))
         (run-hooks 'dirvish-preview-setup-hook)
         (unless text (puthash file (buffer-string) (dv-preview-hash dv)))
         `(buffer . ,(current-buffer))))))
@@ -1192,8 +1192,7 @@ Dirvish sets `revert-buffer-function' to this function."
   (use-local-map dirvish-mode-map)
   (dirvish--hide-dired-header)
   (dirvish--maybe-toggle-cursor 'box) ; restore from `wdired'
-  (setq-local dirvish--attrs-hash
-              (or dirvish--attrs-hash (dirvish--ht))
+  (setq-local dirvish--attrs-hash (or dirvish--attrs-hash (dirvish--ht))
               revert-buffer-function #'dirvish-revert
               tab-bar-new-tab-choice "*scratch*"
               dired-hide-details-hide-symlink-targets nil
diff --git a/extensions/dirvish-peek.el b/extensions/dirvish-peek.el
index 4e0a9bbf6c..77a8637117 100644
--- a/extensions/dirvish-peek.el
+++ b/extensions/dirvish-peek.el
@@ -70,6 +70,7 @@ one of categories in `dirvish-peek-categories'."
       (add-hook 'post-command-hook #'dirvish-peek-update-h 90 t)
       (add-hook 'minibuffer-exit-hook #'dirvish-peek-exit-h nil t)
       (setq new-dv (dirvish--new :type 'peek))
+      (dirvish--init-util-buffers new-dv)
       ;; `dirvish-image-dp' needs this.
       (setf (dv-index new-dv) (cons default-directory (current-buffer)))
       (setf (dv-preview-window new-dv)
@@ -104,10 +105,9 @@ one of categories in `dirvish-peek-categories'."
 
 (defun dirvish-peek-exit-h ()
   "Hook for `minibuffer-exit-hook' to destroy peek session."
-  (dolist (dv (hash-table-values dirvish--session-hash))
-    (when (eq (dv-type dv) 'peek)
-      (dirvish--clear-session dv)
-      (remhash (dv-id dv) dirvish--session-hash)))
+  (when-let* ((dv (dirvish--get-session 'type 'peek)))
+    (dirvish--clear-session dv)
+    (remhash (dv-id dv) dirvish--session-hash))
   (dirvish-prop :peek-last nil))
 
 ;;;###autoload

Reply via email to