On Thu, Feb 25, 2016 at 6:12 AM, Edward K. Ream <edream...@gmail.com> wrote:

> Writing the cffm and cfam commands was snap using c.cloneFindByPredicate,
> a powerful new addition to Leo.
>

​Recent revs add the following new position methods:

- p.is_at_all():  True if p is an @<file> node containing an @all directive.
- p.in_at_all(): True if p is in an @<file> tree whose root contains @all.
- p.is_at_ignore(): True if p is an @ignore node
- p.in_at_ignore_tree(): True if p is in an @ignore tree.

These predicates make it easy to create other predicates that skip @ignore
trees or @<file> trees containing @all.  cffm and cfam do *not *skip such
trees, on the theory that one would typically unmark nodes first before
marking nodes to be cloned.

So here is how to gather only those marked nodes that lie outside any
@ignore tree:

    def isMarked(p):
        return p.isMarked() and not p.in_at_ignore_tree()

    self.cloneFindByPredicate(
        generator = self.all_unique_positions,
        predicate = isMarked,
        flatten = flatten,
        undoType = 'gather-marked',
    )

​EKR

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.

Reply via email to