summaryrefslogtreecommitdiff
path: root/gnosis.el
diff options
context:
space:
mode:
authorThanos Apollo <[email protected]>2024-07-16 17:26:02 +0300
committerThanos Apollo <[email protected]>2024-07-16 17:26:02 +0300
commitec4b2c4e9bb55c1482251de68bf015932bd66d68 (patch)
tree632de6cb2d47c61193833651ebf471cca70a7f59 /gnosis.el
parentf8e2dd8198319498a94d146ddc9f1ba76e150c3b (diff)
parent68e7fcc6bd04ead7824cf717c657b907d66dc75d (diff)
Merge branch '#rewrite-cloze-display'.
* Rewrite cloze display funcs. * Fixing minor bugs. * Remove MC-Cloze from default notes.
Diffstat (limited to 'gnosis.el')
-rw-r--r--gnosis.el40
1 files changed, 23 insertions, 17 deletions
diff --git a/gnosis.el b/gnosis.el
index f5e6d1a..f9ddd7d 100644
--- a/gnosis.el
+++ b/gnosis.el
@@ -142,7 +142,7 @@ a string describing the action."
(defconst gnosis-db-version 2
"Gnosis database version.")
-(defvar gnosis-note-types '("MCQ" "MC-Cloze" "Cloze" "Basic" "Double" "y-or-n")
+(defvar gnosis-note-types '("MCQ" "Cloze" "Basic" "Double" "y-or-n")
"Gnosis available note types.")
(defvar gnosis-previous-note-tags '()
@@ -1493,6 +1493,11 @@ If user-input is equal to CLOZE, return t."
(num 0) ;; Number of clozes revealed
(hints (gnosis-get 'options 'notes `(= id ,id)))
(success nil))
+ ;; Quick fix for old cloze note versions.
+ (cond ((and (stringp hints) (string-empty-p hints))
+ (setq hints nil))
+ ((and (not (listp hints)) (not (string-empty-p hints)))
+ (setq hints (list hints))))
;; Initially display the sentence with no reveals
(gnosis-display-cloze-string main clozes hints nil nil)
(cl-loop for cloze in clozes
@@ -1677,6 +1682,23 @@ NOTES: List of note ids"
(gnosis-review-actions success note note-count))
finally (gnosis-review-commit note-count)))))))
+;;;###autoload
+(defun gnosis-review ()
+ "Start gnosis review session."
+ (interactive)
+ ;; Refresh modeline
+ (setq gnosis-due-notes-total (length (gnosis-review-get-due-notes)))
+ (let ((review-type (gnosis-completing-read "Review: " '("Due notes"
+ "Due notes of deck"
+ "Due notes of specified tag(s)"
+ "All notes of tag(s)"))))
+ (pcase review-type
+ ("Due notes" (gnosis-review-session (gnosis-collect-note-ids :due t)))
+ ("Due notes of deck" (gnosis-review-session (gnosis-collect-note-ids :due t :deck (gnosis--get-deck-id))))
+ ("Due notes of specified tag(s)" (gnosis-review-session (gnosis-collect-note-ids :due t :tags t)))
+ ("All notes of tag(s)" (gnosis-review-session (gnosis-collect-note-ids :tags t))))))
+
+
;; Editing notes
(defun gnosis-edit-read-only-values (&rest values)
"Make the provided VALUES read-only in the whole buffer."
@@ -1952,22 +1974,6 @@ to improve readability."
(format "\n%s '%s" (symbol-name field) (prin1-to-string value)))
(t (format "\n%s %s" (symbol-name field) (prin1-to-string value))))))))
-;;;###autoload
-(defun gnosis-review ()
- "Start gnosis review session."
- (interactive)
- ;; Refresh modeline
- (setq gnosis-due-notes-total (length (gnosis-review-get-due-notes)))
- (let ((review-type (gnosis-completing-read "Review: " '("Due notes"
- "Due notes of deck"
- "Due notes of specified tag(s)"
- "All notes of tag(s)"))))
- (pcase review-type
- ("Due notes" (gnosis-review-session (gnosis-collect-note-ids :due t)))
- ("Due notes of deck" (gnosis-review-session (gnosis-collect-note-ids :due t :deck (gnosis--get-deck-id))))
- ("Due notes of specified tag(s)" (gnosis-review-session (gnosis-collect-note-ids :due t :tags t)))
- ("All notes of tag(s)" (gnosis-review-session (gnosis-collect-note-ids :tags t))))))
-
;;; Database Schemas
(defvar gnosis-db-schema-decks '([(id integer :primary-key :autoincrement)
(name text :not-null)