What is a more idiomatic way to do this? :
(set 'tmp-file (open "/tmp/file" "write"))
(write tmp-file (join (map markup (parse pretext "n" 0)) "n"))
(close tmp-file)
(setf posttext (join (exec "fmt -68 /tmp/file") "n"))
It feels dirty to use a /tmp/file like that. Ideally I'd like to pipe a string through `/bin/fmt` capturing its STDOUT, all within newlisp.
You could have shortened your code by using write-file, but you seem to look for a solution without using an intermediary file.
The following uses STDIN on exec and would leave the result in a file posttest and no temporary file is required:
(exec "fmt -68 > posttext" (join (map markup (parse pretext "n" 0)) "n"))
Then you could (read-file "postttext") to bring the result into memory.
Ps: look also into process which can take two pipes at once.
Thanks, Lutz. I'll play with those variations.