From 0f002c55862fdaf216e427ec73826691dc34c012 Mon Sep 17 00:00:00 2001 From: Matthew Butterick Date: Sat, 9 Jun 2018 17:27:04 -0700 Subject: [PATCH] enable at-reader in `br` languages --- beautiful-racket-lib/br/get-info.rkt | 18 +++++++++++++++--- beautiful-racket-lib/br/main.rkt | 4 +++- beautiful-racket-lib/br/quicklang.rkt | 6 ++++-- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/beautiful-racket-lib/br/get-info.rkt b/beautiful-racket-lib/br/get-info.rkt index 4993fbf..43e2302 100644 --- a/beautiful-racket-lib/br/get-info.rkt +++ b/beautiful-racket-lib/br/get-info.rkt @@ -17,7 +17,19 @@ "until") 'define] [else #f]))))) -(define (br-get-info key default default-filter) +(define (br-get-info key default-value proc) + (define (fallback) (if proc (proc key default-value) default-value)) + (define (try-dynamic-require lib export) + (with-handlers ([exn:missing-module? + (λ (x) (case key + [(drracket:indentation) indenter] + [else (fallback)]))]) + (dynamic-require lib export))) (case key - [(drracket:indentation) indenter] - [else (default-filter key default)])) \ No newline at end of file + [(color-lexer) + (try-dynamic-require 'syntax-color/scribble-lexer 'scribble-lexer)] + [(drracket:indentation) + (try-dynamic-require 'scribble/private/indentation 'determine-spaces)] + [(drracket:keystrokes) + (try-dynamic-require 'scribble/private/indentation 'keystrokes)] + [else (fallback)])) \ No newline at end of file diff --git a/beautiful-racket-lib/br/main.rkt b/beautiful-racket-lib/br/main.rkt index bd30493..7c9d339 100644 --- a/beautiful-racket-lib/br/main.rkt +++ b/beautiful-racket-lib/br/main.rkt @@ -22,4 +22,6 @@ (module reader syntax/module-reader #:language 'br #:info br-get-info - (require br/get-info)) \ No newline at end of file + #:read at:read + #:read-syntax at:read-syntax + (require br/get-info (prefix-in at: scribble/reader))) \ No newline at end of file diff --git a/beautiful-racket-lib/br/quicklang.rkt b/beautiful-racket-lib/br/quicklang.rkt index dc5666d..1d85336 100644 --- a/beautiful-racket-lib/br/quicklang.rkt +++ b/beautiful-racket-lib/br/quicklang.rkt @@ -5,11 +5,13 @@ (for-syntax (all-from-out sugar/debug))) (define-macro (quicklang-mb . EXPRS) - #`(#%module-begin + #'(#%module-begin (provide #%top #%app #%datum #%top-interaction) . EXPRS)) (module reader syntax/module-reader #:language 'br/quicklang #:info br-get-info - (require br/get-info)) \ No newline at end of file + #:read at:read + #:read-syntax at:read-syntax + (require br/get-info (prefix-in at: scribble/reader))) \ No newline at end of file