[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/org-drill d9ffa4b91f 104/251: Add support for typing in bu
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/org-drill d9ffa4b91f 104/251: Add support for typing in buffer input |
Date: |
Mon, 17 Jan 2022 18:59:06 -0500 (EST) |
branch: elpa/org-drill
commit d9ffa4b91fb5e411a755533f1964ac66d63ca5b0
Author: phillord <phillord@16dcompl012>
Commit: phillord <phillord@16dcompl012>
Add support for typing in buffer input
---
org-drill.el | 129 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
org-drill.org | 12 ++++++
2 files changed, 138 insertions(+), 3 deletions(-)
diff --git a/org-drill.el b/org-drill.el
index 6dd55cf06d..2dada15da3 100644
--- a/org-drill.el
+++ b/org-drill.el
@@ -543,6 +543,10 @@ exponential effect on inter-repetition spacing."
:group 'org-drill
:type 'float)
+(defcustom org-drill-presentation-prompt-with-typing nil
+ "Non-nil indicates that answers should be given in a buffer."
+ :group 'org-drill
+ :type 'boolean)
(defvar drill-answer nil
"Global variable that can be bound to a correct answer when an
@@ -1586,10 +1590,32 @@ the current topic."
"have never reviewed."))
prompt)))
+(cl-defun org-drill-presentation-prompt (&key prompt
+ returns
+ (start-time (current-time)))
+ "Create a card prompt with a timer and user-specified menu.
+
+Arguments:
+
+PROMPT: A string that overrides the standard prompt.
+
+RETURNS: An alist of the form ((<char> . <symbol>)...) where
+ <char> is the character pressed and <symbol> is the
+ returned value, which will normally be either a symbol,
+ `t' or `nil'.
-(cl-defun org-drill-presentation-prompt (&key prompt
- returns
- (start-time (current-time)))
+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.
+"
+ (if org-drill-presentation-prompt-with-typing
+ (org-drill-presentation-prompt-in-buffer)
+ (org-drill-presentation-prompt-in-mini-buffer)))
+
+(cl-defun org-drill-presentation-prompt-in-mini-buffer (&key prompt
+ returns
+ (start-time
(current-time)))
"Create a card prompt with a timer and user-specified menu.
Arguments:
@@ -1650,6 +1676,103 @@ Consider reformulating the item to make it easier to
remember.\n"
(t t)))))
+(defvar org-drill-presentation-timer nil
+ "Timer for buffer-entry of answers")
+
+(defun org-drill-presentation-minibuffer-timer-function
+ (item-start-time full-prompt)
+ "Return prompt for mini-buffer in `org-drill-response-mode'."
+ (let ((elapsed (time-subtract (current-time) item-start-time)))
+ (message (concat (if (>= (time-to-seconds elapsed) (* 60 60))
+ "++:++ "
+ (format-time-string "%M:%S " elapsed))
+ full-prompt))))
+
+(define-derived-mode org-drill-response-mode nil "Org-Drill")
+(define-key org-drill-response-mode-map [return] 'org-drill-response-rtn)
+(define-key org-drill-response-mode-map (kbd "C-c q") 'org-drill-response-quit)
+(define-key org-drill-response-mode-map (kbd "C-c e") 'org-drill-response-edit)
+(define-key org-drill-response-mode-map (kbd "C-c s") 'org-drill-response-skip)
+(define-key org-drill-response-mode-map (kbd "C-c t") 'org-drill-response-tags)
+
+(defun org-drill-response-complete ()
+ (kill-buffer (current-buffer))
+ (exit-recursive-edit))
+
+(defun org-drill-response-rtn ()
+ (interactive)
+ (setq drill-typed-answer (buffer-string)
+ exit-kind t)
+ (org-drill-response-complete))
+
+(defun org-drill-response-quit ()
+ (interactive)
+ (setq exit-kind 'quit)
+ (org-drill-response-complete))
+
+(defun org-drill-response-edit ()
+ (interactive)
+ (setq exit-kind 'edit)
+ (org-drill-response-complete))
+
+(defun org-drill-response-skip ()
+ (interactive)
+ (setq exit-kind 'skip)
+ (org-drill-response-complete))
+
+(defun org-drill-response-tags ()
+ (interactive)
+ (setq exit-kind 'tags)
+ (org-drill-response-complete))
+
+(defun org-drill-response-get-buffer-create ()
+ (let ((local-current-input-method
+ current-input-method))
+ (with-current-buffer
+ (get-buffer-create "*Org-Drill*")
+ (erase-buffer)
+ (org-drill-response-mode)
+ (set-input-method local-current-input-method)
+ (current-buffer))))
+
+(defun org-drill-presentation-prompt-in-buffer ()
+ (let* ((item-start-time (current-time))
+ (input nil)
+ (ch nil)
+ (last-second 0)
+ (prompt
+ (format (concat "Type answer then return, "
+ "C-c e=edit, C-c t=tags, C-c s=skip, C-c q=quit.")
+ org-drill--edit-key
+ org-drill--tags-key
+ org-drill--skip-key
+ org-drill--quit-key))
+ (full-prompt
+ (org-drill--make-minibuffer-prompt prompt)))
+ (setq drill-typed-answer nil)
+ (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 org-drill-presentation-timer
+ (run-with-idle-timer 1 t
+ #'org-drill-presentation-minibuffer-timer-function
+ item-start-time full-prompt))
+ (let ((exit-kind)
+ (buf
+ (org-drill-response-get-buffer-create)))
+ (save-window-excursion
+ (select-window
+ (display-buffer-below-selected buf nil))
+ (recursive-edit)
+ (cancel-timer org-drill-presentation-timer)
+ (setq org-drill-presentation-timer nil)
+ exit-kind))))
+
(cl-defun org-drill-presentation-prompt-for-string (prompt)
"Create a card prompt with a timer and user-specified menu.
diff --git a/org-drill.org b/org-drill.org
index 332c46edac..d0a08579e6 100644
--- a/org-drill.org
+++ b/org-drill.org
@@ -461,6 +461,18 @@ Cram sessions are not considered to be part of the normal
learning process for
the tested items. Cramming will not affect when items are next due for
revision.
+* Typing your answers
+
+In some cases, you may find that repeating answers to yourself is not
+enough; repeating answers outload can help, but this may not be
+impossible in some environments. Additionally, where the answers are
+long it can be hard to check for that you really got the answer
+correct.
+
+Under these circumstances, set the variable
+=org-drill-presentation-prompt-with-typing=. Answer attempts can now
+be typed into a buffer, and we will be displayed back to you when the
+answer is given.
* Leeches
# <<leeches>>
- [nongnu] elpa/org-drill 113c5339f9 075/251: Deal with removal of 'org-meta-data-and-drawers' function from Org development version., (continued)
- [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, 2022/01/17
- [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 <=
- [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
- [nongnu] elpa/org-drill 507daae5a2 128/251: Remove org-drill-session-qualities, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 0e89d9a638 134/251: Remove more variables, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill a803289de9 137/251: Remove last of earmuff variables, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill df13d89a4c 119/251: Add interactive test functions, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill d37519f54c 147/251: Clean up robot testing, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 9fa9b6eabf 148/251: Robot test all card types, ELPA Syncer, 2022/01/17