From 65ba87e40ebdcb22c8bb605effbe5b790b456f52 Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Wed, 3 Jan 2024 16:51:57 +0200 Subject: Add gnosis-edit-update-note a loop to update values of fields using gnosis-update --- gnosis.el | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'gnosis.el') diff --git a/gnosis.el b/gnosis.el index 15cc768..15b6fb0 100644 --- a/gnosis.el +++ b/gnosis.el @@ -951,6 +951,38 @@ changes." (insert ")") (insert "\n;; After finishing editing, evaluate expression with `C-x C-e'.") (indent-region (point-min) (point-max))))) + + +(cl-defun gnosis-edit-update-note (&key id main options answer tags (extra-notes nil) (image nil) (second-image nil)) + "Update note with id value of ID. + +ID: Note id +MAIN: Main part of note, the stem part of MCQ, question for basic, etc. +OPTIONS: Options for mcq type notes/Hint for basic & cloze type notes +ANSWER: Answer for MAIN, user is asked for input, if equal user-input += answer review is marked as successfull +TAGS: Tags for note, used to organize & differentiate between notes +EXTRA-NOTES: Notes to display after user-input +IMAGE: Image to display before user-input +SECOND-IMAGE: Image to display after user-input" + ;; Construct the update clause for the emacsql update statement. + (cl-loop for (field . value) in + `((main . ,main) + (options . ,options) + (answer . ,answer) + (tags . ,tags) + (extra-notes . ,extra-notes) + (image . ,image) + (second-image . ,second-image)) + when value + do (cond ((member field '(extra-notes image second-image)) + (gnosis-update 'extras `(= ,field ,value) `(= id ,id))) + ((listp value) + (gnosis-update 'notes `(= ,field ',value) `(= id ,id))) + (t (gnosis-update 'notes `(= ,field ,value) `(= id ,id))))) + (throw 'exit nil)) + + ;;;###autoload (defun gnosis-review () "Start gnosis review session." -- cgit v1.2.3