Codebase list org-drill / 30913a9
Merge branch 'branweb/fix-cram-mode' into 'master' Allow Creating New Session in Cram Mode See merge request phillord/org-drill!9 Phillip Lord 4 years ago
5 changed file(s) with 87 addition(s) and 20 deletion(s). Raw diff Collapse all Expand all
33 /elpa
44 /makefile-local
55 /robot/Makefile
6 /robot/main-test-copy.org
76 /robot/failure.txt
87 /robot/messages.txt
9 /robot/main-test-copy.org~
10 /robot/main-test-interactive-copy.org
11 /robot/all-card-copy.org
12 /robot/basic-run-copy.org
13 /robot/leitner-run-copy.org
14 /robot/spanish-robot-copy.org
15 /robot/explainer-run-copy.org
8 /robot/*-copy.org
9
28542854 (setf (oref session warned-about-id-creation) t))
28552855 (org-id-get-create))
28562856
2857 (defun org-drill (&optional scope drill-match resume-p)
2857 (defun org-drill (&optional scope drill-match resume-p cram)
28582858 "Begin an interactive 'drill session'. The user is asked to
28592859 review a series of topics (headers). Each topic is initially
28602860 presented as a 'question', often with part of the topic content
28872887 It accepts the same values as `org-drill-match', which see.
28882888
28892889 If RESUME-P is non-nil, resume a suspended drill session rather
2890 than starting a new one."
2890 than starting a new one.
2891
2892 CRAM, if non-nil, will start a new session in cram mode. If
2893 resuming a suspended session, this parameter is ignored."
28912894
28922895 (interactive)
28932896 ;; Check org version. Org 7.9.3f introduced a backwards-incompatible change
29082911 (cl-block org-drill
29092912 (unless resume-p
29102913 (org-drill-free-markers session t)
2911 (setf (oref session current-item) nil
2914 (setf (oref session cram-mode) cram
2915 (oref session current-item) nil
29122916 (oref session done-entries) nil
29132917 (oref session dormant-entry-count) 0
29142918 (oref session due-entry-count) 0
29792983 have been reviewed within the last `org-drill-cram-hours'
29802984 hours."
29812985 (interactive)
2982 (setq (oref session cram-mode) t)
2983 (org-drill scope drill-match))
2986 (org-drill scope drill-match nil t))
29842987
29852988 (defun org-drill-cram-tree ()
29862989 "Run an interactive drill session in 'cram mode' using subtree at point.
0 (load-file "robot/robot.el")
1 (load-file "org-drill.el")
2
3 ;; setup
4 (copy "basic-run.org" "cram-run-copy.org")
5
6 ;; normal run
7 (find "cram-run-copy.org")
8 (org-drill)
9 (set-buffer-modified-p nil)
10 (kill-buffer)
11 (robot-check-cards-seen 3)
12
13 ;; cram run with all cards reviewed less than `org-drill-cram-hours`
14 ;; ago, so we expect no new cards to be seen
15 (find "cram-run-copy.org")
16 (org-drill-cram)
17 (robot-check-cards-seen 3)
18
19 ;; cram run that should include all cards, so we expect seen cards to
20 ;; double
21 (setq org-drill-cram-hours 0)
22 (org-drill-cram)
23 (robot-check-cards-seen-and-die 6)
0 #!/usr/bin/env bash
1
2 set -e
3
4 this_dir="$(dirname "$0")"
5 source ${this_dir}/robot.sh
6
7 card_no=3
8
9 # cram mode doesn't modify the buffer so there is no save prompt
10 function run_drill_no_save {
11 sleep_small
12
13 for i in `seq 1 ${card_no}`;
14 do
15 echo Answer: "$i"
16 send_answer
17 done
18
19 echo press any key to continue
20 retn
21 }
22
23 function run_drill {
24 run_drill_no_save
25 echo Save file
26 key y
27 }
28
29
30 launch_emacs ${this_dir}/cram-run.el
31
32 {
33 find_bot
34 run_drill
35 retn
36 run_drill_no_save
37 wait_emacs
38 } || cat robot/failure.txt
5454
5555 (run-with-timer 1 1 #'robot-dump-messages)
5656
57 (defun robot-check-cards-seen-and-die (n)
57 (defun robot-check-cards-seen (n)
58 "N is number of cards we expect to have seen this session.
59 Returns a number representing an exit status code"
5860 (if (= n org-drill-cards-in-this-emacs)
5961 (progn
6062 (princ
6163 (format "Succeeded: Saw %s cards as expected\n" n)
6264 'external-debugging-output)
63 (kill-emacs 0))
64 (princ
65 (format "Failed: Saw %s cards, expecting %s\n"
66 org-drill-cards-in-this-emacs n)
67 'external-debugging-output)
68 (kill-emacs -1)))
65 0)
66 (progn
67 (princ
68 (format "Failed: Saw %s cards, expecting %s\n"
69 org-drill-cards-in-this-emacs n)
70 'external-debugging-output)
71 -1)))
72
73 (defun robot-check-cards-seen-and-die (n)
74 "N is number of cards we expect to have seen this session."
75 (kill-emacs (robot-check-cards-seen n)))
6976
7077 ;; Move the package-user-dir somewhere local
7178 (require 'package)