From 15ed1bab956e663e61e757c98e05bb42e00867a6 Mon Sep 17 00:00:00 2001
From: John Croisant <john@croisant.net>
Date: Sun, 11 Jul 2021 23:46:52 -0500
Subject: [PATCH 2/2] Add `,x1` toplevel command to csi.

Like `,x` but uses `expand1` instead of `expand`. The form is expanded
only once, then pretty-printed.
---
 csi.scm                      | 9 +++++++++
 manual/Using the interpreter | 2 ++
 2 files changed, 11 insertions(+)

diff --git a/csi.scm b/csi.scm
index f22a42b9..5a81f523 100644
--- a/csi.scm
+++ b/csi.scm
@@ -428,6 +428,15 @@ EOF
 	      (printf "undefined module `~a'~%" name))))))
  ",m MODULE         switch to module with name `MODULE'")
 
+(toplevel-command
+ 'x1
+ (let ((pretty-print pretty-print))
+   (lambda ()
+     (let ([expr (read)])
+       (pretty-print (strip-syntax (expand1 expr)))
+       (##sys#void))))
+ ",x1 EXP           Pretty print expand1-ed expression EXP")
+
 
 ;;; Parse options from string:
 
diff --git a/manual/Using the interpreter b/manual/Using the interpreter
index d70fdf23..98be24a1 100644
--- a/manual/Using the interpreter	
+++ b/manual/Using the interpreter	
@@ -133,6 +133,8 @@ The toplevel loop understands a number of special commands:
 
 ; ,x EXP : Pretty-print macroexpanded expression {{EXP}} (the expression is not evaluated).
 
+; ,x1 EXP : Like {{,x}} but {{EXP}} is expanded only one step, using {{expand1}}.
+
 You can define your own toplevel commands using the {{toplevel-command}}
 procedure (see [[Module (chicken csi)]]).
 
-- 
2.25.1

