From: Kevin Rodgers <ihs_4664@yahoo.com>
Subject: Re: Can Emacs pipe a buffer through another one?
Date: Mon, 21 Jun 2004 12:32:13 -0600 [thread overview]
Message-ID: <40D729AD.9010105@yahoo.com> (raw)
In-Reply-To: cb4npg$nbm$1@reader2.panix.com
J Krugman wrote:
> In <40D30930.6090309@yahoo.com> Kevin Rodgers <ihs_4664@yahoo.com> writes:
>>J Krugman wrote:
>>>Perl at least will let one give it code as the argument to the -e
>>>flag, which leaves STDIN available for input. For bash apparently
>>>something similar holds for the -c flag (but I have no experience
>>>with it). I imagine other scripting languages have similar
>>>mechanisms. Anyway, as long as the interpreter reads the entire
>>>script before it executes it (and I don't know of any interpreted
>>>language for which this isn't the case), then STDIN could serve
>>>both for feeding the script to the interpreter, and then feeding
>>>input to the running script[1]. The two tasks do not overlap in time,
>>>so it should be possible to accommodate both, no?
>
>>Cool!
>>
>>(with-current-buffer (get-buffer "A")
>> (shell-command-on-region (point-min)
>> (point-max)
>> (with-current-buffer (get-buffer "B")
>> (buffer-string))
>> (get-buffer "C")))
>>
>
> You lost me there! I don't see how this could possibly do what I
> described.
You want buffer A's contents passed as standard input to the script in
buffer B, with the output going to buffer C. So:
a. First select buffer buffer A, and pass its contents as standard input
to a shell command whose output goes to buffer C.
b. The shell command comes from the contents of buffer B, which is
passed via the -c option to the shell.
`C-h f shell-command-on-region' et al.
> Can you give me an example of how to use this?
Here's what I did:
1. Create buffer A with `C-x b A', and put some text in it:
one
two
three
2. Create buffer B with `C-x b B', and put a simple script in it:
cd ~; pwd
wc
cd /tmp; pwd
3. Create buffer C with `C-x b C'. This step could be avoided by using
(get-buffer-create "C") instead of (get-buffer "C").
4. Copy-and-paste the above form in the *scratch* buffer, and type `C-x
C-e' or `C-j' (see the "Lisp Interaction" and "Lisp Eval" nodes in
the Emacs manual).
5. Buffer C now contains:
/home/kevinr
3 6 28
/tmp
--
Kevin Rodgers
next prev parent reply other threads:[~2004-06-21 18:32 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-06-17 21:09 Can Emacs pipe a buffer through another one? J Krugman
2004-06-17 21:25 ` Barry Margolin
2004-06-18 2:45 ` J Krugman
2004-06-18 15:24 ` Kevin Rodgers
2004-06-20 19:16 ` J Krugman
2004-06-21 18:32 ` Kevin Rodgers [this message]
2004-06-21 20:19 ` Kevin Rodgers
2004-06-17 23:53 ` Marco Parrone
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=40D729AD.9010105@yahoo.com \
--to=ihs_4664@yahoo.com \
/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).