diff options
author | Thanos Apollo <[email protected]> | 2024-01-19 15:21:12 +0200 |
---|---|---|
committer | Thanos Apollo <[email protected]> | 2024-01-19 15:21:12 +0200 |
commit | e5a9b268fe7534f0fc84d71207d885de2375a4f4 (patch) | |
tree | 8f07d543568885b7d4e9d7b87a0c023545a6a36c | |
parent | ade0963b47283ddf00dc37398e42d676646e129a (diff) |
Refactor gnosis-review-note
Simarly to gnosis-add-note recent changes, more extensible & flexible.
This makes it easier to maintain & add new note types in the future.
-rw-r--r-- | gnosis.el | 23 |
1 files changed, 11 insertions, 12 deletions
@@ -998,18 +998,17 @@ Used to reveal all clozes left with `gnosis-face-cloze-unanswered' face." (defun gnosis-review-note (id) "Start review for note with value of id ID, if note is unsuspended." - (cond ((gnosis-suspended-p id) - (message "Note is suspended.")) - (t - (with-current-buffer (switch-to-buffer (get-buffer-create "*gnosis*")) - (let ((type (gnosis-get 'type 'notes `(= id ,id)))) - (gnosis-mode) - (pcase type - ("mcq" (gnosis-review-mcq id)) - ("basic" (gnosis-review-basic id)) - ("cloze" (gnosis-review-cloze id)) - ("y-or-n" (gnosis-review-y-or-n id)) - (_ (error "Malformed note type")))))))) + (when (gnosis-suspended-p id) + (message "Suspended note with id: %s" id) + (sit-for 0.3)) ;; this should only occur in testing/dev cases + (let* ((type (gnosis-get 'type 'notes `(= id ,id))) + (func-name (intern (format "gnosis-review-%s" (downcase type))))) + (if (fboundp func-name) + (progn + (with-current-buffer (switch-to-buffer (get-buffer-create "*gnosis*")) + (gnosis-mode) + (funcall func-name id))) + (error "Malformed note type: '%s'" type)))) (defun gnosis-review-commit (note-num) "Commit review session on git repository. |