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.
This commit is contained in:
parent
88212abab3
commit
206294033b
1 changed files with 19 additions and 1 deletions
|
@ -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)))
|
||||
|
|
Loading…
Reference in a new issue