summaryrefslogtreecommitdiff
path: root/org-fc-type-double.el
blob: cea35ddfd1e7c9b1273d2b4d17c040da1644a855 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
(defvar org-fc-type-double-hole-re
  (rx "{{" (group (* (not (any "}")))) "}}"))

(defvar org-fc-type-double--overlay '())

(defun org-fc-type-double-init ()
  (interactive)
  (org-fc--init-card "double")
  (org-fc-review-data-update '("front" "back")))

(defun org-fc-type-double-setup (position)
  (pcase position
    ("front" (org-fc-type-normal-setup position))
    ("back" (org-fc-type-double-setup-back))
    (_ (error "Invalid double position %s" position))))

(defun org-fc-type-double-setup-back ()
  (org-show-subtree)
  (if (org-fc-has-back-heading-p)
      (setq org-fc-type-double--overlay (org-fc-hide-content "[...]\n"))
      (setq org-fc-type-double--overlay (org-fc-hide-heading "[...]")))
  (org-fc-review-flip-hydra/body))

(defun org-fc-type-double-flip ()
  (message "double flip")
  (pp org-fc-type-double--overlay)
  (if org-fc-type-double--overlay
      (delete-overlay org-fc-type-double--overlay))
  (org-show-subtree)
  (org-fc-review-rate-hydra/body))

;; No-op
(defun org-fc-type-double-update ())

(org-fc-register-type
 'double
 'org-fc-type-double-setup
 'org-fc-type-double-flip
 'org-fc-type-double-update)

(provide 'org-fc-type-double)