Skip to content

Instantly share code, notes, and snippets.

@dmitrym0
Created November 7, 2024 19:34
Show Gist options
  • Save dmitrym0/9e81b746136a538ed5e65fb047433b05 to your computer and use it in GitHub Desktop.
Save dmitrym0/9e81b746136a538ed5e65fb047433b05 to your computer and use it in GitHub Desktop.
init.org
;; -----
(define files-examined-count 0)
(define blacklist '("daily"))
(define whitelist '("org"))
(define (get-extension path)
(let ((parts (string-split path ".")))
(if (> (length parts) 1)
(car (reverse parts))
"")))
(define (is-blacklisted? path blacklist)
(cond ((null? blacklist) #f)
((string-contains? path (car blacklist)) #t) ; Check for partial match
(else (is-blacklisted? path (cdr blacklist)))))
(define (is-whitelisted? extension whitelist)
(cond ((null? whitelist) #f)
((string=? extension (car whitelist)) #t)
(else (is-whitelisted? extension (cdr whitelist)))))
(define (sync-ignore-file path)
(set! files-examined-count (+ files-examined-count 1)) ; Increment global counter
(log-debug (format "-- Examining file ~s" path))
(let ((extension (get-extension path)))
(cond
((is-blacklisted? path blacklist)
(log-debug (format "-- Ignoring file ~s as it is blacklisted" path))
#t)
((not (is-whitelisted? extension whitelist))
(log-debug (format "-- Ignoring file ~s due to unsupported extension: ~s" path extension))
#t)
(else
(log-debug (format "-- File ~s is accepted for processing" path))
#f))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment