From mboxrd@z Thu Jan 1 00:00:00 1970 From: LanX Subject: Re: hyperlinks executing multiline code snippets? Date: Fri, 10 Dec 2010 19:03:18 +0100 Message-ID: References: <871v5psgn1.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1183066464==" Return-path: Received: from [140.186.70.92] (port=48436 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PR7JS-0007tB-0i for emacs-orgmode@gnu.org; Fri, 10 Dec 2010 13:03:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PR7JP-0005Jd-Ap for emacs-orgmode@gnu.org; Fri, 10 Dec 2010 13:03:20 -0500 Received: from mail-ww0-f41.google.com ([74.125.82.41]:33389) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PR7JO-0005JO-Tw for emacs-orgmode@gnu.org; Fri, 10 Dec 2010 13:03:19 -0500 Received: by wwi18 with SMTP id 18so1271326wwi.0 for ; Fri, 10 Dec 2010 10:03:18 -0800 (PST) In-Reply-To: <871v5psgn1.fsf@gmail.com> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Eric Schulte Cc: emacs-orgmode@gnu.org --===============1183066464== Content-Type: multipart/alternative; boundary=00163642724946adf20497122b6e --00163642724946adf20497122b6e Content-Type: text/plain; charset=ISO-8859-1 Hi Eric Thanks looks promising but I'm having problems to use it. I noticed that babel is not a part of 6.30trans and did an upgrade to the latest current version 7.4. Unfortunately it's causing problems (all I did was updating a sym-link to the new package) Am I supposed to set additional PATHs? bye --Rolf emacs-23.1.50 --no-site-file --debug-init emacs/tst.org -------- Debugger entered--Lisp error: (file-error "Cannot open load file" "org-entities") require(org-entities) eval-buffer(#> nil "/home/lanx/.emacs.d/elisp/org/org-mode/lisp/org.el" nil t) ; Reading at buffer position 3964 load-with-code-conversion("/home/lanx/.emacs.d/elisp/org/org-mode/lisp/org.el" "/home/lanx/.emacs.d/elisp/org/org-mode/lisp/org.el" nil nil) load("/home/lanx/.emacs.d/elisp/org/org-mode/lisp/org.el") ... ------- emacs22 --no-site-file --debug-init emacs/tst.org -------- Debugger entered--Lisp error: (file-error "Cannot open load file" "org-macs") require(org-macs) eval-buffer(#> nil "/home/lanx/.emacs.d/elisp/org/org-mode/lisp/org.el" nil t) ; Reading at buffer position 3940 ... -------- 2010/12/10 Eric Schulte > 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 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 > --00163642724946adf20497122b6e Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hi Eric

Thanks looks promising but I'm having problems to use it= .

I noticed that babel is not a part of 6.30trans and did an upgrade= to the latest current version 7.4.

Unfortunately it's causing p= roblems (all I did was updating a sym-link to the new package)

Am I supposed to set additional PATHs?

bye
--Rolf

ema= cs-23.1.50 --no-site-file --debug-init emacs/tst= .org

--------
Debugger entered--Lisp error: (file-error "= ;Cannot open load file" "org-entities")
=A0 require(org-entities)
=A0 eval-buffer(#<buffer=A0 *load*<4>= > nil "/home/lanx/.emacs.d/elisp/org/org-mode/lisp/org.el" nil= t)=A0 ; Reading at buffer position 3964
=A0 load-with-code-conversion(&= quot;/home/lanx/.emacs.d/elisp/org/org-mode/lisp/org.el" "/home/l= anx/.emacs.d/elisp/org/org-mode/lisp/org.el" nil nil)
=A0 load("/home/lanx/.emacs.d/elisp/org/org-mode/lisp/org.el")...
-------


emacs22 --no-site-file --debug-init emacs/tst.org

--------
Debugger entered--Lisp = error: (file-error "Cannot open load file" "org-macs")<= br> =A0 require(org-macs)
=A0 eval-buffer(#<buffer=A0 *load*<4>>= nil "/home/lanx/.emacs.d/elisp/org/org-mode/lisp/org.el" nil t)= =A0 ; Reading at buffer position 3940
...
--------




2010/12/10 Eric Schulte <schulte.eric@gmail.com>
Hi LanX,

The following two options come to mind, although I'm not sure if any ar= e
exactly what you're after.

* named code block and a #+call: line
#+source: counter
#+begin_src perl :results output :var to=3D5
for $i (1..$to){
=A0 print $i;
}
#+end_src

#+results: counter
: 12345

#+call: counter(to=3D3)

#+results: counter(to=3D3)
: 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.c= om> writes:

>>
>> Hi
>>
>> Don't know if this is trivially answered...
>>
>> I'm thinking about using org-mode for a collection of code-sni= ppets which
>> are executed by a click on a link
>>
>> My first idea was to use orgs hyperlink syntax but there I have tw= o
>> problems
>> 1. something like [[shell:code][NAME]] can't be multiline
>> 2. for =A0perl =A0code 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 fol= ded
>> away)?
>>
>> something like?
>>
>> * [[exec:following snippet][name]
>> #+begin_src perl
>> for $i (1..9){
>>
>> =A0 =A0print $i;
>> }
>> #+end_src
>>
>>
>> or
>>
>>
>> * Title
>> #+begin_src perl :hyperlink name
>> for $i (1..9){
>>
>> =A0 =A0print $i;
>> }
>> #+end_src
>>
>>
>>
>> Thanks for any help
>>
>> -- rolf
>>
>
> PS hope this will not produce a duplicate post, "gmail" !=3D= "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

--00163642724946adf20497122b6e-- --===============1183066464== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ 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 --===============1183066464==--