diff options
-rw-r--r-- | tissue/document.scm | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tissue/document.scm b/tissue/document.scm index c70b18e..45de014 100644 --- a/tissue/document.scm +++ b/tissue/document.scm @@ -19,6 +19,7 @@ (define-module (tissue document) #:use-module (rnrs hashtables) #:use-module (rnrs io ports) + #:use-module (srfi srfi-1) #:use-module (srfi srfi-19) #:use-module (srfi srfi-26) #:use-module (srfi srfi-171) @@ -40,6 +41,20 @@ file-document-path read-gemtext-document)) +;; We override the default write to print object slots and values. +(define-method (write (object <object>) port) + "Write OBJECT to PORT." + (format port "#<~a ~a>" + (class-name (class-of object)) + (string-join (filter-map (lambda (slot) + (let ((slot-name (slot-definition-name slot))) + (and (slot-bound? object slot-name) + (call-with-output-string + (cut format <> "~s: ~s" + slot-name + (slot-ref object slot-name)))))) + (class-slots (class-of object)))))) + (define (date->iso-8601 date) "Convert DATE, an SRFI-19 date object, to an ISO-8601 date string." (date->string date "~4")) |