[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/org-drill b2f4874178 051/251: - Fixes to try and force dis
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/org-drill b2f4874178 051/251: - Fixes to try and force display of images during drill sessions. |
Date: |
Mon, 17 Jan 2022 18:59:00 -0500 (EST) |
branch: elpa/org-drill
commit b2f487417887a89889548e5fca7404babdeb7b5b
Author: eeeickythump <devnull@localhost>
Commit: eeeickythump <devnull@localhost>
- Fixes to try and force display of images during drill sessions.
- Fix to correctly reveal current entry when pausing a drill session in
a narrowed buffer. (thanks to Milan Zamazal)
- Support for verbal moods in addition to tenses. "Present indicative"
tense renamed to "simple present".
---
org-drill.el | 168 +++++++++++++++++++++++++++++++++++++++++++++--------------
spanish.org | 4 +-
2 files changed, 130 insertions(+), 42 deletions(-)
diff --git a/org-drill.el b/org-drill.el
index 9f84fac481..72ebb743ac 100755
--- 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.3.5
+;;; Version: 2.3.6
;;; Repository at http://bitbucket.org/eeeickythump/org-drill/
;;;
;;;
@@ -1509,18 +1509,38 @@ concealed by an overlay that displays the string TEXT."
(org-drill-unreplace-entry-text))))
-(defun org-drill-replace-entry-text (text)
+(defmacro with-replaced-entry-text-multi (replacements &rest body)
+ "During the execution of BODY, the entire text of the current entry is
+concealed by an overlay that displays the overlays in REPLACEMENTS."
+ `(progn
+ (org-drill-replace-entry-text ,replacements t)
+ (unwind-protect
+ (progn
+ ,@body)
+ (org-drill-unreplace-entry-text))))
+
+
+(defun org-drill-replace-entry-text (text &optional multi-p)
"Make an overlay that conceals the entire text of the item, not
including properties or the contents of subheadings. The overlay shows
the string TEXT.
+If MULTI-P is non-nil, TEXT must be a list of values which are legal
+for the `display' text property. The text of the item will be temporarily
+replaced by all of these items, in the order in which they appear in
+the list.
Note: does not actually alter the item."
- (let ((ovl (make-overlay (point-min)
- (save-excursion
- (outline-next-heading)
- (point)))))
- (overlay-put ovl 'category
- 'org-drill-replaced-text-overlay)
- (overlay-put ovl 'display text)))
+ (cond
+ ((and multi-p
+ (listp text))
+ (org-drill-replace-entry-text-multi text))
+ (t
+ (let ((ovl (make-overlay (point-min)
+ (save-excursion
+ (outline-next-heading)
+ (point)))))
+ (overlay-put ovl 'category
+ 'org-drill-replaced-text-overlay)
+ (overlay-put ovl 'display text)))))
(defun org-drill-unreplace-entry-text ()
@@ -1530,6 +1550,27 @@ Note: does not actually alter the item."
(delete-overlay ovl)))))
+(defun org-drill-replace-entry-text-multi (replacements)
+ "Make overlays that conceal the entire text of the item, not
+including properties or the contents of subheadings. The overlay shows
+the string TEXT.
+Note: does not actually alter the item."
+ (let ((ovl nil)
+ (p-min (point-min))
+ (p-max (save-excursion
+ (outline-next-heading)
+ (point))))
+ (assert (>= (- p-max p-min) (length replacements)))
+ (dotimes (i (length replacements))
+ (setq ovl (make-overlay (+ p-min (* 2 i))
+ (if (= i (1- (length replacements)))
+ p-max
+ (+ p-min (* 2 i) 1))))
+ (overlay-put ovl 'category
+ 'org-drill-replaced-text-overlay)
+ (overlay-put ovl 'display (nth i replacements)))))
+
+
(defmacro with-replaced-entry-heading (heading &rest body)
`(progn
(org-drill-replace-entry-heading ,heading)
@@ -1588,6 +1629,7 @@ Note: does not actually alter the item."
(defun org-drill-present-default-answer (reschedule-fn)
(org-drill-hide-subheadings-if 'org-drill-entry-p)
(org-drill-unhide-clozed-text)
+ (org-display-inline-images t)
(with-hidden-cloze-hints
(funcall reschedule-fn)))
@@ -1907,6 +1949,21 @@ pieces rather than one."
question
(org-drill-hide-all-subheadings-except nil)
(org-cycle-hide-drawers 'all)
+ (org-display-inline-images t)
+ (prog1 (org-drill-presentation-prompt)
+ (org-drill-hide-subheadings-if 'org-drill-entry-p)))))
+
+
+(defun org-drill-present-card-using-multiple-overlays (replacements &optional
answer)
+ "TEXTS is a list of valid values for the 'display' text property.
+Present these overlays, in sequence, as the only
+visible content of the card."
+ (with-hidden-comments
+ (with-replaced-entry-text-multi
+ replacements
+ (org-drill-hide-all-subheadings-except nil)
+ (org-cycle-hide-drawers 'all)
+ (org-display-inline-images t)
(prog1 (org-drill-presentation-prompt)
(org-drill-hide-subheadings-if 'org-drill-entry-p)))))
@@ -2358,12 +2415,12 @@ than starting a new one."
(org-map-drill-entries
(lambda ()
(org-drill-progress-message
- (+ (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*))
- (incf cnt))
+ (+ (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*))
+ (incf cnt))
(cond
((not (org-drill-entry-p))
nil) ; skip
@@ -2450,7 +2507,9 @@ than starting a new one."
(cond
(end-pos
(when (markerp end-pos)
- (org-drill-goto-entry end-pos))
+ (org-drill-goto-entry end-pos)
+ (org-reveal)
+ (org-show-entry))
(let ((keystr (command-keybinding-to-string 'org-drill-resume)))
(message
"You can continue the drill session with the command
`org-drill-resume'.%s"
@@ -2740,7 +2799,14 @@ copy them across."
("imperfect" "darkturquoise")
("present perfect" "royalblue")
;; future tenses
- ("future" "green"))
+ ("future" "green")
+ ;; moods (backgrounds).
+ ("indicative" nil) ; default
+ ("subjunctive" "medium blue")
+ ("conditional" "grey30")
+ ("negative imperative" "red4")
+ ("positive imperative" "darkgreen")
+ )
"Alist where each entry has the form (TENSE COLOUR), where
TENSE is a string naming a tense in which verbs can be
conjugated, and COLOUR is a string specifying a foreground colour
@@ -2756,50 +2822,72 @@ the name of the tense.")
(inf-hint (org-entry-get (point) "VERB_INFINITIVE_HINT" t))
(translation (org-entry-get (point) "VERB_TRANSLATION" t))
(tense (org-entry-get (point) "VERB_TENSE" nil))
+ (mood (org-entry-get (point) "VERB_MOOD" nil))
(highlight-face nil))
- (unless (and infinitive translation tense)
- (error "Missing information for verb conjugation card (%s, %s, %s) at %s"
- infinitive translation tense (point)))
- (setq tense (downcase (car (read-from-string tense)))
+ (unless (and infinitive translation (or tense mood))
+ (error "Missing information for verb conjugation card (%s, %s, %s, %s)
at %s"
+ infinitive translation tense mood (point)))
+ (setq tense (if tense (downcase (car (read-from-string tense))))
+ mood (if mood (downcase (car (read-from-string mood))))
infinitive (car (read-from-string infinitive))
inf-hint (if inf-hint (car (read-from-string inf-hint)))
translation (car (read-from-string translation)))
(setq highlight-face
(list :foreground
(or (second (assoc-string tense org-drill-verb-tense-alist t))
- "red")))
+ "hotpink")
+ :background
+ (second (assoc-string mood org-drill-verb-tense-alist t))))
(setq infinitive (propertize infinitive 'face highlight-face))
(setq translation (propertize translation 'face highlight-face))
- (setq tense (propertize tense 'face highlight-face))
- (list infinitive inf-hint translation tense)))
+ (if tense (setq tense (propertize tense 'face highlight-face)))
+ (if mood (setq mood (propertize mood 'face highlight-face)))
+ (list infinitive inf-hint translation tense mood)))
(defun org-drill-present-verb-conjugation ()
"Present a drill entry whose card type is 'conjugate'."
- (destructuring-bind (infinitive inf-hint translation tense)
- (org-drill-get-verb-conjugation-info)
- (org-drill-present-card-using-text
- (cond
- ((zerop (random* 2))
- (format "\nTranslate the verb\n\n%s\n\nand conjugate for the %s
tense.\n\n"
- infinitive tense))
- (t
- (format "\nGive the verb that means\n\n%s %s\n
-and conjugate for the %s tense.\n\n"
- translation
- (if inf-hint (format " [HINT: %s]" inf-hint) "")
- tense))))))
+ (flet ((tense-and-mood-to-string
+ (tense mood)
+ (cond
+ ((and tense mood)
+ (format "%s tense, %s mood" tense mood))
+ (tense
+ (format "%s tense" tense))
+ (mood
+ (format "%s mood" mood)))))
+ (destructuring-bind (infinitive inf-hint translation tense mood)
+ (org-drill-get-verb-conjugation-info)
+ (org-drill-present-card-using-text
+ (cond
+ ((zerop (random* 2))
+ (format "\nTranslate the verb\n\n%s\n\nand conjugate for the %s.\n\n"
+ infinitive (tense-and-mood-to-string tense mood)))
+
+ (t
+ (format "\nGive the verb that means\n\n%s %s\n
+and conjugate for the %s.\n\n"
+ translation
+ (if inf-hint (format " [HINT: %s]" inf-hint) "")
+ (tense-and-mood-to-string tense mood))))))))
(defun org-drill-show-answer-verb-conjugation (reschedule-fn)
"Show the answer for a drill item whose card type is 'conjugate'.
RESCHEDULE-FN must be a function that calls `org-drill-reschedule' and
returns its return value."
- (destructuring-bind (infinitive inf-hint translation tense)
+ (destructuring-bind (infinitive inf-hint translation tense mood)
(org-drill-get-verb-conjugation-info)
(with-replaced-entry-heading
- (format "%s tense of %s ==> %s\n\n"
- (capitalize tense)
+ (format "%s of %s ==> %s\n\n"
+ (capitalize
+ (cond
+ ((and tense mood)
+ (format "%s tense, %s mood" tense mood))
+ (tense
+ (format "%s tense" tense))
+ (mood
+ (format "%s mood" mood))))
infinitive translation)
(funcall reschedule-fn))))
diff --git a/spanish.org b/spanish.org
index 0a87cb9ea4..056640f02b 100755
--- a/spanish.org
+++ b/spanish.org
@@ -211,9 +211,9 @@ This is a regular verb.
Bailé con mi novia.
I danced with my girlfriend.
-**** Present Indicative tense
:verb:drill:
+**** Simple present tense
:verb:drill:
:PROPERTIES:
- :VERB_TENSE: "present indicative"
+ :VERB_TENSE: "simple present"
:DRILL_CARD_TYPE: conjugate
:END:
- [nongnu] elpa/org-drill 361aa53a14 069/251: Very overdue items are considered "lapsed" and are presented in the order they, (continued)
- [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
- [nongnu] elpa/org-drill ce1a76c6c9 076/251: Added tag 2.4.5 for changeset 69dde321b38c, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 45237da768 046/251: Added tag 2.3.3 for changeset 1b0cc92cbb6a, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill bd452b9fe1 054/251: The string which separates a hint from the rest of the contents of a cloze is, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill b2f4874178 051/251: - Fixes to try and force display of images during drill sessions.,
ELPA Syncer <=
- [nongnu] elpa/org-drill f9b4c257af 067/251: Check that org version is >= 7.9.3f (the 'org-schedule' function in older, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill e52080c97b 047/251: New option: org-drill-sm5-initial-interval. Allows users of SM5 algorithm to adjust the first, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 8618a532c7 049/251: - Improved progress bar while collecting due items. It is no longer able to overflow, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 88de357a6c 084/251: Undo previous version change to 2.5.0. The current version is 2.4.7., ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 9ea35e11b6 006/251: Added implementation of SM2 algorithm., ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 1daa7d6de5 009/251: Separate counts of pending new, old, and failed items are displayed in custom colours, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 2ba02542f8 015/251: Fixed bug causing items to sometimes appear multiple times during a single drill session., ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 2f92356145 016/251: Added tag 1.5 for changeset 42f3700bc748, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 34f0c03f9a 005/251: Added tag 1.0 for changeset a3f5efca0221, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 9ab44310d5 021/251: - New option: org-drill-hide-item-headings-p. If non-nil, item headings will be made, ELPA Syncer, 2022/01/17