|
|
|
|
@ -49,7 +49,8 @@
|
|
|
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
|
|
|
|
|
;; TODOS:
|
|
|
|
|
;; TODOS: Buffer kill hook not triggered on exit?
|
|
|
|
|
;;
|
|
|
|
|
;;
|
|
|
|
|
;; ERROR: timer shutdown seems to leave things in a wrong state and buffer doesn't die properly
|
|
|
|
|
;; Check on the logic of push-current, needs predicates rather than lazy if conditions
|
|
|
|
|
@ -379,30 +380,37 @@ Note, if there is no tacc-buffer then you shouldn't be touching tacc-info"
|
|
|
|
|
(time-add start-ts
|
|
|
|
|
(if (eq state 'work)
|
|
|
|
|
(tacc-work-period cycle)
|
|
|
|
|
(tacc-break-period cycle)))))
|
|
|
|
|
(if (eq state 'break)
|
|
|
|
|
(tacc-break-period cycle))
|
|
|
|
|
0))))
|
|
|
|
|
|
|
|
|
|
;; 05.3 State manipulation
|
|
|
|
|
|
|
|
|
|
(defun tacc-tick ()
|
|
|
|
|
"Time marches on. Called every second while a tacc timer is running"
|
|
|
|
|
(let* ((now (current-time))
|
|
|
|
|
(state (alist-get 'state tacc-info))
|
|
|
|
|
(cycle (alist-get 'cycle tacc-info))
|
|
|
|
|
(defun tacc-draw-buffer (now state)
|
|
|
|
|
"Redraws the timer buffer and returns the calculated countdown seconds"
|
|
|
|
|
(let* ((cycle (alist-get 'cycle tacc-info))
|
|
|
|
|
(work-ts (alist-get 'work-ts tacc-info))
|
|
|
|
|
(break-ts (alist-get 'break-ts tacc-info))
|
|
|
|
|
(break-ts (alist-gete 'break-ts tacc-info))
|
|
|
|
|
(est (tacc-est-ts state cycle work-ts break-ts))
|
|
|
|
|
(countdown (time-subtract est now)))
|
|
|
|
|
(tacc-timer-buffer-update state est countdown now)
|
|
|
|
|
countdown))
|
|
|
|
|
|
|
|
|
|
(defun tacc-tick ()
|
|
|
|
|
"Time marches on. Called every second while a tacc timer is running"
|
|
|
|
|
(let* ((now (current-time))
|
|
|
|
|
(state (alist-get 'state tacc-info))
|
|
|
|
|
(countdown (tacc-draw-buffer now state)))
|
|
|
|
|
(if (functionp tacc-play-sound-file)
|
|
|
|
|
(cond ((tacc-chime-p countdown)
|
|
|
|
|
(funcall tacc-play-sound-file tacc-sound-chime))
|
|
|
|
|
(t (funcall tacc-play-sound-file tacc-sound-tick))))))
|
|
|
|
|
|
|
|
|
|
(defun tacc-timer-buffer-redraw ()
|
|
|
|
|
"Force a redraw of the timer buffer"
|
|
|
|
|
(let ((now (current-time))
|
|
|
|
|
(state (alist-get 'state tacc-info)))
|
|
|
|
|
(tacc-timer-buffer-update state)))
|
|
|
|
|
;; TODO
|
|
|
|
|
(tacc-draw-buffer now state)))
|
|
|
|
|
|
|
|
|
|
(defun tacc-schedule ()
|
|
|
|
|
"Note the time and schedule the first tick"
|
|
|
|
|
@ -737,8 +745,9 @@ Returns the current tag if no prompt is made"
|
|
|
|
|
(tacc-deschedule)
|
|
|
|
|
(tacc-push-current)
|
|
|
|
|
(tacc-save-record (assoc 'history tacc-info))
|
|
|
|
|
(setcdr (assoc 'state tacc-info) 'stop)
|
|
|
|
|
(kill-buffer (tacc-buffer)))))
|
|
|
|
|
(setq tacc-info (tacc-info-initial))
|
|
|
|
|
(kill-buffer (tacc-buffer))
|
|
|
|
|
(tacc-cleanup-invariant))))
|
|
|
|
|
|
|
|
|
|
;; 09 Hooks setup
|
|
|
|
|
(add-hook 'after-init-hook 'tacc-load-tag-history)
|
|
|
|
|
|