[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/org-drill b02735bde7 094/251: New option 'org-drill-cloze-
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/org-drill b02735bde7 094/251: New option 'org-drill-cloze-length-matches-hidden-text': If non-nil, when |
Date: |
Mon, 17 Jan 2022 18:59:05 -0500 (EST) |
branch: elpa/org-drill
commit b02735bde76e7dc7ab2c93fe0a477d40601023ee
Author: Paul Sexton <eeeickythump@gmail.com>
Commit: Paul Sexton <eeeickythump@gmail.com>
New option 'org-drill-cloze-length-matches-hidden-text': If non-nil, when
concealing cloze deletions, force the length of the ellipsis to match the
length of the missing text. This may be useful to preserve the formatting in
a displayed table, for example.
Arguments to org-drill-presentation-prompt have changed. It now can take
any of the following keyword arguments:
- :prompt STRING - a string to use instead of the standard prompt.
- :returns ALIST - a list of (char . symbol); the function will return
the symbol if the corresponding character is pressed at the prompt.
- :start-time TIME - the time the card started to be displayed.
(Thanks to Bernard Hurley for contribution)
---
org-drill.el | 91 ++++++++++++++++++++++++++++++++++++++++++------------------
1 file changed, 64 insertions(+), 27 deletions(-)
diff --git a/org-drill.el b/org-drill.el
index 275d66ca4c..cdb5dc5e1b 100755
--- a/org-drill.el
+++ b/org-drill.el
@@ -4,7 +4,7 @@
;;; Copyright (C) 2010-2015 Paul Sexton
;;;
;;; Author: Paul Sexton <eeeickythump@gmail.com>
-;;; Version: 2.4.10
+;;; Version: 2.5
;;; Keywords: flashcards, memory, learning, memorization
;;; Repository at http://bitbucket.org/eeeickythump/org-drill/
;;;
@@ -554,6 +554,15 @@ This variable is useful for card types that compute their
answers
random number to another language. ")
+(defcustom org-drill-cloze-length-matches-hidden-text-p
+ nil
+ "If non-nil, when concealing cloze deletions, force the length of
+the ellipsis to match the length of the missing text. This may be useful
+to preserve the formatting in a displayed table, for example."
+ :group 'org-drill
+ :type 'boolean)
+
+
(defvar *org-drill-session-qualities* nil)
(defvar *org-drill-start-time* 0)
(defvar *org-drill-new-entries* nil)
@@ -1515,8 +1524,26 @@ the current topic."
(not (member drill-heading heading-list))))))
-(defun org-drill-presentation-prompt (&rest fmt-and-args)
- (let* ((item-start-time (current-time))
+(cl-defun org-drill-presentation-prompt (&key prompt
+ returns
+ (start-time (current-time)))
+ "Create a card prompt with a timer and user-specified menu.
+
+Arguments:
+
+PROMPT: A string that overrides the standard prompt.
+
+RETURNS: An alist of the form ((<char> . <symbol>)...) where
+ <char> is the character pressed and <symbol> is the
+ returned value, which will normally be either a symbol,
+ `t' or `nil'.
+
+START-TIME: The time the card started to be displayed. This
+ defaults to (current-time), however, if the function
+ is called multiple times from one card then it might
+ be convenient to override this default.
+"
+ (let* ((item-start-time start-time)
(input nil)
(ch nil)
(last-second 0)
@@ -1525,17 +1552,14 @@ the current topic."
(length *org-drill-overdue-entries*)))
(status (first (org-drill-entry-status)))
(prompt
- (if fmt-and-args
- (apply 'format
- (first fmt-and-args)
- (rest fmt-and-args))
- (format (concat "Press key for answer, "
- "%c=edit, %c=tags, %c=skip, %c=quit.")
- org-drill--edit-key
- org-drill--tags-key
- org-drill--skip-key
- org-drill--quit-key))))
- (setq prompt
+ (or prompt
+ (format (concat "Press key for answer, "
+ "%c=edit, %c=tags, %c=skip, %c=quit.")
+ org-drill--edit-key
+ org-drill--tags-key
+ org-drill--skip-key
+ org-drill--quit-key)))
+ (full-prompt
(format "%s %s %s %s %s %s"
(propertize
(char-to-string
@@ -1571,15 +1595,15 @@ the current topic."
'face `(:foreground ,org-drill-new-count-color)
'help-echo (concat "The number of new items that you "
"have never reviewed."))
- prompt))
+ prompt)))
(if (and (eql 'warn org-drill-leech-method)
(org-drill-entry-leech-p))
- (setq prompt (concat
- (propertize "!!! LEECH ITEM !!!
+ (setq full-prompt (concat
+ (propertize "!!! LEECH ITEM !!!
You seem to be having a lot of trouble memorising this item.
Consider reformulating the item to make it easier to remember.\n"
- 'face '(:foreground "red"))
- prompt)))
+ 'face '(:foreground "red"))
+ full-prompt)))
(while (memq ch '(nil org-drill--tags-key))
(setq ch nil)
(while (not (input-pending-p))
@@ -1587,17 +1611,19 @@ Consider reformulating the item to make it easier to
remember.\n"
(message (concat (if (>= (time-to-seconds elapsed) (* 60 60))
"++:++ "
(format-time-string "%M:%S " elapsed))
- prompt))
+ full-prompt))
(sit-for 1)))
(setq input (org-drill--read-key-sequence nil))
(if (stringp input) (setq ch (elt input 0)))
(if (eql ch org-drill--tags-key)
(org-set-tags-command)))
- (cond
- ((eql ch org-drill--quit-key) nil)
- ((eql ch org-drill--edit-key) 'edit)
- ((eql ch org-drill--skip-key) 'skip)
- (t t))))
+ (if returns
+ (or (cdr (assoc ch returns)))
+ (cond
+ ((eql ch org-drill--quit-key) nil)
+ ((eql ch org-drill--edit-key) 'edit)
+ ((eql ch org-drill--skip-key) 'skip)
+ (t t)))))
(defun org-pos-in-regexp (pos regexp &optional nlines)
@@ -1666,6 +1692,9 @@ visual overlay, or with the string TEXT if it is
supplied."
(overlay-put ovl 'category
'org-drill-cloze-overlay-defaults)
(overlay-put ovl 'priority 9999)
+ (if org-drill-cloze-length-matches-hidden-text-p
+ (overlay-put ovl 'display
+ (concat "[" (make-string (max 1 (- (length (match-string
0)) 2)) ?.) "]")))
(when (and hint-sep-pos
(> hint-sep-pos 1))
(let ((hint (substring-no-properties
@@ -1676,8 +1705,16 @@ visual overlay, or with the string TEXT if it is
supplied."
ovl 'display
;; If hint is like `X...' then display [X...]
;; otherwise display [...X]
- (format (if (string-match-p (regexp-quote "...") hint) "[%s]"
"[%s...]")
- hint))))))
+ (format "[%s%s%s]"
+ hint
+ (if (string-match-p (regexp-quote "...") hint) "" "...")
+ (if org-drill-cloze-length-matches-hidden-text-p
+ (make-string (max 0 (- (length (match-string 0))
+ (length hint)
+ (if (string-match-p (regexp-quote
"...") hint) 0 3)
+ 2))
+ ?.)
+ "")))))))
(defun org-drill-hide-cloze-hints ()
- [nongnu] elpa/org-drill 2e37c8a91c 234/251: Merge branch 'fix/show-latex-fragments' into 'master', (continued)
- [nongnu] elpa/org-drill 2e37c8a91c 234/251: Merge branch 'fix/show-latex-fragments' into 'master', ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 30913a9adf 247/251: Merge branch 'branweb/fix-cram-mode' into 'master', ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 0f0ee9f188 241/251: Allow Creating New Session in Cram Mode, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill ace0cf0dcd 250/251: Update CI., ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 7b9b7f1323 209/251: Update documentation, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 546336d207 225/251: Update documentation., ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 602f5c4d96 243/251: Fix use of cl.el, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 94ae5d684d 244/251: update gitignore to exclude all org files in robots dir ending in -copy, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill c65430b71a 045/251: Oops! some some nasty discrepancies have now been fixed.(something went wrong, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 7a3bf3ef30 092/251: Update version in header to 2.4.10., ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill b02735bde7 094/251: New option 'org-drill-cloze-length-matches-hidden-text': If non-nil, when,
ELPA Syncer <=
- [nongnu] elpa/org-drill 6c14bd6c50 129/251: Update robot, Fix remaining CL dependencies, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 11abbd2747 124/251: Add robotized test, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 46d71b5218 141/251: Add lexical-binding, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 2b44b36284 197/251: Fix prompt, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 1429c675e8 191/251: Fix compatability call again!, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 9eb8d72776 163/251: Update README, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 9f9e5e7170 193/251: Renamespace all macros, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 508f2dde21 202/251: Use persist, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill 04923e6c38 214/251: Update gitignore for generated file, ELPA Syncer, 2022/01/17
- [nongnu] elpa/org-drill c0ee1780de 222/251: Update documentation, ELPA Syncer, 2022/01/17