summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--demo.org57
-rw-r--r--doc/card_types.org6
-rw-r--r--org-fc-awk.el6
-rw-r--r--org-fc-hydra.el3
-rw-r--r--org-fc-type-cloze.el28
5 files changed, 77 insertions, 23 deletions
diff --git a/demo.org b/demo.org
index 0d071af..81accb2 100644
--- a/demo.org
+++ b/demo.org
@@ -9,7 +9,7 @@
:REVIEW_DATA:
| position | ease | box | interval | due |
|----------+------+-----+----------+---------------------|
-| front | 2.50 | 4 | 13.69 | 2020-01-25T06:47:55 |
+| front | 2.50 | 6 | 83.98 | 2020-04-05T11:29:48 |
:END:
Front of the card
** Back
@@ -26,8 +26,8 @@ Back of the card
:REVIEW_DATA:
| position | ease | box | interval | due |
|----------+------+-----+----------+---------------------|
-| front | 2.50 | 4 | 14.38 | 2020-01-25T23:25:30 |
-| back | 2.50 | 4 | 14.95 | 2020-01-26T13:02:32 |
+| front | 2.50 | 5 | 35.76 | 2019-02-17T06:10:32 |
+| back | 2.50 | 6 | 94.52 | 2020-04-16T00:33:34 |
:END:
For cards without a "Back" heading, the headings main text is
considered as the back side.
@@ -42,8 +42,8 @@ considered as the back side.
:REVIEW_DATA:
| position | ease | box | interval | due |
|----------+------+-----+----------+---------------------|
-| 0 | 2.50 | 3 | 6.00 | 2019-01-17T12:32:41 |
-| 1 | 2.50 | 4 | 13.91 | 2020-01-25T12:14:46 |
+| 0 | 2.50 | 6 | 89.34 | 2020-04-10T20:11:35 |
+| 1 | 2.50 | 5 | 31.55 | 2019-02-13T01:13:00 |
:END:
A {{cloze deletion}@0} can have multiple {{holes}@1}.
* Cloze Enumeration :fc:
@@ -57,14 +57,53 @@ A {{cloze deletion}@0} can have multiple {{holes}@1}.
:REVIEW_DATA:
| position | ease | box | interval | due |
|----------+------+-----+----------+---------------------|
-| 0 | 2.50 | 2 | 1.00 | 2019-01-12T12:32:37 |
-| 1 | 2.50 | 3 | 6.00 | 2019-01-17T12:32:39 |
-| 2 | 2.50 | 2 | 1.00 | 2019-01-12T12:32:31 |
-| 3 | 2.50 | 2 | 1.00 | 2019-01-12T12:32:48 |
+| 0 | 2.50 | 4 | 13.54 | 2019-01-26T00:58:48 |
+| 1 | 2.50 | 6 | 72.76 | 2020-03-25T06:21:24 |
+| 2 | 2.50 | 5 | 36.18 | 2020-02-17T16:31:25 |
+| 3 | 2.50 | 4 | 16.20 | 2019-01-28T16:51:34 |
:END:
+
Enumerations are useful for
- {{Learning}@0}
- {{Lists}@1}
- {{of}@2}
- {{items}@3}
+* AWK Source Example :fc:
+:PROPERTIES:
+:FC_CREATED: 2020-01-20T21:44:50
+:FC_TYPE: cloze
+:FC_CLOZE_MAX: 2
+:FC_CLOZE_TYPE: single
+:ID: ae675e11-e003-4057-b6b1-1f4702837502
+:END:
+:REVIEW_DATA:
+| position | ease | box | interval | due |
+|----------+------+-----+----------+---------------------|
+| 0 | 2.50 | 1 | 0.01 | 2020-01-20T22:07:25 |
+| 1 | 2.50 | 1 | 0.01 | 2020-01-20T22:07:24 |
+| 2 | 2.50 | 1 | 0.01 | 2020-01-20T22:05:31 |
+:END:
+#+begin_src awk
+ # Set up variables for new file
+ {{BEGINFILE}@0} {
+ title = FILENAME;
+ }
+
+ match($0, /#\+TITLE: (.*)/, a) {
+ title = a[1];
+ }
+
+ {
+ i += 1;
+ if (i > 5) {
+ # Continue with next file
+ {{nextfile}@1};
+ }
+ }
+
+ # Print results for file
+ {{ENDFILE}@2} {
+ print FILENAME, title;
+ }
+#+end_src
diff --git a/doc/card_types.org b/doc/card_types.org
index 64ad903..798ab4c 100644
--- a/doc/card_types.org
+++ b/doc/card_types.org
@@ -44,6 +44,12 @@ Only one hole is hidden.
All holes *behind* the currently review one are hidden, too.
Useful for memorizing lists where the order of items is important.
+** Single ~'single~
+All holes besides the current one are hidden.
+
+Useful for learning syntax or function names of a programming language
+by using a =src= block in the card and marking parts of the code as
+holes.
** Context ~'context~
Holes ~org-fc-type-cloze-context~ (default 1) around the currently
reviewed one are shown.
diff --git a/org-fc-awk.el b/org-fc-awk.el
index d3ca453..40e8a7b 100644
--- a/org-fc-awk.el
+++ b/org-fc-awk.el
@@ -61,16 +61,12 @@ each separated by a tab, into a keyword-number plist."
;;;; TSV
-(defun org-fc-tsv--parse-date (date)
- "Parse an ISO8601 date to an Emacs time."
- (parse-iso8601-time-string (concat date ":00")))
-
(defun org-fc-tsv--parse-element (header element)
"Parse an ELEMENT of a row given a single HEADER element."
(if (listp header)
(pcase (cdr header)
('string element)
- ('date (org-fc-tsv--parse-date element))
+ ('date (parse-iso8601-time-string element))
('number (string-to-number element))
('symbol (intern element))
('keyword (intern (concat ":" element)))
diff --git a/org-fc-hydra.el b/org-fc-hydra.el
index 8bf108b..d75a98d 100644
--- a/org-fc-hydra.el
+++ b/org-fc-hydra.el
@@ -9,8 +9,9 @@
("n" org-fc-type-normal-init "Normal" :exit t)
("t" org-fc-type-text-input-init "Text Input" :exit t)
("d" org-fc-type-double-init "Double" :exit t)
- ("d" (org-fc-type-cloze-init 'deletion) "Deletion" :exit t)
+ ("c" (org-fc-type-cloze-init 'deletion) "Deletion" :exit t)
("e" (org-fc-type-cloze-init 'enumeration) "Enum" :exit t)
+ ("s" (org-fc-type-cloze-init 'single) "Single" :exit t)
("x" (org-fc-type-cloze-init 'context) "Context" :exit t)
("q" nil "Quit" :exit t))
diff --git a/org-fc-type-cloze.el b/org-fc-type-cloze.el
index 6889b32..7b6cf5d 100644
--- a/org-fc-type-cloze.el
+++ b/org-fc-type-cloze.el
@@ -1,8 +1,9 @@
(defvar org-fc-type-cloze-max-hole-property "FC_CLOZE_MAX")
(defvar org-fc-type-cloze-type-property "FC_CLOZE_TYPE")
+;; NOTE: The context type is not implemented yet
(defvar org-fc-type-cloze-types
- '(deletion enumeration context))
+ '(deletion enumeration context single))
(defvar org-fc-type-cloze--overlays '())
@@ -82,7 +83,8 @@
(org-fc-goto-entry-heading)
(let* ((el (org-element-at-point))
(end (org-element-property :contents-end el))
- (overlays nil))
+ (overlays nil)
+ (seen-current nil))
(while (re-search-forward org-fc-type-cloze-id-hole-re end t)
(let ((text (match-string 1))
(hint (match-string 2))
@@ -90,12 +92,22 @@
(hole-beg (match-beginning 0))
(hole-end (match-end 0)))
(if (= hole id)
- (setq overlays (org-fc-type-cloze--overlay-current))
- (if (and (eq type 'enumeration) overlays)
- (org-fc-hide-region hole-beg hole-end "...")
- (progn
- (org-fc-hide-region hole-beg (match-beginning 1))
- (org-fc-hide-region (match-end 1) hole-end))))))
+ (progn (setq overlays (org-fc-type-cloze--overlay-current))
+ (setq seen-current t))
+ (case type
+ ('enumeration
+ (if seen-current
+ (org-fc-hide-region hole-beg hole-end "...")
+ (progn
+ (org-fc-hide-region hole-beg (match-beginning 1))
+ (org-fc-hide-region (match-end 1) hole-end))))
+ ('deletion
+ (progn
+ (org-fc-hide-region hole-beg (match-beginning 1))
+ (org-fc-hide-region (match-end 1) hole-end)))
+ ('single
+ (org-fc-hide-region hole-beg hole-end "..."))
+ (t (error "org-fc: Unknown cloze card type %s" type))))))
overlays)))
(defun org-fc-type-cloze-flip ()