[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Can Emacs pipe a buffer through another one?

From: Barry Margolin
Subject: Re: Can Emacs pipe a buffer through another one?
Date: Thu, 17 Jun 2004 17:25:30 -0400
User-agent: MT-NewsWatcher/3.4 (PPC Mac OS X)

In article <address@hidden>,
 J Krugman <address@hidden> wrote:

> Suppose I have two buffers A and B, not necessarily associated with
> a file on disk, and furthermore, suppose that B's content is a
> script (bash, perl, python, etc.) that prints to STDOUT a transform
> of whatever it reads from STDIN.  (Assume that the first line of
> B is a suitable shebang line.)  It would be really cool if, without
> leaving Emacs, and without creating any new files on disk, one
> could feed the contents of buffer A as STDIN to the script in buffer
> B, and take the resulting output and insert them in some other
> buffer C (possibly replacing some or all of C's contents).  (Of
> course, there should be no reason why these buffers should all be
> different from each other.  For instance, B could be a script that
> rewrites itself.)
> Even cooler would be if instead of using whole buffers for program
> and data as described above, one could use regions.
> Can one already do any of this in Emacs?  If not, can someone give
> me a clue about how to write such a thing in Emacs Lisp?

I can't think of any way this could be done.  If the script isn't put in 
a file, then the way to feed the script to the interpreter would be 
through its stdin.  But if the interpreter is reading the script on 
stdin, then where will it read the data from?

This might have been possible if Unix also supported "interpin", i.e. a 
standard descriptor that's used by interpreters to read their scripts.  
In that case, the script buffer would be piped to the subprocess's 
interpin, while the data buffer would be piped to the subprocess's stdin.

Barry Margolin, address@hidden
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***

reply via email to

[Prev in Thread] Current Thread [Next in Thread]