From d58221c10332b7e695108d4fa8b4c85c6fcd62c5 Mon Sep 17 00:00:00 2001 From: fpi Date: Fri, 31 Jul 2020 19:43:00 +0200 Subject: [PATCH 1/2] Add an option to hide workday blocks on weekends --- README.md | 5 +++++ org-time-budgets.el | 21 ++++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8c8fa7a..5471119 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,11 @@ doing something like: The budgets table can be toggled using V in the agenda. +## Adjusting display of the budget table + +With the variable `org-time-budgets-hide-on-weekend` you can control +whether or not `workday` blocks are also displayed on weekends. + ## Contribute I don't want this thing to die. And I would like to learn cool stuff! :-) diff --git a/org-time-budgets.el b/org-time-budgets.el index 3f87520..1ad6677 100644 --- a/org-time-budgets.el +++ b/org-time-budgets.el @@ -50,6 +50,12 @@ See this example: :group 'org-time-budgets :type 'list) +(defcustom org-time-budgets-hide-on-weekend t + "If t hide `workday' blocks on weekends as defined by +`org-agenda-weekend-days'." + :group 'org-time-budgets + :type 'boolean) + (defvar org-time-budgets-show-budgets t "If non-nil, show time-budgets in agenda buffers.") @@ -108,6 +114,16 @@ See this example: (org-clock-get-table-data file filters)))) (org-agenda-files)))) +(defun org-time-budgets-weekend-p (&optional time) + "Return t if TIME is on a weekend day. + +Weekends are defined as in `org-agenda-weekend-days'. When TIME +is not provided `(current-time)' is used." + (let ((day (decoded-time-weekday + (decode-time + (or time (current-time)))))) + (member day org-agenda-weekend-days))) + (defun org-time-budgets-format-block (block) (let ((current (case block (day (org-time-budgets-time `(:match ,match :block today))) @@ -115,7 +131,10 @@ See this example: (week (org-time-budgets-time `(:match ,match :tstart ,tstart-s :tend ,tend-s))))) (budget (case block (day (/ range-budget 7)) - (workday (/ range-budget 5)) + (workday (if (and org-time-budgets-hide-on-weekend + (org-time-budgets-weekend-p)) + nil + (/ range-budget 5))) (week range-budget)))) (if (and current budget) (format "[%s] %s / %s" From 439e73b730a9e9434c93b3b1892780e5d128246a Mon Sep 17 00:00:00 2001 From: fpi Date: Fri, 31 Jul 2020 19:53:45 +0200 Subject: [PATCH 2/2] Display only the clocked time if budget is zero --- README.md | 4 ++++ org-time-budgets.el | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5471119..b612a00 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,10 @@ The budgets table can be toggled using V in the agenda. With the variable `org-time-budgets-hide-on-weekend` you can control whether or not `workday` blocks are also displayed on weekends. +If you set the budget to zero only the clocked time is shown in the +budgets table. You can use this as a simplified clock table. For +example to track time spent on distractions. + ## Contribute I don't want this thing to die. And I would like to learn cool stuff! :-) diff --git a/org-time-budgets.el b/org-time-budgets.el index 1ad6677..7747854 100644 --- a/org-time-budgets.el +++ b/org-time-budgets.el @@ -137,10 +137,13 @@ is not provided `(current-time)' is used." (/ range-budget 5))) (week range-budget)))) (if (and current budget) + (if (eq budget 0) + (format " %s " + (org-time-budgets-minutes-to-string current)) (format "[%s] %s / %s" (org-time-budgets-bar 14 current budget) (org-time-budgets-minutes-to-string current) - (org-time-budgets-minutes-to-string budget)) + (org-time-budgets-minutes-to-string budget))) " "))) (defun org-time-budgets-table ()