summaryrefslogtreecommitdiff
path: root/gnosis.el
diff options
context:
space:
mode:
authorThanos Apollo <[email protected]>2024-08-06 23:51:51 +0300
committerThanos Apollo <[email protected]>2024-08-06 23:51:51 +0300
commit37f8a26b38b7234f3aef5031662e1f6a2ab1af95 (patch)
tree99b44f11db8699f16f671ebad856c82390286691 /gnosis.el
parent53cb07663067ab28c8b210cd008b74de3ae01d94 (diff)
New function: get-custom-values: Return custom review values.
* Returns custom values to adjust gnosis algorithm for each deck and tag
Diffstat (limited to 'gnosis.el')
-rw-r--r--gnosis.el14
1 files changed, 14 insertions, 0 deletions
diff --git a/gnosis.el b/gnosis.el
index a39d08b..6c69b98 100644
--- a/gnosis.el
+++ b/gnosis.el
@@ -1977,6 +1977,20 @@ SUSPEND: Suspend note, 0 for unsuspend, 1 for suspend"
(gnosis-update 'notes `(= ,field ',value) `(= id ,id)))
(t (gnosis-update 'notes `(= ,field ,value) `(= id ,id))))))
+(defun gnosis-get-custom-values (key search-value &optional values)
+ "Return SEARCH-VALUE for KEY from VALUES.
+
+VALUES: Defaults to `gnosis-custom-values'."
+ (cl-assert (or (eq key :deck) (eq key :tag)) nil "Key value must be either :tag or :deck")
+ (cl-assert (stringp search-value) nil "Search-value must be a string, the name of tag or deck.")
+ (let ((results)
+ (values (or values gnosis-custom-values)))
+ (dolist (rule values)
+ (when (and (plist-get rule key)
+ (equal (plist-get rule key) search-value))
+ (setq results (append results (nth 2 rule)))))
+ results))
+
(defun gnosis-get-date-total-notes (&optional date)
"Return total notes reviewed for DATE.