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

    fix(narrow): better orderless integration
    
    The `dirvish-narrow-regex-builder` option seems redundant, as users are 
unlikely
    to need control over the internal details of how the regular expression 
list is
    compiled. Remove the option and attempt to use `orderless` to build the 
list,
    falling back to `split-string` if `orderless` is unavailable.
---
 docs/EXTENSIONS.org          | 15 ++++-----------
 extensions/dirvish-narrow.el | 13 ++++---------
 2 files changed, 8 insertions(+), 20 deletions(-)

diff --git a/docs/EXTENSIONS.org b/docs/EXTENSIONS.org
index 70d1df0b21..59ed767dd6 100644
--- a/docs/EXTENSIONS.org
+++ b/docs/EXTENSIONS.org
@@ -260,8 +260,6 @@ buffer.  Feel free to experiment with other switches.
 This extension also provides the ~dirvish-fd-jump~ command which allows you to 
go
 to any directory in the file system using results from =fd= command as 
completions.
 
-TODO: fix #207
-
 TODO: try implementing #213
 
 * Turn Dirvish into a tree browser (dirvish-subtree.el)
@@ -331,12 +329,7 @@ finalizing with =RET=, use ~revert-buffer~ (typically 
bound to =g=).
 
 https://github.com/user-attachments/assets/539e1a74-ddf2-41fa-9dc2-3358108828fc
 
-If you have [[https://github.com/oantolin/orderless][orderless]] installed, 
you can have an input string that looks like /test
-~Emacs .\(py\|yaml\)$/, meaning:
-
-- match /test/
-- match /.py/ or /.yaml/ files
-- exclude results containing /Emacs/
-
-The actual matching styles being applied are determined by your orderless
-config.  See ~dirvish-narrow-regex-builder~.
+If [[https://github.com/oantolin/orderless][orderless]] is installed, it is 
automatically used to generate the
+=completion-regexp-list= from your input string for file list filtering. The
+matching style is determined by your =orderless= configuration. If =orderless= 
is
+not available, the regexp list is generated using ~split-string~ instead.
diff --git a/extensions/dirvish-narrow.el b/extensions/dirvish-narrow.el
index 1f9e1ecd75..cf22997df9 100644
--- a/extensions/dirvish-narrow.el
+++ b/extensions/dirvish-narrow.el
@@ -16,14 +16,6 @@
 
 (require 'dirvish)
 
-(defcustom dirvish-narrow-regex-builder
-  (if (fboundp 'orderless-compile) (lambda (s) (cdr (orderless-compile s)))
-    #'split-string)
-  "Function used to generate the `completion-regexp-list' for narrowing.
-The function takes the input string as its sole argument and
-should return a list of regular expressions."
-  :group 'dirvish :type 'function)
-
 ;; Credit: copied from `orderless.el'
 (defcustom dirvish-narrow-match-faces
   [dirvish-narrow-match-face-0
@@ -112,7 +104,9 @@ The search is case insensitive if IGNORE-CASE is non-nil."
     (lambda (action)
       (with-current-buffer (window-buffer (minibuffer-selected-window))
         (save-excursion
-          (cl-loop with regs = (funcall dirvish-narrow-regex-builder action)
+          (cl-loop with regs = (if (fboundp 'orderless-compile)
+                                   (cdr (orderless-compile action))
+                                 (split-string action))
                    for idx from 0
                    for (dir . pos) in dired-subdir-alist
                    do (dirvish-narrow--filter-subdir dir pos regs idx)))))
@@ -143,6 +137,7 @@ IDX the index of DIR in `dired-subdir-alist'."
   (interactive nil dired-mode)
   (when (get-buffer-process (current-buffer))
     (user-error "Current buffer has unfinished jobs"))
+  (require 'orderless nil t)
   (dirvish-narrow--build-indices)
   (let ((dv (dirvish-prop :dv))
         (restore (dirvish-prop :index))

Reply via email to