all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* eval source blocks in a subtree when opening file
@ 2015-08-04 12:13 Tamas Papp
  2015-08-04 16:29 ` Charles C. Berry
  0 siblings, 1 reply; 4+ messages in thread
From: Tamas Papp @ 2015-08-04 12:13 UTC (permalink / raw)
  To: emacs-orgmode

Hi,

I have a file that looks like this (stylized):

--8<---------------cut here---------------start------------->8--- 
* Setup :noexport:

  #+COMMENT: some code here I want to run every time I open the 
  file in SRC blocks

* Experiment 1

  #+COMMENT: code I run when necessary, not every time

* Experiment 2

  #+COMMENT: code I run when necessary, not every time

* end of file :noexport: #+COMMENT: This is just for local 
variables, not exported.   # Local Variables: # 
org-confirm-babel-evaluate: nil # org-export-babel-evaluate: 
'inline-only # End: --8<---------------cut 
here---------------end--------------->8--- 

I would like to do the following: whenever I open the file in 
Emacs, I would like to eval all the source blocks under the 
heading Setup.

I have found org-babel-execute-subtree, but I cannot figure out 
how to call it on the subtree "Setup" from a local eval.

Best,

Tamas

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: eval source blocks in a subtree when opening file
  2015-08-04 12:13 eval source blocks in a subtree when opening file Tamas Papp
@ 2015-08-04 16:29 ` Charles C. Berry
  2015-08-07 14:06   ` Tamas Papp
  0 siblings, 1 reply; 4+ messages in thread
From: Charles C. Berry @ 2015-08-04 16:29 UTC (permalink / raw)
  To: Tamas Papp; +Cc: emacs-orgmode

On Tue, 4 Aug 2015, Tamas Papp wrote:

> Hi,
>

[mock file deleted]

> I would like to do the following: whenever I open the file in Emacs, I would 
> like to eval all the source blocks under the heading Setup.
>
> I have found org-babel-execute-subtree, but I cannot figure out how to call 
> it on the subtree "Setup" from a local eval.


Name the first block in the subtree "start setup" (say).

Then

# Local Variables:
# eval: (org-babel-goto-named-src-block "start setup")
# eval: (org-babel-execute-subtree)
# End:


should do it.

HTH,

Chuck

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: eval source blocks in a subtree when opening file
  2015-08-04 16:29 ` Charles C. Berry
@ 2015-08-07 14:06   ` Tamas Papp
  2015-08-07 18:47     ` Cook, Malcolm
  0 siblings, 1 reply; 4+ messages in thread
From: Tamas Papp @ 2015-08-07 14:06 UTC (permalink / raw)
  To: Charles C. Berry; +Cc: emacs-orgmode

On Tue, Aug 04 2015, Charles C. Berry <ccberry@ucsd.edu> wrote:

> On Tue, 4 Aug 2015, Tamas Papp wrote:
>
>> I would like to do the following: whenever I open the file in Emacs, I would 
>> like to eval all the source blocks under the heading Setup.
>>
>> I have found org-babel-execute-subtree, but I cannot figure out how to call 
>> it on the subtree "Setup" from a local eval.
>
> Name the first block in the subtree "start setup" (say).
>
> Then
>
> # Local Variables:
> # eval: (org-babel-goto-named-src-block "start setup")
> # eval: (org-babel-execute-subtree)
> # End:

Thanks! I found that I can also assign an ID to the section, and then
use

# eval: (progn (org-id-goto ...some-id...) (org-babel-execute-subtree))

It looks like I need the progn for it to work reliably (don't know why).

I am wondering if it would be possible to break a line in Local
Variables, but

# eval: (progn (org-id-goto ...some-id...) \
#              (org-babel-execute-subtree))

didn't work.

Best,

Tamas

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: eval source blocks in a subtree when opening file
  2015-08-07 14:06   ` Tamas Papp
@ 2015-08-07 18:47     ` Cook, Malcolm
  0 siblings, 0 replies; 4+ messages in thread
From: Cook, Malcolm @ 2015-08-07 18:47 UTC (permalink / raw)
  To: 'Tamas Papp', Charles C. Berry; +Cc: emacs-orgmode@gnu.org

> > On Tue, 4 Aug 2015, Tamas Papp wrote:
 > >
 > >> I would like to do the following: whenever I open the file in Emacs,
 > >> I would like to eval all the source blocks under the heading Setup.
 > >>
 > >> I have found org-babel-execute-subtree, but I cannot figure out how
 > >> to call it on the subtree "Setup" from a local eval.
 > >
 > > Name the first block in the subtree "start setup" (say).
 > >
 > > Then
 > >
 > > # Local Variables:
 > > # eval: (org-babel-goto-named-src-block "start setup") # eval:
 > > (org-babel-execute-subtree) # End:
 > 
 > Thanks! I found that I can also assign an ID to the section, and then use
 > 
 > # eval: (progn (org-id-goto ...some-id...) (org-babel-execute-subtree))
 > 
 > It looks like I need the progn for it to work reliably (don't know why).
 > 
 > I am wondering if it would be possible to break a line in Local Variables, but
 > 
 > # eval: (progn (org-id-goto ...some-id...) \
 > #              (org-babel-execute-subtree))
 > 
 > didn't work.
 > 
[Cook, Malcolm] 

Ditch the line continuation character.  This works in my hands with emacs 24.4.1 to set foo to bar:

# Local Variables:
# eval: (setq foo
#   "bar")
# End:



 > Best,
 > 
 > Tamas

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-08-07 18:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-04 12:13 eval source blocks in a subtree when opening file Tamas Papp
2015-08-04 16:29 ` Charles C. Berry
2015-08-07 14:06   ` Tamas Papp
2015-08-07 18:47     ` Cook, Malcolm

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.