From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nick Dokos Subject: Re: remove all #+RESULTS blocks in a file? Date: Wed, 22 Aug 2012 11:01:16 -0400 Message-ID: <12396.1345647676@alphaville> References: <5034DDD2.8090000@gmail.com> Reply-To: nicholas.dokos@hp.com Return-path: Received: from eggs.gnu.org ([208.118.235.92]:55518) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T4CR4-0004Bf-6f for emacs-orgmode@gnu.org; Wed, 22 Aug 2012 11:01:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T4CR3-0003im-6B for emacs-orgmode@gnu.org; Wed, 22 Aug 2012 11:01:34 -0400 Received: from g4t0014.houston.hp.com ([15.201.24.17]:41597) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T4CR2-0003fW-Vk for emacs-orgmode@gnu.org; Wed, 22 Aug 2012 11:01:33 -0400 In-Reply-To: Message from Rainer M Krug of "Wed, 22 Aug 2012 15:25:38 +0200." <5034DDD2.8090000@gmail.com> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Rainer@krugs.de Cc: emacs-orgmode Rainer M Krug 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