Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ doing something like:

The budgets table can be toggled using <kbd>V</kbd> 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.

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! :-)
Expand Down
26 changes: 24 additions & 2 deletions org-time-budgets.el
Original file line number Diff line number Diff line change
Expand Up @@ -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.")

Expand Down Expand Up @@ -108,20 +114,36 @@ 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)))
(workday (org-time-budgets-time `(:match ,match :block today)))
(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)
(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 ()
Expand Down