Skip to content

Commit 3e74411

Browse files
committed
Add print handler for #uuid and #inst
Since we parse these we should also print these. Printing inst up to the second and without timestamp, since that is the resolution we get from Emacs' date-to-time.
1 parent 90cfe3d commit 3e74411

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## Added
44

5+
- Added print handler for `#uuid` and `#inst`
6+
57
## Fixed
68

79
## Changed

parseedn.el

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,13 @@ TAG-READERS is an optional association list. For more information, see
162162
(insert ", ")
163163
(parseedn-print-plist next))))
164164

165+
(defun parseedn-print-inst (time)
166+
"Insert an inst value into the current buffer.
167+
168+
Take an encode-time style value and print it as a timestamp
169+
deliniated by double quotes."
170+
(insert (format-time-string "\"%Y-%m-%dT%T\"" time)))
171+
165172
(defun parseedn-alist-p (list)
166173
"Non-null if and only if LIST is an alist with simple keys."
167174
(while (consp list)
@@ -224,6 +231,10 @@ DATUM can be any Emacs Lisp value."
224231
(error "Don't know how to print: %s" datum))
225232
((eq 'edn-set (car datum))
226233
(insert "#{") (parseedn-print-seq (cadr datum)) (insert "}"))
234+
((eq 'edn-uuid (car datum))
235+
(insert "#uuid ") (parseedn-print-seq (cdr datum)))
236+
((eq 'edn-inst (car datum))
237+
(insert "#inst ") (parseedn-print-inst (cdr datum)))
227238
(t (insert "(") (parseedn-print-seq datum) (insert ")"))))
228239

229240
(t (error "Don't know how to print: %s" datum))))

test/parseedn-test-data.el

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,16 @@
340340
"booleans"
341341
(a-list
342342
:source "[nil true false]"
343-
:edn '([nil t nil]))))
343+
:edn '([nil t nil]))
344+
345+
"uuid"
346+
(a-list
347+
:source "#uuid \"c9c4eac2-7b23-4d62-a444-41a72dc09039\""
348+
:edn '((edn-uuid "c9c4eac2-7b23-4d62-a444-41a72dc09039")))
349+
350+
"inst"
351+
(a-list
352+
:source "#inst \"2020-09-09T06:56:04\""
353+
:edn '((edn-inst 24408 24676 )))))
344354

345355
;;; parseedn-test-data.el ends here

0 commit comments

Comments
 (0)