[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/org-drill ca5231b9b4 043/251: Cloze text is now correctly
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/org-drill ca5231b9b4 043/251: Cloze text is now correctly identified in items whose bodies contain [[bracketed links]]. |
Date: |
Mon, 17 Jan 2022 18:58:59 -0500 (EST) |
branch: elpa/org-drill
commit ca5231b9b4c0cc2fbd29fa8a31ac35d1b2a3869d
Author: eeeickythump <devnull@localhost>
Commit: eeeickythump <devnull@localhost>
Cloze text is now correctly identified in items whose bodies contain
[[bracketed links]].
Fontification of cloze text should now work correctly when the first org
file is loaded.
New file types: hidefirst, hidelast
---
org-drill.el | 145 ++++++++++++++++++++++++++++++++---------------------------
1 file changed, 80 insertions(+), 65 deletions(-)
diff --git a/org-drill.el b/org-drill.el
index 96763abcc4..7592f06075 100755
--- a/org-drill.el
+++ b/org-drill.el
@@ -1,7 +1,8 @@
+;;; -*- coding: utf-8-unix -*-
;;; org-drill.el - Self-testing using spaced repetition
;;;
;;; Author: Paul Sexton <eeeickythump@gmail.com>
-;;; Version: 2.3.2
+;;; Version: 2.3.3
;;; Repository at http://bitbucket.org/eeeickythump/org-drill/
;;;
;;;
@@ -212,6 +213,8 @@ during a drill session."
("show1cloze" . org-drill-present-multicloze-show1)
("show2cloze" . org-drill-present-multicloze-show2)
("multicloze" . org-drill-present-multicloze-hide1)
+ ("hidefirst" . org-drill-present-multicloze-hide-first)
+ ("hidelast" . org-drill-present-multicloze-hide-last)
("hide1_firstmore" . org-drill-present-multicloze-hide1-firstmore)
("show1_lastmore" . org-drill-present-multicloze-show1-lastmore)
("show1_firstless" . org-drill-present-multicloze-show1-firstless)
@@ -1410,8 +1413,9 @@ visual overlay, or with the string TEXT if it is
supplied."
(while (re-search-forward org-drill-cloze-regexp nil t)
;; Don't hide org links, partly because they might contain inline
;; images which we want to keep visible
- (unless (org-pos-in-regexp (match-beginning 0)
- org-bracket-link-regexp 1)
+ (unless (save-match-data
+ (org-pos-in-regexp (match-beginning 0)
+ org-bracket-link-regexp 1))
(org-drill-hide-matched-cloze-text)))))
@@ -1436,8 +1440,9 @@ visual overlay, or with the string TEXT if it is
supplied."
(defun org-drill-hide-cloze-hints ()
(save-excursion
(while (re-search-forward org-drill-cloze-regexp nil t)
- (unless (or (org-pos-in-regexp (match-beginning 0)
- org-bracket-link-regexp 1)
+ (unless (or (save-match-data
+ (org-pos-in-regexp (match-beginning 0)
+ org-bracket-link-regexp 1))
(null (match-beginning 2))) ; hint subexpression matched
(org-drill-hide-region (match-beginning 2) (match-end 2))))))
@@ -1599,14 +1604,19 @@ items if FORCE-SHOW-FIRST or FORCE-SHOW-LAST is
non-nil)."
(save-excursion
(goto-char body-start)
(while (re-search-forward org-drill-cloze-regexp item-end t)
- (incf match-count)))
+ (let ((in-regexp? (save-match-data
+ (org-pos-in-regexp (match-beginning 0)
+ org-bracket-link-regexp 1))))
+ (unless in-regexp?
+ (incf match-count)))))
(if (minusp number-to-hide)
(setq number-to-hide (+ match-count number-to-hide)))
(when (plusp match-count)
(let* ((positions (shuffle-list (loop for i from 1
to match-count
collect i)))
- (match-nums nil))
+ (match-nums nil)
+ (cnt nil))
(if force-hide-first
;; Force '1' to be in the list, and to be the first item
;; in the list.
@@ -1618,12 +1628,23 @@ items if FORCE-SHOW-FIRST or FORCE-SHOW-LAST is
non-nil)."
(setq match-nums
(subseq positions
0 (min number-to-hide (length positions))))
- (dolist (pos-to-hide match-nums)
- (save-excursion
- (goto-char body-start)
- (re-search-forward org-drill-cloze-regexp
- item-end t pos-to-hide)
- (org-drill-hide-matched-cloze-text)))))
+ ;; (dolist (pos-to-hide match-nums)
+ (save-excursion
+ (goto-char body-start)
+ (setq cnt 0)
+ (while (re-search-forward org-drill-cloze-regexp item-end t)
+ (unless (save-match-data
+ (org-pos-in-regexp (match-beginning 0)
+ org-bracket-link-regexp 1))
+ (incf cnt)
+ (if (memq cnt match-nums)
+ (org-drill-hide-matched-cloze-text)))))))
+ ;; (loop
+ ;; do (re-search-forward org-drill-cloze-regexp
+ ;; item-end t pos-to-hide)
+ ;; while (org-pos-in-regexp (match-beginning 0)
+ ;; org-bracket-link-regexp 1))
+ ;; (org-drill-hide-matched-cloze-text)))))
(org-display-inline-images t)
(org-cycle-hide-drawers 'all)
(prog1 (org-drill-presentation-prompt)
@@ -1631,20 +1652,9 @@ items if FORCE-SHOW-FIRST or FORCE-SHOW-LAST is
non-nil)."
(org-drill-unhide-clozed-text))))))
-(defun org-drill-present-multicloze-hide1 ()
- "Hides one of the pieces of text that are marked for cloze deletion,
-chosen at random."
- (org-drill-present-multicloze-hide-n 1))
-
-
-(defun org-drill-present-multicloze-hide2 ()
- "Hides two of the pieces of text that are marked for cloze deletion,
-chosen at random."
- (org-drill-present-multicloze-hide-n 2))
-
-
-(defun org-drill-present-multicloze-hide-nth (cnt)
- "Hide the CNT'th piece of clozed text. 1 is the first piece. If
+(defun org-drill-present-multicloze-hide-nth (to-hide)
+ "Hide the TO-HIDE'th piece of clozed text. 1 is the first piece. If
+TO-HIDE is negative, count backwards, so -1 means the last item, -2
CNT is negative, count backwards, so -1 means the last item, -2
the second to last, etc."
(with-hidden-comments
@@ -1652,7 +1662,8 @@ the second to last, etc."
(let ((item-end nil)
(match-count 0)
(body-start (or (cdr (org-get-property-block))
- (point))))
+ (point)))
+ (cnt 0))
(org-drill-hide-all-subheadings-except nil)
(save-excursion
(outline-next-heading)
@@ -1660,23 +1671,29 @@ the second to last, etc."
(save-excursion
(goto-char body-start)
(while (re-search-forward org-drill-cloze-regexp item-end t)
- (incf match-count)))
+ (let ((in-regexp? (save-match-data
+ (org-pos-in-regexp (match-beginning 0)
+ org-bracket-link-regexp 1))))
+ (unless in-regexp?
+ (incf match-count)))))
+ (if (minusp to-hide)
+ (setq to-hide (+ 1 to-hide match-count)))
(cond
((or (not (plusp match-count))
- (> cnt match-count)
+ (> to-hide match-count))
(and (minusp cnt) (> (abs cnt) match-count)))
nil)
(t
(save-excursion
(goto-char body-start)
- (re-search-forward org-drill-cloze-regexp
- item-end t (if (minusp cnt) (+ 1 cnt match-count)
cnt))
- (org-drill-hide-matched-cloze-text))))
- (org-display-inline-images t)
- (org-cycle-hide-drawers 'all)
- (prog1 (org-drill-presentation-prompt)
- (org-drill-hide-subheadings-if 'org-drill-entry-p)
- (org-drill-unhide-clozed-text))))))
+ (setq cnt 0)
+ (while (re-search-forward org-drill-cloze-regexp item-end t)
+ (unless (save-match-data
+ (org-pos-in-regexp (match-beginning 0)
+ org-bracket-link-regexp 1))
+ (incf cnt)
+ (if (= cnt to-hide)
+ (org-drill-hide-matched-cloze-text)))))))
(defun org-drill-present-multicloze-hide-first ()
@@ -1714,7 +1731,7 @@ piece. The effect is similar to 'show1cloze' except that
the last
item is much less likely to be the item that is visible."
(if (zerop (mod (1+ (org-drill-entry-total-repeats 0)) 4))
;; 25% of time, show any item except the last
- (org-drill-present-multicloze-hide-n -1 nil t)
+ (org-drill-present-multicloze-hide-n -1 nil nil t)
;; 75% of time, show the LAST item
(org-drill-present-multicloze-hide-n -1 nil t)))
@@ -2008,19 +2025,32 @@ RESUMING-P is true if we are resuming a suspended drill
session."
(setq prompt
(format
"%d items reviewed. Session duration %s.
-%d/%d items awaiting review (%s, %s, %s, %s, %s).
-
Recall of reviewed items:
Excellent (5): %3d%% | Near miss (2): %3d%%
Good (4): %3d%% | Failure (1): %3d%%
Hard (3): %3d%% | Abject failure (0): %3d%%
You successfully recalled %d%% of reviewed items (quality > %s)
+%d/%d items still await review (%s, %s, %s, %s, %s).
Tomorrow, %d more items will become due for review.
Session finished. Press a key to continue..."
(length *org-drill-done-entries*)
(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
(org-drill-pending-entry-count)
(+ (org-drill-pending-entry-count)
*org-drill-dormant-entry-count*)
@@ -2045,20 +2075,6 @@ Session finished. Press a key to continue..."
(format "%d old"
(length *org-drill-old-mature-entries*))
'face `(:foreground ,org-drill-mature-count-color))
- (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
*org-drill-due-tomorrow-count*
))
@@ -2430,12 +2446,15 @@ values as `org-drill-scope'."
-(add-hook 'org-mode-hook
- (lambda ()
- (when org-drill-use-visible-cloze-face-p
- (font-lock-add-keywords 'org-mode
- org-drill-cloze-keywords
- nil))))
+(defun org-drill-add-cloze-fontification ()
+ (when org-drill-use-visible-cloze-face-p
+ (font-lock-add-keywords 'org-mode
+ org-drill-cloze-keywords
+ nil)))
+
+(add-hook 'org-mode-hook 'org-drill-add-cloze-fontification)
+
+(org-drill-add-cloze-fontification)
;;; Synching card collections =================================================
@@ -2505,10 +2524,6 @@ equivalent location in DEST to its location in SRC, by
matching
the heading hierarchy. However if IGNORE-NEW-ITEMS-P is non-nil,
we simply ignore any items that do not exist in DEST, and do not
copy them across."
- ;; In future could look at what to do if we find an item in SRC whose ID
- ;; is not present in DEST -- copy the whole item to DEST?
- ;; org-copy-subtree --> org-paste-subtree
- ;; could try to put it "near" the closest marker
(interactive "bImport scheduling info from which buffer?")
(unless dest
(setq dest (current-buffer)))
- [nongnu] elpa/org-drill f5b7472de1 204/251: Remove unused variable, (continued)
- [nongnu] elpa/org-drill f5b7472de1 204/251: Remove unused variable, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 4307a3a387 233/251: Show latex overlays in simple card's answer, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 2d7ea5d00b 245/251: add helper fn to check cards without killing emacs, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill fee727e76e 023/251: Added tag 2.0 for changeset 16cafa21aef0, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 8b72dfbded 024/251: - Can now resume drill sessions after exiting with (e)dit or (q)uit commands!, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 2d039d0429 027/251: Added tag 2.1.1 for changeset 60b0a80ce97a, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill c27d9035ef 030/251: - Added new example card types, more useful than 'spanish_verb':, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill ce3e540b00 035/251: Added tag 2.3.1 for changeset 566cf446fdae, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 0aeff8516d 032/251: - All drill items now receive unique IDs (using the org-id module). This allows, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 1c77d6cf3a 041/251: Removed old doc files (renamed)., ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill ca5231b9b4 043/251: Cloze text is now correctly identified in items whose bodies contain [[bracketed links]].,
ELPA Syncer <=
- [nongnu] elpa/org-drill 8133a8c566 044/251: Added tag 2.3.3 for changeset e68b52fe88ac, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill c410f8dcb0 042/251: Added tag 2.3.2 for changeset 4e43f149ea97, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 7301c9ea71 073/251: Fixed calculation of 'org-drill-entry-days-since-creation' for cases where 'org-drill-entry-days-overdue' returns NIL., ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 361aa53a14 069/251: Very overdue items are considered "lapsed" and are presented in the order they, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 612848a840 068/251: Added tag 2.4.1 for changeset 97f51d64df45, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill d987e8d734 081/251: Added tag 2.5.0 for changeset 9b098bf2648d, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill ec7b5a0cf0 048/251: Added tag 2.3.4 for changeset e472512f0be7, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill d5c55b69f4 061/251: Any LaTeX math fragments in an item will now be rendered inline (if possible), ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill c71a218c68 074/251: Added tag 2.4.4 for changeset 0571437aa238, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill eb95d9415a 059/251: New global variable 'org-drill-match'. Now possible to specify a tags/property/, ELPA Syncer, 2022/01/17