emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Michael Baum <maabaum@gmail.com>
To: Sebastien Vauban <wxhgmqzgwmuf@spammotel.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: How to pass a block of text to a code block as data?
Date: Fri, 8 Feb 2013 21:59:20 -0500	[thread overview]
Message-ID: <CA+G3xFhHDz05Muj9Z1TCDCD+5=9NP7B5ZZu4-NMpS4F9s0qVhQ@mail.gmail.com> (raw)
In-Reply-To: <8638x6y2zn.fsf@somewhere.org>

[-- Attachment #1: Type: text/plain, Size: 2602 bytes --]

Sebastien:

Thanks! That helps a lot. I'm having trouble extending your example,
however. A couple of questions --

- What signals the end of the block of text to be used as data? I take it
that it's important that these all be comment lines staring with a colon
after the #+name label? Is there a way to do the same thing with a begin
and end block construction?

- In this line:
       #+begin_src sh :stdin lines-of-text :results output

does the flag :stdin mean that the following named block literally becomes
the STDIN stream for the code block? If I replace your shell/grep example
with this:

#+begin_src perl :stdin lines-of-text :results output
while (<>) {
   print $_;
}
#+end_src

...it doesn't work, although as far as I know that perl code snippet should
in fact simply print out the incoming lines from stdin.

Thanks again,

Michael

On Fri, Feb 8, 2013 at 3:17 PM, Sebastien Vauban <wxhgmqzgwmuf@spammotel.com
> wrote:

> Hi Michael,
>
> Michael Baum wrote:
> > I haven't been able to figure this out from the org-mode documents yet.
> > What I would like to do is have a source code block in python or perl or
> > something similar. to which I can pass a reference to several lines of
> text
> > that the source code block, when evaluated, would then act on. Which
> would
> > involve iterating through the data text one line at a time and writing
> the
> > output to a buffer.
> >
> > The text data could be indicated by a specific headline or a named block
> of
> > some sort or maybe an internal link, I'm not particularly fussy just so
> > there's a mechanism to do this.
> >
> > Would appreciate any guidance.
>
> #+name: lines-of-text
> : I haven't been able to figure this out from the org-mode documents yet.
> : What I would like to do is have a source code block in python or perl or
> : something similar. to which I can pass a reference to several lines of
> text
> : that the source code block, when evaluated, would then act on. Which
> would
> : involve iterating through the data text one line at a time and writing
> the
> : output to a buffer.
>
> #+begin_src sh :stdin lines-of-text :results output
>   grep would
> #+end_src
>
> #+results:
> #+begin_example
> What I would like to do is have a source code block in python or perl or
> that the source code block, when evaluated, would then act on. Which would
> #+end_example
>
> Best regards,
>   Seb
>
> --
> Sebastien Vauban
>
>
>


-- 
====================================
Michael Baum <maabaum@gmail.com>

You should never have your best trousers on when you go out
 to fight for freedom and truth. - Ibsen

[-- Attachment #2: Type: text/html, Size: 3334 bytes --]

  reply	other threads:[~2013-02-09  2:59 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-08 17:06 How to pass a block of text to a code block as data? Michael Baum
2013-02-08 20:17 ` Sebastien Vauban
2013-02-09  2:59   ` Michael Baum [this message]
2013-02-09 18:49     ` Sean O'Halpin
2013-02-11 21:49       ` Michael Baum
2013-02-11 22:07         ` Eric Schulte

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.orgmode.org/

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

  git send-email \
    --in-reply-to='CA+G3xFhHDz05Muj9Z1TCDCD+5=9NP7B5ZZu4-NMpS4F9s0qVhQ@mail.gmail.com' \
    --to=maabaum@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=wxhgmqzgwmuf@spammotel.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.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

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).