From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Eric Schulte" Subject: Re: Embedded code Date: Tue, 18 Jan 2011 09:16:04 -0700 Message-ID: <8762tmfa74.fsf@gmail.com> References: <2324250583714673900@unknownmsgid> <87aaizhz23.fsf@gmail.com> <4D3554AC.1060303@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from [140.186.70.92] (port=47109 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PfEQ3-0003Hq-5b for emacs-orgmode@gnu.org; Tue, 18 Jan 2011 11:32:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PfEPt-00044K-4G for emacs-orgmode@gnu.org; Tue, 18 Jan 2011 11:28:28 -0500 Received: from mail-pw0-f41.google.com ([209.85.160.41]:40971) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PfEPs-00042P-Rp for emacs-orgmode@gnu.org; Tue, 18 Jan 2011 11:28:21 -0500 Received: by mail-pw0-f41.google.com with SMTP id 8so1450267pwj.0 for ; Tue, 18 Jan 2011 08:28:20 -0800 (PST) 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: Rainer M Krug Cc: Ido Magal , emacs-orgmode@gnu.org Rainer M Krug writes: > On 01/18/2011 12:48 AM, Eric Schulte wrote: >> Hi, >> >> This is possible using Babel, the attached org-mode file will execute >> its code block every time it is opened. You can replace the contents of >> the code block with any arbitrary elisp you would like to have executed >> in the file. >> >> To see this work, save the attached org-mode file to your system, open >> the file, answer "y" to allow execution, and then check your messages >> buffer for the "I have been run" message to see that the code block has >> in fact been evaluated. > > This is indeed very useful (e.g. if I open an R script, to open an R > session and source the file). > > But it seems that all code blocks are evaluated on loading. Is there a > way of only executing a specific code block? > Yes, replace the # -*- eval: (org-babel-execute-buffer) -*- with # -*- eval: (save-excursion (org-babel-goto-named-src-block NAME) (org-babel-execute-src-block)) -*- where NAME is replaced with the name of the code block to execute. Cheers -- Eric