From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dan Davison Subject: Re: Embedded code Date: Wed, 19 Jan 2011 23:54:39 +0000 Message-ID: References: <2324250583714673900@unknownmsgid> <87aaizhz23.fsf@gmail.com> <4D3554AC.1060303@gmail.com> <8762tmfa74.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from [140.186.70.92] (port=57323 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pfhrh-0007wp-4e for emacs-orgmode@gnu.org; Wed, 19 Jan 2011 18:55:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Pfhrf-0006IX-JO for emacs-orgmode@gnu.org; Wed, 19 Jan 2011 18:55:00 -0500 Received: from lo.gmane.org ([80.91.229.12]:50462) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Pfhrf-0006I5-8e for emacs-orgmode@gnu.org; Wed, 19 Jan 2011 18:54:59 -0500 Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1Pfhrc-0005wg-OV for emacs-orgmode@gnu.org; Thu, 20 Jan 2011 00:54:56 +0100 Received: from 94.196.187.99.threembb.co.uk ([94.196.187.99]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 20 Jan 2011 00:54:56 +0100 Received: from dandavison7 by 94.196.187.99.threembb.co.uk with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 20 Jan 2011 00:54:56 +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: emacs-orgmode@gnu.org "Eric Schulte" writes: > 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)) -*- I think `sbe' can be used here for a nice short version. E.g. # -*- eval: (sbe NAME) -*- or this at the end # Local variables: # eval:(sbe NAME) # End: where NAME is a double-quoted string. Dan > > where NAME is replaced with the name of the code block to execute. > > Cheers -- Eric > > _______________________________________________ > 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