summaryrefslogtreecommitdiff
path: root/gnosis.el
diff options
context:
space:
mode:
authorThanos Apollo <[email protected]>2024-03-03 02:28:02 +0200
committerThanos Apollo <[email protected]>2024-03-03 02:28:02 +0200
commitaacca17ea77fc3cda71ee950b9aa27a5a3e2d97a (patch)
treeecc8356572182fc6eea9e06175915cef00f19686 /gnosis.el
parentcbf93bf3b216dc356184d59c05d07b8e6c76aa21 (diff)
Add gnosis-dashboard-output-decks
Diffstat (limited to 'gnosis.el')
-rw-r--r--gnosis.el29
1 files changed, 29 insertions, 0 deletions
diff --git a/gnosis.el b/gnosis.el
index d3df6c1..840523b 100644
--- a/gnosis.el
+++ b/gnosis.el
@@ -1559,6 +1559,35 @@ name and all notes formatted as nested lists"
do (cl-remove-if (lambda (x) (and (vectorp x) (zerop (length x)))) item)
collect (prin1-to-string item)))
+(defun gnosis-dashboard-output-decks ()
+ "Return deck contents for gnosis dashboard."
+ (setq tabulated-list-format [("Name" 15 t)
+ ("failure-factor" 15 t)
+ ("ef-increase" 15 t)
+ ("ef-decrease" 15 t)
+ ("ef-threshold" 15 t)
+ ("Notes" 10 t)])
+ (tabulated-list-init-header)
+ (let ((max-id (apply 'max (gnosis-select 'id 'decks '1=1 t)))
+ (decks (gnosis-select 'name 'decks '1=1 t)))
+ (setq tabulated-list-entries
+ (cl-loop for id from 1 to max-id
+ for output = (gnosis-dashboard-output-deck id)
+ when output
+ collect (list (number-to-string id) (vconcat output)))))
+ (local-set-key (kbd "e") #'gnosis-dashboard-edit-deck)
+ (local-set-key (kbd "d") #'(lambda () (interactive) (gnosis-delete-deck
+ (string-to-number (tabulated-list-get-id)))
+ (gnosis-dashboard-output-decks)
+ (revert-buffer t t t)))
+ (local-set-key (kbd "a") #'(lambda () (interactive) (gnosis-add-deck (read-string "Deck name: "))
+ (gnosis-dashboard-output-decks)
+ (revert-buffer t t t)))
+ (local-set-key (kbd "s") #'(lambda () (interactive) (gnosis-suspend-deck
+ (string-to-number (tabulated-list-get-id)))
+ (gnosis-dashboard-output-decks)
+ (revert-buffer t t t))))
+
(defun gnosis-dashboard-edit-note ()
"Get note id from tabulated list and edit it."
(interactive)