Skip to content

Commit

Permalink
[2_19] Re-impl save-object and load-object by string-load and string-…
Browse files Browse the repository at this point in the history
…save
  • Loading branch information
da-liii authored Sep 27, 2024
1 parent ebcfa1a commit ea2add1
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions TeXmacs/progs/kernel/boot/abbrevs.scm
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,14 @@
(symbol->keyword (string->symbol (string-append "%" (number->string x)))))

(define-public (save-object file value)
(call-with-output-file (url-materialize file "") (lambda (port)
(let-temporarily (((*s7* 'print-length) 9223372036854775807)) (write value port)))))
(string-save
(let-temporarily (((*s7* 'print-length) 9223372036854775807))
(object->string value))
file))

(define-public (load-object file)
(let ((r (call-with-input-file (url-materialize file "r") (lambda (port) (read port)))))
(if (eof-object? r) '() r)))
(with-input-from-string (string-load file)
(lambda () (read))))

(define-public (persistent-ref dir key)
(and (persistent-has? dir key)
Expand Down

0 comments on commit ea2add1

Please sign in to comment.