Re: How to solve: module 'syscalls' requires package OS
Jean Louis <[email protected]> Mon, 27 Mar 2017 17:07:14 +0300
| Newsgroups | gmane.lisp.clisp.general |
|---|---|
| Message-ID | <[email protected]> |
On Mon, Mar 27, 2017 at 02:00:26PM +0000, [email protected] wrote: > Are you sure streamtools does nothing weird? > What does your slurp-stream-io-command do? (defun slurp-stream-io-command (command string) "Returns the output of a command to which string has been fed, very usable for markdown, emacs Org mode processing and similar" (let* ((stream (make-pipe-io-stream command :external-format "utf-8")) (in (two-way-stream-input-stream stream)) (out (two-way-stream-output-stream stream)) (result "")) (princ string out) (finish-output out) (close out) (setf result (format nil "~{~a~^~%~}" (reverse (let ((my-in '())) (with-open-stream (str in) (loop :for line = (read-line str nil nil) :while line :do (push line my-in))) my-in)))) (finish-output in) (close in) result)) I think the above is too complicated, yet it is working. > You are asking for help, but there's still something you can do yourself: > Try and narrow down the bug. What if you eliminate parts of your > program, e.g. It is working now, I don't get stack overflow. Thank you. Yet, whatever bug is there, maybe, I don't even know. > a) Replace input with a fixed three-liner? > (let ((input '("* Demo" "**Chapter 1"))) ... > b) Replace the call to Emacs with a no-op? > (tmp-md will re-use a previous file named /run/shm/rcd-wrs-XXXXXX.md) > c) Don't call (slurp-stream-io-command "/usr/bin/discount_markdown -F 0x4" output)? > d) Various combinations of the above? Thank you much. Yes, of course I first tested without anything. The stack overflow happened on reading of standard input, and now I cannot repeat it. Yet now it works this way: (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)) (load "/home/data1/protected/Programming/git/RCDBusiness/lib/lisp/streamtools.lisp") ;; (require "syscalls") (defun main () (let ((input '()) (output '())) (with-open-file (out tmp-org :direction :output :external-format "utf-8") (loop for line = (read-line *standard-input* nil nil) while line do (write-line line out))) (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)) (setf output (with-open-file (stream tmp-md :direction :input :external-format "utf-8") (loop for line = (read-line stream nil nil) while line collect line))) (setf output (format nil "~{~a~^~%~}" output)) (setf output (slurp-stream-io-command "/usr/bin/discount_markdown -F 0x4" output)) (princ output)) (exit)) ;; ;; (saveinitmem "org2html" :quiet t :init-function 'main :verbose nil :norc t :documentation "Converts Org standard input into markdown" :executable t) ;; (main) saveinitmem "org2html" :quiet t :init-function 'main :verbose nil :norc t :documentation "Converts Org standard input into markdown" :executable t) Bytes permanently allocated: 165,312 Bytes currently in use: 3,515,616 Bytes available until next GC: 878,904 3515616 ; 878904 ; 165312 ; 1 ; 106864 ; 12000 [2]> [~/bin/rcd] admin-> ./org2html #+TITLE: Something * section Some texxt <div id="table-of-contents"> <h2>Table of Contents</h2> <div id="text-table-of-contents"> <ul> <li><a href="#orge68b214">1. section</a></li> </ul> </div> </div> <p><a id="orge68b214"></a></p> <h1>section</h1> <p>Some texxt</p> ------------------------------------------------------------------------------ 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