From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Julian M. Burgos" Subject: Re: running a source code by name Date: Wed, 30 May 2018 06:59:24 +0000 Message-ID: References: <87h8mrq25l.fsf@gmail.com> <790089EC-9901-4115-9F0C-7B9F0A913B0A@ucsd.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:37927) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fNv5Z-0001Bp-RD for emacs-orgmode@gnu.org; Wed, 30 May 2018 03:00:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fNv5W-00036g-Oo for emacs-orgmode@gnu.org; Wed, 30 May 2018 03:00:05 -0400 Received: from hafgarpur.hafro.is ([130.208.64.48]:47062) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fNv5W-00032o-CP for emacs-orgmode@gnu.org; Wed, 30 May 2018 03:00:02 -0400 In-reply-to: <790089EC-9901-4115-9F0C-7B9F0A913B0A@ucsd.edu> 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 , emacs-orgmode , John Kitchin Thanks guys. A combination of org-babel-goto-named-src-block and org-babel-execute-src-block did the trick. I am building an org template to create html presentations using the R package xaringan. In my case each slide is a markdown source block. The elisp block tangles everything into a Rmd file, and the R block runs rmarkdown::render and opens the resulting html file in a browser. Thanks again. :) Berry, Charles writes: > OK, I have to note that this will also do the job that the OP requested= : > > #+begin_src emacs-lisp :results silent :var result=3DmyRcode > > #+end_src > > although it seems a little strange to write an empty src block for its = side effects. > > I suppose I should have suggested this in the first place: > > #+begin_src emacs-lisp :results silent :noweb yes > <> > #+end_src > > although the return value from the noweb reference could be troublesome= depending on what else is included in the latter src block. > > Chuck > >> On May 28, 2018, at 1:16 PM, John Kitchin wr= ote: >> >> 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=3DmyPyCode >> 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 >> https://emea01.safelinks.protection.outlook.com/?url=3Dhttp%3A%2F%2Fki= tchingroup.cheme.cmu.edu&data=3D02%7C01%7C%7Cfdaa27b411604ed32a0108d5c4d9= fa01%7C8e105b94435e4303a61063620dbe162b%7C0%7C0%7C636631362846470731&sdat= a=3D4K%2B96NBf5KPaoz13laaAR0%2FaqY2FlefTLy%2BPXy6YtO8%3D&reserved=3D0 >> >> >> On Mon, May 28, 2018 at 9:25 AM, Berry, Charles wro= te: >> >> >> > 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 s= econd >> >> code block with an elisp call to run that first code. Something li= ke 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 >> >> >> >> >> -- Julian Mariano Burgos, PhD Hafranns=C3=B3knastofnun, ranns=C3=B3kna- og r=C3=A1=C3=B0gjafarstofnun h= afs og vatna/ Marine and Freshwater Research Institute Botnsj=C3=A1varsvi=C3=B0s / Demersal Division Sk=C3=BAlagata 4, 121 Reykjav=C3=ADk, Iceland S=C3=ADmi/Telephone : +354-5752037 Br=C3=A9fs=C3=ADmi/Telefax: +354-5752001 Netfang/Email: julian.burgos@hafogvatn.is