summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThanos Apollo <[email protected]>2024-02-21 23:39:22 +0200
committerThanos Apollo <[email protected]>2024-02-21 23:39:22 +0200
commit773b16f09a477b7ba1ab69fd531a5eff317e7c2e (patch)
treeb87b9f6fcee4d5fe69bbfe3a432b40575e1d53f2
parent8ff330788c29895922ed626266b8095ecbdadde5 (diff)
[Feature] Add gnosis-hint-prompt
Store value of previous hint & utilize it with read-from-minibuffer
-rw-r--r--gnosis.el17
1 files changed, 13 insertions, 4 deletions
diff --git a/gnosis.el b/gnosis.el
index f851263..8dd8e34 100644
--- a/gnosis.el
+++ b/gnosis.el
@@ -125,6 +125,9 @@ When nil, the image will be displayed at its original size."
(defvar gnosis-previous-note-tags '()
"Tags input from previously added note.")
+(defvar gnosis-previous-hint nil
+ "Hint input from previously added note.")
+
;;; Faces
(defgroup gnosis-faces nil
@@ -537,7 +540,7 @@ Refer to `gnosis-add-note--basic' for more."
(gnosis-add-note--basic :deck deck
:question (read-string "Question: ")
:answer (read-string "Answer: ")
- :hint (read-string "Hint: ")
+ :hint (gnosis-hint-prompt gnosis-previous-hint)
:extra (read-string "Extra: ")
:image (gnosis-select-image)
:tags (gnosis-tag-prompt)))))
@@ -574,7 +577,7 @@ Refer to `gnosis-add-note--double' for more."
:image (when (y-or-n-p "Add image to display during review?")
(funcall gnosis-completing-read-function "Select image: "
(gnosis-directory-files)))
- :hint (read-string "Hint: ")
+ :hint (gnosis-hint-prompt gnosis-previous-hint)
:extra (read-string "Extra: ")
:image (gnosis-select-image)
:tags (gnosis-tag-prompt)))))
@@ -603,7 +606,7 @@ refer to `gnosis-add-note--y-or-n' for more information about keyword values."
(gnosis-add-note--y-or-n :deck deck
:question (read-string "Question: ")
:answer (read-char-choice "Answer: [y] or [n]? " '(?y ?n))
- :hint (read-string "Hint: ")
+ :hint (gnosis-hint-prompt gnosis-previous-hint)
:extra (read-string "Extra: ")
:image (gnosis-select-image)
:tags (gnosis-tag-prompt)))))
@@ -676,7 +679,7 @@ See `gnosis-add-note--cloze' for more reference."
(while (y-or-n-p (format "Add note of type `cloze' to `%s' deck? " deck))
(gnosis-add-note--cloze :deck deck
:note (read-string "Question: ")
- :hint (read-string "Hint: ")
+ :hint (gnosis-hint-prompt gnosis-previous-hint)
:extra (read-string "Extra: ")
:image (gnosis-select-image)
:tags (gnosis-tag-prompt)))))
@@ -843,6 +846,12 @@ Returns a list of unique tags."
(setf gnosis-previous-note-tags (if use-prev tags (reverse tags)))
(reverse tags)))
+(defun gnosis-hint-prompt (previous-hint &optional prompt)
+ (let* ((prompt (or prompt "Hint: "))
+ (hint (read-from-minibuffer prompt previous-hint)))
+ (setf gnosis-previous-hint hint)
+ hint))
+
;; Review
;;;;;;;;;;
(defun gnosis-review-is-due-p (note-id)