emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Babel: Programmatically evaluate a heading and subtrees?


From: Ken Mankoff
Subject: Re: Babel: Programmatically evaluate a heading and subtrees?
Date: Mon, 01 Mar 2021 15:26:40 -0800
User-agent: mu4e 1.4.3; emacs 27.1

Hi Nathan,

On 2021-02-20 at 11:10 -08, Nathan Neff <nathan.neff@gmail.com> wrote...
> I have some code like this:
>
> * Heading 1
>
> # code block name:FOO
>
> ** Subheading 1
>
> # code block
>
> ** Subheading 2
>
> # code block
>
> I find that I often want to evaluate the code in Heading 1 and its
> subheadings.
>
> Currently, I navigate to Heading 1 and then use org-babel-execute-subtree
>
> I see that there's a function called org-babel-goto-named-src-block,
> so I think I could write a small function to jump to FOO in Heading 1
> and then run execute subtree and then jump back to my previous
> location in Emacs.
>
> Is there a more programmatic or built-in way? For example:
> org-babel-execute-block-and-subheadings FOO

What about,

(defun my/eval-parent-subtree()
  (save-excursion
    (outline-up-heading 1)
    (org-babel-execute-subtree)))

And then binding that to some key or something? Or (outline-up-heading 99) if 
you always want to go to "*". Or make that line a bit more dynamically 
controllable by use of 'prefix-arg' ?

  -k.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]