From: Jarmo Hurri <jarmo.hurri@iki.fi>
To: emacs-orgmode@gnu.org
Subject: Babel: filtering code to produce another block
Date: Wed, 13 Sep 2017 11:34:17 +0300 [thread overview]
Message-ID: <87fubr80ae.fsf@iki.fi> (raw)
Greetings.
This question can again be described shortly and in more detail.
1. Short form: what would be a convenient way to filter the source
code in a Babel source code block so that the output would be the
source code in another block?
2. Then the long form. I need to emulate the very basics of one
programming language, namely Processing
https://processing.org/
with another, namely Asymptote
http://asymptote.sourceforge.net/
This is to be done within Org. I need to do this to illustrate on
paper the visual output of simple, static (no animation) Processing
programs.
Making this work roughly isn't too difficult, because these two
languages have very similar syntaxes. For example, provided that a
function rect() has been implemented in Asymptote, the following
code is legit in both Processing and Asymptote:
#+name: pic
#+BEGIN_SRC asymptote
size (800, 600);
for (int i = 0; i < 10; i += 2)
rect (i * 10, i * 20, 30, 10);
#+END_SRC
After this block has been defined I can show it as "Processing
code" and draw a picture with Asymptote, using noweb if need be. It
is also easy to use transforms so that the coordinate systems of
the two languages match. Furthermore, typedef can be used to align
some variable type differences.
However, my current issue is dealing with 'final' in Asymptote. The
following is not legit Asymptote code:
#+BEGIN_SRC asymptote
size (800, 600);
final int S = 20;
rect (100, 100, S, S);
#+END_SRC
It would be legit if the word 'final' were simply removed. Which
brings me to the question: what would be an easy way to filter this
block to produce another block? The header arguments of the two
blocks would be different from each other.
Thanks in advance,
Jarmo
reply other threads:[~2017-09-13 8:34 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=87fubr80ae.fsf@iki.fi \
--to=jarmo.hurri@iki.fi \
--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).