Re: How to solve: module 'syscalls' requires package OS
Jean Louis <[email protected]> Fri, 24 Mar 2017 23:41:51 +0300
| Newsgroups | gmane.lisp.clisp.general |
|---|---|
| Message-ID | <[email protected]> |
Hello Jörg, Danke, thank you. On Fri, Mar 24, 2017 at 01:51:21PM +0000, [email protected] wrote: > Do not require syscalls. :-) > The code you provided only uses standard Common Lisp and a few CLISP > extensions (ext:saveinitmem, ext:shell). Now it works without it. > > (let ((input (with-open-stream (str *standard-input*) > Do you realize that WITH-OPEN-STREAM closes the stream upon exit? > Unless you really know what you do, programs are usually advised > against closing their stdio handles. On this one I just need to read from *standard-input*, the Org file, then launch emacs to export to markdown, later I convert markdown to HTML with the favorite variety. > >(defparameter memdir "/run/shm/") > Don't reinvent the wheel. There's a reason people have, for decades, > recommended adding namespace decorations to special variables, > e.g. use *memdir*. OK sure, yet it is very short and not as important. > > (format stream input)) > That is as bad as printf(stream, format) in C. This will error out if there happens to be > any #\~ resp. '%' in the input! Yes, thank you, I got that. I was thinking I am getting good output, it wasn't. > Huh? Why store a whole intermediate copy in RAM? > Why not immediately copy *standard-input* to a file-stream? Yes, in the first run, maybe it is possible to simply read and directly put into the file. And putting it into the file is required for Emacs Org conversion. Of course functional style is what I like and use now in Lisp. This one is very short, and just to be used for receiving Org through *standard-input* and giving back the HTML. Now, the problem is that in this version it works if I launch it with lisp (CLISP), yet if I launch it as saved memory image, I get stack overflow with RESET. Do you know why the saved memory image is giving me stack overflow? Jean (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 '())) (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))) (setf output (slurp-stream-io-command "/usr/bin/discount_markdown -F 0x4" output)) (princ output)) (exit)) ;; (saveinitmem "org2markdown" :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