From c394d27332619677fae17f6b927a2b4fe0bdf363 Mon Sep 17 00:00:00 2001 From: Matthew Butterick Date: Thu, 7 May 2020 07:57:24 -0700 Subject: [PATCH] less dynamism --- pollen/setup.rkt | 46 +++++++++++++++++++++++++++++----------------- 1 file changed, 29 insertions(+), 17 deletions(-) diff --git a/pollen/setup.rkt b/pollen/setup.rkt index fc76f78..125398a 100644 --- a/pollen/setup.rkt +++ b/pollen/setup.rkt @@ -48,16 +48,28 @@ 'NAME (λ () DEFAULT-NAME))))))])) +(define-syntax (define-nonsettable stx) + (syntax-case stx () + [(_ NAME DEFAULT-VALUE) + (with-syntax ([DEFAULT-NAME (format-id stx "default-~a" #'NAME)] + [NAME-THUNKED (format-id stx "~a" #'NAME)] + [NAME-FAIL-THUNKED (format-id stx "fail-thunk-~a" #'NAME)] ) + #'(begin + (provide (prefix-out setup: NAME-THUNKED) DEFAULT-NAME) + (define DEFAULT-NAME DEFAULT-VALUE) + ;; can take a dir argument that sets start point for (get-path-to-override) search. + (define (NAME-THUNKED [dir #false]) DEFAULT-VALUE)))])) + (define-settable cache-watchlist null) (define-settable envvar-watchlist null) -(define-settable preproc-source-ext 'pp) -(define-settable markup-source-ext 'pm) -(define-settable markdown-source-ext 'pmd) -(define-settable null-source-ext 'p) -(define-settable pagetree-source-ext 'ptree) -(define-settable template-source-ext 'pt) -(define-settable scribble-source-ext 'scrbl) +(define-nonsettable preproc-source-ext 'pp) +(define-nonsettable markup-source-ext 'pm) +(define-nonsettable markdown-source-ext 'pmd) +(define-nonsettable null-source-ext 'p) +(define-nonsettable pagetree-source-ext 'ptree) +(define-nonsettable template-source-ext 'pt) +(define-nonsettable scribble-source-ext 'scrbl) ;; these are deliberately not settable because they're just internal signalers, no effect on external interface (define+provide default-mode-auto 'auto) @@ -67,9 +79,9 @@ (define+provide default-mode-pagetree 'ptree) (define+provide default-mode-template 'template) -(define-settable old-cache-names '("pollen.cache" "pollen-cache")) -(define-settable cache-dir-name "compiled") -(define-settable cache-subdir-name "pollen") +(define-nonsettable old-cache-names '("pollen.cache" "pollen-cache")) +(define-nonsettable cache-dir-name "compiled") +(define-nonsettable cache-subdir-name "pollen") (define+provide default-cache-names (list* (cache-dir-name) (old-cache-names))) (define-settable decodable-extensions (list (markup-source-ext) (pagetree-source-ext))) @@ -81,14 +93,14 @@ (define-settable command-char #\◊) (define-settable template-command-char #\∂) -(define-settable template-prefix "template") -(define-settable fallback-template-prefix "fallback") -(define-settable template-meta-key "template") +(define-nonsettable template-prefix "template") +(define-nonsettable fallback-template-prefix "fallback") +(define-nonsettable template-meta-key "template") -(define-settable main-export 'doc) ; don't forget to change fallback template too -(define-settable meta-export 'metas) -(define-settable meta-tag-name 'meta) -(define-settable define-meta-name 'define-meta) +(define-nonsettable main-export 'doc) ; don't forget to change fallback template too +(define-nonsettable meta-export 'metas) +(define-nonsettable meta-tag-name 'meta) +(define-nonsettable define-meta-name 'define-meta) ;; tags from https://developer.mozilla.org/en-US/docs/Web/HTML/Block-level_elements (define-settable block-tags (cons (main-root-node) '(address article aside blockquote body canvas dd div dl fieldset figcaption figure footer form h1 h2 h3 h4 h5 h6 header hgroup hr li main nav noscript ol output p pre section table tfoot ul video)))