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 ;; 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