From f354a7dc077b36393efdd1c024f8f1d9d4390ed0 Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Thu, 9 May 2024 23:15:11 +0300 Subject: [Refactor] Add gnosis-review-actions Seperate actions to take during review of gnosis note. Use recursion to be able to do more than one action, e.g edit & then override note. --- gnosis.el | 41 +++++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/gnosis.el b/gnosis.el index 9797c16..4ed7b11 100644 --- a/gnosis.el +++ b/gnosis.el @@ -1274,6 +1274,30 @@ NOTE-NUM: The number of notes reviewed in the session." (gnosis-vc-push)) (message "Review session finished. %d notes reviewed." note-num))) +(defun gnosis-review-actions (success note note-count) + "Specify action during review of note. + +SUCCESS: Review result +NOTE: Note ID +NOTE-COUNT: Total notes reviewed" + (pcase (car (read-multiple-choice + "Note actions" + '((?n "next") + (?o "override") + (?s "suspend") + (?e "edit") + (?q "quit")))) + (?n (gnosis-review--update note success)) + (?o (setf success (if success nil t)) + (gnosis-display-next-review note success) + (gnosis-review-actions success note note-count)) + (?s (gnosis-suspend-note note)) + (?e (gnosis-edit-note note t) + (recursive-edit) + (gnosis-review-actions success note note-count)) + (?q (gnosis-review--update note success) + (gnosis-review-commit note-count) + (cl-return)))) (defun gnosis-review--session (notes) "Start review session for NOTES. @@ -1286,22 +1310,7 @@ NOTES: List of note ids" (cl-loop for note in notes do (let ((success (gnosis-review-note note))) (setf note-count (1+ note-count)) - (pcase (car (read-multiple-choice - "Note actions" - '((?n "next") - (?o "override") - (?s "suspend") - (?e "edit") - (?q "quit")))) - (?n (gnosis-review--update note success)) - (?o (gnosis-review-override note success)) - (?s (gnosis-suspend-note note)) - (?e (gnosis-review--update note success) - (gnosis-edit-note note t) - (recursive-edit)) - (?q (gnosis-review--update note success) - (gnosis-review-commit note-count) - (cl-return))) + (gnosis-review-actions success note note-count) (setq gnosis-due-notes-total (length (gnosis-review-get-due-notes)))) finally (gnosis-review-commit note-count)))))) -- cgit v1.2.3