From ef901153404d24ca1694a2b98e845eaca47aa085 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Tue, 23 Apr 2019 18:46:09 +0200 Subject: Change how util is loaded. --- module/config.scm | 20 +++++++++++--------- module/main.scm | 12 ++++++------ module/parameters.scm | 23 +++++++++++++++++++++++ 3 files changed, 40 insertions(+), 15 deletions(-) create mode 100644 module/parameters.scm (limited to 'module') diff --git a/module/config.scm b/module/config.scm index f15c73d5..6a7358e4 100644 --- a/module/config.scm +++ b/module/config.scm @@ -2,6 +2,7 @@ ;;; Currently loaded by main, and requires that `calendar-files` ;;; is set to a list of files (or directories). +(define-module (config) #:use-module (parameters)) (use-modules (srfi srfi-26) (srfi srfi-88) @@ -9,10 +10,10 @@ (ice-9 regex) (ice-9 rdelim)) -(define calendar-files - (let ((path (string-append (getenv "HOME") "/.calendars/"))) - (map (cut string-append path <>) - (scandir path (lambda (str) (not (char=? #\. (string-ref str 0)))))))) +(calendar-files + (let ((path (string-append (getenv "HOME") "/.calendars/"))) + (map (cut string-append path <>) + (scandir path (lambda (str) (not (char=? #\. (string-ref str 0)))))))) ;;; TODO possibly replace with propper lookup (define my-courses @@ -26,8 +27,9 @@ (define* (aref alist key optional: default) (or (assoc-ref alist key) default key)) -(define (summary-filter ev str) - (regexp-substitute/global - #f "T[A-Z]{3}[0-9]{2}" str - 'pre (lambda (m) (aref my-courses (string->symbol (match:substring m)))) - 'post)) +(summary-filter + (lambda (ev str) + (regexp-substitute/global + #f "T[A-Z]{3}[0-9]{2}" str + 'pre (lambda (m) (aref my-courses (string->symbol (match:substring m)))) + 'post))) diff --git a/module/main.scm b/module/main.scm index 6a2cd9c9..095a4d7c 100755 --- a/module/main.scm +++ b/module/main.scm @@ -22,6 +22,8 @@ (terminal util) (html html) + + (parameters) ) (define (ev-time 'VEVENT) calendars))) (let* ((repeating regular (partition repeating? events))) diff --git a/module/parameters.scm b/module/parameters.scm new file mode 100644 index 00000000..45b8862b --- /dev/null +++ b/module/parameters.scm @@ -0,0 +1,23 @@ +;;; Commentary: + +;; This file should define all global configurable variables which +;; doesn't belong anywhere else. The config module should then import +;; this module, and set all configs as needed. The config module +;; should also be able to set configs gotten from other parts. + +;;; Code: + +(define-module (parameters)) + +(define (ensure pred?) + (lambda (v) + (unless (pred? v) + (error "Bad value to config")) + v)) + +(define-public calendar-files + (make-parameter + '() (ensure list?))) + +(define-public summary-filter + (make-parameter (lambda (_ a) a) (ensure procedure?))) -- cgit v1.2.3