aboutsummaryrefslogtreecommitdiff
path: root/lib/state.lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/state.lisp')
-rw-r--r--lib/state.lisp10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/state.lisp b/lib/state.lisp
index 123bd79..8ab6c51 100644
--- a/lib/state.lisp
+++ b/lib/state.lisp
@@ -86,7 +86,7 @@
(defun fetch-draft (name)
"Fetch a draft by name form the *DRAFTS* association list."
- (cdr (assoc name *drafts*)))
+ (cdr (assoc name *drafts* :test #'string-equal)))
(defun drop-draft (name)
"Drop a draft by NAME from the *DFRAFTS* association list."
@@ -143,6 +143,12 @@ CACHED-ONELINERS-FILE. NIL if there is no such file."
:shell (prompt "With which shell should oneliners be run? "
:prefill "bash")))
+(defun read-drafts-file ()
+ (read-from-file (drafts-file)))
+
+(defun write-drafts-to-disk ()
+ (print-to-file *drafts* (drafts-file)))
+
(defun ensure-config ()
"Ensures that a configuration file exists on disk, prompting the
user for some input if it does not."
@@ -158,6 +164,7 @@ user for some input if it does not."
sets the api's *host* variable. If BODY produces no errors, the "
`(let* ((*config* (ensure-config))
(*cache* (read-cache-file))
+ (*drafts* (read-drafts-file))
(api:*host* (config-host *config*)))
(assert api:*host* () "ol must be configured with a server host.")
(set-term-width)
@@ -165,6 +172,7 @@ sets the api's *host* variable. If BODY produces no errors, the "
(progn
,@body
;; only if there is no error do we save the local state.
+ (write-drafts-to-disk)
(write-cache-to-disk)
(write-config-to-disk))
(error (e)