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

    feat: make `dired-find-file-other-window` uses preview window (#335)
    
    This commit makes `dired-find-file-other-window` command display files (not
    directory) in the active preview window.
    
    closes #335
---
 dirvish.el | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/dirvish.el b/dirvish.el
index 5869f6657d..e47b35822c 100644
--- a/dirvish.el
+++ b/dirvish.el
@@ -615,8 +615,11 @@ FIND-FN can be one of `find-file', `find-alternate-file',
          (cl-return-from dirvish--find-entry))
     ;; forward requests from `find-dired'
     (unless dv (cl-return-from dirvish--find-entry (funcall find-fn entry)))
-    (and (dv-curr-layout dv) (eq find-fn 'find-file-other-window)
-         (dirvish-layout-toggle))
+    (unless dir? (mapc #'dirvish--kill-buffer (dv-preview-buffers dv)))
+    (when (and (dv-curr-layout dv) (eq find-fn 'find-file-other-window))
+      (if dir? (dirvish-layout-toggle)
+        (select-window (dv-preview-window dv))
+        (cl-return-from dirvish--find-entry (find-file entry))))
     (when (and dir? (eq find-fn 'find-alternate-file))
       (dirvish-save-dedication (find-file entry))
       (with-current-buffer cur ; check if the buffer should be killed
@@ -624,7 +627,6 @@ FIND-FN can be one of `find-file', `find-alternate-file',
              (cl-return-from dirvish--find-entry)))
       (cl-return-from dirvish--find-entry (dirvish--kill-buffer cur)))
     (if dir? (dirvish-save-dedication (funcall find-fn entry))
-      (mapc #'dirvish--kill-buffer (dv-preview-buffers dv))
       (funcall (dv-open-file dv) dv find-fn entry))))
 
 ;;;; Preview

Reply via email to