From 352b2b4aa8658965e67855cd0e9b698c299b6a23 Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Sun, 16 Jun 2024 20:29:04 +0300 Subject: Add gnosis-review-action--edit --- gnosis.el | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/gnosis.el b/gnosis.el index 0d815d9..b7bd513 100644 --- a/gnosis.el +++ b/gnosis.el @@ -1324,6 +1324,18 @@ 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-action--edit (success note note-count) + "Edit NOTE during review. + +Save current contents of *gnosis-edit* buffer, if any, and start +editing NOTE with it's new contents. + +After done editing, call `gnosis-review-actions' with SUCCESS NOTE +NOTE-COUNT." + (gnosis-edit-save-exit) + (gnosis-edit-note note t) + (recursive-edit) + (gnosis-review-actions success note note-count)) (defun gnosis-review-actions (success note note-count) "Specify action during review of note. -- cgit v1.2.3 From b573f1d2238976e0d8d8e17737a0ce290b7465f3 Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Sun, 16 Jun 2024 20:29:38 +0300 Subject: Add gnosis-review-action--quit --- gnosis.el | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/gnosis.el b/gnosis.el index b7bd513..0c16c25 100644 --- a/gnosis.el +++ b/gnosis.el @@ -1336,6 +1336,18 @@ NOTE-COUNT." (gnosis-edit-note note t) (recursive-edit) (gnosis-review-actions success note note-count)) + +(defun gnosis-review-action--quit (success note note-count) + "Quit review session. + +Update result for NOTE review with SUCCESS and commit session for NOTE-COUNT. + +This function should be used with `gnosis-review-actions', to finish +the review session." + (gnosis-review-result note success) + (gnosis-review-commit note-count) + ;; Break the loop of `gnosis-review-session' + (throw 'stop-loop t)) (defun gnosis-review-actions (success note note-count) "Specify action during review of note. -- cgit v1.2.3 From 8d31b7883a19b513dca76572c97f710f27bd1e74 Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Sun, 16 Jun 2024 20:29:48 +0300 Subject: Add gnosis-review-action--suspend --- gnosis.el | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/gnosis.el b/gnosis.el index 0c16c25..00af476 100644 --- a/gnosis.el +++ b/gnosis.el @@ -1348,6 +1348,15 @@ the review session." (gnosis-review-commit note-count) ;; Break the loop of `gnosis-review-session' (throw 'stop-loop t)) + +(defun gnosis-review-action--suspend (success note note-count) + "Suspend/Unsuspend NOTE. + +This function should be used with `gnosis-review-actions', which +should be recursively called using SUCCESS, NOTE, NOTE-COUNT." + (gnosis-suspend-note note) + (gnosis-review-actions success note note-count)) + (defun gnosis-review-actions (success note note-count) "Specify action during review of note. -- cgit v1.2.3 From 772e4aec801da45b40a7ca41533346e4f2751acc Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Sun, 16 Jun 2024 20:30:15 +0300 Subject: Add gnosis-review-action--override --- gnosis.el | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/gnosis.el b/gnosis.el index 00af476..1c56c24 100644 --- a/gnosis.el +++ b/gnosis.el @@ -1357,6 +1357,15 @@ should be recursively called using SUCCESS, NOTE, NOTE-COUNT." (gnosis-suspend-note note) (gnosis-review-actions success note note-count)) +(defun gnosis-review-action--override (success note note-count) + "Override current review result for SUCCESS. + +This function should be used with `gnosis-review-actions', which will +be called with new SUCCESS value plus NOTE & NOTE-COUNT." + (setf success (if success nil t)) + (gnosis-display-next-review note success) + (gnosis-review-actions success note note-count)) + (defun gnosis-review-actions (success note note-count) "Specify action during review of note. -- cgit v1.2.3 From 9b0415cf7590d0185d76fc99f454b4069e77b83a Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Sun, 16 Jun 2024 20:31:07 +0300 Subject: Refactor gnosis-review-actions Use gnosis-review-action--FUNC functions, breaking this into smaller parts & ensuring everything works properly. --- gnosis.el | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/gnosis.el b/gnosis.el index 1c56c24..48aa652 100644 --- a/gnosis.el +++ b/gnosis.el @@ -1380,17 +1380,10 @@ NOTE-COUNT: Total notes reviewed" (?e "edit") (?q "quit")))) (?n (gnosis-review-result 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-result note success) - (gnosis-review-commit note-count) - ;; Break the loop of `gnosis-review-session' - (throw 'stop-loop t)))) + (?o (gnosis-review-action--override success note note-count)) + (?s (gnosis-review-action--suspend success note note-count)) + (?e (gnosis-review-action--edit success note note-count)) + (?q (gnosis-review-action--quit success note note-count)))) (defun gnosis-review-session (notes) "Start review session for NOTES. -- cgit v1.2.3 From 8b24e05f6f02cad2063673271f199b268406a408 Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Sun, 16 Jun 2024 20:33:21 +0300 Subject: [fix] gnosis-edit-save-exit: Adjust for existing *gnosis-edit* buffers This should allow to call gnosis-edit-save-exit at the start of gnosis-edit-* functions. If a user had forgotten to save previous changes this would have caused an error before. --- gnosis.el | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/gnosis.el b/gnosis.el index 48aa652..6394b03 100644 --- a/gnosis.el +++ b/gnosis.el @@ -1539,10 +1539,12 @@ INITIAL-INTERVAL: Initial interval for notes of deck" (cl-defun gnosis-edit-save-exit (&optional exit-func &rest args) "Save edits and exit using EXIT-FUNC, with ARGS." (interactive) - (eval-buffer) - (quit-window t) - (when exit-func - (apply exit-func args))) + (when (get-buffer "*gnosis-edit*") + (switch-to-buffer "*gnosis-edit*") + (eval-buffer) + (quit-window t) + (when exit-func + (apply exit-func args)))) (defvar-keymap gnosis-edit-mode-map :doc "gnosis-edit keymap" -- cgit v1.2.3