From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Kitchin Subject: Re: running a source code by name Date: Mon, 28 May 2018 13:16:35 -0700 Message-ID: References: <87h8mrq25l.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000749af9056d49cb85" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:57813) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fNOZM-0003hx-D2 for emacs-orgmode@gnu.org; Mon, 28 May 2018 16:16:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fNOZL-0007BZ-6P for emacs-orgmode@gnu.org; Mon, 28 May 2018 16:16:40 -0400 Received: from mail-wr0-x231.google.com ([2a00:1450:400c:c0c::231]:40920) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fNOZK-000791-RI for emacs-orgmode@gnu.org; Mon, 28 May 2018 16:16:39 -0400 Received: by mail-wr0-x231.google.com with SMTP id l41-v6so21964426wre.7 for ; Mon, 28 May 2018 13:16:38 -0700 (PDT) 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: "Berry, Charles" Cc: Eric S Fraga , "Julian M. Burgos" , emacs-orgmode --000000000000749af9056d49cb85 Content-Type: text/plain; charset="UTF-8" Here is yet another variation, that may be suitable for what you want: #+name: myPyCode #+BEGIN_SRC python print('Hello') #+END_SRC #+BEGIN_SRC emacs-lisp :var results=myPyCode results #+END_SRC #+RESULTS: : Hello John ----------------------------------- Professor John Kitchin Doherty Hall A207F Department of Chemical Engineering Carnegie Mellon University Pittsburgh, PA 15213 412-268-7803 @johnkitchin http://kitchingroup.cheme.cmu.edu On Mon, May 28, 2018 at 9:25 AM, Berry, Charles wrote: > > > > On May 28, 2018, at 7:35 AM, Eric S Fraga wrote: > > > > On Monday, 28 May 2018 at 11:13, Julian M. Burgos wrote: > >> Dear list, > >> > >> I have an org file with an R source code block. I want to have a second > >> code block with an elisp call to run that first code. Something like > this > >> > >> > >> #+begin_src emacs-lisp :results silent :tangle no > >> > >> ... Some elisp code to run the "myRcode" block. > > > > Something along the lines of: > > > > (org-babel-goto-named-src-block "myRcode") > > (org-babel-execute-src-block) > > > > should do the job? > > Maybe wrap it in > > (save-excursion ... ) > > or use > > (org-sbe "myRcode") > > or > > (org-babel-ref-resolve "myRcode") > > which both can also pass :var args. > > HTH, > > Chuck > > > > > --000000000000749af9056d49cb85 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Here is yet another variation, that may be suitable for wh= at you want:


#+name: myPyCode
<= div>#+BEGIN_SRC python
print('Hello')
#+END_SRC=


#+BEGIN_SRC emacs-lisp :var result= s=3DmyPyCode
results
#+END_SRC

#+RESULTS:
: Hello


John
=
-----------------------------------
Professor John Kitchin=C2=A0
= Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon= University
Pittsburgh, PA 15213
412-268-7803

On Mon, May 28, 2018 at 9:25 AM, Berry, Char= les <ccberry@ucsd.edu> wrote:


> On May 28, 2018, at 7:35 AM, Eric S Fraga <esflists@gmail.com> wrote:
>
> On Monday, 28 May 2018 at 11:13, Julian M. Burgos wrote:
>> Dear list,
>>
>> I have an org file with an R source code block.=C2=A0 I want to ha= ve a second
>> code block with an elisp call to run that first code.=C2=A0 Someth= ing like this
>>
>>
>> #+begin_src emacs-lisp :results silent :tangle no
>>
>> ... Some elisp code to run the "myRcode" block.
>
> Something along the lines of:
>
>=C2=A0 =C2=A0 (org-babel-goto-named-src-block "myRcode")=
>=C2=A0 =C2=A0 (org-babel-execute-src-block)
>
> should do the job?

Maybe wrap it in

=C2=A0 =C2=A0 =C2=A0 =C2=A0 (save-excursion ... )

or use

=C2=A0 =C2=A0 =C2=A0 =C2=A0 (org-sbe "myRcode")

or

=C2=A0 =C2=A0 =C2=A0 =C2=A0 (org-babel-ref-resolve "myRcode")
which both can also pass :var args.

HTH,

Chuck





--000000000000749af9056d49cb85--