[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Can I use Emacs as pipe-thru formatter?
From: |
Barry Margolin |
Subject: |
Re: Can I use Emacs as pipe-thru formatter? |
Date: |
Tue, 05 Aug 2003 15:00:46 GMT |
In article <bgoebt$gf0$1@reader1.panix.com>,
Irving Kimura <irving_kimura@lycos.com> wrote:
>Since, under Unix at least, it's not too difficult for a Perl script
>to pipe a string through an external program, one possible way to
>do what I want to do would be to write an "Emacs pipe" that somehow
>uses javascript-mode.el to pretty print its stdin and spits the
>results to stdout:
>
> % cat ugly.js | emacs_js_pretty_printer > pretty.js
>
>But I have no idea about how to write such a pipe. I would greatly
>appreciate any help or advice on how to do this, or any other ideas
>on how to tackle this problem.
Someone asked almost the same question a week or two ago.
Emacs doesn't read and write stdin/stdout, so it can't be used as a filter
in a pipeline. But you can use -batch and -eval to make it run a function
and then exit, so you could have it read ugly.js into a buffer, format it,
and then write the result out to pretty.js.
--
Barry Margolin, barry.margolin@level3.com
Level(3), Woburn, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.