unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* How to I read from the stdin input stream from inside Emacs?
@ 2016-01-24  1:24 Davin Pearson
  2016-01-24  1:37 ` John Mastro
  0 siblings, 1 reply; 2+ messages in thread
From: Davin Pearson @ 2016-01-24  1:24 UTC (permalink / raw)
  To: help-gnu-emacs

I have the following command in my Makefile:

foo:
     javac *.java |& emacs --batch --load sjs-error.el --funcall doit

I have tried the following code but it doesn't work:

(defun doit ()
   (while (input-pending-p)
     (message (format "input %s" last-input-event))))

 I also tried the following code but it doesn't work:

(defun doit ()
  (while (input-pending-p)
    (message (read-key-sequence))))

Please could one of you braniacs come up with some code that works!




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: How to I read from the stdin input stream from inside Emacs?
  2016-01-24  1:24 How to I read from the stdin input stream from inside Emacs? Davin Pearson
@ 2016-01-24  1:37 ` John Mastro
  0 siblings, 0 replies; 2+ messages in thread
From: John Mastro @ 2016-01-24  1:37 UTC (permalink / raw)
  To: help-gnu-emacs@gnu.org; +Cc: Davin Pearson

> I have the following command in my Makefile:
>
> foo:
>      javac *.java |& emacs --batch --load sjs-error.el --funcall doit
>
> I have tried the following code but it doesn't work:
>
> (defun doit ()
>    (while (input-pending-p)
>      (message (format "input %s" last-input-event))))
>
>  I also tried the following code but it doesn't work:
>
> (defun doit ()
>   (while (input-pending-p)
>     (message (read-key-sequence))))
>
> Please could one of you braniacs come up with some code that works!

You could use something like this:

(defun doit ()
  (let (line)
    (while (setq line (read-from-minibuffer ""))
      (message "input: %s" line))))

In batch mode, Emacs essentially treats stdin as minibuffer input.

-- 
john



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-01-24  1:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-24  1:24 How to I read from the stdin input stream from inside Emacs? Davin Pearson
2016-01-24  1:37 ` John Mastro

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).