summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--org-fc-algo-sm2.el57
-rw-r--r--org-fc-awk.el6
-rw-r--r--org-fc-cache.el6
-rw-r--r--org-fc-core.el26
-rw-r--r--org-fc-dashboard.el14
-rw-r--r--org-fc-review.el25
-rw-r--r--org-fc.el9
-rw-r--r--tests/org-fc-filter-test.el6
8 files changed, 74 insertions, 75 deletions
diff --git a/org-fc-algo-sm2.el b/org-fc-algo-sm2.el
index 1283bd8..3ed01dd 100644
--- a/org-fc-algo-sm2.el
+++ b/org-fc-algo-sm2.el
@@ -31,7 +31,7 @@
(require 'org-fc-core)
(defmacro org-fc-property (symbol standard doc &rest args)
- (let (defcustom-args property reader)
+ (let (defcustom-args property)
(while args
(let ((keyword (pop args)))
(unless (symbolp keyword)
@@ -41,38 +41,37 @@
(let ((value (pop args)))
(cl-case keyword
(:property (setq property value))
- (:reader (setq reader value))
(t
(push value defcustom-args)
(push keyword defcustom-args))))))
(unless property
(error "Missing keyword :property"))
(let ((property-symbol (intern (concat (symbol-name symbol) "-property"))))
- `(progn
- (defcustom
- ,symbol
- ,standard
- ,doc
- ,@defcustom-args)
- (defcustom
- ,property-symbol
- ,property
- ,(format "Headline property for `%s'" symbol)
- :type 'string
- :group ,(plist-get defcustom-args :group))
- (defun ,symbol ()
- ,(format "Getter for `%s'" symbol)
- (if-let ((value (org-entry-get (point) ,property-symbol t)))
- ;; TODO: Switch on possible types
- (read value)
- ;; ,(case (plist-get defcustom-args :type)
- ;; ('string 'value)
- ;; ('float '(string-to-number value))
- ;; ('list '(read value))
- ;; (t (error "Unsupported property type %s"
- ;; (plist-get defcustom-args :type)
-
- ,symbol))))))
+ `(progn
+ (defcustom
+ ,symbol
+ ,standard
+ ,doc
+ ,@defcustom-args)
+ (defcustom
+ ,property-symbol
+ ,property
+ ,(format "Headline property for `%s'" symbol)
+ :type 'string
+ :group ,(plist-get defcustom-args :group))
+ (defun ,symbol ()
+ ,(format "Getter for `%s'" symbol)
+ (if-let ((value (org-entry-get (point) ,property-symbol t)))
+ ;; TODO: Switch on possible types
+ (read value)
+ ;; ,(case (plist-get defcustom-args :type)
+ ;; ('string 'value)
+ ;; ('float '(string-to-number value))
+ ;; ('list '(read value))
+ ;; (t (error "Unsupported property type %s"
+ ;; (plist-get defcustom-args :type)
+
+ ,symbol))))))
;;;; Properties
@@ -132,7 +131,7 @@ INTERVAL is by a random factor between `org-fc-algo-sm2-fuzz-min' and
`org-fc-algo-sm2-fuzz-max'"
(let ((min (org-fc-algo-sm2-fuzz-min))
(max (org-fc-algo-sm2-fuzz-max)))
- (* interval (+ min (cl-random (- max min))))))
+ (* interval (+ min (cl-random (- max min))))))
;;;; Main Algorithm
@@ -167,7 +166,7 @@ EASE, BOX and INTERVAL are the current parameters of the card."
(defun org-fc-algo-sm2-initial-review-data (position)
"Initial SM2 review data for POSITION."
(list position (org-fc-algo-sm2-ease-initial) 0 0
- (org-fc-timestamp-now)))
+ (org-fc-timestamp-in 0)))
;;; Footer
diff --git a/org-fc-awk.el b/org-fc-awk.el
index 444352a..951c1a6 100644
--- a/org-fc-awk.el
+++ b/org-fc-awk.el
@@ -103,9 +103,9 @@ ITAGS and LTAGS are strings `\":tag1:tag2:\"'"
FILTER can be either nil or a function taking a single card as
its input."
(let ((index (org-fc-awk-index-paths paths)))
- (if filter
- (cl-remove-if-not filter index)
- index)))
+ (if filter
+ (cl-remove-if-not filter index)
+ index)))
(defun org-fc-awk-index-paths (paths)
"Generate a list of all cards and positions in PATHS."
diff --git a/org-fc-cache.el b/org-fc-cache.el
index 83fee37..9168bd6 100644
--- a/org-fc-cache.el
+++ b/org-fc-cache.el
@@ -32,7 +32,11 @@
;;; Code:
+(require 'parse-time)
+
(require 'org-fc-core)
+(require 'org-fc-awk)
+(require 'org-fc-review)
;;; Queue / Processing of Files
@@ -163,7 +167,7 @@ This is especially relevant w.r.t a card's due date / suspension state before re
(if (org-fc-suspended-entry-p)
(error "Trying to review a suspended card"))
(let* ((position (plist-get cur :position))
- (review-data (org-fc-get-review-data))
+ (review-data (org-fc-review-data-get))
(row (assoc position review-data #'string=))
(due (parse-iso8601-time-string (nth 4 row))))
(unless (time-less-p due (current-time))
diff --git a/org-fc-core.el b/org-fc-core.el
index 0a5e733..3323f11 100644
--- a/org-fc-core.el
+++ b/org-fc-core.el
@@ -26,6 +26,7 @@
(require 'outline)
+(require 'org-id)
(require 'org-indent)
(require 'org-element)
@@ -650,31 +651,6 @@ Positions are shuffled in a way that preserves the order of the
(with-current-buffer (find-file path)
(org-fc-review-buffer))))
-;;; Header Line
-
-(defvar org-fc-original-header-line-format nil
- "`header-line-format' before it was set by org-fc.")
-
-(defun org-fc-set-header-line ()
- "Set the header-line for review."
- (let* ((remaining (1+ (length (oref org-fc--session cards))))
- (current (oref org-fc--session current-item))
- (title
- (unless (member "notitle" (plist-get current :tags))
- (plist-get current :filetitle))))
- (setq org-fc-original-header-line-format header-line-format)
- (setq-local
- header-line-format
- `((org-fc-review-flip-mode "Flip")
- (org-fc-review-rate-mode "Rate")
- (org-fc-review-edit-mode "Edit")
- ,(format " (%d) " remaining)
- ,title))))
-
-(defun org-fc-reset-header-line ()
- "Reset the header-line to its original value."
- (setq-local header-line-format org-fc-original-header-line-format))
-
;;; Contexts
(defvar org-fc-custom-contexts '()
diff --git a/org-fc-dashboard.el b/org-fc-dashboard.el
index be977af..38a7f8e 100644
--- a/org-fc-dashboard.el
+++ b/org-fc-dashboard.el
@@ -147,13 +147,13 @@ environment without svg support."
(dolist (value values)
(svg-rectangle svg pos 0 (* width (car value)) height :fill (cdr value))
(if (> (* width (car value)) (* 2 fontsize))
- (svg-text svg (format "%.1f" (* 100 (car value)))
- :font-size fontsize
- :fill "white"
- :font-weight "bold"
- :font-family "sans-serif"
- :x (+ pos 5)
- :y (+ fontsize (floor (- height fontsize) 2))))
+ (svg-text svg (format "%.1f" (* 100 (car value)))
+ :font-size fontsize
+ :fill "white"
+ :font-weight "bold"
+ :font-family "sans-serif"
+ :x (+ pos 5)
+ :y (+ fontsize (floor (- height fontsize) 2))))
(setq pos (+ pos (* width (car value)))))
(svg-image svg)))
diff --git a/org-fc-review.el b/org-fc-review.el
index 9339b7b..f41baeb 100644
--- a/org-fc-review.el
+++ b/org-fc-review.el
@@ -470,6 +470,31 @@ removed."
('easy (cl-incf (cl-getf ratings :easy) 1)))
(cl-incf (cl-getf ratings :total 1))))
+;;; Header Line
+
+(defvar org-fc-original-header-line-format nil
+ "`header-line-format' before it was set by org-fc.")
+
+(defun org-fc-set-header-line ()
+ "Set the header-line for review."
+ (let* ((remaining (1+ (length (oref org-fc-review--session cards))))
+ (current (oref org-fc-review--session current-item))
+ (title
+ (unless (member "notitle" (plist-get current :tags))
+ (plist-get current :filetitle))))
+ (setq org-fc-original-header-line-format header-line-format)
+ (setq-local
+ header-line-format
+ `((org-fc-review-flip-mode "Flip")
+ (org-fc-review-rate-mode "Rate")
+ (org-fc-review-edit-mode "Edit")
+ ,(format " (%d) " remaining)
+ ,title))))
+
+(defun org-fc-reset-header-line ()
+ "Reset the header-line to its original value."
+ (setq-local header-line-format org-fc-original-header-line-format))
+
;;; Modes
(defvar org-fc-review-flip-mode-map
diff --git a/org-fc.el b/org-fc.el
index 04f6bd4..f763607 100644
--- a/org-fc.el
+++ b/org-fc.el
@@ -26,20 +26,15 @@
;;
;;; Code:
-(require 'cl-lib)
-(require 'org-id)
-(require 'parse-time)
-(require 'subr-x)
-
(require 'org-fc-core)
(require 'org-fc-compat)
(require 'org-fc-awk)
-(require 'org-fc-cache)
(require 'org-fc-algo-sm2)
-(require 'org-fc-dashboard)
(require 'org-fc-review)
+(require 'org-fc-dashboard)
+(require 'org-fc-cache)
(require 'org-fc-type-normal)
(require 'org-fc-type-double)
diff --git a/tests/org-fc-filter-test.el b/tests/org-fc-filter-test.el
index 13c5dcd..3458c7b 100644
--- a/tests/org-fc-filter-test.el
+++ b/tests/org-fc-filter-test.el
@@ -60,8 +60,8 @@
(should
(org-fc-test-compare-ids
(org-fc-test-filter-index index '(and (tag "file1")
- (tag "file2")
- (tag "file3")))
+ (tag "file2")
+ (tag "file3")))
'(c-double c-cloze)))
;; Negation
@@ -74,5 +74,5 @@
(should
(org-fc-test-compare-ids
(org-fc-test-filter-index index '(and (not (type normal))
- (tag "file1")))
+ (tag "file1")))
'(c-double c-cloze)))))