From a122e66ecee80a3976e078b7ee2677248da97b28 Mon Sep 17 00:00:00 2001 From: Pierre Neidhardt Date: Fri, 11 Dec 2020 21:54:47 +0100 Subject: [PATCH] ambrevar/shell: Add match-name. --- .local/share/common-lisp/source/ambrevar/shell.lisp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.local/share/common-lisp/source/ambrevar/shell.lisp b/.local/share/common-lisp/source/ambrevar/shell.lisp index 58a11428..42e350c5 100644 --- a/.local/share/common-lisp/source/ambrevar/shell.lisp +++ b/.local/share/common-lisp/source/ambrevar/shell.lisp @@ -37,6 +37,16 @@ Useful for `finder'." (string= ext (pathname-type file))) (cons extension more-extensions)))) +(export-always 'match-name) +(defun match-name (name &rest more-names) + "Return a predicate that matches when one of the names is contained in the +file basename. +Basename includes the extension. Useful for `finder'." + (lambda (file) + (some (lambda (name) + (str:contains? name (file-basename file))) + (cons name more-names)))) + (export-always 'match-directory) (defun match-directory (&key (empty? t) (non-empty? t) (files? t)) "Return a predicate that matches on directories.