From 773b16f09a477b7ba1ab69fd531a5eff317e7c2e Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Wed, 21 Feb 2024 23:39:22 +0200 Subject: [Feature] Add gnosis-hint-prompt Store value of previous hint & utilize it with read-from-minibuffer --- gnosis.el | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'gnosis.el') 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) -- cgit v1.2.3