summaryrefslogtreecommitdiff
path: root/gnosis.el
diff options
context:
space:
mode:
authorThanos Apollo <[email protected]>2023-12-25 05:06:59 +0200
committerThanos Apollo <[email protected]>2023-12-25 05:07:50 +0200
commit891eae20ea8cff9bc03fb1d355cb2204edd3408e (patch)
treea6ae3487edab94ed007fc8e72347eb5e73472b2d /gnosis.el
parent02eb3c7b1abfb616f179ca311f481589d5476c4e (diff)
Redo gnosis--get-deck-id as cl-defun
Diffstat (limited to 'gnosis.el')
-rw-r--r--gnosis.el11
1 files changed, 5 insertions, 6 deletions
diff --git a/gnosis.el b/gnosis.el
index e363d77..54f08a9 100644
--- a/gnosis.el
+++ b/gnosis.el
@@ -113,10 +113,9 @@ Set SPLIT to t to split all input given."
(error "No decks found"))
(completing-read "Deck: " (gnosis--select 'name 'decks)))
-(defun gnosis--get-deck-id ()
- "Select id for deck name."
- (let ((deck (gnosis--get-deck-name)))
- (gnosis-get 'id 'decks `(= name ,deck))))
+(cl-defun gnosis--get-deck-id (&optional (deck (gnosis--get-deck-name)))
+ "Get id for DECK name."
+ (gnosis-get 'id 'decks `(= name ,deck)))
(defun gnosis-delete-deck (deck)
"Delete DECK."
@@ -135,7 +134,7 @@ choice in the `CHOICES' list. Each note must correspond to one `DECK'.
EXTRA are extra information displayed after an answer is given.
TAGS are used to organize questions."
(interactive
- (list :deck (gnosis--get-deck-id)
+ (list :deck (gnosis--get-deck-name)
:question (read-string "Question: ")
:choices (gnosis--prompt "Choices")
;; NOTE: string-to-number transforms non-number strings to 0
@@ -146,7 +145,7 @@ TAGS are used to organize questions."
(error "Correct answer value must be the index number of the correct answer"))
((null tags)
(setq tags 'untagged)))
- (gnosis--insert-into 'notes `([nil "mcq" ,question ,choices ,correct-answer ,tags ,deck]))
+ (gnosis--insert-into 'notes `([nil "mcq" ,question ,choices ,correct-answer ,tags ,(gnosis--get-deck-id deck)]))
(gnosis--insert-into 'review `([nil ,gnosis-algorithm-ef ,gnosis-algorithm-ff ,gnosis-algorithm-interval]))
(gnosis--insert-into 'review-log `([nil ,(gnosis-algorithm-date) ,(gnosis-algorithm-date) 0 0 0]))
(gnosis--insert-into 'extras `([nil ,extra nil])))