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

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

[nongnu] elpa/org-drill 361aa53a14 069/251: Very overdue items are consi


From: ELPA Syncer
Subject: [nongnu] elpa/org-drill 361aa53a14 069/251: Very overdue items are considered "lapsed" and are presented in the order they
Date: Mon, 17 Jan 2022 18:59:02 -0500 (EST)

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

    Very overdue items are considered "lapsed" and are presented in the order 
they
    were originally added, rather than by how overdue they are.
    
    DRILL_LAST_REVIEWED now uses an inactive timestamp (previously active).
    
    Fix for rendering of latex fragments.
---
 org-drill.el | 114 +++++++++++++++++++++++++++++++++++++++--------------------
 1 file changed, 75 insertions(+), 39 deletions(-)

diff --git a/org-drill.el b/org-drill.el
index e5b0d49780..a467bc6864 100644
--- a/org-drill.el
+++ b/org-drill.el
@@ -2,7 +2,7 @@
 ;;; org-drill.el - Self-testing using spaced repetition
 ;;;
 ;;; Author: Paul Sexton <eeeickythump@gmail.com>
-;;; Version: 2.4.1
+;;; Version: 2.4.2
 ;;; Repository at http://bitbucket.org/eeeickythump/org-drill/
 ;;;
 ;;;
@@ -1363,7 +1363,7 @@ How well did you do? (0-5, ?=help, e=edit, t=tags, 
q=quit)"
                 (sit-for 0.5)))))
           (org-set-property "DRILL_LAST_QUALITY" (format "%d" quality))
           (org-set-property "DRILL_LAST_REVIEWED"
-                            (time-to-active-org-timestamp (current-time))))
+                            (time-to-inactive-org-timestamp (current-time))))
         quality))
      ((= ch ?e)
       'edit)
@@ -1720,12 +1720,13 @@ Note: does not actually alter the item."
 ;; topic, and should return t if the user chose to see the answer and rate 
their
 ;; recall, nil if they chose to quit.
 
+
 (defun org-drill-present-simple-card ()
   (with-hidden-comments
    (with-hidden-cloze-hints
     (with-hidden-cloze-text
      (org-drill-hide-all-subheadings-except nil)
-     (org-preview-latex-fragment)       ; overlay all LaTeX fragments with 
images
+     (org-drill--show-latex-fragments)  ; overlay all LaTeX fragments with 
images
      (ignore-errors
        (org-display-inline-images t))
      (org-cycle-hide-drawers 'all)
@@ -1744,7 +1745,7 @@ Note: does not actually alter the item."
    (t
     (org-drill-hide-subheadings-if 'org-drill-entry-p)
     (org-drill-unhide-clozed-text)
-    (org-preview-latex-fragment)
+    (org-drill--show-latex-fragments)
     (ignore-errors
       (org-display-inline-images t))
     (org-cycle-hide-drawers 'all)
@@ -1752,6 +1753,11 @@ Note: does not actually alter the item."
      (funcall reschedule-fn)))))
 
 
+(defun org-drill--show-latex-fragments ()
+  (org-remove-latex-fragment-image-overlays)
+  (org-toggle-latex-fragment '(4)))
+
+
 (defun org-drill-present-two-sided-card ()
   (with-hidden-comments
    (with-hidden-cloze-hints
@@ -1762,7 +1768,7 @@ Note: does not actually alter the item."
            (goto-char (nth (random* (min 2 (length drill-sections)))
                            drill-sections))
            (org-show-subtree)))
-       (org-preview-latex-fragment)
+       (org-drill--show-latex-fragments)
        (ignore-errors
          (org-display-inline-images t))
        (org-cycle-hide-drawers 'all)
@@ -1780,7 +1786,7 @@ Note: does not actually alter the item."
          (save-excursion
            (goto-char (nth (random* (length drill-sections)) drill-sections))
            (org-show-subtree)))
-       (org-preview-latex-fragment)
+       (org-drill--show-latex-fragments)
        (ignore-errors
          (org-display-inline-images t))
        (org-cycle-hide-drawers 'all)
@@ -1862,7 +1868,7 @@ items if FORCE-SHOW-FIRST or FORCE-SHOW-LAST is non-nil)."
       ;;  while (org-pos-in-regexp (match-beginning 0)
       ;;                           org-bracket-link-regexp 1))
       ;; (org-drill-hide-matched-cloze-text)))))
-      (org-preview-latex-fragment)
+      (org-drill--show-latex-fragments)
       (ignore-errors
         (org-display-inline-images t))
       (org-cycle-hide-drawers 'all)
@@ -1911,12 +1917,12 @@ the second to last, etc."
                       ;; org link, or if it occurs inside a LaTeX math
                       ;; fragment
                       (or (org-pos-in-regexp (match-beginning 0)
-                                         org-bracket-link-regexp 1)
+                                             org-bracket-link-regexp 1)
                           (org-inside-LaTeX-fragment-p)))
               (incf cnt)
               (if (= cnt to-hide)
                   (org-drill-hide-matched-cloze-text)))))))
-      (org-preview-latex-fragment)
+      (org-drill--show-latex-fragments)
       (ignore-errors
         (org-display-inline-images t))
       (org-cycle-hide-drawers 'all)
@@ -2111,26 +2117,28 @@ See `org-drill' for more details."
                                    'org-drill-present-default-answer)
                      present-empty-cards (third presentation-fn)
                      presentation-fn (first presentation-fn)))
-          (cond
-           ((null presentation-fn)
-            (message "%s:%d: Unrecognised card type '%s', skipping..."
-                     (buffer-name) (point) card-type)
-            (sit-for 0.5)
-            'skip)
-           (t
-            (setq cont (funcall presentation-fn))
-            (cond
-             ((not cont)
-              (message "Quit")
-              nil)
-             ((eql cont 'edit)
-              'edit)
-             ((eql cont 'skip)
-              'skip)
-             (t
-              (save-excursion
-                (funcall answer-fn
-                         (lambda () (org-drill-reschedule)))))))))))))
+          (prog1
+              (cond
+               ((null presentation-fn)
+                (message "%s:%d: Unrecognised card type '%s', skipping..."
+                         (buffer-name) (point) card-type)
+                (sit-for 0.5)
+                'skip)
+               (t
+                (setq cont (funcall presentation-fn))
+                (cond
+                 ((not cont)
+                  (message "Quit")
+                  nil)
+                 ((eql cont 'edit)
+                  'edit)
+                 ((eql cont 'skip)
+                  'skip)
+                 (t
+                  (save-excursion
+                    (funcall answer-fn
+                             (lambda () (org-drill-reschedule))))))))
+            (org-remove-latex-fragment-image-overlays)))))))
 
 
 (defun org-drill-entries-pending-p ()
@@ -2384,17 +2392,43 @@ all the markers used by Org-Drill will be freed."
     (free-marker m)))
 
 
+;;; overdue-data is a list of entries, each entry has the form (POS DUE AGE)
+;;; where POS is a marker pointing to the start of the entry, and
+;;; DUE is a number indicating how many days ago the entry was due.
+;;; AGE is the number of days elapsed since item creation (nil if unknown).
+;;; if age > 60, sort by age (oldest first)
+;;; if age < 60, sort by due (biggest first)
+
+;;; if (age a) <= 60 and (age b) <= 60, sort by due
+;;; else sort by age
+
+
 (defun org-drill-order-overdue-entries (overdue-data)
-  (setq *org-drill-overdue-entries*
-        (mapcar 'car
-                (sort (shuffle-list overdue-data)
-                      (lambda (a b) (> (cdr a) (cdr b)))))))
+  (let* ((lapsed-days 60)
+         (not-lapsed (remove-if (lambda (a) (> (or (third a) 0) lapsed-days))
+                                overdue-data))
+         (lapsed (remove-if-not (lambda (a) (> (or (third a) 0)
+                                          lapsed-days)) overdue-data)))
+    (setq *org-drill-overdue-entries*
+          (mapcar 'first
+                  (append
+                   (sort (shuffle-list not-lapsed)
+                         (lambda (a b) (> (second a) (second b))))
+                   (sort lapsed
+                         (lambda (a b) (> (third a) (third b)))))))))
+
+
+(defun org-drill-entry-days-since-creation ()
+  (let ((timestamp (org-entry-get (point) "DATE_ADDED")))
+    (if timestamp
+        (- (org-time-stamp-to-now timestamp)))))
 
 
 (defun org-drill-entry-status ()
-  "Returns a list (STATUS DUE) where DUE is the number of days overdue,
-zero being due today, -1 being scheduled 1 day in the future. STATUS is
-one of the following values:
+  "Returns a list (STATUS DUE AGE) where DUE is the number of days overdue,
+zero being due today, -1 being scheduled 1 day in the future.
+AGE is the number of days elapsed since the item was created (nil if unknown).
+STATUS is one of the following values:
 - nil, if the item is not a drill entry, or has an empty body
 - :unscheduled
 - :future
@@ -2408,6 +2442,7 @@ one of the following values:
     (unless (org-at-heading-p)
       (org-back-to-heading))
     (let ((due (org-drill-entry-days-overdue))
+          (age (org-drill-entry-days-since-creation))
           (last-int (org-drill-entry-last-interval 1)))
       (list
        (cond
@@ -2446,7 +2481,7 @@ one of the following values:
          :young)
         (t
          :old))
-       due))))
+       due age))))
 
 
 (defun org-drill-progress-message (collected scanned)
@@ -2554,7 +2589,8 @@ work correctly with older versions of org mode. Your org 
mode version (%s) appea
                        (sit-for 0.5)
                        (setq warned-about-id-creation t))
                      (org-id-get-create) ; ensure drill entry has unique ID
-                     (destructuring-bind (status due) (org-drill-entry-status)
+                     (destructuring-bind (status due age)
+                         (org-drill-entry-status)
                        (case status
                          (:unscheduled
                           (incf *org-drill-dormant-entry-count*))
@@ -2572,7 +2608,7 @@ work correctly with older versions of org mode. Your org 
mode version (%s) appea
                          (:young
                           (push (point-marker) 
*org-drill-young-mature-entries*))
                          (:overdue
-                          (push (cons (point-marker) due) overdue-data))
+                          (push (list (point-marker) due age) overdue-data))
                          (:old
                           (push (point-marker) *org-drill-old-mature-entries*))
                          )))))



reply via email to

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