summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Tom Willemsen2012-08-17 01:26:52 +0200
committerGravatar Tom Willemsen2012-08-17 01:26:52 +0200
commit206294033b83d95b50f98d664b78afdc25fd9852 (patch)
tree8a1d794e239a7d398a7118463cf1cd4bd1e68ae4
parent88212abab3ee6e0ef94c20236bcce35ac4f43b12 (diff)
downloadundone-206294033b83d95b50f98d664b78afdc25fd9852.tar.gz
undone-206294033b83d95b50f98d664b78afdc25fd9852.zip
Use one big file for now
* undone/main.scm (todo-list-file): Check to see if we should use a file in XDG_DATA_HOME or HOME. (mkdirs): New function. (save): Ensure the directory tree exists by calling `mkdirs' first.
-rw-r--r--undone/main.scm20
1 files changed, 19 insertions, 1 deletions
diff --git a/undone/main.scm b/undone/main.scm
index 18beab3..750bf09 100644
--- a/undone/main.scm
+++ b/undone/main.scm
@@ -57,7 +57,15 @@
where #t
sort-by #f nil)))))
-(define todo-list-file "todo.scm")
+(define todo-list-file
+ (let* ((xdg (getenv "XDG_DATA_HOME"))
+ (home (getenv "HOME"))
+ (todo-file-name "todo.scm")
+ (xdg-todo-file (string-append xdg "/undone/" todo-file-name))
+ (home-todo-file (string-append xdg "/.undone/" todo-file-name)))
+ (if (and xdg (not (file-exists? home-todo-file)))
+ xdg-todo-file
+ home-todo-file)))
(define rc-file
(let* ((xdg (getenv "XDG_CONFIG_HOME"))
@@ -95,8 +103,18 @@
(string-append (getenv "HOME") "/."))
"undone")))
+(define (mkdirs path)
+ (let ((parent (dirname path)))
+ (if (not (file-exists? parent))
+ (mkdirs parent)))
+
+ (if (not (file-exists? path))
+ (mkdir path)))
+
(define (save)
"Save the list."
+ (mkdirs (dirname todo-list-file))
+
(let ((port (open-output-file todo-list-file)))
(write todo-list port)
(close-port port)))