summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThanos Apollo <[email protected]>2024-01-03 07:01:47 +0200
committerThanos Apollo <[email protected]>2024-01-03 07:10:23 +0200
commitdb1ca87f10a402c28b1abd1c3db8ceaaaf45666f (patch)
treeef1ad0d956ebb973889c82fc74127846a71a9c6e
parent511a4fa54ca7c7ef38a2e9c923b9de194029fd72 (diff)
Add gnosis-edit-ef
Edit easiness factor values and update them on gnosis-db.
-rw-r--r--gnosis.el19
1 files changed, 19 insertions, 0 deletions
diff --git a/gnosis.el b/gnosis.el
index d114ddc..b9d1d8e 100644
--- a/gnosis.el
+++ b/gnosis.el
@@ -866,6 +866,25 @@ NOTE-NUM: The number of notes reviewed in the session."
finally (gnosis-review-commit note-count)))))
+;; Change values
+
+(defun gnosis-edit-ef (id)
+ "Edit easiness factor values for note with id value ID."
+ (let ((ef-full (caar (gnosis-select 'ef 'review `(= id ,id))))
+ (old-value-index (pcase (completing-read "Change Factor: " '("Increase" "Decrease" "Total"))
+ ("Total" 2)
+ ("Decrease" 1)
+ ("Increase" 0)))
+ (new-value (float (string-to-number (read-string "New value: ")))))
+ ;; error checking.
+ (cond ((>= 0 new-value) (error "New value needs to be a number & higher than `0'"))
+ ;; Check if when total-ef is selected, new value is higher than 1.3
+ ((and (>= 1.3 new-value) (= old-value-index 2) (error "New total ef needs to be higher than `1.3'"))))
+ ;; Use `gnosis-replace-item-at-index' to generate new list with
+ ;; new ef value. Change ef value at gnosis-db using
+ ;; `gnosis-update'
+ (gnosis-update 'review `(= ef ',(gnosis-replace-item-at-index old-value-index new-value ef-full)) `(= id ,id))))
+
;;;###autoload
(defun gnosis-review ()
"Start gnosis review session."