From a4938d04e1af34dc9bbbe894869902675e4f7db4 Mon Sep 17 00:00:00 2001 From: Vivianne Langdon Date: Mon, 4 Mar 2024 13:59:36 -0500 Subject: [PATCH] Add christine's pk (cpk) and cpk-values! --- uniseg/internal.scm | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/uniseg/internal.scm b/uniseg/internal.scm index cc55e40..9f0c2d3 100644 --- a/uniseg/internal.scm +++ b/uniseg/internal.scm @@ -3,6 +3,7 @@ #:use-module (ice-9 textual-ports) #:use-module (ice-9 exceptions) #:use-module (ice-9 i18n) + #:use-module (ice-9 pretty-print) #:use-module (web uri) #:use-module (web client) #:use-module (web request) @@ -13,6 +14,8 @@ @codepoint-range @comment @ws + cpk-values + cpk cons-hash-list! hex-string->integer format-exception-msg @@ -95,4 +98,26 @@ (with-input-from-file path (λ () (get-string-all (current-input-port)))) #\newline)) +;; kludge: emacs mis-renders this as a string, so... +(define hash-semicolon-semicolon + (list->string '(#\# #\; #\;))) +;; for debugging +(define (cpk . vals) + "Peek at values for print debugging, but return 'em" + (display hash-semicolon-semicolon (current-error-port)) + (display " cpk\n" (current-error-port)) + (pretty-print vals (current-error-port)) + ;; return the last value + (last vals)) + +(define-syntax-rule (cpk-values print-these ... body) + ;; Like pk, but supporting multiple value return + (call-with-values + (lambda () body) + (lambda vals + (display hash-semicolon-semicolon (current-error-port)) + (display " cpk-values\n" (current-error-port)) + (pretty-print (list print-these ... '*values:* vals) + (current-error-port)) + (apply values vals))))