branch: elpa/dirvish commit 9c9fbe4201c9f9271dfe66ba6f3f1370e111a3c1 Author: Alex Lu <hellosimon1...@hotmail.com> Commit: Alex Lu <hellosimon1...@hotmail.com>
refactor: replace `project-root` with `vc-root-dir` `project-current` raises an error in git submodules, not sure if it's a bug. --- dirvish-widgets.el | 2 +- dirvish.el | 13 +++++-------- extensions/dirvish-peek.el | 4 +--- extensions/dirvish-side.el | 4 ++-- 4 files changed, 9 insertions(+), 14 deletions(-) diff --git a/dirvish-widgets.el b/dirvish-widgets.el index c1a121f891..5cf48e004b 100644 --- a/dirvish-widgets.el +++ b/dirvish-widgets.el @@ -493,7 +493,7 @@ GROUP-TITLES is a list of group titles." (dirvish-define-mode-line project "Return a string showing current project." - (let ((project (dirvish--get-project-root)) + (let ((project (dirvish--vc-root-dir)) (face (if (dirvish--selected-p) 'dired-header 'dirvish-inactive))) (if project (setq project (file-name-base (directory-file-name project))) diff --git a/dirvish.el b/dirvish.el index 277c11f0a1..515e857dbd 100644 --- a/dirvish.el +++ b/dirvish.el @@ -23,8 +23,6 @@ (require 'dired) (require 'cl-lib) -(eval-when-compile (require 'project)) -(declare-function ansi-color-apply-on-region "ansi-color") ;;;; User Options @@ -379,11 +377,9 @@ ALIST is window arguments passed to `window--display-buffer'." ((symbol-function 'recentf-track-closed-file) #'ignore)) (let (kill-buffer-query-functions) (kill-buffer buffer))))) -(defun dirvish--get-project-root (&optional directory) - "Get project root path of DIRECTORY." - (when-let* ((pj (project-current nil directory)) - (pj-root (project-root pj))) - (expand-file-name pj-root))) +(defun dirvish--vc-root-dir () + "Get expanded `vc-root-dir'." + (when-let* ((root (vc-root-dir))) (expand-file-name root))) (defun dirvish--get-parent-path (path) "Get parent directory of PATH." @@ -721,6 +717,7 @@ A dirvish preview dispatcher is a function consumed by (defun dirvish-apply-ansicolor-h (_win pos) "Update dirvish ansicolor in preview window from POS." + (declare-function ansi-color-apply-on-region "ansi-color") (let (buffer-read-only) (ansi-color-apply-on-region (goto-char pos) (progn (forward-line (frame-height)) (point))))) @@ -1296,7 +1293,7 @@ Dirvish sets `revert-buffer-function' to this function." (dirvish-save-dedication (switch-to-buffer (dired-noselect dir))) (dirvish--build-layout dv))))) - (cond ; created new tab / frame in a reused session, kill the one + (cond ; created new tab / frame in a reused session, clear the old one ((not (equal old-frame frame)) (killall (append (list buf) (mapcar #'cdr (dv-roots dv)))) (build-dv (dirvish--new :curr-layout layout) frame dir)) diff --git a/extensions/dirvish-peek.el b/extensions/dirvish-peek.el index 37c10f85ed..154a1be45a 100644 --- a/extensions/dirvish-peek.el +++ b/extensions/dirvish-peek.el @@ -105,9 +105,7 @@ one of categories in `dirvish-peek-categories'." (setq cand (format "FILE_REMOTE_EXCEPTION:::%s" fname)) (setq cand fname)))) ('project-file - (setq cand (expand-file-name - cand (or (dirvish--get-project-root) - (car (minibuffer-history-value)))))) + (setq cand (expand-file-name cand (dirvish--vc-root-dir)))) ('library (condition-case err (setq cand (file-truename (find-library-name cand))) diff --git a/extensions/dirvish-side.el b/extensions/dirvish-side.el index a3ecb2d74e..fee0d92b07 100644 --- a/extensions/dirvish-side.el +++ b/extensions/dirvish-side.el @@ -116,7 +116,7 @@ filename until the project root when opening a side session." ((not (active-minibuffer-window))) (win (dirvish-side--session-visible-p)) (dv (with-current-buffer (window-buffer win) (dirvish-curr))) - (dir (or (dirvish--get-project-root) default-directory)) + (dir (or (dirvish--vc-root-dir) default-directory)) (prev (with-selected-window win (dirvish-prop :index))) (curr buffer-file-name) ((not (string-suffix-p "COMMIT_EDITMSG" curr))) @@ -177,7 +177,7 @@ otherwise it defaults to `project-current'." (read-directory-name "Open sidetree: ")))) (let ((fullframep (when-let* ((dv (dirvish-curr))) (dv-curr-layout dv))) (visible (dirvish-side--session-visible-p)) - (path (or path (dirvish--get-project-root) default-directory))) + (path (or path (dirvish--vc-root-dir) default-directory))) (cond (fullframep (user-error "Can not create side session here")) ((eq visible (selected-window)) (dirvish-quit)) (visible (select-window visible))