chickadee » pathfinder » pf:compound

pf:compound extsprocedure

Create a matcher object suitable for passing to path-find or path-find-all. For each directory, this matches any files that match the current search term and additionally have zero or more of the extensions in the EXTS list. Furthermore, these results are returned sorted by extension priority, where the priority is higher for extensions earlier in the list. This behavior is like that of the Hike library for Ruby.

The extensions in the EXTS list should include the dot at the beginning, meaning ".exe" not "exe". It is not legal to use the empty string, nor to have a dot within the extension.

(define p (make-pathfinder '("app/assets" "vendor/plugins/3e8/assets"
                             "vendor/plugins/jquery" "template/assets")
           matcher: (pf:compound '(".scss" ".coffee" ".sass" ".scm" ".php"))
           root: "/var/zb-app"))

; tree under /var/zb-app
; ./app/assets/js/app.js
; ./app/assets/js/menu.js.coffee
; ./template/assets/css/menu.css
; ./template/assets/js/search.js
; ./template/assets/js/menu.js
; ./vendor/plugins/3e8/assets/css/menu.css.sass  
; ./vendor/plugins/3e8/assets/css/menu.css.scss
; ./vendor/plugins/3e8/assets/css/menu.css.scss.php
; ./vendor/plugins/3e8/assets/css/menu.css.scss.scm
; ./vendor/plugins/jquery/js/jquery.js

(path-find p "js/menu.js")
  ; => "/var/zb-app/app/assets/js/menu.js.coffee"
(path-find-all p "js/menu.js")
  ; => ("/var/zb-app/app/assets/js/menu.js.coffee"
  ;     "/var/zb-app/template/assets/js/menu.js")
(path-find p "js/search.js")
  ; => "/var/zb-app/template/assets/js/search.js"
(path-find p "js/jquery.js")
  ; => "/var/zb-app/vendor/plugins/jquery/js/jquery.js"
(path-find p "css/menu.css")
  ; => "/var/zb-app/vendor/plugins/3e8/assets/css/menu.css.scss"
(path-find-all p "css/menu.css")
  ; => ("/var/zb-app/vendor/plugins/3e8/assets/css/menu.css.scss"
  ;     "/var/zb-app/vendor/plugins/3e8/assets/css/menu.css.sass"
  ;     "/var/zb-app/vendor/plugins/3e8/assets/css/menu.css.scss.scm"
  ;     "/var/zb-app/vendor/plugins/3e8/assets/css/menu.css.scss.php"
  ;     "/var/zb-app/template/assets/css/menu.css")
(path-find p "css/menu.css" pf:exact)
  ; => "/var/zb-app/template/assets/css/menu.css"