This code
(defun insert-dateutc.* ()
(interactive)
(insert (with-temp-buffer
(call-process "date" nil t nil "+%Y-%m-%dT%H:%M:%S")
(buffer-substring-no-properties 1 (line-end-position 0)))))
(defun insert-random-uuid.* ()
(interactive)
(with-temp-buffer
(call-process "uuidgen" nil t nil)
(buffer-substring-no-properties 1 (line-end-position 0))))
which works stand-alone, but when stuck into this code
(defun foo ()
(interactive)
(insert (format "'(start-symbol :id %s
:graph
:ts %s
:0.0
:1.0
)" (insert-random-uuid.*) (insert-dateutc.*))))
produces this:
2015-11-19T16:07:38'(start-symbol :id 9c5a8a91-325a-44d1-8535-03afc10f405a
:graph
:ts nil
:0.0
:1.0
)nil
That is, it's sticking the formatted date outside the format
output. I can only assume that I'm going to the buffer-substring-no-properties
too many times, or it needs to be reset or something. An earlier version that simply did this
(defun foo ()
(interactive)
(insert (format "'(start-symbol :id %s
:graph
:ts %s
:0.0
:1.0
)" (insert-random-uuid.*) (format-time-string "%Y-%m-%dT%H:%M:%S"))))
played well with insert-random-uuid.*
See:
'(start-symbol :id 2bfebed2-82c3-4ccb-b9f3-84b82a421e06
:graph
:ts 2015-11-19T16:21:39
:0.0
:1.0
)nil
Not sure what the problem is. . . .
insert
frominsert-dateutc.*
? (And maybe remove "insert" from both function names?) – Drew Nov 19 '15 at 16:30insert
too many times is bad. – 147pm Nov 19 '15 at 16:41