From 775e61a9ec40c080d8b2e5b82475ff6b4e862870 Mon Sep 17 00:00:00 2001 From: Colin Okay Date: Sun, 20 Feb 2022 11:32:48 -0600 Subject: trying to use magic ed to edit explainations --- src/lib.lisp | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/lib.lisp b/src/lib.lisp index b21272a..b8c7343 100644 --- a/src/lib.lisp +++ b/src/lib.lisp @@ -12,9 +12,10 @@ (defvar *config* nil "A configuration plist") -(defun make-config (&key host api-token) +(defun make-config (&key host api-token editor) (append (when host (list :host host)) - (when api-token (list :api-token api-token)))) + (when api-token (list :api-token api-token)) + (when editor (list :editor editor)))) (defun valid-config-p (config) (and (listp config) @@ -51,6 +52,11 @@ (defun (setf api-token) (newval) (setf (getf *config* :api-token) newval)) +(defun make-temp-file-name () + (merge-pathnames (format nil "~a" (gensym "oneliners")) (uiop:temporary-directory))) + +(defun string-from-editor () + (magic-ed:magic-ed make-temp-file-name :eval nil :output :string)) (defun config-file () (merge-pathnames ".config/oneliners.config" (user-homedir-pathname))) @@ -102,12 +108,17 @@ the directories that appear in the value of that variable." (brief (prompt "Brief Description: ")) (tags - (when (y-or-n-p "Add tags in addition to: ~{~a ~}?" init-tags) - (ppcre:split " +" (prompt "(e.g. foo bar goo): ")))) + (append init-tags + (when (y-or-n-p "Add tags in addition to: ~{~a ~}?" init-tags) + (ppcre:split " +" (prompt "(e.g. foo bar goo): "))))) (explaination (when (y-or-n-p "Provide an explaination?") - (prompt "Go head: ")))) - (format t "Adding a new oneliner.~%") + (string-from-editor)))) + (format t "Adding a new oneliner.~%~s~%" + (list :oneliners oneliner + :tags tags + :brief brief + :explanation explaination)) ;; (api:request-with ;; (:host (host) -- cgit v1.2.3