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.
This commit is contained in:
parent
cae98ebdfb
commit
3d7138e45a
1 changed files with 11 additions and 0 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue