diff options
Diffstat (limited to '')
-rw-r--r-- | guile_interface.scm.c | 21 | ||||
-rw-r--r-- | vcalendar.scm | 2 | ||||
-rw-r--r-- | vcalendar/primitive.scm | 1 |
3 files changed, 24 insertions, 0 deletions
diff --git a/guile_interface.scm.c b/guile_interface.scm.c index a5921869..3d0bff1e 100644 --- a/guile_interface.scm.c +++ b/guile_interface.scm.c @@ -111,6 +111,27 @@ SCM_DEFINE(vcomponent_children, "%vcomponent-children", 1, 0, 0, return llist; } +SCM_DEFINE(vcomponent_filter_children_x, "%vcomponent-filter-children!", + 2, 0, 0, + (SCM pred, SCM component), + "Remove all children from component who DOESN'T satisfy `pred`") +{ + scm_assert_foreign_object_type (vcomponent_type, component); + vcomponent* cal = scm_foreign_object_ref (component, 0); + + for (LINK(vcomponent)* l = FIRST(&cal->components); + l->after != NULL; + l = l->after) + { + if (scm_is_false(scm_call_1 (pred, scm_from_vcomponent(l->value)))) { + FFREE(vcomponent, l->value); + UNLINK(LINK(vcomponent))(l); + } + } + + return SCM_UNSPECIFIED; +} + SCM_DEFINE(vcomponent_push_child_x, "%vcomponent-push-child!", 2, 0, 0, (SCM component, SCM child), "") diff --git a/vcalendar.scm b/vcalendar.scm index 143d9e79..2ce5a438 100644 --- a/vcalendar.scm +++ b/vcalendar.scm @@ -59,6 +59,8 @@ (define-public copy-vcomponent %vcomponent-shallow-copy) +(define-public filter-children! %vcomponent-filter-children!) + (define-public (search cal term) (cdr (let ((events (filter (lambda (ev) (eq? 'VEVENT (type ev))) (children cal)))) diff --git a/vcalendar/primitive.scm b/vcalendar/primitive.scm index e575115c..fdce550c 100644 --- a/vcalendar/primitive.scm +++ b/vcalendar/primitive.scm @@ -3,6 +3,7 @@ (define-module (vcalendar primitive) #:export (%vcomponent-children %vcomponent-push-child! + %vcomponent-filter-children! %vcomponent-parent |