help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Is there some more elegant read from STDIN?


From: Jean Louis
Subject: Is there some more elegant read from STDIN?
Date: Fri, 12 Jul 2019 20:33:45 +0200
User-agent: Mutt/1.10.1 (2018-07-13)

I would like t oknow if there is any more elegant
read from STDIN on comman line, like when using
--script ?

References:

https://joelmccracken.github.io/entries/reading-writing-data-in-emacs-batch-via-stdin-stdout/

https://github.com/clarkgrubb/hyperpolyglot/issues/107#issuecomment-510984788

Working example:

#!/usr/local/bin/emacs --script

(defun org-stding-to-html-body-only ()
  "Reads org text body from STDIN and export full only body HTML"
  (let ((org-document-content "")
        this-read)
    (while (setq this-read (ignore-errors
                             (read-from-minibuffer "")))
      (setq org-document-content (concat org-document-content "\n" this-read)))

    (with-temp-buffer
      (org-mode)
      (insert org-document-content)
      (org-html-export-as-html nil nil nil t)
      (princ (buffer-string)))))

(org-stding-to-html-body-only)

Is there some better way to accept stdin then this
one?

Jean



reply via email to

[Prev in Thread] Current Thread [Next in Thread]