Re: Reading pipe from *standard-input*?
Jean Louis <[email protected]> Fri, 24 Mar 2017 00:00:23 +0300
| Newsgroups | gmane.lisp.clisp.general |
|---|---|
| Message-ID | <[email protected]> |
I have made now new version, and new version works as
org2markdown-pipe.lisp file, yet if I save the memory image, I get within
few seconds program stack overflow RESET.
Also I am sure there is more elegant reading from *standard-input* and
writing to *standard-output* then this kind of list making and
converting to string. If somebody knows, let me know.
(defparameter memdir "/run/shm/")
(defparameter tmp-file "rcd-wrs-XXXXXX")
(defparameter tmp-org (format nil "~a~a.org" memdir tmp-file))
(defparameter tmp-md (format nil "~a~a.md" memdir tmp-file))
(require "syscalls")
(defun main ()
(let ((input '())
(output '()))
(loop for line = (read-line *standard-input* nil nil)
while line do (push line input))
(setf input (format nil "~{~a~^~%~}" (reverse input)))
(with-open-file (stream tmp-org :direction :output :if-exists :supersede :if-does-not-exist :create :external-format "utf-8")
(princ input stream))
(shell (format nil "emacs -Q -l ~~/.emacs.d/elpa/org-20170210/org-autoloads.el \"~a\" --batch -f org-mode -f org-md-export-to-markdown --kill" tmp-org))
(with-open-file (stream tmp-md :direction :input :external-format "utf-8")
(loop :for line = (read-line stream nil nil)
:while line
:do (push line output)))
(setf output (format nil "~{~a~^~%~}" (reverse output)))
(princ output)))
;; (saveinitmem "org2markdown-pipe" :quiet t :init-function 'main :verbose nil :norc t :documentation "Converts Org standard input into markdown" :executable t)
(main)
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
clisp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/clisp-list