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
|
b
|
EOF |
428 | 428 | (printf "undefined module `~a'~%" name)))))) |
429 | 429 | ",m MODULE switch to module with name `MODULE'") |
430 | 430 | |
| 431 | (toplevel-command |
| 432 | 'x1 |
| 433 | (let ((pretty-print pretty-print)) |
| 434 | (lambda () |
| 435 | (let ([expr (read)]) |
| 436 | (pretty-print (strip-syntax (expand1 expr))) |
| 437 | (##sys#void)))) |
| 438 | ",x1 EXP Pretty print expand1-ed expression EXP") |
| 439 | |
431 | 440 | |
432 | 441 | ;;; Parse options from string: |
433 | 442 | |
diff --git a/manual/Using the interpreter b/manual/Using the interpreter
index d70fdf23..98be24a1 100644
a
|
b
|
The toplevel loop understands a number of special commands: |
133 | 133 | |
134 | 134 | ; ,x EXP : Pretty-print macroexpanded expression {{EXP}} (the expression is not evaluated). |
135 | 135 | |
| 136 | ; ,x1 EXP : Like {{,x}} but {{EXP}} is expanded only one step, using {{expand1}}. |
| 137 | |
136 | 138 | You can define your own toplevel commands using the {{toplevel-command}} |
137 | 139 | procedure (see [[Module (chicken csi)]]). |
138 | 140 | |