summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThanos Apollo <[email protected]>2024-03-03 02:25:22 +0200
committerThanos Apollo <[email protected]>2024-03-03 02:25:22 +0200
commit70aac53df16e3cf4321f68ebe8e1fcded4abf4c3 (patch)
tree56de2c1f11d98fb9eff6ad08702fa4f0779d71ae
parentfc94a7ff9f26df967b9ff5744c9c2305ed474304 (diff)
gnosis-dashboard-output-notes: Rewrite
- Specify tabulated-list-format - Fix bug, when a note was deleted it would have broken the dashboard - Specify keybindings using local-set-key
-rw-r--r--gnosis.el19
1 files changed, 17 insertions, 2 deletions
diff --git a/gnosis.el b/gnosis.el
index f88a1f2..d973d64 100644
--- a/gnosis.el
+++ b/gnosis.el
@@ -1526,8 +1526,23 @@ name and all notes formatted as nested lists"
(defun gnosis-dashboard-output-notes ()
"Return note contents for gnosis dashboard."
(let ((max-id (apply 'max (gnosis-select 'id 'notes '1=1 t))))
- (cl-loop for id from 1 to max-id collect
- (list (number-to-string id) (vconcat (gnosis-dashboard-output-note id))))))
+ (setq tabulated-list-format [("Main" 30 t)
+ ("Options" 20 t)
+ ("Answer" 25 t)
+ ("Tags" 25 t)
+ ("Type" 10 t)
+ ("Suspend" 2 t)])
+ (tabulated-list-init-header)
+ (setf tabulated-list-entries
+ (cl-loop for id from 1 to max-id
+ for output = (gnosis-dashboard-output-note id)
+ when output
+ collect (list (number-to-string id) (vconcat output))))
+ (local-set-key (kbd "e") #'gnosis-dashboard-edit-note)
+ (local-set-key (kbd "s") #'(lambda () (interactive) (gnosis-suspend-note
+ (string-to-number (tabulated-list-get-id)))
+ (gnosis-dashboard-output-notes)
+ (revert-buffer t t t)))))
(defun gnosis-dashboard-edit-note ()
"Get note id from tabulated list and edit it."