emacs-devel
[Top][All Lists]
Advanced

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

Re: emacsclient in elisp


From: Jean Louis
Subject: Re: emacsclient in elisp
Date: Fri, 21 May 2021 09:21:35 +0300
User-agent: Mutt/2.0.6 (2021-03-06)

* Eli Zaretskii <eliz@gnu.org> [2021-05-20 18:11]:
> > Date: Thu, 20 May 2021 17:31:55 +0300
> > From: Jean Louis <bugs@gnu.support>
> > Cc: Stefan Monnier <monnier@iro.umontreal.ca>,
> >  "emacs-devel@gnu.org" <emacs-devel@gnu.org>
> > 
> > It would be useful to have Emacs that can read stdin. 
> 
> Emacs already is capable of doing that, see the node "Input Streams"
> in the ELisp manual.

emacs -Q -l process-org.el -l ~/.emacs.d/elpa/org-20201216/org-autoloads.el 
my-file.org --batch -f org-mode -f process-org

I have tried this way, it seem to be waiting for lines, but then it becomes 
error. I was expecting that `read-string' gets its stream reading. Maybe it 
works, I am not sure. But `read' cannot read strings, it is for expressions, 
the `read' is the only function described to receive input streams in that 
section of manual.

process-org.el:

(defun process-org () 
  (let ((line))
    (with-temp-buffer 
      (while (not (string= (setq line (read-string "")) ""))
        (insert line)
        (insert "\n"))
      (org-md-export-to-markdown))))

(defun tell-me ()
  (read-from-string ""))

And if I use this function:

(defun process-org () 
  (let ((line))
    (with-temp-buffer 
      (while (not (string= (setq line (read t)) ""))
        (insert line)
        (insert "\n"))
      (org-md-export-to-markdown))))

Then some lines will pass, some will not pass, as it prioritizes Lisp
expressions, not strings primarily.

Yes, Emacs can read stdin, only now it can read expressions. It would
be good that it can read anything. When reading standard input, one
need no input prompts. So I think a designated function is needed to
read standard input, that we may do something like:

cat file | emacs ...

as that way it becomes the tool to process text on command line.

Thank you,
Jean Louis



reply via email to

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