From: "Eric Schulte" <schulte.eric@gmail.com>
To: LanX <lanx.perl@googlemail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: hyperlinks executing multiline code snippets?
Date: Fri, 10 Dec 2010 10:05:06 -0700 [thread overview]
Message-ID: <871v5psgn1.fsf@gmail.com> (raw)
In-Reply-To: <AANLkTin_KqdeDJZ+C8UUBb6g+Ez2gLrKsz67bWP+MKmM@mail.gmail.com> (LanX's message of "Fri, 10 Dec 2010 17:14:26 +0100")
Hi LanX,
The following two options come to mind, although I'm not sure if any are
exactly what you're after.
* named code block and a #+call: line
#+source: counter
#+begin_src perl :results output :var to=5
for $i (1..$to){
print $i;
}
#+end_src
#+results: counter
: 12345
#+call: counter(to=3)
#+results: counter(to=3)
: 123
C-c C-c on the call line to execute the counter block, the block does
not need to be located near the call line, and using the Library of
Babel could even be located in another file.
* using an elisp link
[[elisp:(sbe counter (to "8"))][count to 8]]
Clicking on the link above will also call the code block.
Best -- Eric
LanX <lanx.perl@googlemail.com> writes:
>>
>> Hi
>>
>> Don't know if this is trivially answered...
>>
>> I'm thinking about using org-mode for a collection of code-snippets which
>> are executed by a click on a link
>>
>> My first idea was to use orgs hyperlink syntax but there I have two
>> problems
>> 1. something like [[shell:code][NAME]] can't be multiline
>> 2. for perl code I'll need to escape certain characters when using
>> [[shell:...] or [[elisp:...]
>>
>> my second idea was org-babel, but AFAI see
>> 1. it seems to execute code-snippets only when exporting
>> 2. the code can't be hidden behind a NAME in a link text
>>
>> Is there a way to combine both ways?
>>
>> A hyperlink which executes a codesnippet (which is per default folded
>> away)?
>>
>> something like?
>>
>> * [[exec:following snippet][name]
>> #+begin_src perl
>> for $i (1..9){
>>
>> print $i;
>> }
>> #+end_src
>>
>>
>> or
>>
>>
>> * Title
>> #+begin_src perl :hyperlink name
>> for $i (1..9){
>>
>> print $i;
>> }
>> #+end_src
>>
>>
>>
>> Thanks for any help
>>
>> -- rolf
>>
>
> PS hope this will not produce a duplicate post, "gmail" != "googlemail"
> confusion
> _______________________________________________
> Emacs-orgmode mailing list
> Please use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
next prev parent reply other threads:[~2010-12-10 17:05 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-10 15:20 hyperlinks executing multiline code snippets? LanX
2010-12-10 15:52 ` LanX
2010-12-10 16:14 ` LanX
2010-12-10 17:05 ` Eric Schulte [this message]
2010-12-10 18:03 ` LanX
2010-12-10 18:08 ` LanX
2010-12-10 22:14 ` LanX
2010-12-11 2:23 ` LanX
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=871v5psgn1.fsf@gmail.com \
--to=schulte.eric@gmail.com \
--cc=emacs-orgmode@gnu.org \
--cc=lanx.perl@googlemail.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).