emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Eric Schulte <schulte.eric@gmail.com>
To: Eric Schulte <schulte.eric@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: org babel support for tcl and awk
Date: Tue, 24 May 2011 13:03:41 -0600	[thread overview]
Message-ID: <87vcwz9b02.fsf@gmail.com> (raw)
In-Reply-To: <874o4kvvcb.fsf@ucl.ac.uk> (Eric S. Fraga's message of "Tue, 24 May 2011 18:53:24 +0100")

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

Eric S Fraga <e.fraga@ucl.ac.uk> writes:

> Eric Schulte <schulte.eric@gmail.com> writes:
>
> [...]
>
>> As an example, I've worked up an very simple ob-awk.el file from
>> ob-template.el, it is attached along with an example org-mode file which
>> demonstrates its usage.
>
> Eric,
>
> this is great to see as I use awk quite often.  What is involved in
> extending this to be able to run an awk script on input from within the
> org file (output of another babel block, for instance, as my typical use
> of awk is to re-arrange output from another program...)?  Or, if you
> wish, can you suggest one of the ob-XXX modules that best illustrates
> how to do this and I can give it a try?
>

I've made a quick change so that any variable named "stdin" is treated
specially, in that, rather than using its value to replace strings of
$stdin in the text of the awk code, the value of the stdin variable is
saved into the file processed by awk.  This allows awk to operate over
Org-mode references.

See the attached example file.

If babel code block supported a pipe or an actual stdin header argument,
that would be the ideal way to add this behavior, but currently nothing
of that nature exists.

Please let me know if this misses part of your suggestion, or more
generally what else may be advisable before we add this to the core.

Cheers -- Eric


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: example.org --]
[-- Type: text/x-org, Size: 653 bytes --]

* awk example

#+results: simple-table
| 1 | 2 | 3 |
| 4 | 5 | 6 |
| 7 | 8 | 9 |

#+begin_src awk :var stdin=simple-table
  {print $1}
#+end_src

#+results:
: 1
: 4
: 7

#+results: simple-text
: Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
: eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enimad
: minim veniam, quis nostrud exercitation ullamco laboris nisi ut
: aliquip ex ea commodo consequat. Duis aute irure dolor in
: reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
: pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
: culpa qui officia deserunt mollit anim id est laborum.

[-- Attachment #3: ob-awk.el --]
[-- Type: application/emacs-lisp, Size: 4665 bytes --]

[-- Attachment #4: Type: text/plain, Size: 67 bytes --]


>
> Thanks,
> eric

-- 
Eric Schulte
http://cs.unm.edu/~eschulte/

  reply	other threads:[~2011-05-24 19:03 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-24  9:31 org babel support for tcl and awk orgmode
2011-05-24 12:51 ` Eric Schulte
2011-05-24 17:53   ` Eric S Fraga
2011-05-24 19:03     ` Eric Schulte [this message]
2011-05-24 19:55       ` Sebastien Vauban
2011-05-24 23:51         ` Eric Schulte
2011-05-25 12:30           ` Sebastien Vauban
2011-05-25 15:57             ` Eric Schulte
2011-05-26 11:18               ` Sebastien Vauban
2011-05-26 13:37                 ` Eric Schulte
2011-05-26 13:03       ` Eric Schulte
2011-05-26 15:15         ` Eric S Fraga
2011-05-24 18:57   ` orgmode

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=87vcwz9b02.fsf@gmail.com \
    --to=schulte.eric@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /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).