From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Barry Margolin Newsgroups: gmane.emacs.help Subject: Re: Can I use Emacs as pipe-thru formatter? Date: Tue, 05 Aug 2003 15:00:46 GMT Organization: Level(3) Communications, Woburn, MA Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: References: NNTP-Posting-Host: deer.gmane.org X-Trace: main.gmane.org 1060096571 24322 80.91.224.253 (5 Aug 2003 15:16:11 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Tue, 5 Aug 2003 15:16:11 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Aug 05 17:16:31 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 19k3Y6-0004mq-00 for ; Tue, 05 Aug 2003 17:16:31 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.20) id 19k3XD-0005fX-I8 for geh-help-gnu-emacs@m.gmane.org; Tue, 05 Aug 2003 11:15:35 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!bloom-beacon.mit.edu!nycmny1-snh1.gtei.net!crtntx1-snh1.gtei.net!news.gtei.net!news.level3.com.POSTED!53ab2750!not-for-mail Original-Newsgroups: gnu.emacs.help Mail-Copies-To: never X-Newsreader: trn 4.0-test72 (19 April 1999) Originator: barmar@genuity.net (Barry Margolin) Original-Lines: 26 Original-NNTP-Posting-Host: 171.78.176.30 Original-X-Trace: news.level3.com 1060095646 171.78.176.30 (Tue, 05 Aug 2003 15:00:46 GMT) Original-NNTP-Posting-Date: Tue, 05 Aug 2003 15:00:46 GMT Original-Xref: shelby.stanford.edu gnu.emacs.help:115686 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:11604 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:11604 In article , Irving Kimura 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.