summaryrefslogtreecommitdiff
path: root/org-fc-review.el
diff options
context:
space:
mode:
authorLeon Rische <leon.rische@me.com>2021-03-07 15:53:14 +0100
committerLeon Rische <leon.rische@me.com>2021-03-07 15:53:14 +0100
commit43bb7ab15c37b452418e1a9095e01e56d56c5ef8 (patch)
treeea240bd26fde4f41e14d93a8cf0cc432518c01eb /org-fc-review.el
parentbb83211fc9dd09f744a9e1a6d25edfc2a2a5cc5c (diff)
Extract core functions
Diffstat (limited to 'org-fc-review.el')
-rw-r--r--org-fc-review.el53
1 files changed, 48 insertions, 5 deletions
diff --git a/org-fc-review.el b/org-fc-review.el
index 998cbb5..c371a61 100644
--- a/org-fc-review.el
+++ b/org-fc-review.el
@@ -35,6 +35,52 @@
;;
;;; Code:
+(require 'eieio)
+
+(require 'org-fc-core)
+
+;;; Hooks
+
+(defcustom org-fc-before-setup-hook '()
+ "Functions run before a card is set up for review."
+ :type 'hook
+ :group 'org-fc)
+
+(defcustom org-fc-after-setup-hook '()
+ "Functions run after a card is set up for review."
+ :type 'hook
+ :group 'org-fc)
+
+(defcustom org-fc-after-flip-hook '()
+ "Functions run after a card is flipped during review."
+ :type 'hook
+ :group 'org-fc)
+
+(defcustom org-fc-before-review-hook '()
+ "Functions run when a review session is started."
+ :type 'hook
+ :group 'org-fc)
+
+(defcustom org-fc-after-review-hook '()
+ "Functions run when a review session ends / is quit."
+ :type 'hook
+ :group 'org-fc)
+
+;;; Variables
+
+(defvar org-fc-review--session nil
+ "Current review session.")
+
+(defvar org-fc-review--timestamp nil
+ "Time the last card was flipped.
+Used to calculate the time needed for reviewing a card.")
+
+(defvar org-fc-reviewing-existing-buffer nil
+ "Track if the current buffer was open before the review.")
+(make-variable-buffer-local 'org-fc-reviewing-existing-buffer)
+
+;;; Main Review Functions
+
;;;###autoload
(defun org-fc-review (context)
"Start a review session for all cards in CONTEXT.
@@ -113,7 +159,7 @@ If RESUMING is non-nil, some parts of the buffer setup are skipped."
(org-display-inline-images)
(run-hooks 'org-fc-before-setup-hook)
- (setq org-fc-timestamp (time-to-seconds (current-time)))
+ (setq org-fc-review--timestamp (time-to-seconds (current-time)))
(let ((step (funcall (org-fc-type-setup-fn type) position)))
(run-hooks 'org-fc-after-setup-hook)
@@ -166,7 +212,7 @@ same ID as the current card in the session."
(id (plist-get card :id))
(position (plist-get card :position))
(now (time-to-seconds (current-time)))
- (delta (- now org-fc-timestamp)))
+ (delta (- now org-fc-review--timestamp)))
(org-fc-review-add-rating org-fc-review--session rating)
(org-fc-review-update-data path id position rating delta)
(org-fc-review-reset)
@@ -424,9 +470,6 @@ removed."
('easy (cl-incf (cl-getf ratings :easy) 1)))
(cl-incf (cl-getf ratings :total 1))))
-(defvar org-fc-review--session nil
- "Current review session.")
-
;;; Modes
(defvar org-fc-review-flip-mode-map