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

    feat(fd): add `dirvish-fd-setup-hook` (closes #207)
---
 extensions/dirvish-fd.el     | 7 ++++++-
 extensions/dirvish-narrow.el | 4 ++--
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/extensions/dirvish-fd.el b/extensions/dirvish-fd.el
index 097868a6c8..e250dd0177 100644
--- a/extensions/dirvish-fd.el
+++ b/extensions/dirvish-fd.el
@@ -33,6 +33,10 @@
   "The default fd program."
   :type 'string :group 'dirvish)
 
+(defcustom dirvish-fd-setup-hook nil
+  "Functions called after the `fd` process exits successfully."
+  :type 'hook :group 'dirvish)
+
 (defun dirvish-fd--find-gnu-ls (&optional remote)
   "Find ls from gnu coreutils on a local or REMOTE host ."
   (let* ((ls (executable-find "ls" remote))
@@ -297,7 +301,8 @@ value 16, let the user choose the root directory of their 
search."
       (dirvish-prop :fd-time
         (format " %s %s "
                 (propertize "Took:" 'face 'font-lock-doc-face)
-                (propertize took 'face (if (eq status 0) 'success 'error)))))
+                (propertize took 'face 'success)))
+      (run-hooks 'dirvish-fd-setup-hook))
     (force-mode-line-update t)))
 
 ;;;###autoload
diff --git a/extensions/dirvish-narrow.el b/extensions/dirvish-narrow.el
index db6726d627..6dfc8be156 100644
--- a/extensions/dirvish-narrow.el
+++ b/extensions/dirvish-narrow.el
@@ -137,7 +137,7 @@ IDX the index of DIR in `dired-subdir-alist'."
     (user-error "Current buffer has unfinished jobs"))
   (dirvish-narrow--build-indices)
   (let ((dv (dirvish-prop :dv))
-        (of (dirvish-prop :index))
+        (restore (dirvish-prop :index))
         (bstr (buffer-string))
         input buffer-read-only)
     (font-lock-mode -1) (buffer-disable-undo)
@@ -150,7 +150,7 @@ IDX the index of DIR in `dired-subdir-alist'."
         (when (= (length input) 0)
           (erase-buffer) (insert bstr)
           (unless (cdr dired-subdir-alist) (dirvish--hide-dired-header)))
-        (dired-goto-file of)
+        (when restore (dired-goto-file restore))
         (font-lock-mode 1) (buffer-enable-undo)))))
 
 (provide 'dirvish-narrow)

Reply via email to