From 51be603b7bf819b34864403fb3b913186cbaf2bd Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Tue, 6 Feb 2024 15:02:20 +0200 Subject: Add gnosis-push-command --- gnosis.el | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'gnosis.el') diff --git a/gnosis.el b/gnosis.el index 93bdb61..587b64d 100644 --- a/gnosis.el +++ b/gnosis.el @@ -74,6 +74,11 @@ between two strings to consider them as similar." :type 'integer :group 'gnosis) +(defcustom gnosis-push-command nil + "Command to run to push " + :type 'string + group 'gnosis) + (defvar gnosis-images-dir (expand-file-name "images" gnosis-dir) "Gnosis images directory.") -- cgit v1.2.3 From 732ee3d5882fdcac7a753afe3030535abdf88912 Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Thu, 8 Feb 2024 18:25:41 +0200 Subject: gnosis.el: Refactor for new success value, t or nil First implementation of gnosis ef was supposed to take a "quality" value of 0 to 3 for reviews, which was never actually implemented. --- gnosis.el | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'gnosis.el') diff --git a/gnosis.el b/gnosis.el index 587b64d..ee79398 100644 --- a/gnosis.el +++ b/gnosis.el @@ -855,7 +855,8 @@ well." (defun gnosis-review--algorithm (id success) "Return next review date & ef for note with value of id ID. -SUCCESS is a binary value, 1 = success, 0 = failure. +SUCCESS is a boolean value, t for success, nil for failure. + Returns a list of the form ((yyyy mm dd) ef)." (let ((ff gnosis-algorithm-ff) (ef (nth 2 (gnosis-get 'ef 'review `(= id ,id)))) @@ -890,8 +891,8 @@ such as the easiness factor (ef)." (defun gnosis-review-new-ef (id success) "Return new ef for note with value of id ID. -SUCCESS is a binary value, 1 = success, 0 = failure. -Returns a list of the form (ef-increase ef-decrease ef)." +Returns a list of the form (ef-increase ef-decrease ef). +SUCCESS is a boolean value, t for success, nil for failure." (let ((ef (nth 1 (gnosis-review--algorithm id success))) (old-ef (gnosis-get 'ef 'review `(= id ,id)))) (cl-substitute (gnosis-review-round ef) (nth 2 old-ef) old-ef))) @@ -924,9 +925,9 @@ SUCCESS is a binary value, 1 is for successful review." (user-choice (gnosis-mcq-answer id))) (if (string= answer user-choice) (progn - (gnosis-review--update id 1) + (gnosis-review--update id t) (message "Correct!")) - (gnosis-review--update id 0) + (gnosis-review--update id nil) (message "False")) (gnosis-display-correct-answer-mcq answer user-choice) (gnosis-display-extra id) @@ -942,7 +943,7 @@ SUCCESS is a binary value, 1 is for successful review." (success (gnosis-compare-strings answer user-input))) (gnosis-display-basic-answer answer success user-input) (gnosis-display-extra id) - (gnosis-review--update id (if success 1 0)) + (gnosis-review--update id success) (gnosis-display-next-review id))) (defun gnosis-review-y-or-n (id) @@ -955,7 +956,7 @@ SUCCESS is a binary value, 1 is for successful review." (success (equal answer user-input))) (gnosis-display-y-or-n-answer :answer answer :success success) (gnosis-display-extra id) - (gnosis-review--update id (if success 1 0)) + (gnosis-review--update id success) (gnosis-display-next-review id))) (defun gnosis-review-cloze--input (cloze) @@ -995,10 +996,10 @@ Used to reveal all clozes left with `gnosis-face-cloze-unanswered' face." ;; clozes. (when (< num clozes-num) (gnosis-review-cloze-reveal-unaswered clozes)) (gnosis-display-cloze-user-answer (cdr input)) - (gnosis-review--update id 0) + (gnosis-review--update id nil) (cl-return))) ;; Update note after all clozes are revealed successfully - finally (gnosis-review--update id 1))) + finally (gnosis-review--update id t))) (gnosis-display-extra id) (gnosis-display-next-review id)) -- cgit v1.2.3 From 268c5f35ba45364d93dcebe3854e8763efa55923 Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Thu, 8 Feb 2024 18:28:02 +0200 Subject: [FIX] gnosis-review--update: Fix next interval This fixes a bug for input the wrong value for success when calculating the next interval & refactors to use new boolean value for success. --- gnosis.el | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'gnosis.el') diff --git a/gnosis.el b/gnosis.el index ee79398..88655cf 100644 --- a/gnosis.el +++ b/gnosis.el @@ -900,15 +900,16 @@ SUCCESS is a boolean value, t for success, nil for failure." (defun gnosis-review--update (id success) "Update review-log for note with value of id ID. -SUCCESS is a binary value, 1 is for successful review." - (let ((ef (gnosis-review-new-ef id success))) +SUCCESS is a boolean value, t for success, nil for failure." + (let ((ef (gnosis-review-new-ef id success)) + (next-rev (car (gnosis-review--algorithm id success)))) ;; Update review-log (gnosis-update 'review-log `(= last-rev ',(gnosis-algorithm-date)) `(= id ,id)) - (gnosis-update 'review-log `(= next-rev ',(car (gnosis-review--algorithm id success))) `(= id ,id)) + (gnosis-update 'review-log `(= next-rev ',next-rev) `(= id ,id)) (gnosis-update 'review-log `(= n (+ 1 ,(gnosis-get 'n 'review-log `(= id ,id)))) `(= id ,id)) ;; Update review (gnosis-update 'review `(= ef ',ef) `(= id ,id)) - (if (= success 1) + (if success (progn (gnosis-update 'review-log `(= c-success ,(1+ (gnosis-get 'c-success 'review-log `(= id ,id)))) `(= id ,id)) (gnosis-update 'review-log `(= t-success ,(1+ (gnosis-get 't-success 'review-log `(= id ,id)))) `(= id ,id)) (gnosis-update 'review-log `(= c-fails 0) `(= id ,id))) -- cgit v1.2.3 From 006de80905d9628e51687975c08d2a080adc5ca4 Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Thu, 8 Feb 2024 18:29:11 +0200 Subject: Add gnosis-auto-push Boolean value, when t auto pushes with git --- gnosis.el | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'gnosis.el') diff --git a/gnosis.el b/gnosis.el index 88655cf..dcc6450 100644 --- a/gnosis.el +++ b/gnosis.el @@ -74,10 +74,10 @@ between two strings to consider them as similar." :type 'integer :group 'gnosis) -(defcustom gnosis-push-command nil - "Command to run to push " - :type 'string - group 'gnosis) +(defcustom gnosis-auto-push nil + "Automatically run `git push' at the end of every review session." + :type 'boolean + :group 'gnosis) (defvar gnosis-images-dir (expand-file-name "images" gnosis-dir) "Gnosis images directory.") @@ -1036,6 +1036,8 @@ NOTE-NUM: The number of notes reviewed in the session." (shell-command (concat git " add " (shell-quote-argument "gnosis.db"))) (shell-command (concat git " commit -m " (shell-quote-argument (concat (format "Total notes for session: %d " note-num))))) + (when gnosis-auto-push + (shell-command (concat git " push"))) (message "Review session finished. %d notes reviewed." note-num))) (defun gnosis-review--session (notes) -- cgit v1.2.3 From 36830b3f388413e2e3de188ced22e9f1368a9d4a Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Thu, 8 Feb 2024 18:39:02 +0200 Subject: Version bump: 0.1.6 --- gnosis.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gnosis.el') diff --git a/gnosis.el b/gnosis.el index dcc6450..7641a1b 100644 --- a/gnosis.el +++ b/gnosis.el @@ -5,7 +5,7 @@ ;; Author: Thanos Apollo ;; Keywords: extensions ;; URL: https://git.thanosapollo.org/gnosis -;; Version: 0.1.5 +;; Version: 0.1.6 ;; Package-Requires: ((emacs "27.2") (compat "29.1.4.2") (emacsql "20240124")) -- cgit v1.2.3