branch: elpa/dirvish commit ed9a2f077c76a2461ec6dc119a5cf5789f35c9cf Author: Alex Lu <hellosimon1...@hotmail.com> Commit: Alex Lu <hellosimon1...@hotmail.com>
fix(core): add a shim for `find-dired` and doc it (closes #261) --- dirvish.el | 42 +++++++++++++++++++++--------------------- docs/COMPARISON.org | 22 +++++++++------------- docs/CUSTOMIZING.org | 10 ++++++++-- 3 files changed, 38 insertions(+), 36 deletions(-) diff --git a/dirvish.el b/dirvish.el index 3ed45f465a..4c96e11040 100644 --- a/dirvish.el +++ b/dirvish.el @@ -690,32 +690,32 @@ ARGS is a list of keyword arguments for `dirvish' struct." "Ensure FN and ARGS applied with window undedicated." (dirvish-save-dedication (apply fn args))) -(defun dirvish-find-entry-a (&optional entry) +(cl-defun dirvish-find-entry-a (&optional entry) "Find ENTRY in current dirvish session. ENTRY can be a filename or a string with format of `dirvish-fd-bufname' used to query or create a `fd' result buffer, it defaults to filename under the cursor when it is nil." (let* ((entry (or entry (dired-get-filename nil t))) - (buffer (cond ((string-prefix-p "🔍" entry) (dirvish-fd-find entry)) - ((file-directory-p entry) (dired-noselect entry)) - ((string-suffix-p "/" entry) - (user-error - (concat entry " is not a valid directory")))))) - (if buffer (dirvish-save-dedication (switch-to-buffer buffer)) - (let* ((ext (downcase (or (file-name-extension entry) ""))) - (file (expand-file-name entry)) - (process-connection-type nil) - (ex (cl-loop - for (exts . (cmd . args)) in dirvish-open-with-programs - thereis (and (not (dirvish-prop :remote)) - (executable-find cmd) - (member ext exts) - (append (list cmd) args))))) - (if ex (apply #'start-process "" nil "nohup" - (cl-substitute file "%f" ex :test 'string=)) - (let* ((dv (dirvish-curr)) (fn (dv-open-file-fn dv))) - (if fn (funcall fn) (dirvish--clear-session dv))) - (find-file file)))))) + (buf (cond ((string-prefix-p "🔍" entry) + (dirvish-fd-find entry)) + ((file-directory-p entry) + (dired-noselect entry)) + ((string-suffix-p "/" entry) + (user-error (concat entry " is not a directory"))))) + (dv (dirvish-curr)) process-connection-type file) + (when buf (cl-return-from dirvish-find-entry-a + (dirvish-save-dedication (switch-to-buffer buf)))) + (setq file (expand-file-name entry)) + (cl-loop with e = (downcase (or (file-name-extension entry) "")) + for (es . (c . a)) in dirvish-open-with-programs + when (and (member e es) (executable-find c)) do + (cl-return-from dirvish-find-entry-a + (let ((a (cl-substitute file "%f" a :test #'string=))) + (apply #'start-process "" nil "nohup" (append (list c) a))))) + (unless dv (cl-return-from dirvish-find-entry-a (find-file file))) + (if-let* ((fn (dv-open-file-fn dv))) (funcall fn) + (dirvish--clear-session dv)) + (find-file file))) (defun dirvish-insert-subdir-a (dirname &rest _) "Setup newly inserted subdir DIRNAME for this Dirvish buffer." diff --git a/docs/COMPARISON.org b/docs/COMPARISON.org index 850bacf9a3..8ae81d5906 100644 --- a/docs/COMPARISON.org +++ b/docs/COMPARISON.org @@ -117,19 +117,15 @@ a visual indicator for files that has unique nested paths. * find-dired | fd-dired -Dirvish has no plan to support =find-dired= or =fd-dired= since we have the far -better option =dirvish-fd=. The advantages of using =dirvish-fd= over =find/fd-dired= -including but not limited to: - -1. File preview works for ~dirvish-fd~ as well. -2. ~dirvish-fd-switches-menu~ allows us to change the =fd= flags interactively. -3. ~dirvish-quicksort~ and ~dirvish-ls-switches-menu~ also works in the result - buffer of ~dirvish-fd~. -4. The result buffer of ~dirvish-fd~ is added to Dirvish's local history, which - means commands like ~dirvish-history-go-forward/backward~ works seamlessly with - ~dirvish-fd~. - - ... +Compared to =find/fd-dired=, =dirvish-fd= offers several advantages: + ++ File previews are supported. ++ The =dirvish-fd-switches-menu= allows interactive modification of =fd= flags. ++ =dirvish-quicksort= and =dirvish-ls-switches-menu= are fully functional within the + =dirvish-fd= result buffer. ++ The =dirvish-fd= result buffer is integrated into Dirvish's local history, + enabling seamless navigation with commands like =dirvish-history-go-forward= and + =dirvish-history-go-backward=. * dired-git-info | diff-hl | dired-k diff --git a/docs/CUSTOMIZING.org b/docs/CUSTOMIZING.org index 7e15be5e5f..ae4fb73a6b 100644 --- a/docs/CUSTOMIZING.org +++ b/docs/CUSTOMIZING.org @@ -85,6 +85,12 @@ Apart from the hooks provided by Dired, Dirvish got some additions. | ~dirvish-find-entry-hook~ | Executed after finding a entry. | |---------------------------+------------------------------------------| +** =find-dired= integration + +=find-dired= should work seamlessly with Dirvish. However, there are currently no +plans to integrate Dirvish further into its output buffer, as =dirvish-fd= offers +a superior alternative. See [[file:EXTENSIONS.org][Extensions:dirvish-fd.el]] for more information. + * Dirvish "attributes" A Dirvish attribute is a visual element that shows up within the file line, @@ -281,8 +287,8 @@ you don't have to require them explicitly if you installed dirvish from MELPA or (setq delete-by-moving-to-trash t) (setq dired-listing-switches "-l --almost-all --human-readable --group-directories-first --no-group") - :bind ; Bind `dirvish|dirvish-side|dirvish-dwim' as you see fit - (("C-c f" . dirvish-fd) + :bind ; Bind `dirvish-fd|dirvish-side|dirvish-dwim' as you see fit + (("C-c f" . dirvish) :map dirvish-mode-map ; Dirvish inherits `dired-mode-map' ("a" . dirvish-quick-access) ("f" . dirvish-file-info-menu)