[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/org-drill cda03224dc 098/251: Added new card type, "simple
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/org-drill cda03224dc 098/251: Added new card type, "simpletyped". Instead of just pressing space to reveal |
Date: |
Mon, 17 Jan 2022 18:59:05 -0500 (EST) |
branch: elpa/org-drill
commit cda03224dc9535940a19c269e19cade88505b484
Author: Paul Sexton <eeeickythump@gmail.com>
Commit: Paul Sexton <eeeickythump@gmail.com>
Added new card type, "simpletyped". Instead of just pressing space to reveal
the answer, the user is prompted to type a text string followed by enter.
This string is then displayed again when the user is rating his/her recall
for the item. This card type might be useful when learning languages with
difficult or irregular spelling.
New presentation function, org-drill-presentation-prompt-for-string, which
is
used by the "simpletyped" card type.
New variable, drill-typed-answer, which is set to the last text string
typed by a user.
---
org-drill.el | 176 +++++++++++++++++++++++++++++++++++++++--------------------
1 file changed, 118 insertions(+), 58 deletions(-)
diff --git a/org-drill.el b/org-drill.el
index d40ce7f51c..c6ef4fca1a 100755
--- a/org-drill.el
+++ b/org-drill.el
@@ -284,6 +284,7 @@ the current item.")
(defcustom org-drill-card-type-alist
'((nil org-drill-present-simple-card)
("simple" org-drill-present-simple-card)
+ ("simpletyped" org-drill-present-simple-card-with-typed-answer)
("twosided" org-drill-present-two-sided-card nil t)
("multisided" org-drill-present-multi-sided-card nil t)
("hide1cloze" org-drill-present-multicloze-hide1)
@@ -553,6 +554,13 @@ This variable is useful for card types that compute their
answers
random number to another language. ")
+(defvar drill-typed-answer nil
+ "Global variable that can be bound to the last answer typed by
+the user. Used by card types that ask the user to type in an
+answer, rather than just pressing spacebar to reveal the
+answer.")
+
+
(defcustom org-drill-cloze-length-matches-hidden-text-p
nil
"If non-nil, when concealing cloze deletions, force the length of
@@ -1391,6 +1399,10 @@ of QUALITY."
(let ((ch nil)
(input nil)
(next-review-dates (org-drill-hypothetical-next-review-dates))
+ (typed-answer-statement (if drill-typed-answer
+ (format "Your answer: %s\n"
+ drill-typed-answer)
+ ""))
(key-prompt (format "(0-5, %c=help, %c=edit, %c=tags, %c=quit)"
org-drill--help-key
org-drill--edit-key
@@ -1413,12 +1425,14 @@ of QUALITY."
4 - After a little bit of thought you remembered. (+%s days)
5 - You remembered the item really easily. (+%s days)
-How well did you do? %s"
+%sHow well did you do? %s"
(round (nth 3 next-review-dates))
(round (nth 4 next-review-dates))
(round (nth 5 next-review-dates))
+ typed-answer-statement
key-prompt)
- (format "How well did you do? %s" key-prompt))))
+ (format "%sHow well did you do? %s"
+ typed-answer-statement key-prompt))))
(cond
((stringp input)
(setq ch (elt input 0)))
@@ -1523,6 +1537,49 @@ the current topic."
(not (member drill-heading heading-list))))))
+(defun org-drill--make-minibuffer-prompt (prompt)
+ (let ((status (first (org-drill-entry-status)))
+ (mature-entry-count (+ (length *org-drill-young-mature-entries*)
+ (length *org-drill-old-mature-entries*)
+ (length *org-drill-overdue-entries*))))
+ (format "%s %s %s %s %s %s"
+ (propertize
+ (char-to-string
+ (cond
+ ((eql status :failed) ?F)
+ (*org-drill-cram-mode* ?C)
+ (t
+ (case status
+ (:new ?N) (:young ?Y) (:old ?o) (:overdue ?!)
+ (t ??)))))
+ 'face `(:foreground
+ ,(case status
+ (:new org-drill-new-count-color)
+ ((:young :old) org-drill-mature-count-color)
+ ((:overdue :failed) org-drill-failed-count-color)
+ (t org-drill-done-count-color))))
+ (propertize
+ (number-to-string (length *org-drill-done-entries*))
+ 'face `(:foreground ,org-drill-done-count-color)
+ 'help-echo "The number of items you have reviewed this session.")
+ (propertize
+ (number-to-string (+ (length *org-drill-again-entries*)
+ (length *org-drill-failed-entries*)))
+ 'face `(:foreground ,org-drill-failed-count-color)
+ 'help-echo (concat "The number of items that you failed, "
+ "and need to review again."))
+ (propertize
+ (number-to-string mature-entry-count)
+ 'face `(:foreground ,org-drill-mature-count-color)
+ 'help-echo "The number of old items due for review.")
+ (propertize
+ (number-to-string (length *org-drill-new-entries*))
+ 'face `(:foreground ,org-drill-new-count-color)
+ 'help-echo (concat "The number of new items that you "
+ "have never reviewed."))
+ prompt)))
+
+
(cl-defun org-drill-presentation-prompt (&key prompt
returns
(start-time (current-time)))
@@ -1546,10 +1603,6 @@ START-TIME: The time the card started to be displayed.
This
(input nil)
(ch nil)
(last-second 0)
- (mature-entry-count (+ (length *org-drill-young-mature-entries*)
- (length *org-drill-old-mature-entries*)
- (length *org-drill-overdue-entries*)))
- (status (first (org-drill-entry-status)))
(prompt
(or prompt
(format (concat "Press key for answer, "
@@ -1559,42 +1612,7 @@ START-TIME: The time the card started to be displayed.
This
org-drill--skip-key
org-drill--quit-key)))
(full-prompt
- (format "%s %s %s %s %s %s"
- (propertize
- (char-to-string
- (cond
- ((eql status :failed) ?F)
- (*org-drill-cram-mode* ?C)
- (t
- (case status
- (:new ?N) (:young ?Y) (:old ?o) (:overdue ?!)
- (t ??)))))
- 'face `(:foreground
- ,(case status
- (:new org-drill-new-count-color)
- ((:young :old) org-drill-mature-count-color)
- ((:overdue :failed) org-drill-failed-count-color)
- (t org-drill-done-count-color))))
- (propertize
- (number-to-string (length *org-drill-done-entries*))
- 'face `(:foreground ,org-drill-done-count-color)
- 'help-echo "The number of items you have reviewed this
session.")
- (propertize
- (number-to-string (+ (length *org-drill-again-entries*)
- (length *org-drill-failed-entries*)))
- 'face `(:foreground ,org-drill-failed-count-color)
- 'help-echo (concat "The number of items that you failed, "
- "and need to review again."))
- (propertize
- (number-to-string mature-entry-count)
- 'face `(:foreground ,org-drill-mature-count-color)
- 'help-echo "The number of old items due for review.")
- (propertize
- (number-to-string (length *org-drill-new-entries*))
- 'face `(:foreground ,org-drill-new-count-color)
- 'help-echo (concat "The number of new items that you "
- "have never reviewed."))
- prompt)))
+ (org-drill--make-minibuffer-prompt prompt)))
(if (and (eql 'warn org-drill-leech-method)
(org-drill-entry-leech-p))
(setq full-prompt (concat
@@ -1625,6 +1643,34 @@ Consider reformulating the item to make it easier to
remember.\n"
(t t)))))
+(cl-defun org-drill-presentation-prompt-for-string (prompt)
+ "Create a card prompt with a timer and user-specified menu.
+
+Arguments:
+
+PROMPT: A string that overrides the standard prompt.
+
+START-TIME: The time the card started to be displayed. This
+ defaults to (current-time), however, if the function
+ is called multiple times from one card then it might
+ be convenient to override this default.
+"
+ (let* ((prompt
+ (or prompt
+ "Type your answer and press <Enter>: "))
+ (full-prompt
+ (org-drill--make-minibuffer-prompt prompt)))
+ (if (and (eql 'warn org-drill-leech-method)
+ (org-drill-entry-leech-p))
+ (setq full-prompt (concat
+ (propertize "!!! LEECH ITEM !!!
+You seem to be having a lot of trouble memorising this item.
+Consider reformulating the item to make it easier to remember.\n"
+ 'face '(:foreground "red"))
+ full-prompt)))
+ (setq drill-typed-answer (read-string full-prompt nil nil nil t))))
+
+
(defun org-pos-in-regexp (pos regexp &optional nlines)
(save-excursion
(goto-char pos)
@@ -1873,22 +1919,36 @@ Note: does not actually alter the item."
(defun org-drill-present-default-answer (reschedule-fn)
- (cond
- (drill-answer
- (with-replaced-entry-text
- (format "\nAnswer:\n\n %s\n" drill-answer)
- (prog1
- (funcall reschedule-fn)
- (setq drill-answer nil))))
- (t
- (org-drill-hide-subheadings-if 'org-drill-entry-p)
- (org-drill-unhide-clozed-text)
- (org-drill--show-latex-fragments)
- (ignore-errors
- (org-display-inline-images t))
- (org-cycle-hide-drawers 'all)
- (with-hidden-cloze-hints
- (funcall reschedule-fn)))))
+ (prog1 (cond
+ (drill-answer
+ (with-replaced-entry-text
+ (format "\nAnswer:\n\n %s\n" drill-answer)
+ (funcall reschedule-fn)
+ ))
+ (t
+ (org-drill-hide-subheadings-if 'org-drill-entry-p)
+ (org-drill-unhide-clozed-text)
+ (org-drill--show-latex-fragments)
+ (ignore-errors
+ (org-display-inline-images t))
+ (org-cycle-hide-drawers 'all)
+ (with-hidden-cloze-hints
+ (funcall reschedule-fn))))
+ (setq drill-answer nil
+ drill-typed-answer nil)))
+
+
+(defun org-drill-present-simple-card-with-typed-answer ()
+ (with-hidden-comments
+ (with-hidden-cloze-hints
+ (with-hidden-cloze-text
+ (org-drill-hide-all-subheadings-except nil)
+ (org-drill--show-latex-fragments) ; overlay all LaTeX fragments with
images
+ (ignore-errors
+ (org-display-inline-images t))
+ (org-cycle-hide-drawers 'all)
+ (prog1 (org-drill-presentation-prompt-for-string nil)
+ (org-drill-hide-subheadings-if 'org-drill-entry-p))))))
(defun org-drill--show-latex-fragments ()
- [nongnu] elpa/org-drill 396b3078b7 070/251: Added tag 2.4.2 for changeset 648125435aad, (continued)
- [nongnu] elpa/org-drill 396b3078b7 070/251: Added tag 2.4.2 for changeset 648125435aad, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 6be323d033 055/251: Entries in 'org-drill-card-type-alist' can now take a fourth argument, 'drill-empty-p' (boolean). If true, items of this type are not skipped if their bodies are empty., ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 224a959b26 064/251: Added tag 2.4.0 for changeset 37dd8ae06ded, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 42e9bf3230 078/251: Added tag 2.4.6 for changeset e7bb422d8cb1, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 8e6bf15ac8 066/251: Fix the defcustom definitions and provide :tag property for choices, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill c67928667e 072/251: Added tag 2.4.3 for changeset c289780f11d7, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 113c5339f9 075/251: Deal with removal of 'org-meta-data-and-drawers' function from Org development version., ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill e04ae39758 096/251: Remove obsolete dependency on org-learn., ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill db7a9c7746 088/251: Added new variable 'org-drill-item-count-includes-failed-items-p'. Default is, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 4f8543a95e 097/251: Added tag 2.5.1 for changeset 7a8df02a7ffc, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill cda03224dc 098/251: Added new card type, "simpletyped". Instead of just pressing space to reveal,
ELPA Syncer <=
- [nongnu] elpa/org-drill 738b956a16 099/251: Updated version number in header., ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 9c86731452 086/251: During drills, pressing keys for quit, edit and skip now works again., ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill fa03aa7696 087/251: Added tag 2.4.8 for changeset 080a526cc34a, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill a9d3447041 101/251: Reinstated dependency on 'org-learn' library., ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 562baba885 102/251: Added tag 2.6.1 for changeset 586920548547, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill d9ffa4b91f 104/251: Add support for typing in buffer input, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 45e92eca74 109/251: Add org-drill-cram-tree function, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill ef79a22735 111/251: Add explain support, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill ef9bad812c 112/251: Explain tags now inherit, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 6959903b99 113/251: Explain status of fork, ELPA Syncer, 2022/01/17