summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Isaac2022-06-28 10:06:12 +0530
committerArun Isaac2022-06-28 10:08:35 +0530
commita5f905f8c0656c5ea8ee957a5abc2e0dc7aa0193 (patch)
tree913d503a218cd991ce07810c013e9b723c9b6e0d
parent1135bc9bea5eb6ca10074dc565ad0c1cf52fdbe7 (diff)
downloadtissue-a5f905f8c0656c5ea8ee957a5abc2e0dc7aa0193.tar.gz
tissue-a5f905f8c0656c5ea8ee957a5abc2e0dc7aa0193.tar.lz
tissue-a5f905f8c0656c5ea8ee957a5abc2e0dc7aa0193.zip
document: Add slot-set utility.
* tissue/document.scm (slot-set): New public function.
-rw-r--r--tissue/document.scm10
1 files changed, 9 insertions, 1 deletions
diff --git a/tissue/document.scm b/tissue/document.scm
index 45de014..70a3263 100644
--- a/tissue/document.scm
+++ b/tissue/document.scm
@@ -28,7 +28,8 @@
#:use-module (term ansi-color)
#:use-module (xapian xapian)
#:use-module (tissue utils)
- #:export (object->scm
+ #:export (slot-set
+ object->scm
scm->object
<document>
document-title
@@ -41,6 +42,13 @@
file-document-path
read-gemtext-document))
+(define (slot-set object slot-name value)
+ "Set SLOT-NAME in OBJECT to VALUE. This is a purely functional setter
+that operates on a copy of OBJECT. It does not mutate OBJECT."
+ (let ((clone (shallow-clone object)))
+ (slot-set! clone slot-name value)
+ clone))
+
;; We override the default write to print object slots and values.
(define-method (write (object <object>) port)
"Write OBJECT to PORT."