all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / 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

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.