From 5feda6addc02c83f0782e6b65d72c5db97ad128a Mon Sep 17 00:00:00 2001 From: Pierre Neidhardt Date: Sat, 16 Jan 2021 01:14:55 +0100 Subject: [PATCH] ambrevar: Move match-extensions and match-name to `file'. --- .../common-lisp/source/ambrevar/file.lisp | 19 +++++++++++++++++++ .../common-lisp/source/ambrevar/shell.lisp | 19 ------------------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/.local/share/common-lisp/source/ambrevar/file.lisp b/.local/share/common-lisp/source/ambrevar/file.lisp index f4773335..a875fd32 100644 --- a/.local/share/common-lisp/source/ambrevar/file.lisp +++ b/.local/share/common-lisp/source/ambrevar/file.lisp @@ -196,6 +196,25 @@ Without PREDICATES, list all files." (lambda (file) (local-time:timestamp> (modification-date file) timestamp))) +(export-always 'match-extensions) +(defun match-extensions (extension &rest more-extensions) + "Return a predicate for files that match on of the provided extensions. +Useful for `finder'." + (lambda (file) + (some (lambda (ext) + (string= ext (extension 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 (basename file))) + (cons name more-names)))) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defparameter %magic-cookie-mime nil "Internal storage for `magic-cookie-mime'.") diff --git a/.local/share/common-lisp/source/ambrevar/shell.lisp b/.local/share/common-lisp/source/ambrevar/shell.lisp index f0eb51e9..3d079b13 100644 --- a/.local/share/common-lisp/source/ambrevar/shell.lisp +++ b/.local/share/common-lisp/source/ambrevar/shell.lisp @@ -29,25 +29,6 @@ (delete-if #'sera:resolve-executable (cons program more-programs)))) (error "Missing programs: ~{~a~,^, ~}" missing-programs))) -(export-always 'match-extensions) -(defun match-extensions (extension &rest more-extensions) - "Return a predicate for files that match on of the provided extensions. -Useful for `finder'." - (lambda (file) - (some (lambda (ext) - (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.