[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] remove all #+RESULTS blocks in a file?
From: |
Nick Dokos |
Subject: |
Re: [O] remove all #+RESULTS blocks in a file? |
Date: |
Wed, 22 Aug 2012 11:01:16 -0400 |
Rainer M Krug <address@hidden> wrote:
> Hi
>
> I want to remove all #+RESULTS blocks in a file / section.
> org-babel-remove-result works nicely for
> a single block, but when the cursor is in a heading (e.g. in Test), only the
> first block is removed.
>
> Is this a bug or a feature?
>
> If a feature, is there a way of removing *all* #+RESULTS bocks in a file?
>
> Thanks,
>
> Rainer
>
>
> * Test
> #+begin_src sh :output both
> echo Test
> #+end_src
>
> #+RESULTS:
> : Test
>
> #+begin_src sh :output both
> echo Test
> #+end_src
>
> #+RESULTS:
> : Test
>
>
Although the following will do in a pinch, it is *not* the
best solution: it uses a string match to step from code block
to code block, instead of using org-element; but the idea is
the same, so the org-element solution is left as an exercise for
the interested reader :-)
Note that org-babel-remove-result presupposes that
point is in the corresponding source block: you can't blindly
use it from anywhere.
--8<---------------cut here---------------start------------->8---
(defun rmk-org-remove-all-result-blocks ()
(interactive)
(save-excursion
(goto-char (point-min))
(while (search-forward "#+begin_src " nil t)
(org-babel-remove-result))))
--8<---------------cut here---------------end--------------->8---
Nick