emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* deleting hidden parts of sparse trees
@ 2008-07-07  8:55 Dan Davison
  2008-07-07 16:44 ` Carsten Dominik
  0 siblings, 1 reply; 5+ messages in thread
From: Dan Davison @ 2008-07-07  8:55 UTC (permalink / raw)
  To: emacs org-mode mailing list

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 (?), 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. So that's good. However, I don't
know how to do it programmatically, because org-export-visible has
interactive keyboard input. (Or am I just exposing my ignorance
here??)  I've looked at the code, and what occurs to me is to hack out
the middle bit of org-export-visible as a separate function, say
org-prune-invisible or something. I sort of tried. It, err, didn't
work. Anyone think this would be worth doing? (The functionality, if
not via my suggested route)

Dan

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

* Re: deleting hidden parts of sparse trees
  2008-07-07  8:55 deleting hidden parts of sparse trees Dan Davison
@ 2008-07-07 16:44 ` Carsten Dominik
  2008-07-07 16:48   ` Carsten Dominik
  0 siblings, 1 reply; 5+ messages in thread
From: Carsten Dominik @ 2008-07-07 16:44 UTC (permalink / raw)
  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

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

* Re: deleting hidden parts of sparse trees
  2008-07-07 16:44 ` Carsten Dominik
@ 2008-07-07 16:48   ` Carsten Dominik
  2008-07-08 17:20     ` Dan Davison
  0 siblings, 1 reply; 5+ messages in thread
From: Carsten Dominik @ 2008-07-07 16:48 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: emacs org-mode mailing list


On Jul 7, 2008, at 9:44 AM, Carsten Dominik wrote:
>
> (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.


Even much more dangerous then I thought, the command shown above
actually deletes anything covered by overlays, not only outline
overlays.  Just one misplaced parenthesis......

Here is the corrected version.

(defun outline-delete-invisible ()
   "Delete all text covered 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))))))

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

* Re: deleting hidden parts of sparse trees
  2008-07-07 16:48   ` Carsten Dominik
@ 2008-07-08 17:20     ` Dan Davison
       [not found]       ` <2E800125-C30C-477E-AB79-01571C4C0D4D@uva.nl>
  0 siblings, 1 reply; 5+ messages in thread
From: Dan Davison @ 2008-07-08 17:20 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: emacs org-mode mailing list

On Mon, Jul 07, 2008 at 09:48:37AM -0700, Carsten Dominik wrote:
>
> On Jul 7, 2008, at 9:44 AM, Carsten Dominik wrote:
>>
<...>
>>
>> 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.
>
>
> Even much more dangerous then I thought, the command shown above
> actually deletes anything covered by overlays, not only outline
> overlays.  Just one misplaced parenthesis......
>
> Here is the corrected version.
>
> (defun outline-delete-invisible ()
>   "Delete all text covered 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))))))
>

Excellent! Thanks for the lesson.

My motivation for the request is as follows. I have a 'master' org
file (a database of plant photos arranged in a taxonomic hierarchy),
and I want to publish it as html, together with html versions of
various sparse trees derived from that master file according to tag
matching criteria etc. One option would be to write my own publishing
function, that creates each sparse tree and calls org-export-visible
on it. But I'd be recoding a load of stuff that has already been
addressed by org-publish. However, with the new function, I can create
the org-files corresponding to the sparse trees, and then let
org-publish-org-to-html deal with the master and the derived org files
in one go, which is a much better solution IMO.

DAn

p.s. warning heeded: I copy to a temp buffer, create sparse tree
and delete invisible in there.

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

* Re: deleting hidden parts of sparse trees
       [not found]       ` <2E800125-C30C-477E-AB79-01571C4C0D4D@uva.nl>
@ 2008-07-08 19:04         ` Dan Davison
  0 siblings, 0 replies; 5+ messages in thread
From: Dan Davison @ 2008-07-08 19:04 UTC (permalink / raw)
  To: emacs org-mode mailing list

On Tue, Jul 08, 2008 at 10:28:04AM -0700, Carsten Dominik wrote:
> Hi Dan, this is very interesting.
>
> Maybe you would like to write a little document how you use Org for this 
> purpose, what your setup is, why you chose Org to do this etc and put it 

Yep, I'd be happy to. (It was somewhat pretentious of me to call my
personal collection of random photos of flowers a 'database', but
still happy to.)

Dan

> up on the web?  I'd happily link to it from the Org webpages - we need 
> more of these examples.
>
> - Carsten
>
> On Jul 8, 2008, at 10:20 AM, Dan Davison wrote:
>
>> On Mon, Jul 07, 2008 at 09:48:37AM -0700, Carsten Dominik wrote:
>>>
>>> On Jul 7, 2008, at 9:44 AM, Carsten Dominik wrote:
>>>>
>> <...>
>>>>
>>>> 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.
>>>
>>>
>>> Even much more dangerous then I thought, the command shown above
>>> actually deletes anything covered by overlays, not only outline
>>> overlays.  Just one misplaced parenthesis......
>>>
>>> Here is the corrected version.
>>>
>>> (defun outline-delete-invisible ()
>>>  "Delete all text covered 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))))))
>>>
>>
>> Excellent! Thanks for the lesson.
>>
>> My motivation for the request is as follows. I have a 'master' org
>> file (a database of plant photos arranged in a taxonomic hierarchy),
>> and I want to publish it as html, together with html versions of
>> various sparse trees derived from that master file according to tag
>> matching criteria etc. One option would be to write my own publishing
>> function, that creates each sparse tree and calls org-export-visible
>> on it. But I'd be recoding a load of stuff that has already been
>> addressed by org-publish. However, with the new function, I can create
>> the org-files corresponding to the sparse trees, and then let
>> org-publish-org-to-html deal with the master and the derived org files
>> in one go, which is a much better solution IMO.
>>
>> DAn
>>
>> p.s. warning heeded: I copy to a temp buffer, create sparse tree
>> and delete invisible in there.

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

end of thread, other threads:[~2008-07-08 19:05 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-07-07  8:55 deleting hidden parts of sparse trees Dan Davison
2008-07-07 16:44 ` Carsten Dominik
2008-07-07 16:48   ` Carsten Dominik
2008-07-08 17:20     ` Dan Davison
     [not found]       ` <2E800125-C30C-477E-AB79-01571C4C0D4D@uva.nl>
2008-07-08 19:04         ` Dan Davison

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).