From 12aa7314ad85f442f8bfe85839127bf1929be2ba Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Thu, 16 Feb 2023 22:34:00 +0100 Subject: [PATCH] Only extend the reader while reading wisp. Thanks to Maxime Devos! * module/language/wisp/spec.scm (read-one-wisp-sexp): extend hash only in fluid * module/language/wisp.scm (wisp-scheme-read-chunk): extend hash in fluid --- module/language/wisp.scm | 18 ++++++++++-------- module/language/wisp/spec.scm | 8 ++------ 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/module/language/wisp.scm b/module/language/wisp.scm index 65ef8e65a..7a12e126a 100644 --- a/module/language/wisp.scm +++ b/module/language/wisp.scm @@ -725,14 +725,16 @@ Match is awesome!" a)))))) (define (wisp-scheme-read-chunk port) - "Read and parse one chunk of wisp-code" - (let (( lines (wisp-scheme-read-chunk-lines port))) - (wisp-make-improper - (wisp-replace-empty-eof - (wisp-unescape-underscore-and-colon - (wisp-replace-paren-quotation-repr - (wisp-propagate-source-properties - (wisp-scheme-indentation-to-parens lines)))))))) + "Read and parse one chunk of wisp-code" + (with-fluids ((%read-hash-procedures (fluid-ref %read-hash-procedures))) + (read-hash-extend #\# (lambda args #\#)) + (let ((lines (wisp-scheme-read-chunk-lines port))) + (wisp-make-improper + (wisp-replace-empty-eof + (wisp-unescape-underscore-and-colon + (wisp-replace-paren-quotation-repr + (wisp-propagate-source-properties + (wisp-scheme-indentation-to-parens lines))))))))) (define (wisp-scheme-read-all port) "Read all chunks from the given port" diff --git a/module/language/wisp/spec.scm b/module/language/wisp/spec.scm index 3ba248aa9..477036c71 100644 --- a/module/language/wisp/spec.scm +++ b/module/language/wisp/spec.scm @@ -45,12 +45,8 @@ ;; Don't use the globally-acting read-hash-extend, because this ;; doesn't make much sense in parenthese-y (non-Wisp) Scheme. ;; Instead, use fluids to temporarily add the extension. - (read-hash-extend #\# (λ (chr port) #\#)) - (define %read-hash-procedures/parameter - (fluid->parameter %read-hash-procedures)) - (parameterize ((%read-hash-procedures/parameter - `((#\# ,(λ (chr port) #\#)) - ,@(%read-hash-procedures/parameter)))) + (with-fluids ((%read-hash-procedures (fluid-ref %read-hash-procedures))) + (read-hash-extend #\# (lambda args #\# )) ;; Read Wisp files as UTF-8, to support non-ASCII characters. ;; TODO: would be nice to support ';; coding: whatever' lines ;; like in parenthese-y Scheme. -- 2.39.1