From c2bd634d455b06ce38f1cf04a60609c047aa47c4 Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Fri, 5 Jul 2024 05:48:43 +0300 Subject: Add gnosis-review-keybindings Making action keybindings customizable. --- gnosis.el | 40 +++++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/gnosis.el b/gnosis.el index 10c54d4..532691f 100644 --- a/gnosis.el +++ b/gnosis.el @@ -107,6 +107,19 @@ When nil, the image will be displayed at its original size." :type 'integer :group 'gnosis) +(defcustom gnosis-review-keybindings + '((?n . "next") + (?o . "override") + (?s . "suspend") + (?e . "edit") + (?q . "quit")) + "List of action bindings for `gnosis-review-actions'. + +Each element should be a list of a single character (the key), +a string describing the action." + :type '(alist :key-type character :value-type string) + :group 'gnosis) + (defvar gnosis-images-dir (expand-file-name "images" gnosis-dir) "Gnosis images directory.") @@ -1563,19 +1576,20 @@ be called with new SUCCESS value plus NOTE & NOTE-COUNT." 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-result note success)) - (?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)))) +NOTE-COUNT: Total notes reviewed + +To customize the keybindings, adjust `gnosis-review-keybindings'." + (let* ((choices (mapcar (lambda (pair) + (list (car pair) (cdr pair))) + gnosis-review-keybindings)) + (choice (car (read-multiple-choice "Note actions" choices))) + (action (alist-get choice gnosis-review-keybindings))) + (pcase action + ("next" (gnosis-review-result note success)) + ("override" (gnosis-review-action--override success note note-count)) + ("suspend" (gnosis-review-action--suspend success note note-count)) + ("edit" (gnosis-review-action--edit success note note-count)) + ("quit" (gnosis-review-action--quit success note note-count))))) (defun gnosis-review-session (notes) "Start review session for NOTES. -- cgit v1.2.3