From 3d7138e45af5a288995442dff249e8eaa00803d5 Mon Sep 17 00:00:00 2001 From: Tom Willemsen Date: Sun, 16 Sep 2012 14:22:44 +0200 Subject: [PATCH] Add delete command The delete command removes an item from the todo-list, it does this by filtering out the item wich has the given `id' value and saving the result. --- undone/main.scm | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/undone/main.scm b/undone/main.scm index 2f400e9..f627c31 100644 --- a/undone/main.scm +++ b/undone/main.scm @@ -157,6 +157,14 @@ (cons var val))) args)))))) +(define (delete args) + "Delete the specified element." + (set! todo-list + (filter (lambda (elm) + (not (eq? (get-field-value id elm) + (string->number (car args))))) + todo-list))) + (define-view default "Default todo-list view, show only the title." "~2d ~a~%" id content) @@ -188,6 +196,9 @@ ((add) (add (list-tail args 2)) (save)) + ((delete) + (delete (list-tail args 2)) + (save)) ((view) (view (list-tail args 2))) ((views)