Skip to content

Commit b63639f

Browse files
committed
Add a dired-narrow command that uses completion-styles
1 parent f49a8bb commit b63639f

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,7 @@ These narrowing functions are provided:
550550
* `dired-narrow`
551551
* `dired-narrow-regexp`
552552
* `dired-narrow-fuzzy`
553+
* `dired-narrow-completion-styles`
553554

554555
You can also create your own narrowing functions quite easily. To
555556
define new narrowing function, use `dired-narrow--internal` and

dired-narrow.el

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,17 @@ read from minibuffer."
276276
(interactive)
277277
(dired-narrow--internal 'dired-narrow--regexp-filter))
278278

279+
(defun dired-narrow--completion-styles-filter (filter)
280+
"Return whether `completion-styles' FILTER matches the current dired file."
281+
(completion-all-completions filter (list (dired-utils-get-filename 'no-dir))
282+
nil (length filter)))
283+
284+
;;;###autoload
285+
(defun dired-narrow-completion-styles ()
286+
"Narrow a dired buffer to the files matching a `completion-styles' query."
287+
(interactive)
288+
(dired-narrow--internal #'dired-narrow--completion-styles-filter))
289+
279290
(defun dired-narrow--string-filter (filter)
280291
(let ((words (split-string filter " ")))
281292
(--all? (save-excursion (search-forward it (line-end-position) t)) words)))

0 commit comments

Comments
 (0)