Newer
Older
cl-todo / cl-todo.lisp
;;;;
;;;; A simple TODO app for the GNOME desktop
;;;; (mainly written to try out GTK+Lisp)
;;;;
;;;; (c) Daniel Vedder 2020
;;;; Licensed under the terms of the MIT license
;;;;

(in-package :cl-todo)

(defvar *task-list* NIL)
(defconstant +runfile+ (uiop:native-namestring "~/.todo"))


(defun launch ()
	(setf *task-list* (load-task-file))
	;;TODO
	)

(defun load-task-file (&optional (file-name +runfile+))
	"Load a list of (task) strings from the run file"
	(with-open-file (f file-name :if-does-not-exist nil)
		(when (null f)
			(format t "~&No task file found at ~S" file-name)
			(return-from load-task-file))
		(do* ((line (read-line f nil nil)
				  (read-line f nil nil))
				 (tasks NIL))
			((null line) tasks)
			(setf tasks (append tasks (list line))))))

(defun write-task-list (&optional (lst *task-list*) (filename +runfile+))
	"Write the task list to file, one entry per line."
	(let ((f (open filename :direction :output)))
		(dolist (i lst) (format f "~&~S" i))
		(close f)))

(defun add-task! (task)
	"Append a task to the task list"
	(setf *task-list* (append *task-list* (list task))))

(defun remove-task! (task)
	"Remove a task from the list"
	(setf *task-list*
		(remove-if #'(lambda (s) (equalp s task))
			*task-list* :count 1)))