From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Thomas S. Dye" Subject: Re: Generate new babel code blocks and/or initialized code/data? Date: Tue, 20 Sep 2016 09:33:15 -1000 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:53730) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bmQnT-0008Th-HV for emacs-orgmode@gnu.org; Tue, 20 Sep 2016 15:33:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bmQnP-00070R-BP for emacs-orgmode@gnu.org; Tue, 20 Sep 2016 15:33:39 -0400 Received: from gproxy8-pub.mail.unifiedlayer.com ([67.222.33.93]:35150) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1bmQnP-0006zV-49 for emacs-orgmode@gnu.org; Tue, 20 Sep 2016 15:33:35 -0400 In-reply-to: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Lawrence Bottorff Cc: emacs-orgmode Mailinglist Aloha Lawrence, Lawrence Bottorff writes: > So I can run code for a REPL-type language like Clojure in a babel code > block and get "results," e.g., a Clojure code block takes in a vector of > mappings and produces new "results": > > #+RESULTS[abc5c51bb569a82c19c4eea1c385c74e839922c7]: > symmetrize-body-parts-test > | :name | head | :size | 3 | > | :name | left-eye | :size | 1 | > | :name | right-eye | :size | 1 | > | :name | left-ear | :size | 1 | > . . . > > but could I generate results that aren't just static output listed after a > #+RESULTS tag, rather, embedded in a newly created babel code block? I'd > like such output "initialized" as far as the running REPL is concerned too. > Is it possible to generate new code/data that is immediately known to the > REPL session? Any examples don't have to be Clojure. You can use the :session header argument which will give you access to any variables created during the session: http://orgmode.org/worg/org-contrib/babel/languages/ob-doc-clojure.html#orgheadline13 You can pass the function results to a variable argument, which makes possible chaining (see http://www.jstatsoft.org/v46/i03): #+header: :var x=myfunc(2) You can also embed and call a function in a source code block using noweb syntax: http://orgmode.org/worg/org-contrib/babel/intro.html#literate-programming hth, Tom -- Thomas S. Dye http://www.tsdye.com