emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/org-drill 8b72dfbded 024/251: - Can now resume drill sessi


From: ELPA Syncer
Subject: [nongnu] elpa/org-drill 8b72dfbded 024/251: - Can now resume drill sessions after exiting with (e)dit or (q)uit commands!
Date: Mon, 17 Jan 2022 18:58:57 -0500 (EST)

branch: elpa/org-drill
commit 8b72dfbded08af1444a795c379d4bd588b2a8a3a
Author: eeeickythump <devnull@localhost>
Commit: eeeickythump <devnull@localhost>

    - Can now resume drill sessions after exiting with (e)dit or (q)uit 
commands!
      Use 'M-x org-drill-resume'.
    - Finessed the prioritisation of items during drill sessions.
      - We now present failed and OVERDUE items first. Overdue status is 
defined in days and
        has some leeway, defined by a new variable 
'org-drill-overdue-interval-factor'.
      - Next we present YOUNG items (learned or relearned recently, so have 
short intervals).
        The definition of 'young' is via the variable 
'org-drill-days-before-old'.
      - Finally we present a random mix of OLD items and NEW items.
    - Final report gives info about counts of pending overdue, young, and old 
items.
    - Timer shows '++:++' if > 1 hour passes while reviewing an item.
---
 README.html  | 434 +++++++++++++++++++++++++++++------------------------
 README.org   | 167 ++++++++++++++-------
 org-drill.el | 475 ++++++++++++++++++++++++++++++++++++++++-------------------
 3 files changed, 678 insertions(+), 398 deletions(-)

diff --git a/README.html b/README.html
index 5561788659..a6ac24afb2 100755
--- a/README.html
+++ b/README.html
@@ -7,7 +7,7 @@ lang="en" xml:lang="en">
 <title>Org-Drill</title>
 <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
 <meta name="generator" content="Org-mode"/>
-<meta name="generated" content="2011-04-08 16:00:36 "/>
+<meta name="generated" content="2011-04-13 11:23:22 "/>
 <meta name="author" content="Paul Sexton"/>
 <meta name="description" content=""/>
 <meta name="keywords" content=""/>
@@ -83,7 +83,6 @@ lang="en" xml:lang="en">
 
 <h1 class="title">Org-Drill</h1>
 
-
 <div id="table-of-contents">
 <h2>Table of Contents</h2>
 <div id="text-table-of-contents">
@@ -106,17 +105,18 @@ lang="en" xml:lang="en">
 <li><a href="#sec-7">Leeches </a></li>
 <li><a href="#sec-8">Customisation </a>
 <ul>
-<li><a href="#sec-8_1">Appearance of items during drill sessions </a></li>
+<li><a href="#sec-8_1">Visual appearance of items during drill sessions 
</a></li>
 <li><a href="#sec-8_2">Duration of drill sessions </a></li>
-<li><a href="#sec-8_3">Spaced repetition algorithm </a>
+<li><a href="#sec-8_3">Definition of old and overdue items </a></li>
+<li><a href="#sec-8_4">Spaced repetition algorithm </a>
 <ul>
-<li><a href="#sec-8_3_1">Choice of algorithm </a></li>
-<li><a href="#sec-8_3_2">Random variation of repetition intervals </a></li>
-<li><a href="#sec-8_3_3">Adjustment for early or late review of items </a></li>
-<li><a href="#sec-8_3_4">Adjusting item difficulty globally </a></li>
+<li><a href="#sec-8_4_1">Choice of algorithm </a></li>
+<li><a href="#sec-8_4_2">Random variation of repetition intervals </a></li>
+<li><a href="#sec-8_4_3">Adjustment for early or late review of items </a></li>
+<li><a href="#sec-8_4_4">Adjusting item difficulty globally </a></li>
 </ul>
 </li>
-<li><a href="#sec-8_4">Per-file customisation settings </a></li>
+<li><a href="#sec-8_5">Per-file customisation settings </a></li>
 </ul>
 </li>
 <li><a href="#sec-9">Incremental reading </a></li>
@@ -131,9 +131,9 @@ lang="en" xml:lang="en">
 
 
 <p>
-Org-Drill uses the spaced repetition algorithm in <code>org-learn</code> to 
conduct
-interactive "drill sessions", using org files as sources of facts to be
-memorised. The material to be remembered is presented to the student in random
+Org-Drill is an extension for <a href="http://www.gnu.org/software/emacs/";>GNU 
Emacs</a> <a href="http://orgmode.org/";>Org mode</a>. Org-Drill uses a <a 
href="http://en.wikipedia.org/wiki/Spaced_repetition";>spaced repetition</a> 
algorithm to conduct interactive "drill sessions", using org files
+as sources of facts to be memorised. Each topic is treated as a "flash
+card". The material to be remembered is presented to the student in random
 order. The student rates his or her recall of each item, and this information
 is fed back to <code>org-learn</code> to schedule the item for later revision.
 </p>
@@ -150,19 +150,14 @@ student in different ways.
 For more on the spaced repetition algorithm, and examples of other programs
 that use it, see:
 </p><ul>
-<li>
-<a href="http://supermemo.com/index.htm";>SuperMemo</a> (see descriptions of 
the SM2, SM5 and SM8 algorithms)
+<li><a href="http://supermemo.com/index.htm";>SuperMemo</a> (see descriptions 
of the SM2, SM5 and SM8 algorithms)
 </li>
-<li>
-<a href="http://ichi2.net/anki/";>Anki</a>
+<li><a href="http://ichi2.net/anki/";>Anki</a>
 </li>
-<li>
-<a href="http://mnemosyne-proj.org/index.php";>Mnemosyne</a>
-
+<li><a href="http://mnemosyne-proj.org/index.php";>Mnemosyne</a>
 </li>
 </ul>
 
-
 </div>
 
 </div>
@@ -240,17 +235,13 @@ This will be adequate for some items, but usually you 
will want to write items
 where you have more control over what information is hidden from the user for
 recall purposes. For this reason, some other card types are defined, including:
 </p><ul>
-<li>
-<a href="#sec-4_3">Two-sided cards</a>
+<li><a href="#sec-4_3">Two-sided cards</a>
 </li>
-<li>
-<a href="#sec-4_4">Multi-sided cards</a>
+<li><a href="#sec-4_4">Multi-sided cards</a>
 </li>
-<li>
-<a href="#Multicloze--cards">Multicloze cards</a>
+<li><a href="#Multicloze-cards">Multicloze cards</a>
 </li>
-<li>
-<a href="#sec-4_6">User-defined card types</a>
+<li><a href="#sec-4_6">User-defined card types</a>
 </li>
 </ul>
 
@@ -281,11 +272,11 @@ heading, and the answer within a subheading. For example:
 
 
 
-<pre class="src src-org"><span style="color: #f0ffff; background-color: 
#4169e1; font-weight: bold;">* Item                                   
</span><span style="color: #66cdaa; background-color: #4169e1; font-weight: 
bold;">:drill:</span><span style="color: #f0ffff; background-color: #4169e1; 
font-weight: bold;">
-</span>What is the capital city of Estonia?
+<pre class="example">* Item                                   :drill:
+What is the capital city of Estonia?
 
-<span style="color: #4876ff; background-color: #000080; font-weight: bold;">** 
The Answer
-</span>Tallinn.
+** The Answer
+Tallinn.
 </pre>
 
 
@@ -318,8 +309,8 @@ example:
 
 
 
-<pre class="src src-org"><span style="color: #f0ffff; background-color: 
#4169e1; font-weight: bold;">* Item                                   
</span><span style="color: #66cdaa; background-color: #4169e1; font-weight: 
bold;">:drill:</span><span style="color: #f0ffff; background-color: #4169e1; 
font-weight: bold;">
-</span>The capital city of Estonia is <span style="color: 
#ab82ff;">[Tallinn]</span>.
+<pre class="example">* Item                                   :drill:
+The capital city of Estonia is [Tallinn].
 </pre>
 
 
@@ -350,8 +341,8 @@ Example:
 
 
 
-<pre class="src src-org">Type 1 hypersensitivity reactions are mediated by 
<span style="color: #ab82ff;">[immunoglobulin E</span><span style="color: 
#483d8b;">|molecule</span><span style="color: #ab82ff;">]</span>
-and <span style="color: #ab82ff;">[mast cells</span><span style="color: 
#483d8b;">|cell type</span><span style="color: #ab82ff;">]</span>.
+<pre class="example">Type 1 hypersensitivity reactions are mediated by 
[immunoglobulin E|molecule]
+and [mast cells|cell type].
 </pre>
 
 
@@ -373,7 +364,7 @@ and <font style="background-color: blue;" color="cyan">
 </div>
 
 <div id="outline-container-4_3" class="outline-3">
-<h3 id="sec-4_3"><a name="Two-sided--cards" 
id="Two-sided--cards"></a>Two-sided cards </h3>
+<h3 id="sec-4_3"><a name="Two-sided-cards" id="Two-sided-cards"></a>Two-sided 
cards </h3>
 <div class="outline-text-3" id="text-4_3">
 
 
@@ -398,21 +389,21 @@ review.
 
 
 
-<pre class="src src-org"><span style="color: #f0ffff; background-color: 
#4169e1; font-weight: bold;">* Noun                                             
  </span><span style="color: #66cdaa; background-color: #4169e1; font-weight: 
bold;">:drill:</span><span style="color: #f0ffff; background-color: #4169e1; 
font-weight: bold;">
-</span><span style="color: #8b4789;">    :PROPERTIES:</span>
-    <span style="color: #8b4789;">:DRILL_CARD_TYPE:</span> <span style="color: 
#006400;">twosided</span>
-<span style="color: #8b4789;">    :END:</span>
+<pre class="example">* Noun                                               
:drill:
+    :PROPERTIES:
+    :DRILL_CARD_TYPE: twosided
+    :END:
 
 Translate this word.
 
-<span style="color: #4876ff; background-color: #000080; font-weight: bold;">** 
Spanish
-</span>la mujer
+** Spanish
+la mujer
 
-<span style="color: #4876ff; background-color: #000080; font-weight: bold;">** 
English
-</span>the woman
+** English
+the woman
 
-<span style="color: #4876ff; background-color: #000080; font-weight: bold;">** 
Example sentence
-</span>&#191;Qui&#233;n fue esa mujer?
+** Example sentence
+¿Quién fue esa mujer?
 Who was that woman?
 </pre>
 
@@ -430,7 +421,7 @@ not one of the first two 'sides' of the topic.
 </div>
 
 <div id="outline-container-4_4" class="outline-3">
-<h3 id="sec-4_4"><a name="Multi-sided--cards" 
id="Multi-sided--cards"></a>Multi-sided cards </h3>
+<h3 id="sec-4_4"><a name="Multi-sided-cards" 
id="Multi-sided-cards"></a>Multi-sided cards </h3>
 <div class="outline-text-3" id="text-4_4">
 
 
@@ -443,21 +434,21 @@ subheading is always shown and all others are always 
hidden.
 
 
 
-<pre class="src src-org"><span style="color: #f0ffff; background-color: 
#4169e1; font-weight: bold;">* Noun                                             
  </span><span style="color: #66cdaa; background-color: #4169e1; font-weight: 
bold;">:drill:</span><span style="color: #f0ffff; background-color: #4169e1; 
font-weight: bold;">
-</span><span style="color: #8b4789;">    :PROPERTIES:</span>
-    <span style="color: #8b4789;">:DRILL_CARD_TYPE:</span> <span style="color: 
#006400;">multisided</span>
-<span style="color: #8b4789;">    :END:</span>
+<pre class="example">* Noun                                               
:drill:
+    :PROPERTIES:
+    :DRILL_CARD_TYPE: multisided
+    :END:
 
 Translate.
 
-<span style="color: #4876ff; background-color: #000080; font-weight: bold;">** 
Spanish
-</span>la mesa
+** Spanish
+la mesa
 
-<span style="color: #4876ff; background-color: #000080; font-weight: bold;">** 
English
-</span>the table
+** English
+the table
 
-<span style="color: #4876ff; background-color: #000080; font-weight: bold;">** 
Picture
-</span><span style="color: #00bfff; text-decoration: underline;">PICTURE</span>
+** Picture
+[[file:table.jpg][PICTURE]]
 </pre>
 
 
@@ -472,7 +463,7 @@ The user will be shown the main text and either 'la mujer', 
<i>or</i> 'the woman
 </div>
 
 <div id="outline-container-4_5" class="outline-3">
-<h3 id="sec-4_5"><a name="Multi-cloze--cards" 
id="Multi-cloze--cards"></a>Multi-cloze cards </h3>
+<h3 id="sec-4_5"><a name="Multi-cloze-cards" 
id="Multi-cloze-cards"></a>Multi-cloze cards </h3>
 <div class="outline-text-3" id="text-4_5">
 
 
@@ -484,7 +475,7 @@ facts, such as the following:
 
 
 
-<pre class="src src-org">The capital city of New Zealand is Wellington, which 
is located in the
+<pre class="example">The capital city of New Zealand is Wellington, which is 
located in the
 South Island and has a population of about 400,000.
 </pre>
 
@@ -497,8 +488,8 @@ There is more than one fact in this statement &ndash; you 
could create a single
 
 
 
-<pre class="src src-org">The capital city of <span style="color: 
#ab82ff;">[New Zealand]</span> is <span style="color: 
#ab82ff;">[Wellington]</span>, which is located in
-the <span style="color: #ab82ff;">[North</span><span style="color: 
#483d8b;">|North/South</span><span style="color: #ab82ff;">]</span> Island and 
has a population of about <span style="color: #ab82ff;">[400,000]</span>.
+<pre class="example">The capital city of [New Zealand] is [Wellington], which 
is located in
+the [North|North/South] Island and has a population of about [400,000].
 </pre>
 
 
@@ -516,29 +507,29 @@ like this:
 
 
 
-<pre class="src src-org"><span style="color: #f0ffff; background-color: 
#4169e1; font-weight: bold;">* Fact
-</span>The capital city of <span style="color: #ab82ff;">[New Zealand]</span> 
is Wellington, which has a population of
+<pre class="example">* Fact
+The capital city of [New Zealand] is Wellington, which has a population of
 about 400,000.
 
-<span style="color: #f0ffff; background-color: #4169e1; font-weight: bold;">* 
Fact
-</span>The capital city of New Zealand is <span style="color: 
#ab82ff;">[Wellington]</span>, which has a population of
+* Fact
+The capital city of New Zealand is [Wellington], which has a population of
 about 400,000.
 
-<span style="color: #f0ffff; background-color: #4169e1; font-weight: bold;">* 
Fact
-</span>The capital city of New Zealand is Wellington, which has a population of
-about <span style="color: #ab82ff;">[400,000]</span>.
+* Fact
+The capital city of New Zealand is Wellington, which has a population of
+about [400,000].
 
-<span style="color: #f0ffff; background-color: #4169e1; font-weight: bold;">* 
Fact
-</span>The capital city of <span style="color: #ab82ff;">[New Zealand]</span> 
is Wellington, which is located in the
+* Fact
+The capital city of [New Zealand] is Wellington, which is located in the
 the North Island.
 
-<span style="color: #f0ffff; background-color: #4169e1; font-weight: bold;">* 
Fact
-</span>The capital city of New Zealand is <span style="color: 
#ab82ff;">[Wellington]</span>, which is located in
+* Fact
+The capital city of New Zealand is [Wellington], which is located in
 the North Island.
 
-<span style="color: #f0ffff; background-color: #4169e1; font-weight: bold;">* 
Fact
-</span>The capital city of New Zealand is Wellington, which is located in
-the <span style="color: #ab82ff;">[North</span><span style="color: 
#483d8b;">|North/South</span><span style="color: #ab82ff;">]</span> Island.
+* Fact
+The capital city of New Zealand is Wellington, which is located in
+the [North|North/South] Island.
 </pre>
 
 
@@ -559,13 +550,13 @@ will be hidden.
 
 
 
-<pre class="src src-org"><span style="color: #f0ffff; background-color: 
#4169e1; font-weight: bold;">* Fact
-</span><span style="color: #8b4789;">  :PROPERTIES:</span>
-  <span style="color: #8b4789;">:DRILL_CARD_TYPE:</span> <span style="color: 
#006400;">multicloze</span>
-<span style="color: #8b4789;">  :END:</span>
+<pre class="example">* Fact
+  :PROPERTIES:
+  :DRILL_CARD_TYPE: multicloze
+  :END:
 
-The capital city of <span style="color: #ab82ff;">[New Zealand]</span> is 
<span style="color: #ab82ff;">[Wellington]</span>, which is located in
-the <span style="color: #ab82ff;">[North</span><span style="color: 
#483d8b;">|North/South</span><span style="color: #ab82ff;">]</span> Island and 
has a population of about <span style="color: #ab82ff;">[400,000]</span>.
+The capital city of [New Zealand] is [Wellington], which is located in
+the [North|North/South] Island and has a population of about [400,000].
 </pre>
 
 
@@ -576,7 +567,7 @@ the <span style="color: #ab82ff;">[North</span><span 
style="color: #483d8b;">|No
 </div>
 
 <div id="outline-container-4_6" class="outline-3">
-<h3 id="sec-4_6"><a name="User-defined--card--types" 
id="User-defined--card--types"></a>User-defined card types </h3>
+<h3 id="sec-4_6"><a name="User-defined-card-types" 
id="User-defined-card-types"></a>User-defined card types </h3>
 <div class="outline-text-3" id="text-4_6">
 
 
@@ -612,25 +603,19 @@ argument, SCOPE, which allows it to take drill items from 
other
 sources. Possible values for SCOPE are:
 </p>
 <dl>
-<dt>tree</dt><dd>
-The subtree starting with the entry at the cursor.
+<dt>tree</dt><dd>The subtree starting with the entry at the cursor.
 </dd>
-<dt>file</dt><dd>
-The current buffer, including both hidden and non-hidden items.
+<dt>file</dt><dd>The current buffer, including both hidden and non-hidden 
items.
 </dd>
-<dt>file-with-archives</dt><dd>
-The current buffer, and any archives associated with it.
+<dt>file-with-archives</dt><dd>The current buffer, and any archives associated 
with it.
 </dd>
-<dt>agenda</dt><dd>
-All agenda files.
+<dt>agenda</dt><dd>All agenda files.
 </dd>
-<dt>agenda-with-archives</dt><dd>
-All agenda files with any archive files associated
-with them.
+<dt>agenda-with-archives</dt><dd>All agenda files with any archive files 
associated
+     with them.
 </dd>
-<dt>(file1 file2 &hellip;)</dt><dd>
-A list of filenames. All files in the list will be
-scanned.
+<dt>(file1 file2 &hellip;)</dt><dd>A list of filenames. All files in the list 
will be
+     scanned.
 </dd>
 </dl>
 
@@ -642,28 +627,45 @@ numbers is (taken from <code>org-learn</code>):
 </p>
 <table border="2" cellspacing="0" cellpadding="6" rules="groups" 
frame="hsides">
 <caption></caption>
-<colgroup><col class="right" /><col class="left" /><col class="left" />
+<colgroup><col class="right" /><col class="left" /><col class="left" /><col 
class="left" />
 </colgroup>
 <thead>
-<tr><th scope="col" class="right">Quality</th><th scope="col" 
class="left">SuperMemo label</th><th scope="col" class="left">Meaning</th></tr>
+<tr><th scope="col" class="right">Quality</th><th scope="col" 
class="left">SuperMemo label</th><th scope="col" class="left">Fail?</th><th 
scope="col" class="left">Meaning</th></tr>
 </thead>
 <tbody>
-<tr><td class="right">0</td><td class="left">NULL</td><td class="left">You 
have forgotten this card completely.</td></tr>
-<tr><td class="right">1</td><td class="left">BAD</td><td class="left">Wrong 
answer.</td></tr>
-<tr><td class="right">2</td><td class="left">FAIL</td><td class="left">Barely 
correct, the interval was too long.</td></tr>
-<tr><td class="right">3</td><td class="left">PASS</td><td class="left">Correct 
answer, but with much effort.</td></tr>
-<tr><td class="right">4</td><td class="left">GOOD</td><td class="left">Correct 
answer, with a little thought.</td></tr>
-<tr><td class="right">5</td><td class="left">BRIGHT</td><td 
class="left">Correct answer, effortless.</td></tr>
+<tr><td class="right">0</td><td class="left">NULL</td><td 
class="left">Yes</td><td class="left">Wrong, and the answer is unfamiliar when 
you see it.</td></tr>
+<tr><td class="right">1</td><td class="left">BAD</td><td 
class="left">Yes</td><td class="left">Wrong answer.</td></tr>
+<tr><td class="right">2</td><td class="left">FAIL</td><td 
class="left">Yes</td><td class="left">Almost, but not quite correct.</td></tr>
+<tr><td class="right">3</td><td class="left">PASS</td><td 
class="left">No</td><td class="left">Correct answer, but with much 
effort.</td></tr>
+<tr><td class="right">4</td><td class="left">GOOD</td><td 
class="left">No</td><td class="left">Correct answer, with a little 
thought.</td></tr>
+<tr><td class="right">5</td><td class="left">BRIGHT</td><td 
class="left">No</td><td class="left">Correct answer, effortless.</td></tr>
 </tbody>
 </table>
 
 
 <p>
 You can press '?'  at the prompt if you have trouble remembering what the
-numbers 0&ndash;5 signify. At any time you can press 'q' to finish the drill 
early
-(your progress will be saved), 's' to skip the current item without viewing the
-answer, or 'e' to finish the drill and jump to the current topic for editing
-(your progress up to that point will be saved).
+numbers 0&ndash;5 signify.
+</p>
+<p>
+At any time you can press 'q' to finish the drill early (your progress up to
+that point will be saved), 's' to skip the current item without viewing the
+answer, or 'e' to escape from the drill and jump to the current topic for
+editing (again, your progress up to that point will be saved).
+</p>
+<p>
+After exiting the drill session with 'e' or 'q', you can resume where you left
+off, using the command <code>org-drill-resume</code>. This will return you to 
the item
+that you were viewing when you left the session. For example, if you are shown
+an item and realise that it is poorly formulated, or contains an error, you can
+press 'e' to leave the drill, then correct the item, then press
+<code>M-x org-drill-resume</code> and continue where you left off.
+</p>
+<p>
+Note that 'drastic' edits, such as deleting or moving items, can sometimes
+cause Org-Drill to "lose its place" in the file, preventing it from
+successfully resuming the session. In that case you will need to start a new
+session.
 </p>
 
 </div>
@@ -719,16 +721,13 @@ Leech items can be handled in one of three ways. You can 
choose how Org-Drill
 handles leeches by setting the variable <code>org-drill-leech-method</code> to 
one of the
 following values:
 </p><dl>
-<dt>nil</dt><dd>
-Leech items are tagged with the <code>leech</code> tag, but otherwise treated 
the
-same as normal items.
+<dt>nil</dt><dd>Leech items are tagged with the <code>leech</code> tag, but 
otherwise treated the
+         same as normal items.
 </dd>
-<dt>skip</dt><dd>
-Leech items are not included in drill sessions.
+<dt>skip</dt><dd>Leech items are not included in drill sessions.
 </dd>
-<dt>warn</dt><dd>
-Leech items are still included in drill sessions, but a warning
-message is printed when each leech item is presented.
+<dt>warn</dt><dd>Leech items are still included in drill sessions, but a 
warning
+  message is printed when each leech item is presented.
 </dd>
 </dl>
 
@@ -762,7 +761,7 @@ settings by adding elisp code to your configuration file 
(<code>.emacs</code>).
 </div>
 
 <div id="outline-container-8_1" class="outline-3">
-<h3 id="sec-8_1">Appearance of items during drill sessions </h3>
+<h3 id="sec-8_1">Visual appearance of items during drill sessions </h3>
 <div class="outline-text-3" id="text-8_1">
 
 
@@ -828,17 +827,78 @@ session will not end until <i>all</i> outstanding items 
have been reviewed.
 </div>
 
 <div id="outline-container-8_3" class="outline-3">
-<h3 id="sec-8_3">Spaced repetition algorithm </h3>
+<h3 id="sec-8_3">Definition of old and overdue items </h3>
 <div class="outline-text-3" id="text-8_3">
 
 
 
+<p>
+Org-Drill prioritises <i>overdue</i> items in each drill session, presenting 
them
+before other items are seen. Overdue items are defined in terms of how far in
+the past the item is scheduled for review. The threshold is defined in terms
+of a proportion rather than an absolute number of days. If days overdue is
+greater than
+</p>
+<pre class="example">
+last-interval * (factor - 1)
+</pre>
+
+
+<p>
+and is at least one day overdue, then the item is considered 'overdue'. The
+default factor is 1.2, meaning that the due date can overrun by 20% before the
+item is considered overdue.
+</p>
+<p>
+To change the factor that determines when items become overdue, use something
+like the following in your .emacs. Note that the value should never be less
+than 1.0.
+</p>
+
+
+
+<pre class="example">(setq org-drill-overdue-interval-factor 1.1)
+</pre>
+
+
+
+<p>
+After prioritising overdue items, Org-Drill next prioritises <i>young</i>
+items. These are items which were recently learned (or relearned in the case of
+a failure), and which therefore have short inter-repetition intervals.
+"Recent" is defined as an inter-repetition interval less than a fixed number of
+days, rather than a number of repetitions. This ensures that more difficult
+items are reviewed more often than easier items before they stop being 'young'.
+</p>
+<p>
+The default definition of a young item is one with an inter-repetition interval
+of 10 days or less. To change this, use the following:
+</p>
+
+
+
+<pre class="example">(setq org-drill-days-before-old 7)
+</pre>
+
+
+
+
+</div>
 
 </div>
 
-<div id="outline-container-8_3_1" class="outline-4">
-<h4 id="sec-8_3_1">Choice of algorithm </h4>
-<div class="outline-text-4" id="text-8_3_1">
+<div id="outline-container-8_4" class="outline-3">
+<h3 id="sec-8_4">Spaced repetition algorithm </h3>
+<div class="outline-text-3" id="text-8_4">
+
+
+
+
+</div>
+
+<div id="outline-container-8_4_1" class="outline-4">
+<h4 id="sec-8_4_1">Choice of algorithm </h4>
+<div class="outline-text-4" id="text-8_4_1">
 
 
 
@@ -846,31 +906,25 @@ session will not end until <i>all</i> outstanding items 
have been reviewed.
 Org-Drill supports three different spaced repetition algorithms, all based on
 SuperMemo algorithms. These are:
 </p><dl>
-<dt><a href="http://www.supermemo.com/english/ol/sm2.htm";>SM2</a></dt><dd>
-an early algorithm, used in SuperMemo 2.0 (1988), which remains very
-popular &ndash; Anki and Mnemosyne, two of the most popular spaced repetition
-programs, use SM2. This algorithm stores an 'ease factor' for each item,
-which is modified each time you rate your recall of the item.
+<dt><a href="http://www.supermemo.com/english/ol/sm2.htm";>SM2</a></dt><dd>an 
early algorithm, used in SuperMemo 2.0 (1988), which remains very
+  popular &ndash; Anki and Mnemosyne, two of the most popular spaced repetition
+  programs, use SM2. This algorithm stores an 'ease factor' for each item,
+  which is modified each time you rate your recall of the item.
 </dd>
-<dt><a href="http://www.supermemo.com/english/ol/sm5.htm";>SM5</a> 
(default)</dt><dd>
-used in SuperMemo 5.0 (1989). This algorithm uses 'ease
-factors' but also uses a persistent, per-user 'matrix of optimal factors'
-which is also modified after each item repetition.
+<dt><a href="http://www.supermemo.com/english/ol/sm5.htm";>SM5</a> 
(default)</dt><dd>used in SuperMemo 5.0 (1989). This algorithm uses 'ease
+     factors' but also uses a persistent, per-user 'matrix of optimal factors'
+     which is also modified after each item repetition.
 </dd>
-<dt>Simple8</dt><dd>
-an experimental algorithm based on the <a 
href="http://www.supermemo.com/english/algsm8.htm";>SM8</a> algorithm. SM8 is 
used
-in SuperMemo 8.0 (1998) and is almost identical to SM11 which is
-used in SuperMemo 2002. Like SM5, it uses a matrix of optimal
-factors. Simple8 differs from SM8 in that it does not adapt the
-matrix to the individual user, though it does adapt each item's
-'ease factor'.
-
+<dt>Simple8</dt><dd>an experimental algorithm based on the <a 
href="http://www.supermemo.com/english/algsm8.htm";>SM8</a> algorithm. SM8 is 
used
+             in SuperMemo 8.0 (1998) and is almost identical to SM11 which is
+             used in SuperMemo 2002. Like SM5, it uses a matrix of optimal
+             factors. Simple8 differs from SM8 in that it does not adapt the
+             matrix to the individual user, though it does adapt each item's
+             'ease factor'.
 </dd>
 </dl>
 
-
-<p>
-If you want Org-Drill to use the <code>SM2</code> algorithm, put the following 
in your
+<p>If you want Org-Drill to use the <code>SM2</code> algorithm, put the 
following in your
 <code>.emacs</code>:
 </p>
 
@@ -886,9 +940,9 @@ If you want Org-Drill to use the <code>SM2</code> 
algorithm, put the following i
 
 </div>
 
-<div id="outline-container-8_3_2" class="outline-4">
-<h4 id="sec-8_3_2">Random variation of repetition intervals </h4>
-<div class="outline-text-4" id="text-8_3_2">
+<div id="outline-container-8_4_2" class="outline-4">
+<h4 id="sec-8_4_2">Random variation of repetition intervals </h4>
+<div class="outline-text-4" id="text-8_4_2">
 
 
 
@@ -922,9 +976,9 @@ your <code>.emacs</code>:
 
 </div>
 
-<div id="outline-container-8_3_3" class="outline-4">
-<h4 id="sec-8_3_3">Adjustment for early or late review of items </h4>
-<div class="outline-text-4" id="text-8_3_3">
+<div id="outline-container-8_4_3" class="outline-4">
+<h4 id="sec-8_4_3">Adjustment for early or late review of items </h4>
+<div class="outline-text-4" id="text-8_4_3">
 
 
 
@@ -951,9 +1005,9 @@ effect on the SM2 algorithm.
 
 </div>
 
-<div id="outline-container-8_3_4" class="outline-4">
-<h4 id="sec-8_3_4">Adjusting item difficulty globally </h4>
-<div class="outline-text-4" id="text-8_3_4">
+<div id="outline-container-8_4_4" class="outline-4">
+<h4 id="sec-8_4_4">Adjusting item difficulty globally </h4>
+<div class="outline-text-4" id="text-8_4_4">
 
 
 
@@ -995,8 +1049,8 @@ To alter the learn fraction, put the following in your 
.emacs:
 
 
 
-<pre class="src src-elisp"><span style="color: #696969;">(</span>setq 
org-drill-learn-fraction 0.45<span style="color: #696969;">)</span>   <span 
style="color: #db7093;">; </span><span style="color: #db7093;">change the value 
as desired
-</span></pre>
+<pre class="example">(setq org-drill-learn-fraction 0.45)   ; change the value 
as desired
+</pre>
 
 
 
@@ -1006,9 +1060,9 @@ To alter the learn fraction, put the following in your 
.emacs:
 
 </div>
 
-<div id="outline-container-8_4" class="outline-3">
-<h3 id="sec-8_4">Per-file customisation settings </h3>
-<div class="outline-text-3" id="text-8_4">
+<div id="outline-container-8_5" class="outline-3">
+<h3 id="sec-8_5">Per-file customisation settings </h3>
+<div class="outline-text-3" id="text-8_5">
 
 
 
@@ -1020,10 +1074,10 @@ special settings when running a Drill session using 
that file:
 
 
 
-<pre class="src src-org"><span style="color: #db7093;"># Local 
Variables&#58;</span>
-<span style="color: #db7093;"># org-drill-maximum-items-per-session:    
50</span>
-<span style="color: #db7093;"># org-drill-spaced-repetition-algorithm:  
simple8</span>
-<span style="color: #db7093;"># End:</span>
+<pre class="example"># Local Variables:
+# org-drill-maximum-items-per-session:    50
+# org-drill-spaced-repetition-algorithm:  simple8
+# End:
 </pre>
 
 
@@ -1069,26 +1123,26 @@ captured facts.
 
 
 
-<pre class="src src-elisp"><span style="color: #696969;">(</span>setq 
org-capture-templates
-       `<span style="color: #696969;">((</span><span style="color: 
#008b00;">"u"</span>
-         <span style="color: #008b00;">"Task: Read this URL"</span>
+<pre class="example">(setq org-capture-templates
+       `(("u"
+         "Task: Read this URL"
          entry
-         <span style="color: #696969;">(</span>file+headline <span 
style="color: #008b00;">"tasks.org"</span> <span style="color: 
#008b00;">"Articles To Read"</span><span style="color: #696969;">)</span>
-         ,<span style="color: #696969;">(</span>concat <span style="color: 
#008b00;">"* TODO Read article: '%:description'\nURL: %c\n\n"</span><span 
style="color: #696969;">)</span>
-         <span style="color: #4169e1;">:empty-lines</span> 1
-         <span style="color: #4169e1;">:immediate-finish</span> t<span 
style="color: #696969;">)</span>
+         (file+headline "tasks.org" "Articles To Read")
+         ,(concat "* TODO Read article: '%:description'\nURL: %c\n\n")
+         :empty-lines 1
+         :immediate-finish t)
 
-        <span style="color: #696969;">(</span><span style="color: 
#008b00;">"w"</span>
-         <span style="color: #008b00;">"Capture web snippet"</span>
+        ("w"
+         "Capture web snippet"
          entry
-         <span style="color: #696969;">(</span>file+headline <span 
style="color: #008b00;">"my-facts.org"</span> <span style="color: 
#008b00;">"Inbox"</span><span style="color: #696969;">)</span>
-         ,<span style="color: #696969;">(</span>concat <span style="color: 
#008b00;">"* Fact: '%:description'        :"</span>
-                  <span style="color: #696969;">(</span>format <span 
style="color: #008b00;">"%s"</span> org-drill-question-tag<span style="color: 
#696969;">)</span>
-                  <span style="color: #008b00;">":\n:PROPERTIES:\n:DATE_ADDED: 
%u\n:SOURCE_URL: %c\n:END:\n\n%i\n%?\n"</span><span style="color: 
#696969;">)</span>
-         <span style="color: #4169e1;">:empty-lines</span> 1
-         <span style="color: #4169e1;">:immediate-finish</span> t<span 
style="color: #696969;">)</span>
-        <span style="color: #db7093;">;; </span><span style="color: 
#db7093;">...other capture templates...
-</span>    <span style="color: #696969;">))</span>
+         (file+headline "my-facts.org" "Inbox")
+         ,(concat "* Fact: '%:description'        :"
+                  (format "%s" org-drill-question-tag)
+                  ":\n:PROPERTIES:\n:DATE_ADDED: %u\n:SOURCE_URL: 
%c\n:END:\n\n%i\n%?\n")
+         :empty-lines 1
+         :immediate-finish t)
+        ;; ...other capture templates...
+    ))
 </pre>
 
 
@@ -1097,14 +1151,12 @@ captured facts.
 Using these templates and <code>org-protocol</code>, you can set up buttons in 
your web
 browser to:
 </p><ul>
-<li>
-Create a task telling you to read the URL of the currently viewed webpage
+<li>Create a task telling you to read the URL of the currently viewed webpage
 </li>
-<li>
-Turn a region of selected text on a webpage, into a new fact which is saved
-to whichever file and heading you nominate in the template. The fact will
-contain a timestamp, and a hyperlink back to the webpage where you created
-it.
+<li>Turn a region of selected text on a webpage, into a new fact which is saved
+  to whichever file and heading you nominate in the template. The fact will
+  contain a timestamp, and a hyperlink back to the webpage where you created
+  it.
 </li>
 </ul>
 
@@ -1166,10 +1218,10 @@ something like:
 
 
 
-<pre class="src src-org"><span style="color: #4876ff; background-color: 
#000080; font-weight: bold;">** Fact: 'Tuberculosis - Wikipedia, the Free 
Encyclopedia'        </span><span style="color: #66cdaa; background-color: 
#000080; font-weight: bold;">:drill:</span><span style="color: #4876ff; 
background-color: #000080; font-weight: bold;">
-</span>
+<pre class="example">** Fact: 'Tuberculosis - Wikipedia, the Free 
Encyclopedia'        :drill:
+
 Prevention relies on screening programs and vaccination, usually with Bacillus
-Calmette-Gu&#233;rin vaccine.
+Calmette-Guérin vaccine.
 </pre>
 
 
@@ -1196,10 +1248,10 @@ or give it different tags or properties, for example.
 </div>
 </div>
 <div id="postamble">
-<p class="author"> Author: Paul Sexton
-</p>
-<p class="date"> Date: 2011-04-08 16:00:36 </p>
-<p class="creator">HTML generated by org-mode 7.4 in emacs 23</p>
+<p class="date">Date: 2011-04-13 11:23:22 </p>
+<p class="author">Author: Paul Sexton</p>
+<p class="creator">Org version 7.5 with Emacs version 23</p>
+<a href="http://validator.w3.org/check?uri=referer";>Validate XHTML 1.0</a>
 </div>
 </div>
 </body>
diff --git a/README.org b/README.org
index 77688c2ba3..0e187e0300 100755
--- a/README.org
+++ b/README.org
@@ -1,15 +1,18 @@
 # -*- mode: org; coding: utf-8 -*-
 #+STARTUP: showall
 #+OPTIONS: num:nil
+# Make absolutely sure the emacs lisp examples below don't get spuriously 
evaluated
+#+BABEL: :exports code
 #+TITLE: Org-Drill
 #+AUTHOR: Paul Sexton
 
 * Synopsis
 
 
-Org-Drill uses the spaced repetition algorithm in =org-learn= to conduct
-interactive "drill sessions", using org files as sources of facts to be
-memorised. The material to be remembered is presented to the student in random
+Org-Drill is an extension for [[http://www.gnu.org/software/emacs/][GNU 
Emacs]] [[http://orgmode.org/][Org mode]]. Org-Drill uses a 
[[http://en.wikipedia.org/wiki/Spaced_repetition][spaced
+repetition]] algorithm to conduct interactive "drill sessions", using org files
+as sources of facts to be memorised. Each topic is treated as a "flash
+card". The material to be remembered is presented to the student in random
 order. The student rates his or her recall of each item, and this information
 is fed back to =org-learn= to schedule the item for later revision.
 
@@ -33,9 +36,9 @@ that use it, see:
 Put the following in your =.emacs=. You will also need to make sure that Org's
 "contrib/lisp" directory is in the emacs load-path.
 
-#+BEGIN_SRC elisp
+#+BEGIN_EXAMPLE
 (require 'org-drill)
-#+END_SRC
+#+END_EXAMPLE
 
 
 
@@ -91,13 +94,13 @@ presented during a drill session, any subheadings are 
"collapsed" with their
 contents hidden. So, you could include the question as text beneath the main
 heading, and the answer within a subheading. For example:
 
-#+BEGIN_SRC org
+#+BEGIN_EXAMPLE
 * Item                                   :drill:
 What is the capital city of Estonia?
 
 ** The Answer
 Tallinn.
-#+END_SRC
+#+END_EXAMPLE
 
 When this item is presented for review, the text beneath the main heading will
 be visible, but the contents of the subheading ("The Answer") will be hidden.
@@ -115,10 +118,10 @@ will be obscured. The text is then revealed after the 
user presses a key. For
 example:
 
 
-#+BEGIN_SRC org
+#+BEGIN_EXAMPLE
 * Item                                   :drill:
 The capital city of Estonia is [Tallinn].
-#+END_SRC
+#+END_EXAMPLE
 
 During review, the user will see:
 
@@ -136,10 +139,10 @@ the rest of the text is hidden.
 
 Example:
 
-#+BEGIN_SRC org
+#+BEGIN_EXAMPLE
 Type 1 hypersensitivity reactions are mediated by [immunoglobulin E|molecule]
 and [mast cells|cell type].
-#+END_SRC
+#+END_EXAMPLE
 
 #+BEGIN_QUOTE
 Type 1 hypersensitivity reactions are mediated by
@@ -168,7 +171,7 @@ A two sided card can have more than 2 subheadings, but all 
subheadings after
 the first two are considered as "notes" and will always be hidden during topic
 review.
 
-#+BEGIN_SRC org
+#+BEGIN_EXAMPLE
 * Noun                                               :drill:
     :PROPERTIES:
     :DRILL_CARD_TYPE: twosided
@@ -185,7 +188,7 @@ the woman
 ** Example sentence
 ¿Quién fue esa mujer?
 Who was that woman?
-#+END_SRC
+#+END_EXAMPLE
 
 In this example, the user will be shown the main text -- "Translate this word"
 -- and either 'la mujer', /or/ 'the woman', at random. The section 'Example
@@ -201,7 +204,7 @@ The =multisided= card type is similar to =twosided=, except 
that any
 subheading has a chance of being presented during the topic review. One
 subheading is always shown and all others are always hidden.
 
-#+BEGIN_SRC org
+#+BEGIN_EXAMPLE
 * Noun                                               :drill:
     :PROPERTIES:
     :DRILL_CARD_TYPE: multisided
@@ -217,7 +220,7 @@ the table
 
 ** Picture
 [[file:table.jpg][PICTURE]]
-#+END_SRC
+#+END_EXAMPLE
 
 The user will be shown the main text and either 'la mujer', /or/ 'the woman',
 /or/ a picture of a table.
@@ -230,18 +233,18 @@ The user will be shown the main text and either 'la 
mujer', /or/ 'the woman',
 Often, you will wish to create cards out of sentences that express several
 facts, such as the following:
 
-#+BEGIN_SRC org
+#+BEGIN_EXAMPLE
 The capital city of New Zealand is Wellington, which is located in the
 South Island and has a population of about 400,000.
-#+END_SRC
+#+END_EXAMPLE
 
 There is more than one fact in this statement -- you could create a single
 'simple' card with all the facts marked as cloze text, like so:
 
-#+BEGIN_SRC org
+#+BEGIN_EXAMPLE
 The capital city of [New Zealand] is [Wellington], which is located in
 the [North|North/South] Island and has a population of about [400,000].
-#+END_SRC
+#+END_EXAMPLE
 
 But this card will be difficult to remember. If you get just one of the 4
 hidden facts wrong, you will fail the card. A card like this is likely to
@@ -251,7 +254,7 @@ A better way to express all these facts using 'simple' 
cards is to create
 several cards, with one fact per card. You might end up with something
 like this:
 
-#+BEGIN_SRC org
+#+BEGIN_EXAMPLE
 * Fact
 The capital city of [New Zealand] is Wellington, which has a population of
 about 400,000.
@@ -275,7 +278,7 @@ the North Island.
 * Fact
 The capital city of New Zealand is Wellington, which is located in
 the [North|North/South] Island.
-#+END_SRC
+#+END_EXAMPLE
 
 However, this is really cumbersome. The 'multicloze' card type exists for this
 situation. Multicloze cards behave like 'simple' cards, except that when there
@@ -288,7 +291,7 @@ but change its card type to 'multicloze'. Each time the 
card is presented for
 review, one of 'New Zealand', 'Wellington', 'the South Island' or '400,000'
 will be hidden.
 
-#+BEGIN_SRC org
+#+BEGIN_EXAMPLE
 * Fact
   :PROPERTIES:
   :DRILL_CARD_TYPE: multicloze
@@ -296,7 +299,7 @@ will be hidden.
 
 The capital city of [New Zealand] is [Wellington], which is located in
 the [North|North/South] Island and has a population of about [400,000].
-#+END_SRC
+#+END_EXAMPLE
 
 
 ** User-defined card types
@@ -335,20 +338,34 @@ During a drill session, you will be presented with each 
item, then asked to
 rate your recall of it by pressing a key between 0 and 5. The meaning of these
 numbers is (taken from =org-learn=):
 
-| Quality | SuperMemo label | Meaning                                    |
-|---------+-----------------+--------------------------------------------|
-|       0 | NULL            | You have forgotten this card completely.   |
-|       1 | BAD             | Wrong answer.                              |
-|       2 | FAIL            | Barely correct, the interval was too long. |
-|       3 | PASS            | Correct answer, but with much effort.      |
-|       4 | GOOD            | Correct answer, with a little thought.     |
-|       5 | BRIGHT          | Correct answer, effortless.                |
+| Quality | SuperMemo label | Fail? | Meaning                                  
            |
+|---------+-----------------+-------+------------------------------------------------------|
+|       0 | NULL            | Yes   | Wrong, and the answer is unfamiliar when 
you see it. |
+|       1 | BAD             | Yes   | Wrong answer.                            
            |
+|       2 | FAIL            | Yes   | Almost, but not quite correct.           
            |
+|       3 | PASS            | No    | Correct answer, but with much effort.    
            |
+|       4 | GOOD            | No    | Correct answer, with a little thought.   
            |
+|       5 | BRIGHT          | No    | Correct answer, effortless.              
            |
 
 You can press '?'  at the prompt if you have trouble remembering what the
-numbers 0--5 signify. At any time you can press 'q' to finish the drill early
-(your progress will be saved), 's' to skip the current item without viewing the
-answer, or 'e' to finish the drill and jump to the current topic for editing
-(your progress up to that point will be saved).
+numbers 0--5 signify.
+
+At any time you can press 'q' to finish the drill early (your progress up to
+that point will be saved), 's' to skip the current item without viewing the
+answer, or 'e' to escape from the drill and jump to the current topic for
+editing (again, your progress up to that point will be saved).
+
+After exiting the drill session with 'e' or 'q', you can resume where you left
+off, using the command =org-drill-resume=. This will return you to the item
+that you were viewing when you left the session. For example, if you are shown
+an item and realise that it is poorly formulated, or contains an error, you can
+press 'e' to leave the drill, then correct the item, then press
+=M-x org-drill-resume= and continue where you left off.
+
+Note that 'drastic' edits, such as deleting or moving items, can sometimes
+cause Org-Drill to "lose its place" in the file, preventing it from
+successfully resuming the session. In that case you will need to start a new
+session.
 
 
 * Cram mode
@@ -404,23 +421,23 @@ Org-Drill has several settings which you change using
 settings by adding elisp code to your configuration file (=.emacs=).
 
 
-** Appearance of items during drill sessions
+** Visual appearance of items during drill sessions
 
 
 If you want cloze-deleted text to show up in a special font within Org mode
 buffers, add this to your .emacs:
 
-#+BEGIN_SRC elisp
+#+BEGIN_EXAMPLE
 (setq org-drill-use-visible-cloze-face-p t)
-#+END_SRC
+#+END_EXAMPLE
 
 Item headings may contain information that "gives away" the answer to the item,
 either in the heading text or in tags. If you want item headings to be made
 invisible while each item is being tested, add:
 
-#+BEGIN_SRC elisp
+#+BEGIN_EXAMPLE
 (setq org-drill-hide-item-headings-p t)
-#+END_SRC
+#+END_EXAMPLE
 
 
 ** Duration of drill sessions
@@ -430,16 +447,54 @@ By default, a drill session will end when either 30 items 
have been
 successfully reviewed, or 20 minutes have passed. To change this behaviour, use
 the following settings.
 
-#+BEGIN_SRC elisp
+#+BEGIN_EXAMPLE
 (setq org-drill-maximum-items-per-session 40)
 (setq org-drill-maximum-duration 30)   ; 30 minutes
-#+END_SRC
+#+END_EXAMPLE
 
 If either of these variables is set to nil, then item count or elapsed time
 will not count as reasons to end the session. If both variables are nil, the
 session will not end until /all/ outstanding items have been reviewed.
 
 
+** Definition of old and overdue items
+
+
+Org-Drill prioritises /overdue/ items in each drill session, presenting them
+before other items are seen. Overdue items are defined in terms of how far in
+the past the item is scheduled for review. The threshold is defined in terms
+of a proportion rather than an absolute number of days. If days overdue is
+greater than
+
+: last-interval * (factor - 1)
+
+and is at least one day overdue, then the item is considered 'overdue'. The
+default factor is 1.2, meaning that the due date can overrun by 20% before the
+item is considered overdue.
+
+To change the factor that determines when items become overdue, use something
+like the following in your .emacs. Note that the value should never be less
+than 1.0.
+
+#+BEGIN_EXAMPLE
+(setq org-drill-overdue-interval-factor 1.1)
+#+END_EXAMPLE
+
+After prioritising overdue items, Org-Drill next prioritises /young/
+items. These are items which were recently learned (or relearned in the case of
+a failure), and which therefore have short inter-repetition intervals.
+"Recent" is defined as an inter-repetition interval less than a fixed number of
+days, rather than a number of repetitions. This ensures that more difficult
+items are reviewed more often than easier items before they stop being 'young'.
+
+The default definition of a young item is one with an inter-repetition interval
+of 10 days or less. To change this, use the following:
+
+#+BEGIN_EXAMPLE
+(setq org-drill-days-before-old 7)
+#+END_EXAMPLE
+
+
 ** Spaced repetition algorithm
 
 
@@ -466,9 +521,9 @@ SuperMemo algorithms. These are:
 If you want Org-Drill to use the =SM2= algorithm, put the following in your
 =.emacs=:
 
-#+BEGIN_SRC elisp
+#+BEGIN_EXAMPLE
 (setq org-drill-spaced-repetition-algorithm 'sm2)
-#+END_SRC
+#+END_EXAMPLE
 
 
 *** Random variation of repetition intervals
@@ -488,9 +543,9 @@ To enable random "noise" for item intervals, set the 
variable
 =org-drill-add-random-noise-to-intervals-p= to true by putting the following in
 your =.emacs=:
 
-#+BEGIN_SRC elisp
+#+BEGIN_EXAMPLE
 (setq org-drill-add-random-noise-to-intervals-p t)
-#+END_SRC
+#+END_EXAMPLE
 
 
 *** Adjustment for early or late review of items
@@ -500,9 +555,9 @@ Reviewing items earlier or later than their scheduled 
review date may affect
 how soon the next review date should be scheduled. Code to make this adjustment
 is also presented on the SuperMemo website. It can be enabled with:
 
-#+BEGIN_SRC elisp
+#+BEGIN_EXAMPLE
 (setq org-drill-adjust-intervals-for-early-and-late-repetitions-p t)
-#+END_SRC
+#+END_EXAMPLE
 
 This will affect both early and late repetitions if the Simple8 algorithm is
 used. For the SM5 algorithm it will affect early repetitions only. It has no
@@ -536,9 +591,9 @@ successfully recalled each time, with an average quality of 
just under 4.
 
 To alter the learn fraction, put the following in your .emacs:
 
-#+BEGIN_SRC elisp
+#+BEGIN_EXAMPLE
 (setq org-drill-learn-fraction 0.45)   ; change the value as desired
-#+END_SRC
+#+END_EXAMPLE
 
 
 ** Per-file customisation settings
@@ -548,12 +603,12 @@ Most of the above settings are safe as file-local 
variables. This means you can
 include a commented section like this at the end of your .org file to apply
 special settings when running a Drill session using that file:
 
-#+BEGIN_SRC org
+#+BEGIN_EXAMPLE
 # Local Variables:
 # org-drill-maximum-items-per-session:    50
 # org-drill-spaced-repetition-algorithm:  simple8
 # End:
-#+END_SRC org
+#+END_EXAMPLE
 
 
 * Incremental reading
@@ -581,7 +636,7 @@ An example of using Org-Drill for incremental reading is 
given below. First,
 and most importantly, we need to define a couple of =org-capture= templates for
 captured facts.
 
-#+BEGIN_SRC elisp
+#+BEGIN_EXAMPLE
 (setq org-capture-templates
        `(("u"
          "Task: Read this URL"
@@ -602,7 +657,7 @@ captured facts.
          :immediate-finish t)
         ;; ...other capture templates...
     ))
-#+END_SRC
+#+END_EXAMPLE
 
 Using these templates and =org-protocol=, you can set up buttons in your web
 browser to:
@@ -654,12 +709,12 @@ your "fact" file in Emacs. You should see that each piece 
of text you selected
 has been turned into a drill item. Continuing the above example, you would see
 something like:
 
-#+BEGIN_SRC org
+#+BEGIN_EXAMPLE
 ** Fact: 'Tuberculosis - Wikipedia, the Free Encyclopedia'        :drill:
 
 Prevention relies on screening programs and vaccination, usually with Bacillus
 Calmette-Guérin vaccine.
-#+END_SRC
+#+END_EXAMPLE
 
 You need to edit this fact so it makes sense independent of its context, as
 that is how it will be presented to you in future. The easiest way to turn the
diff --git a/org-drill.el b/org-drill.el
index 7c35915fc8..d82b93e21b 100755
--- a/org-drill.el
+++ b/org-drill.el
@@ -1,7 +1,7 @@
 ;;; org-drill.el - Self-testing using spaced repetition
 ;;;
 ;;; Author: Paul Sexton <eeeickythump@gmail.com>
-;;; Version: 2.0
+;;; Version: 2.1
 ;;; Repository at http://bitbucket.org/eeeickythump/org-drill/
 ;;;
 ;;;
@@ -278,17 +278,39 @@ they were reviewed at least this many hours ago."
   :type 'integer)
 
 
-(defvar *org-drill-session-qualities* nil)
-(defvar *org-drill-start-time* 0)
-(defvar *org-drill-new-entries* nil)
-(defvar *org-drill-dormant-entry-count* 0)
-(defvar *org-drill-mature-entries* nil)
-(defvar *org-drill-failed-entries* nil)
-(defvar *org-drill-again-entries* nil)
-(defvar *org-drill-done-entries* nil)
-(defvar *org-drill-cram-mode* nil
-  "Are we in 'cram mode', where all items are considered due
-for review unless they were already reviewed in the recent past?")
+;;; NEW items have never been presented in a drill session before.
+;;; MATURE items HAVE been presented at least once before.
+;;; - YOUNG mature items were scheduled no more than
+;;;   ORG-DRILL-DAYS-BEFORE-OLD days after their last
+;;;   repetition. These items will have been learned 'recently' and will have a
+;;;   low repetition count.
+;;; - OLD mature items have intervals greater than
+;;;   ORG-DRILL-DAYS-BEFORE-OLD.
+;;; - OVERDUE items are past their scheduled review date by more than
+;;;   LAST-INTERVAL * (ORG-DRILL-OVERDUE-INTERVAL-FACTOR - 1) days,
+;;;   regardless of young/old status.
+
+
+(defcustom org-drill-days-before-old
+  10
+  "When an item's inter-repetition interval rises above this value in days,
+it is no longer considered a 'young' (recently learned) item."
+  :group 'org-drill
+  :type 'integer)
+
+
+(defcustom org-drill-overdue-interval-factor
+  1.2
+  "An item is considered overdue if its scheduled review date is
+more than (ORG-DRILL-OVERDUE-INTERVAL-FACTOR - 1) * LAST-INTERVAL
+days in the past. For example, a value of 1.2 means an additional
+20% of the last scheduled interval is allowed to elapse before
+the item is overdue. A value of 1.0 means no extra time is
+allowed at all - items are immediately considered overdue if
+there is even one day's delay in reviewing them. This variable
+should never be less than 1.0."
+  :group 'org-drill
+  :type 'float)
 
 
 (defcustom org-drill-learn-fraction
@@ -303,14 +325,39 @@ exponential effect on inter-repetition spacing."
   :type 'float)
 
 
+(defvar *org-drill-session-qualities* nil)
+(defvar *org-drill-start-time* 0)
+(defvar *org-drill-new-entries* nil)
+(defvar *org-drill-dormant-entry-count* 0)
+(defvar *org-drill-due-entry-count* 0)
+(defvar *org-drill-overdue-entry-count* 0)
+(defvar *org-drill-overdue-entries* nil
+  "List of markers for items that are considered 'overdue', based on
+the value of ORG-DRILL-OVERDUE-INTERVAL-FACTOR.")
+(defvar *org-drill-young-mature-entries* nil
+  "List of markers for mature entries whose last inter-repetition
+interval was <= ORG-DRILL-DAYS-BEFORE-OLD days.")
+(defvar *org-drill-old-mature-entries* nil
+  "List of markers for mature entries whose last inter-repetition
+interval was greater than ORG-DRILL-DAYS-BEFORE-OLD days.")
+(defvar *org-drill-failed-entries* nil)
+(defvar *org-drill-again-entries* nil)
+(defvar *org-drill-done-entries* nil)
+(defvar *org-drill-current-item* nil
+  "Set to the marker for the item currently being tested.")
+(defvar *org-drill-cram-mode* nil
+  "Are we in 'cram mode', where all items are considered due
+for review unless they were already reviewed in the recent past?")
+
+
 ;;; Make the above settings safe as file-local variables.
 
 
 (put 'org-drill-question-tag 'safe-local-variable 'stringp)
 (put 'org-drill-maximum-items-per-session 'safe-local-variable
-     '(lambda (val) (or (stringp val) (null val))))
+     '(lambda (val) (or (integerp val) (null val))))
 (put 'org-drill-maximum-duration 'safe-local-variable
-     '(lambda (val) (or (stringp val) (null val))))
+     '(lambda (val) (or (integerp val) (null val))))
 (put 'org-drill-failure-quality 'safe-local-variable 'integerp)
 (put 'org-drill-forgetting-index 'safe-local-variable 'integerp)
 (put 'org-drill-leech-failure-threshold 'safe-local-variable 'integerp)
@@ -325,6 +372,8 @@ exponential effect on inter-repetition spacing."
      'safe-local-variable 'booleanp)
 (put 'org-drill-cram-hours 'safe-local-variable 'integerp)
 (put 'org-drill-learn-fraction 'safe-local-variable 'floatp)
+(put 'org-drill-days-before-old 'safe-local-variable 'integerp)
+(put 'org-drill-overdue-interval-factor 'safe-local-variable 'floatp)
 
 
 ;;;; Utilities ================================================================
@@ -454,22 +503,58 @@ drill entry."
        (member "leech" (org-get-local-tags))))
 
 
-(defun org-drill-entry-due-p ()
+;; (defun org-drill-entry-due-p ()
+;;   (cond
+;;    (*org-drill-cram-mode*
+;;     (let ((hours (org-drill-hours-since-last-review)))
+;;       (and (org-drill-entry-p)
+;;            (or (null hours)
+;;                (>= hours org-drill-cram-hours)))))
+;;    (t
+;;     (let ((item-time (org-get-scheduled-time (point))))
+;;       (and (org-drill-entry-p)
+;;            (or (not (eql 'skip org-drill-leech-method))
+;;                (not (org-drill-entry-leech-p)))
+;;            (or (null item-time)         ; not scheduled
+;;                (not (minusp             ; scheduled for today/in past
+;;                      (- (time-to-days (current-time))
+;;                         (time-to-days item-time))))))))))
+
+
+(defun org-drill-entry-days-overdue ()
+  "Returns:
+- NIL if the item is not to be regarded as scheduled for review at all.
+  This is the case if it is not a drill item, or if it is a leech item
+  that we wish to skip, or if we are in cram mode and have already reviewed
+  the item within the last few hours.
+- 0 if the item is new, or if it scheduled for review today.
+- A negative integer - item is scheduled that many days in the future.
+- A positive integer - item is scheduled that many days in the past."
   (cond
    (*org-drill-cram-mode*
     (let ((hours (org-drill-hours-since-last-review)))
       (and (org-drill-entry-p)
            (or (null hours)
-               (>= hours org-drill-cram-hours)))))
+               (>= hours org-drill-cram-hours))
+           0)))
    (t
     (let ((item-time (org-get-scheduled-time (point))))
-      (and (org-drill-entry-p)
-           (or (not (eql 'skip org-drill-leech-method))
-               (not (org-drill-entry-leech-p)))
-           (or (null item-time)         ; not scheduled
-               (not (minusp             ; scheduled for today/in future
-                     (- (time-to-days (current-time))
-                        (time-to-days item-time))))))))))
+      (cond
+       ((or (not (org-drill-entry-p))
+            (and (eql 'skip org-drill-leech-method)
+                 (org-drill-entry-leech-p)))
+        nil)
+       ((null item-time)                ; not scheduled -> due now
+        0)
+       (t
+        (- (time-to-days (current-time))
+           (time-to-days item-time))))))))
+
+
+(defun org-drill-entry-due-p ()
+  (let ((due (org-drill-entry-days-overdue)))
+    (and (not (null due))
+         (not (minusp due)))))
 
 
 (defun org-drill-entry-new-p ()
@@ -478,11 +563,11 @@ drill entry."
          (null item-time))))
 
 
-(defun org-drill-entry-last-quality ()
+(defun org-drill-entry-last-quality (&optional default)
   (let ((quality (org-entry-get (point) "DRILL_LAST_QUALITY")))
     (if quality
         (string-to-number quality)
-      nil)))
+      default)))
 
 
 (defun org-drill-entry-failure-count ()
@@ -1027,6 +1112,9 @@ the current topic."
          (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*)))
          (prompt
           (if fmt-and-args
               (apply 'format
@@ -1047,7 +1135,7 @@ the current topic."
                    'help-echo (concat "The number of items that you failed, "
                                       "and need to review again."))
                   (propertize
-                   (number-to-string (length *org-drill-mature-entries*))
+                   (number-to-string mature-entry-count)
                    'face `(:foreground ,org-drill-mature-count-color)
                    'help-echo "The number of old items due for review.")
                   (propertize
@@ -1067,11 +1155,12 @@ Consider reformulating the item to make it easier to 
remember.\n"
     (while (memq ch '(nil ?t))
       (setq ch nil)
       (while (not (input-pending-p))
-        (message (concat (format-time-string
-                          "%M:%S " (time-subtract
-                                   (current-time) item-start-time))
-                         prompt))
-        (sit-for 1))
+        (let ((elapsed (time-subtract (current-time) item-start-time)))
+          (message (concat (if (>= (time-to-seconds elapsed) (* 60 60))
+                               "++:++ "
+                             (format-time-string "%M:%S " elapsed))
+                           prompt))
+          (sit-for 1)))
       (setq input (read-key-sequence nil))
       (if (stringp input) (setq ch (elt input 0)))
       (if (eql ch ?t)
@@ -1281,7 +1370,9 @@ Review will occur regardless of whether the topic is due 
for review or whether
 it meets the definition of a 'review topic' used by `org-drill'.
 
 Returns a quality rating from 0 to 5, or nil if the user quit, or the symbol
-EDIT if the user chose to exit the drill and edit the current item.
+EDIT if the user chose to exit the drill and edit the current item. Choosing
+the latter option leaves the drill session suspended; it can be resumed
+later using `org-drill-resume'.
 
 See `org-drill' for more details."
   (interactive)
@@ -1323,14 +1414,18 @@ See `org-drill' for more details."
            (not (org-drill-maximum-duration-reached-p))
            (or *org-drill-new-entries*
                *org-drill-failed-entries*
-               *org-drill-mature-entries*
+               *org-drill-young-mature-entries*
+               *org-drill-old-mature-entries*
+               *org-drill-overdue-entries*
                *org-drill-again-entries*))))
 
 
 (defun org-drill-pending-entry-count ()
   (+ (length *org-drill-new-entries*)
      (length *org-drill-failed-entries*)
-     (length *org-drill-mature-entries*)
+     (length *org-drill-young-mature-entries*)
+     (length *org-drill-old-mature-entries*)
+     (length *org-drill-overdue-entries*)
      (length *org-drill-again-entries*)))
 
 
@@ -1358,19 +1453,28 @@ maximum number of items."
          (not (org-drill-maximum-item-count-reached-p))
          (not (org-drill-maximum-duration-reached-p)))
     (pop-random *org-drill-failed-entries*))
-   ;; Next priority is newly added items, and items which
-   ;; are not new and were not failed when they were last
-   ;; reviewed.
+   ;; Next priority is overdue items.
+   ((and *org-drill-overdue-entries*
+         (not (org-drill-maximum-item-count-reached-p))
+         (not (org-drill-maximum-duration-reached-p)))
+    (pop-random *org-drill-overdue-entries*))
+   ;; Next priority is 'young' items.
+   ((and *org-drill-young-mature-entries*
+         (not (org-drill-maximum-item-count-reached-p))
+         (not (org-drill-maximum-duration-reached-p)))
+    (pop-random *org-drill-young-mature-entries*))
+   ;; Next priority is newly added items, and older entries.
+   ;; We pool these into a single group.
    ((and (or *org-drill-new-entries*
-             *org-drill-mature-entries*)
+             *org-drill-old-mature-entries*)
          (not (org-drill-maximum-item-count-reached-p))
          (not (org-drill-maximum-duration-reached-p)))
     (if (< (random (+ (length *org-drill-new-entries*)
-                      (length *org-drill-mature-entries*)))
+                      (length *org-drill-old-mature-entries*)))
            (length *org-drill-new-entries*))
         (pop-random *org-drill-new-entries*)
       ;; else
-      (pop-random *org-drill-mature-entries*)))
+      (pop-random *org-drill-old-mature-entries*)))
    ;; After all the above are done, last priority is items
    ;; that were failed earlier THIS SESSION.
    (*org-drill-again-entries*
@@ -1379,33 +1483,43 @@ maximum number of items."
     nil)))
 
 
-(defun org-drill-entries ()
+(defun org-drill-entries (&optional resuming-p)
   "Returns nil, t, or a list of markers representing entries that were
-'failed' and need to be presented again before the session ends."
+'failed' and need to be presented again before the session ends.
+
+RESUMING-P is true if we are resuming a suspended drill session."
   (block org-drill-entries
     (while (org-drill-entries-pending-p)
-      (setq m (org-drill-pop-next-pending-entry))
-      (unless m
-        (error "Unexpectedly ran out of pending drill items"))
-      (save-excursion
-        (switch-to-buffer (marker-buffer m))
-        (goto-char m)
-        (setq result (org-drill-entry))
-        (cond
-         ((null result)
-          (message "Quit")
-          (return-from org-drill-entries nil))
-         ((eql result 'edit)
-          (setq end-pos (point-marker))
-          (return-from org-drill-entries nil))
-         ((eql result 'skip)
-          nil)                          ; skip this item
-         (t
+      (let ((m (cond
+                ((or (not resuming-p)
+                     (null *org-drill-current-item*))
+                 (org-drill-pop-next-pending-entry))
+                (t                      ; resuming a suspended session.
+                 (setq resuming-p nil)
+                 *org-drill-current-item*))))
+        (setq *org-drill-current-item* m)
+        (unless m
+          (error "Unexpectedly ran out of pending drill items"))
+        (save-excursion
+          (switch-to-buffer (marker-buffer m))
+          (goto-char m)
+          (setq result (org-drill-entry))
           (cond
-           ((<= result org-drill-failure-quality)
-            (push m *org-drill-again-entries*))
+           ((null result)
+            (message "Quit")
+            (setq end-pos :quit)
+            (return-from org-drill-entries nil))
+           ((eql result 'edit)
+            (setq end-pos (point-marker))
+            (return-from org-drill-entries nil))
+           ((eql result 'skip)
+            nil)                        ; skip this item
            (t
-            (push m *org-drill-done-entries*)))))))))
+            (cond
+             ((<= result org-drill-failure-quality)
+              (push m *org-drill-again-entries*))
+             (t
+              (push m *org-drill-done-entries*))))))))))
 
 
 
@@ -1416,10 +1530,10 @@ maximum number of items."
                                  *org-drill-session-qualities*))
                 (max 1 (length *org-drill-session-qualities*))))
         (prompt nil))
-  (setq prompt
-   (format
-    "%d items reviewed
-%d items awaiting review (%s, %s, %s). %d items dormant.
+    (setq prompt
+          (format
+           "%d items reviewed
+%d/%d items awaiting review (%s, %s, %s, %s, %s).
 Session duration %s
 
 Recall of reviewed items:
@@ -1429,59 +1543,75 @@ Recall of reviewed items:
 
 You successfully recalled %d%% of reviewed items (quality > %s)
 Session finished. Press a key to continue..."
-    (length *org-drill-done-entries*)
-    (org-drill-pending-entry-count)
-    (propertize
-     (format "%d failed"
-             (+ (length *org-drill-failed-entries*)
-                (length *org-drill-again-entries*)))
-     'face `(:foreground ,org-drill-failed-count-color))
-    (propertize
-     (format "%d old"
-             (length *org-drill-mature-entries*))
-     'face `(:foreground ,org-drill-mature-count-color))
-    (propertize
-     (format "%d new"
-             (length *org-drill-new-entries*))
-     'face `(:foreground ,org-drill-new-count-color))
-    *org-drill-dormant-entry-count*
-    (format-seconds "%h:%.2m:%.2s"
-                    (- (float-time (current-time)) *org-drill-start-time*))
-    (round (* 100 (count 5 *org-drill-session-qualities*))
-           (max 1 (length *org-drill-session-qualities*)))
-    (round (* 100 (count 2 *org-drill-session-qualities*))
-           (max 1 (length *org-drill-session-qualities*)))
-    (round (* 100 (count 4 *org-drill-session-qualities*))
-           (max 1 (length *org-drill-session-qualities*)))
-    (round (* 100 (count 1 *org-drill-session-qualities*))
-           (max 1 (length *org-drill-session-qualities*)))
-    (round (* 100 (count 3 *org-drill-session-qualities*))
-           (max 1 (length *org-drill-session-qualities*)))
-    (round (* 100 (count 0 *org-drill-session-qualities*))
-           (max 1 (length *org-drill-session-qualities*)))
-    pass-percent
-    org-drill-failure-quality
-    ))
-
-  (while (not (input-pending-p))
+           (length *org-drill-done-entries*)
+           (org-drill-pending-entry-count)
+           (+ (org-drill-pending-entry-count)
+              *org-drill-dormant-entry-count*)
+           (propertize
+            (format "%d failed"
+                    (+ (length *org-drill-failed-entries*)
+                       (length *org-drill-again-entries*)))
+            'face `(:foreground ,org-drill-failed-count-color))
+           (propertize
+            (format "%d overdue"
+                    (length *org-drill-overdue-entries*))
+            'face `(:foreground ,org-drill-failed-count-color))
+           (propertize
+            (format "%d new"
+                    (length *org-drill-new-entries*))
+            'face `(:foreground ,org-drill-new-count-color))
+           (propertize
+            (format "%d young"
+                    (length *org-drill-young-mature-entries*))
+            'face `(:foreground ,org-drill-mature-count-color))
+           (propertize
+            (format "%d old"
+                    (length *org-drill-old-mature-entries*))
+            'face `(:foreground ,org-drill-mature-count-color))
+           (format-seconds "%h:%.2m:%.2s"
+                           (- (float-time (current-time)) 
*org-drill-start-time*))
+           (round (* 100 (count 5 *org-drill-session-qualities*))
+                  (max 1 (length *org-drill-session-qualities*)))
+           (round (* 100 (count 2 *org-drill-session-qualities*))
+                  (max 1 (length *org-drill-session-qualities*)))
+           (round (* 100 (count 4 *org-drill-session-qualities*))
+                  (max 1 (length *org-drill-session-qualities*)))
+           (round (* 100 (count 1 *org-drill-session-qualities*))
+                  (max 1 (length *org-drill-session-qualities*)))
+           (round (* 100 (count 3 *org-drill-session-qualities*))
+                  (max 1 (length *org-drill-session-qualities*)))
+           (round (* 100 (count 0 *org-drill-session-qualities*))
+                  (max 1 (length *org-drill-session-qualities*)))
+           pass-percent
+           org-drill-failure-quality
+           ))
+
+    (while (not (input-pending-p))
       (message "%s" prompt)
       (sit-for 0.5))
-  (read-char-exclusive)
+    (read-char-exclusive)
 
-  (if (< pass-percent (- 100 org-drill-forgetting-index))
-      (read-char-exclusive
-       (format
-        "%s
+    (if (< pass-percent (- 100 org-drill-forgetting-index))
+        (read-char-exclusive
+         (format
+          "%s
 You failed %d%% of the items you reviewed during this session.
+%d (%d%%) of all items scanned were overdue.
+
 Are you keeping up with your items, and reviewing them
 when they are scheduled? If so, you may want to consider
 lowering the value of `org-drill-learn-fraction' slightly in
 order to make items appear more frequently over time."
-        (propertize "WARNING!" 'face 'org-warning)
-        (- 100 pass-percent))))))
+          (propertize "WARNING!" 'face 'org-warning)
+          (- 100 pass-percent)
+          *org-drill-overdue-entry-count*
+          (round (* 100 *org-drill-overdue-entry-count*)
+                 (+ *org-drill-dormant-entry-count*
+                    *org-drill-due-entry-count*)))
+         ))))
 
 
-(defun org-drill (&optional scope)
+(defun org-drill (&optional scope resume-p)
   "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
@@ -1518,64 +1648,101 @@ agenda  All agenda files
 agenda-with-archives
         All agenda files with any archive files associated with them
  (file1 file2 ...)
-        If this is a list, all files in the list will be scanned."
+        If this is a list, all files in the list will be scanned.
+
+If RESUME-P is non-nil, resume a suspended drill session rather
+than starting a new one."
 
   (interactive)
   (let ((end-pos nil)
         (cnt 0))
     (block org-drill
-      (setq *org-drill-done-entries* nil
-            *org-drill-dormant-entry-count* 0
-            *org-drill-new-entries* nil
-            *org-drill-mature-entries* nil
-            *org-drill-failed-entries* nil
-            *org-drill-again-entries* nil)
-      (setq *org-drill-session-qualities* nil)
-      (setq *org-drill-start-time* (float-time (current-time)))
+      (unless resume-p
+        (setq *org-drill-current-item* nil
+              *org-drill-done-entries* nil
+              *org-drill-dormant-entry-count* 0
+              *org-drill-due-entry-count* 0
+              *org-drill-overdue-entry-count* 0
+              *org-drill-new-entries* nil
+              *org-drill-overdue-entries* nil
+              *org-drill-young-mature-entries* nil
+              *org-drill-old-mature-entries* nil
+              *org-drill-failed-entries* nil
+              *org-drill-again-entries* nil)
+        (setq *org-drill-session-qualities* nil)
+        (setq *org-drill-start-time* (float-time (current-time))))
       (unwind-protect
           (save-excursion
-            (let ((org-trust-scanner-tags t))
-              (org-map-entries
-               (lambda ()
-                 (when (zerop (% (incf cnt) 50))
-                   (message "Processing drill items: %4d%s"
-                            (+ (length *org-drill-new-entries*)
-                               (length *org-drill-mature-entries*)
-                               (length *org-drill-failed-entries*))
-                            (make-string (ceiling cnt 50) ?.)))
-                 (cond
-                  ((not (org-drill-entry-p))
-                   nil)                 ; skip
-                  ((not (org-drill-entry-due-p))
-                   (incf *org-drill-dormant-entry-count*))
-                  ((org-drill-entry-new-p)
-                   (push (point-marker) *org-drill-new-entries*))
-                  ((and (org-drill-entry-last-quality)
-                        (<= (org-drill-entry-last-quality)
-                            org-drill-failure-quality))
-                   (push (point-marker) *org-drill-failed-entries*))
-                  (t
-                   (push (point-marker) *org-drill-mature-entries*))))
-               (concat "+" org-drill-question-tag) scope))
+            (unless resume-p
+              (let ((org-trust-scanner-tags t))
+                (org-map-entries
+                 (lambda ()
+                   (when (zerop (% (incf cnt) 50))
+                     (message "Processing drill items: %4d%s"
+                              (+ (length *org-drill-new-entries*)
+                                 (length *org-drill-overdue-entries*)
+                                 (length *org-drill-young-mature-entries*)
+                                 (length *org-drill-old-mature-entries*)
+                                 (length *org-drill-failed-entries*))
+                              (make-string (ceiling cnt 50) ?.)))
+                   (let ((due (org-drill-entry-days-overdue))
+                         (last-int (org-drill-entry-last-interval 1)))
+                   (cond
+                    ((not (org-drill-entry-p))
+                     nil)               ; skip
+                    ((or (null due)     ; unscheduled - usually a skipped leech
+                         (minusp due))  ; scheduled in the future
+                     (incf *org-drill-dormant-entry-count*))
+                    ((org-drill-entry-new-p)
+                     (push (point-marker) *org-drill-new-entries*))
+                    ((<= (org-drill-entry-last-quality 9999)
+                         org-drill-failure-quality)
+                     ;; Mature entries that were failed last time are FAILED,
+                     ;; regardless of how young, old or overdue they are.
+                     (push (point-marker) *org-drill-failed-entries*))
+                    ((and (> due 1)     ; enforce a sane minimum 'overdue' gap
+                          ;;(> due org-drill-days-before-overdue)
+                          (> (/ (+ due last-int) last-int)
+                             org-drill-overdue-interval-factor))
+                     ;; Overdue status overrides young versus old distinction.
+                     (push (point-marker) *org-drill-overdue-entries*))
+                    ((<= (org-drill-entry-last-interval 9999)
+                         org-drill-days-before-old)
+                     ;; Item is 'young'.
+                     (push (point-marker) *org-drill-young-mature-entries*))
+                    (t
+                     (push (point-marker) *org-drill-old-mature-entries*)))))
+                 (concat "+" org-drill-question-tag) scope)))
+            (setq *org-drill-due-entry-count* (org-drill-pending-entry-count))
+            (setq *org-drill-overdue-entry-count*
+                  (length *org-drill-overdue-entries*))
             (cond
              ((and (null *org-drill-new-entries*)
                    (null *org-drill-failed-entries*)
-                   (null *org-drill-mature-entries*))
+                   (null *org-drill-overdue-entries*)
+                   (null *org-drill-young-mature-entries*)
+                   (null *org-drill-old-mature-entries*))
               (message "I did not find any pending drill items."))
              (t
-              (org-drill-entries)
+              (org-drill-entries resume-p)
               (message "Drill session finished!"))))
         (progn
-          (dolist (m (append *org-drill-new-entries*
-                             *org-drill-failed-entries*
-                             *org-drill-again-entries*
-                             *org-drill-mature-entries*))
-            (free-marker m)))))
+          (unless end-pos
+            (dolist (m (append  *org-drill-done-entries*
+                                *org-drill-new-entries*
+                                *org-drill-failed-entries*
+                                *org-drill-again-entries*
+                                *org-drill-overdue-entries*
+                                *org-drill-young-mature-entries*
+                                *org-drill-old-mature-entries*))
+              (free-marker m))))))
     (cond
      (end-pos
-      (switch-to-buffer (marker-buffer end-pos))
-      (goto-char (marker-position end-pos))
-      (message "Edit topic."))
+      (when (markerp end-pos)
+        (switch-to-buffer (marker-buffer end-pos))
+        (goto-char (marker-position end-pos)))
+      (message
+       "You can continue the drill session with `M-x org-drill-resume'."))
      (t
       (org-drill-final-report)
       (if (eql 'sm5 org-drill-spaced-repetition-algorithm)
@@ -1599,6 +1766,12 @@ hours."
     (org-drill scope)))
 
 
+(defun org-drill-resume ()
+  "Resume a suspended drill session. Sessions are suspended by
+exiting them with the `edit' option."
+  (interactive)
+  (org-drill nil t))
+
 
 (add-hook 'org-mode-hook
           (lambda ()



reply via email to

[Prev in Thread] Current Thread [Next in Thread]