[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/org-drill 30913a9adf 247/251: Merge branch 'branweb/fix-cr
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/org-drill 30913a9adf 247/251: Merge branch 'branweb/fix-cram-mode' into 'master' |
Date: |
Mon, 17 Jan 2022 18:59:22 -0500 (EST) |
branch: elpa/org-drill
commit 30913a9adfa047d478d46e6f70cc6ace662db375
Merge: 602f5c4d96 78d3472033
Author: Phillip Lord <phillip.lord@russet.org.uk>
Commit: Phillip Lord <phillip.lord@russet.org.uk>
Merge branch 'branweb/fix-cram-mode' into 'master'
Allow Creating New Session in Cram Mode
See merge request phillord/org-drill!9
---
.gitignore | 10 ++--------
org-drill.el | 13 ++++++++-----
robot/cram-run.el | 24 ++++++++++++++++++++++++
robot/cram-run.sh | 39 +++++++++++++++++++++++++++++++++++++++
robot/robot.el | 21 ++++++++++++++-------
5 files changed, 87 insertions(+), 20 deletions(-)
diff --git a/.gitignore b/.gitignore
index 458a6f3d0e..fe7e8b01a5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,13 +4,7 @@ org-drill.html
/elpa
/makefile-local
/robot/Makefile
-/robot/main-test-copy.org
/robot/failure.txt
/robot/messages.txt
-/robot/main-test-copy.org~
-/robot/main-test-interactive-copy.org
-/robot/all-card-copy.org
-/robot/basic-run-copy.org
-/robot/leitner-run-copy.org
-/robot/spanish-robot-copy.org
-/robot/explainer-run-copy.org
+/robot/*-copy.org
+
diff --git a/org-drill.el b/org-drill.el
index 48ea08a447..d7a840b1b1 100644
--- a/org-drill.el
+++ b/org-drill.el
@@ -2855,7 +2855,7 @@ STATUS is one of the following values:
(setf (oref session warned-about-id-creation) t))
(org-id-get-create))
-(defun org-drill (&optional scope drill-match resume-p)
+(defun org-drill (&optional scope drill-match resume-p cram)
"Begin an interactive 'drill session'. The user is asked to
review a series of topics (headers). Each topic is initially
presented as a 'question', often with part of the topic content
@@ -2888,7 +2888,10 @@ todo query. Only items matching the query will be
considered.
It accepts the same values as `org-drill-match', which see.
If RESUME-P is non-nil, resume a suspended drill session rather
-than starting a new one."
+than starting a new one.
+
+CRAM, if non-nil, will start a new session in cram mode. If
+resuming a suspended session, this parameter is ignored."
(interactive)
;; Check org version. Org 7.9.3f introduced a backwards-incompatible change
@@ -2909,7 +2912,8 @@ work correctly with older versions of org mode. Your org
mode version (%s) appea
(cl-block org-drill
(unless resume-p
(org-drill-free-markers session t)
- (setf (oref session current-item) nil
+ (setf (oref session cram-mode) cram
+ (oref session current-item) nil
(oref session done-entries) nil
(oref session dormant-entry-count) 0
(oref session due-entry-count) 0
@@ -2980,8 +2984,7 @@ all drill items are considered to be due for review,
unless they
have been reviewed within the last `org-drill-cram-hours'
hours."
(interactive)
- (setq (oref session cram-mode) t)
- (org-drill scope drill-match))
+ (org-drill scope drill-match nil t))
(defun org-drill-cram-tree ()
"Run an interactive drill session in 'cram mode' using subtree at point.
diff --git a/robot/cram-run.el b/robot/cram-run.el
new file mode 100644
index 0000000000..a754013df4
--- /dev/null
+++ b/robot/cram-run.el
@@ -0,0 +1,24 @@
+(load-file "robot/robot.el")
+(load-file "org-drill.el")
+
+;; setup
+(copy "basic-run.org" "cram-run-copy.org")
+
+;; normal run
+(find "cram-run-copy.org")
+(org-drill)
+(set-buffer-modified-p nil)
+(kill-buffer)
+(robot-check-cards-seen 3)
+
+;; cram run with all cards reviewed less than `org-drill-cram-hours`
+;; ago, so we expect no new cards to be seen
+(find "cram-run-copy.org")
+(org-drill-cram)
+(robot-check-cards-seen 3)
+
+;; cram run that should include all cards, so we expect seen cards to
+;; double
+(setq org-drill-cram-hours 0)
+(org-drill-cram)
+(robot-check-cards-seen-and-die 6)
diff --git a/robot/cram-run.sh b/robot/cram-run.sh
new file mode 100755
index 0000000000..a4d6ec9b5a
--- /dev/null
+++ b/robot/cram-run.sh
@@ -0,0 +1,39 @@
+#!/usr/bin/env bash
+
+set -e
+
+this_dir="$(dirname "$0")"
+source ${this_dir}/robot.sh
+
+card_no=3
+
+# cram mode doesn't modify the buffer so there is no save prompt
+function run_drill_no_save {
+ sleep_small
+
+ for i in `seq 1 ${card_no}`;
+ do
+ echo Answer: "$i"
+ send_answer
+ done
+
+ echo press any key to continue
+ retn
+}
+
+function run_drill {
+ run_drill_no_save
+ echo Save file
+ key y
+}
+
+
+launch_emacs ${this_dir}/cram-run.el
+
+{
+ find_bot
+ run_drill
+ retn
+ run_drill_no_save
+ wait_emacs
+} || cat robot/failure.txt
diff --git a/robot/robot.el b/robot/robot.el
index f7053b8632..3d965b0e46 100644
--- a/robot/robot.el
+++ b/robot/robot.el
@@ -55,18 +55,25 @@
(run-with-timer 1 1 #'robot-dump-messages)
-(defun robot-check-cards-seen-and-die (n)
+(defun robot-check-cards-seen (n)
+ "N is number of cards we expect to have seen this session.
+Returns a number representing an exit status code"
(if (= n org-drill-cards-in-this-emacs)
(progn
(princ
(format "Succeeded: Saw %s cards as expected\n" n)
'external-debugging-output)
- (kill-emacs 0))
- (princ
- (format "Failed: Saw %s cards, expecting %s\n"
- org-drill-cards-in-this-emacs n)
- 'external-debugging-output)
- (kill-emacs -1)))
+ 0)
+ (progn
+ (princ
+ (format "Failed: Saw %s cards, expecting %s\n"
+ org-drill-cards-in-this-emacs n)
+ 'external-debugging-output)
+ -1)))
+
+(defun robot-check-cards-seen-and-die (n)
+ "N is number of cards we expect to have seen this session."
+ (kill-emacs (robot-check-cards-seen n)))
;; Move the package-user-dir somewhere local
(require 'package)
- [nongnu] elpa/org-drill 56ddd56396 213/251: Update documentation, (continued)
- [nongnu] elpa/org-drill 56ddd56396 213/251: Update documentation, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 03551ffa3c 231/251: Show LaTex overlays after clearing them, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 7adb9aab5a 207/251: Update documentation, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill d2fe915d7a 236/251: Merge branch 'fix/latex-overlays' into 'master', ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill de1e419ae3 215/251: All more README tests, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 4f8b910347 224/251: Update documentation, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 6e812e7fef 211/251: Fix typo in function name in README, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 0444db69f5 210/251: fix reversed member arguments, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill d1d7fde5e3 200/251: Regularize white space, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 2e37c8a91c 234/251: Merge branch 'fix/show-latex-fragments' into 'master', ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 30913a9adf 247/251: Merge branch 'branweb/fix-cram-mode' into 'master',
ELPA Syncer <=
- [nongnu] elpa/org-drill 0f0ee9f188 241/251: Allow Creating New Session in Cram Mode, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill ace0cf0dcd 250/251: Update CI., ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 7b9b7f1323 209/251: Update documentation, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 546336d207 225/251: Update documentation., ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 602f5c4d96 243/251: Fix use of cl.el, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 94ae5d684d 244/251: update gitignore to exclude all org files in robots dir ending in -copy, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill c65430b71a 045/251: Oops! some some nasty discrepancies have now been fixed.(something went wrong, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 7a3bf3ef30 092/251: Update version in header to 2.4.10., ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill b02735bde7 094/251: New option 'org-drill-cloze-length-matches-hidden-text': If non-nil, when, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 6c14bd6c50 129/251: Update robot, Fix remaining CL dependencies, ELPA Syncer, 2022/01/17