all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Emanuel Berg <embe8573@student.uu.se>
To: help-gnu-emacs@gnu.org
Subject: Re: 'emacs -batch -eval ... -f ...' outputs everyday crunching to stderr?
Date: Sun, 21 Sep 2014 01:15:19 +0200	[thread overview]
Message-ID: <87iokhlw8o.fsf@debian.uxu> (raw)
In-Reply-To: 878um2rbvy.fsf@debian.uxu

Emanuel Berg <embe8573@student.uu.se> writes:

> The strange thing is that the 2>&1 is required. It
> seems, 'emacs -batch -eval ... -f ...' outputs the
> "Loading..." and "Wrote..." stuff to stderr - any
> ideas why?

In the Emacs man page, emacs(1), it says:

    --batch ...  The editor will send messages to
      stderr. ...

It doesn't say why, but I just had another problem that
made me think about this.

There is a shell tool called 'par'. You can use it to
justify a file (at the 54th char) like this:

par 54j < input.txt > output.txt

However, fed with the language of honor and heroes
(Swedish), par doesn't work (probably because of out
three special chars). (I wrote the Debian maintainer
about this, but he didn't replied. In the par manpage,
par(1), they provide another email that doesn't work.
Anyway the Debian guy didn't reply.)

So I thought I'd do it in Emacs instead. In zsh:

justify () {
    file=\"$1\"
    emacs --batch --eval "
      (progn
        (find-file $file)
        (setq fill-column 54)
        (fill-region (point-min) (point-max) 'full)
        (princ (buffer-string))
        (kill-buffer) )" 2> /dev/null \
    | pr -o 4 -t
}

(The last line - pr - is to get a left margin of 4
whitespaces.)

When I wrote it, I noticed it was practical for batch
Emacs to output to stderr - that way, I could redirect
it to /dev/null and have Emacs print exactly what I
wanted (the `princ' part).

So I suppose this is the reason - or one of the reasons
- for batch Emacs to behave like this. I don't know if
it makes sense, but it is very manageable, which is what
matters the most. If it were to make sense, perhaps
batch Emacs would just shut up - unless there is a real
error - which then, naturally, would go to stderr?

-- 
underground experts united


      parent reply	other threads:[~2014-09-20 23:15 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-02  2:31 'emacs -batch -eval ... -f ...' outputs everyday crunching to stderr? Emanuel Berg
     [not found] ` <mailman.8241.1409820712.1147.help-gnu-emacs@gnu.org>
2014-09-04 18:52   ` Emanuel Berg
2014-09-20 23:15 ` Emanuel Berg [this message]

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

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

  git send-email \
    --in-reply-to=87iokhlw8o.fsf@debian.uxu \
    --to=embe8573@student.uu.se \
    --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.
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.