Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,7 @@ These narrowing functions are provided:
* `dired-narrow`
* `dired-narrow-regexp`
* `dired-narrow-fuzzy`
* `dired-narrow-completion-styles` (use any builtin completion style or something like [orderless](https://github.com/oantolin/orderless))

You can also create your own narrowing functions quite easily. To
define new narrowing function, use `dired-narrow--internal` and
Expand Down
11 changes: 11 additions & 0 deletions dired-narrow.el
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,17 @@ read from minibuffer."
(interactive)
(dired-narrow--internal 'dired-narrow--regexp-filter))

(defun dired-narrow--completion-styles-filter (filter)
"Return whether `completion-styles' FILTER matches the current dired file."
(completion-all-completions filter (list (dired-utils-get-filename 'no-dir))
nil (length filter)))

;;;###autoload
(defun dired-narrow-completion-styles ()
"Narrow a dired buffer to the files matching a `completion-styles' query."
(interactive)
(dired-narrow--internal #'dired-narrow--completion-styles-filter))

(defun dired-narrow--string-filter (filter)
(let ((words (split-string filter " ")))
(--all? (save-excursion (search-forward it (line-end-position) t)) words)))
Expand Down