aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2023-05-28 02:13:34 -0700
committerKaz Kylheku <kaz@kylheku.com>2023-05-28 02:13:34 -0700
commit4845d7979e3676c006035be35e33ccc45af4fffa (patch)
treea53c627f2e692ed1dde887ace6b669ee5af39501
parent87b0002faa80f358938bd2dabd8ac4bdd5bd9a50 (diff)
downloadtl-who-4845d7979e3676c006035be35e33ccc45af4fffa.tar.gz
tl-who-4845d7979e3676c006035be35e33ccc45af4fffa.tar.bz2
tl-who-4845d7979e3676c006035be35e33ccc45af4fffa.zip
Fix (htm ...) output resetting indentation to zero.
This is an issue present in the original Common Lisp implementation. When the (htm ...) inner macros are being expanded, they are not receiving the *indent* level. We address this by adding yet another unreleased feature to TXR Lisp that will appear in TXR 287: expander-let. * who.tl (tree-to-template): Here, instead of generating a ^(let ((*indent* , *indent*)) ...) which does nothing, we use expander-let. All the expansion of the structured code to HTML text fragments happens at macro-expansion time. But macro-expansion time will not execute a binding form like (let ((*indent* <value>)) ...). It will just expand it! The (htm ...) subforms get expanded in a context in which all the functions that expanded the outer macro have already terminated and undone their own local binding of *indent*. The expander-let construct causes the macro expander itself to do the binding. So it will pick up the indentation where the previous expansion pass left off. (with-html-output): The previous fix isn't enough, because the way the local html macro is defined also wrecks indentation. htm expands to an invocation of with-html-output which copies the :indent argument value from the surrouning with-html-output. If that is 0 or t, it will reset the indentation to zero. The htm macro should just leave the indentation alone; not pass that keyword argument so that the current *indent* value gets propagated.
-rw-r--r--who.tl4
1 files changed, 2 insertions, 2 deletions
diff --git a/who.tl b/who.tl
index 85f5a34..3ea8d80 100644
--- a/who.tl
+++ b/who.tl
@@ -168,7 +168,7 @@
(ncon [process-tag element tree-to-template]))
(@(consp)
;; list - insert as sexp
- (add ^(let ((*indent* , *indent*)) ,element)))
+ (add ^(expander-let ((*indent* , *indent*)) ,element)))
;; something else - insert verbatim
(@else (add else))))))
@@ -229,7 +229,7 @@
. body)
^(let ((,var ,(or stream var)))
(macrolet ((htm (. body)
- ^(with-html-output (,',var nil :prologue nil :indent ,,indent)
+ ^(with-html-output (,',var nil :prologue nil)
,*body))
(fmt (. args)
^(format ,',var ,*args))