diff options
author | Thanos Apollo <[email protected]> | 2024-07-23 17:58:16 +0300 |
---|---|---|
committer | Thanos Apollo <[email protected]> | 2024-07-23 18:36:16 +0300 |
commit | 2afc62757d40b3420bf3ff0cda34d7fc9324c35e (patch) | |
tree | 60a1db0904079d0ecf1984a125cc874a252eea47 /gnosis-dashboard.el | |
parent | 09b600b75ad94b82bedc73262797fa88efac4be0 (diff) |
New function: dashboard-reviews-graph
* Create a github-like heatmap for month DATES.
This is still under review!
Diffstat (limited to 'gnosis-dashboard.el')
-rw-r--r-- | gnosis-dashboard.el | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/gnosis-dashboard.el b/gnosis-dashboard.el index 35dbdfe..d42b759 100644 --- a/gnosis-dashboard.el +++ b/gnosis-dashboard.el @@ -105,6 +105,29 @@ Skips days where no note was reviewed." (propertize string 'face 'shadow)) ((> num 0) (propertize string 'face 'font-lock-constant-face)))) + +(defun gnosis-dashboard-reviews-graph (dates &optional remove-spaces) + "Insert graph for month DATES. + +Optionally, use REMOVE-SPACES when using multiple months." + (let ((count 0) + (insert-column (current-column))) + (cl-loop for day in dates + when (= count 0) + do (let ((current-column (current-column))) + (and (< (move-to-column insert-column) insert-column) + ;; TODO: Rewrite this! + (insert (make-string (- (- insert-column current-column) remove-spaces) ?\s)))) + (insert " ") + do (end-of-line) + (insert (gnosis-dashboard--graph-propertize (format "[%s] " (if (= day 0) "-" "x")) day)) + (cl-incf count) + when (= count 7) + do (setq count 0) + (end-of-line) + (when (and (/= (forward-line 1) 0) (eobp)) + (insert "\n") + (forward-line 0))))) (defun gnosis-dashboard-output-note (id) "Output contents for note with ID, formatted for gnosis dashboard." (cl-loop for item in (append (gnosis-select '[main options answer tags type] 'notes `(= id ,id) t) |