From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Eric Schulte" Subject: Re: hyperlinks executing multiline code snippets? Date: Fri, 10 Dec 2010 10:05:06 -0700 Message-ID: <871v5psgn1.fsf@gmail.com> References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from [140.186.70.92] (port=59572 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PR6PT-0006sj-1g for emacs-orgmode@gnu.org; Fri, 10 Dec 2010 12:05:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PR6PF-0003Wm-Mw for emacs-orgmode@gnu.org; Fri, 10 Dec 2010 12:05:18 -0500 Received: from mail-pw0-f41.google.com ([209.85.160.41]:58914) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PR6PF-0003WT-Dr for emacs-orgmode@gnu.org; Fri, 10 Dec 2010 12:05:17 -0500 Received: by pwj8 with SMTP id 8so306208pwj.0 for ; Fri, 10 Dec 2010 09:05:13 -0800 (PST) In-Reply-To: (LanX's message of "Fri, 10 Dec 2010 17:14:26 +0100") 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: LanX Cc: emacs-orgmode@gnu.org 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