diff options
author | Thanos Apollo <[email protected]> | 2024-08-03 19:11:18 +0300 |
---|---|---|
committer | Thanos Apollo <[email protected]> | 2024-08-03 19:11:18 +0300 |
commit | 05b2916cb9824134a9ce89d9b19c4d010aa73307 (patch) | |
tree | 6a9e4856149ade22b0a4154de9912d1eb952573c /gnosis-dashboard.el | |
parent | fdde698749edcae9e87a17f93f42aebd7d2afe3a (diff) |
New function: Add dashboard-mark-toggle.
* Mark current note at point, it's value is being stored at selected-ids.
Diffstat (limited to 'gnosis-dashboard.el')
-rw-r--r-- | gnosis-dashboard.el | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/gnosis-dashboard.el b/gnosis-dashboard.el index af22ac7..848f37f 100644 --- a/gnosis-dashboard.el +++ b/gnosis-dashboard.el @@ -432,6 +432,32 @@ DASHBOARD-TYPE: either 'Notes' or 'Decks' to display the respective dashboard." (gnosis-collect-note-ids :query (read-string "Search for note: ")))))) (tabulated-list-print t))) +(defun gnosis-dashboard-mark-toggle () + "Toggle mark on the current item in the tabulated-list." + (interactive) + (let ((inhibit-read-only t) + (entry (tabulated-list-get-entry)) + (id (tabulated-list-get-id))) + (if (derived-mode-p 'tabulated-list-mode) + (if entry + (let ((beg (line-beginning-position)) + (end (line-end-position)) + (overlays (overlays-in (line-beginning-position) (line-end-position)))) + (if (cl-some (lambda (ov) (overlay-get ov 'gnosis-mark)) overlays) + (progn + (remove-overlays beg end 'gnosis-mark t) + (setq gnosis-dashboard--selected-ids (remove id gnosis-dashboard--selected-ids)) + ;; (message "Unmarked: %s" (aref entry 0)) + ) + (let ((ov (make-overlay beg end))) + (setf gnosis-dashboard--selected-ids + (append gnosis-dashboard--selected-ids (list id))) + (overlay-put ov 'face 'highlight) + (overlay-put ov 'gnosis-mark t) + ;; (message "Marked: %s" (aref entry 0)) + ))) + (message "No entry at point")) + (message "Not in a tabulated-list-mode")))) (transient-define-prefix gnosis-dashboard-menu () "Transient buffer for gnosis dashboard interactions." |