From mboxrd@z Thu Jan 1 00:00:00 1970 From: Carsten Dominik Subject: Re: deleting hidden parts of sparse trees Date: Mon, 7 Jul 2008 09:44:16 -0700 Message-ID: <4D539FB1-44C6-4E19-B7A4-C147ED623C0A@uva.nl> References: <20080707085512.GA10608@stats.ox.ac.uk> Mime-Version: 1.0 (Apple Message framework v924) Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KFtp8-0004cO-0q for emacs-orgmode@gnu.org; Mon, 07 Jul 2008 12:44:22 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KFtp6-0004cB-3J for emacs-orgmode@gnu.org; Mon, 07 Jul 2008 12:44:20 -0400 Received: from [199.232.76.173] (port=43384 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KFtp5-0004c8-Vm for emacs-orgmode@gnu.org; Mon, 07 Jul 2008 12:44:20 -0400 Received: from korteweg.uva.nl ([146.50.98.70]:58702) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KFtp5-0005p3-Ka for emacs-orgmode@gnu.org; Mon, 07 Jul 2008 12:44:19 -0400 In-Reply-To: <20080707085512.GA10608@stats.ox.ac.uk> 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: Dan Davison Cc: emacs org-mode mailing list On Jul 7, 2008, at 1:55 AM, Dan Davison wrote: > I'd like to be able to create a 'pruned' tree -- I am thinking of an > operation that is similar to sparse tree creation, but which results > in the deletion (not just folding) of all subtrees that contain no > matching entries. > > I don't think this currently exists as such (?), No, it does not. > but it is possible to do > what I want by (1) creating a sparse tree, and (2) org-export-visible, > selecting the 'keep-buffer' option. That is a possibility, but for your task a much more direct way would be to iterate directly over the overlays in the buffer and to delete text accordingly. (defun outline-delete-invisible () "Delete all text covert by overlays with `invisible' property `outline'." (interactive) (let ((ovls (overlays-in (point-min) (point-max))) o) (while (setq o (pop ovls)) (and (eq (overlay-get o 'invisible) 'outline)) (delete-region (overlay-start o) (overlay-end o))))) Do I need to mention that this will be a dangerous operation, deleting lots of invisible text? You might find out only ater it is too late to recover. HTH - Carsten