Skip to content

Latest commit

 

History

History
111 lines (58 loc) · 2.22 KB

welcome.org

File metadata and controls

111 lines (58 loc) · 2.22 KB

Welcome back!

----- Yesterday’s report -----

<< Previous Reset Next >>

Page setup

(require 'org-clock)

;; Helper functions

(defun welcome-goto-clocktable ()
  "Helper function to move the point to the clocktable line."
  (goto-char (point-min))
  (search-forward "#+BEGIN: clocktable")
  (beginning-of-line))

(defun welcome-clocktable-previous ()
  (welcome-goto-clocktable)
  (org-clocktable-shift 'left 1))

(defun welcome-clocktable-next ()
  (welcome-goto-clocktable)
  (org-clocktable-shift 'right 1))

(defun welcome-get-initial-block ()
  (let* ((today (decode-time (current-time)))
	   (day-of-week (org-day-of-week (nth 3 today) (nth 4 today) (nth 5 today)))
	   (last-working-day (if (or (= day-of-week 1)) 3 1)))
    (format "today-%d" last-working-day)))

(defun welcome-clocktable-reset ()
  (let ((block (format ":block %s" (welcome-get-initial-block))))
    (welcome-goto-clocktable)
    (re-search-forward (rx ":block " (+ (not whitespace))))
    (replace-match block)
    (org-update-all-dblocks)))

;; Init clocktable

(save-excursion
  (welcome-goto-clocktable)
  (let* ((today (decode-time (current-time)))
	   (day-of-week (org-day-of-week (nth 3 today) (nth 4 today) (nth 5 today)))
	   (last-working-day (if (or (= day-of-week 1)) 3 1)))
    (search-forward "today-")
    (delete-char 1)
    (insert (number-to-string last-working-day))))

(org-update-all-dblocks)

;; Init projects

(save-excursion
  (goto-char (point-min))
  (search-forward "#+call: projects-template")
  (org-babel-execute-src-block nil (org-babel-lob-get-info)))

;; Finalization

(save-buffer)