aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Tom Willemse2022-10-25 23:18:55 -0700
committerGravatar Tom Willemse2022-10-25 23:18:55 -0700
commit7342368178da952926bbffe65470ea547960af14 (patch)
tree9eda3b7ca583e71a0287a50c7dc947179c0bf8a8
parent875e63d62a3190e916d42c488262d849a2d3d421 (diff)
downloademacs-config-7342368178da952926bbffe65470ea547960af14.tar.gz
emacs-config-7342368178da952926bbffe65470ea547960af14.zip
[oni-org] Add functions to create and update a Pomodoro overview
This is meant to be used as a daily overview of the Pomodoro's that I've gone through during the day. Should be put in my journal. For that reason, and because I haven't figured out how to make it idempotent on days that aren't today, I've added an exclusion of ‘journal.org’ to the ‘oni-org-update-all-dblocks-live’ function.
-rw-r--r--oni-org/oni-org.el46
1 files changed, 44 insertions, 2 deletions
diff --git a/oni-org/oni-org.el b/oni-org/oni-org.el
index 8e0d741..fc1f1f0 100644
--- a/oni-org/oni-org.el
+++ b/oni-org/oni-org.el
@@ -4,7 +4,7 @@
;; Author: Tom Willemse <tom@ryuslash.org>
;; Keywords: local
-;; Version: 2022.1019.224918
+;; Version: 2022.1025.230035
;; Package-Requires: (oni-yasnippet oni-alert oni-hydra org org-contrib org-bullets org-edna diminish all-the-icons olivetti form-feed)
;; This program is free software; you can redistribute it and/or modify
@@ -476,7 +476,8 @@ also move point to the start of the heading."
(defun oni-org-update-all-dblocks-live ()
"Call ‘org-update-all-dblocks’ if the current file isn't an archive file."
- (if (not (string-suffix-p "_archive" (buffer-file-name)))
+ (if (not (or (string-suffix-p "_archive" (buffer-file-name))
+ (string= "journal.org" (buffer-file-name))))
(org-update-all-dblocks)))
(setq org-todo-keywords
@@ -941,5 +942,46 @@ placed above TARGET. Otherwise it will be placed below it."
(goto-char (point-max))))
(org-paste-subtree heading-level nil nil t))))
+;;; Pomodoro dynamic block
+
+(defun oni-org-dblock-write-pomodoro-overview (params)
+ (let* ((date (plist-get params :date))
+ (info (org-map-entries (lambda ()
+ (let ((components (org-heading-components)))
+ (list (cons 'done (and (org-entry-is-done-p) t))
+ (cons 'title (nth 4 components))
+ (cons 'poms (string-to-number (or (alist-get "POMS" (org-entry-properties) nil nil #'string=) "0")))
+ (cons 'id (org-id-get-create)))))
+ (format "TODO=\"NEXT\"|CLOSED>=\"<%s 0:00>\"+CLOSED<=\"<%s 23:59>\""
+ date date)
+ 'agenda)))
+ (insert
+ (string-trim-right
+ (apply #'concat "| | Task | Effort |\n"
+ "|-+------+--------|\n"
+ (mapcar (lambda (itm)
+ (let ((emphasis (if (alist-get 'done itm) "+" ""))
+ (title (alist-get 'title itm)))
+ (format "| | %s[[id:%s][%s]]%s | %s |\n"
+ emphasis
+ (alist-get 'id itm)
+ (if (> (length title) 60)
+ (format "%s..." (substring title 0 57))
+ title)
+ emphasis
+ (make-string (alist-get 'poms itm) ?X))))
+ info))))
+ (org-table-align)))
+
+(defun oni-org-insert-pomodoro-overview ()
+ "Create a dynamic block showing the Pomodoro overview for today."
+ (interactive)
+ (org-create-dblock `(:name "oni-pomodoro-overview"
+ :date ,(format-time-string "%Y-%m-%d")))
+ (org-update-dblock))
+
+(defalias 'org-dblock-write:oni-pomodoro-overview 'oni-org-dblock-write-pomodoro-overview)
+(org-dynamic-block-define "oni-pomodoro-overview" #'oni-org-insert-pomodoro-overview)
+
(provide 'oni-org)
;;; oni-org.el ends here