unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Eric Abrahamsen <eric@ericabrahamsen.net>
To: help-gnu-emacs@gnu.org
Subject: Re: reading from standard input in batch mode
Date: Tue, 22 May 2018 13:49:15 -0700	[thread overview]
Message-ID: <87zi0rxvp0.fsf@ericabrahamsen.net> (raw)
In-Reply-To: 874lizzah6.fsf@ericabrahamsen.net

Eric Abrahamsen <eric@ericabrahamsen.net> writes:

> Eric Abrahamsen <eric@ericabrahamsen.net> writes:
>
>> I'm trying to figure out how batch mode works, and I want to do
>> something very simple: call a subordinate emacs process, passing it a
>> string, and have it write the string to a file. It's not working but I
>> don't know how to debug this.
>>
>> In boomerang.el:
>>
>> (defun boomerang ()
>>   (let ((msg (read)))
>>     (append-to-file msg
>> 		    nil
>> 		    "/home/eric/tmp/results.txt")))
>>
>> In my main emacs:
>>
>> (shell-command
>> "emacs -Q --batch -l boomerang.el -f boomerang \"hi there\"")
>>
>> The subordinate emacs starts and finishes (returning 255, which just
>> came up on a thread in emacs.devel, I think), but no file is written. As
>> far as I know, `read' should be reading from standard-input in this
>> case. What am I doing wrong?
>
> I figured it out, it should have been (read t). Ignore me!

No, dangit, it still doesn't work. I changed the (read) to (read t), and
changed the invocation to:

(shell-command
 "emacs -Q --batch -l boomerang.el -f boomerang \"hi there\"" "*output*"
 "*error*")

And *output* contains "Lisp expression:" (ie, it's still trying to read
from the minibuffer), and *error* contains "Error reading from stdin",
(ie, it couldn't read from the minibuffer).

Am I passing the string in incorrectly?




  reply	other threads:[~2018-05-22 20:49 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-22 20:16 reading from standard input in batch mode Eric Abrahamsen
2018-05-22 20:44 ` Eric Abrahamsen
2018-05-22 20:49   ` Eric Abrahamsen [this message]
2018-05-22 20:50   ` Noam Postavsky
2018-05-22 21:07     ` Eric Abrahamsen
2018-05-22 21:18       ` Eric Abrahamsen
2018-05-22 21:26       ` Noam Postavsky
2018-05-22 21:52         ` Eric Abrahamsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87zi0rxvp0.fsf@ericabrahamsen.net \
    --to=eric@ericabrahamsen.net \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).