branch: elpa/dirvish commit 836f6054352f4cd5f9c4e2c928011beafe89e5cc Author: Alex Lu <hellosimon1...@hotmail.com> Commit: Alex Lu <hellosimon1...@hotmail.com>
refactor: better support for `kill-current-buffer` --- README.org | 4 ++-- dirvish.el | 12 +++++------- extensions/dirvish-side.el | 5 +++-- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/README.org b/README.org index 7cfff94b1d..538d1d4e6e 100644 --- a/README.org +++ b/README.org @@ -40,11 +40,11 @@ activate Dirvish globally with =M-x dirvish-override-dired-mode RET=. + =M-x dirvish RET= - Welcome to Dirvish! Use your favorite dired commands here! + Welcome to Dirvish! Use your favorite dired commands here, press ~q~ to quit. + =M-x dirvish-dwim RET= - Works the same as `dirvish` when the selected window is the only window; + Works the same as ~dirvish~ when the selected window is the only window; otherwise, it avoids occupying the entire frame. + =M-x dirvish-dispatch RET= diff --git a/dirvish.el b/dirvish.el index 2dbb515e62..82c98965fd 100644 --- a/dirvish.el +++ b/dirvish.el @@ -780,13 +780,11 @@ filename or a string with format of `dirvish-fd-bufname'." "Remove buffer from session's buffer list." (when-let* ((dv (dirvish-curr)) (buf (current-buffer))) (setf (dv-roots dv) (cl-remove-if (lambda (i) (eq (cdr i) buf)) (dv-roots dv))) - (if (dv-roots dv) ; it might be killed by user in a fullframe session - (when-let* (((eq (cdr (dv-index dv)) buf)) - ((dv-curr-layout dv)) - (win (dv-root-window dv)) - ((window-live-p win))) - (setf (dv-index dv) (car (dv-roots dv))) - (with-selected-window win ; we have to prevend this window get deleted + (when (eq (cdr (dv-index dv)) buf) (setf (dv-index dv) (car (dv-roots dv)))) + (if (dv-roots dv) ; killed by user in `ibuffer' or using `kill-current-buffer' + (when-let* ((win (dv-root-window dv)) + ((and (window-live-p win) (window-dedicated-p win)))) + (with-selected-window win ; prevend this dedicated window get deleted (dirvish-save-dedication (switch-to-buffer (cdr (dv-index dv)))))) (when-let* ((layout (dv-curr-layout dv)) (wconf (dv-winconf dv)) diff --git a/extensions/dirvish-side.el b/extensions/dirvish-side.el index 77f047fc6d..6a52a542aa 100644 --- a/extensions/dirvish-side.el +++ b/extensions/dirvish-side.el @@ -84,8 +84,9 @@ filename until the project root when opening a side session." (defun dirvish-side-root-conf-fn (buffer) "Setup BUFFER for side session." (let ((name (buffer-name buffer))) - (unless (string-prefix-p " *SIDE::" name) ; hide it by prefix with " " - (rename-buffer (format " *SIDE::%s" name))))) + (unless (dirvish-prop :side-buf-renamed) ; hide it by prefix with " " + (rename-buffer (format " *SIDE::%s" name)) + (dirvish-prop :side-buf-renamed t)))) (defun dirvish-side-root-window-fn (dv) "Create root window of DV according to `dirvish-side-display-alist'."