From f1532b4eca797f5aab4ec1a693a767a7a3e603c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Sat, 9 Apr 2022 21:58:52 +0200 Subject: Replace config system with paramater based system. This new setup stores all configurations are parameters. This forces everything into modules, and ensures that we can't have a module use an unloaded config. It (unfortunatelly) also causes users to have to specify namespaces when defining values, but ini-files (and the like) already does that. Also, there is nothing stopping a new `set-config!' from being defined which allows un-namespaced operation. The commit also removes the introspection procedures. They where a bit weird to begin with, since they only showed loaded fields. And since the program had no way of properly serializing or deserializing them we remove them for the time being. They would however be good to reintroduce together with a proper menu for editing simple configuration (see Emacs' `custom-set-variables'). --- module/vcomponent/config.scm | 16 ++++++++++++++++ module/vcomponent/datetime/output.scm | 6 ++++-- module/vcomponent/util/instance.scm | 5 ++--- 3 files changed, 22 insertions(+), 5 deletions(-) create mode 100644 module/vcomponent/config.scm (limited to 'module/vcomponent') diff --git a/module/vcomponent/config.scm b/module/vcomponent/config.scm new file mode 100644 index 00000000..b2598207 --- /dev/null +++ b/module/vcomponent/config.scm @@ -0,0 +1,16 @@ +(define-module (vcomponent config) + :use-module (hnh util) + :use-module (calp translation) + :use-module (calp util config)) + +(define-config calendar-files '() + description: (_ "Which files to parse. Takes a list of paths or a single string which will be globbed.") + pre: (lambda (v) + (cond [(list? v) v] + [(string? v) ((@ (glob) glob) v)] + [else #f]))) + +(define-config default-calendar "" + description: (_ "Default calendar to use for operations. Set to empty string to unset") + pre: (ensure string?)) + diff --git a/module/vcomponent/datetime/output.scm b/module/vcomponent/datetime/output.scm index fe909ebb..8cb55782 100644 --- a/module/vcomponent/datetime/output.scm +++ b/module/vcomponent/datetime/output.scm @@ -4,6 +4,7 @@ :use-module (vcomponent base) :use-module (text util) :use-module (calp translation) + :use-module ((hnh util exceptions) :select (warning)) :use-module ((vcomponent recurrence display) :select (format-recurrence-rule)) ) @@ -38,11 +39,12 @@ ".")) (define-public (format-summary ev str) - ((get-config 'summary-filter) ev str)) + ((@ (calp html filter) summary-filter) ev str)) ;; NOTE this should have information about context (html/term/...) (define-public (format-description ev str) - (catch #t (lambda () ((get-config 'description-filter) ev str)) + (catch #t (lambda () ((@ (calp html filter) description-filter) + ev str)) (lambda (err . args) ;; Warning message for failure to format description. ;; First argument is name of warning/error, diff --git a/module/vcomponent/util/instance.scm b/module/vcomponent/util/instance.scm index d17b672a..038c6505 100644 --- a/module/vcomponent/util/instance.scm +++ b/module/vcomponent/util/instance.scm @@ -1,6 +1,5 @@ (define-module (vcomponent util instance) :use-module (hnh util) - :use-module ((calp util config) :select (get-config)) :use-module ((oop goops) :select (make)) :use-module (calp translation) :export (global-event-object) @@ -14,10 +13,10 @@ ;; evaluate this to early. (define-once global-event-object (make (@@ (vcomponent util instance methods) ) - calendar-files: (get-config 'calendar-files))) + calendar-files: ((@ (vcomponent config) calendar-files)))) (define-public (reload) (let ((new-value (make (@@ (vcomponent util instance methods) ) - calendar-files: (get-config 'calendar-files)))) + calendar-files: ((@ (vcomponent config) calendar-files))))) (format (current-error-port) (_ "Reload done~%")) (set! global-event-object new-value))) -- cgit v1.2.3