|
|
|
@ -272,13 +272,13 @@ registered" sym-name)
|
|
|
|
|
|
|
|
|
|
|
|
(defun tacc-info-initial ()
|
|
|
|
(defun tacc-info-initial ()
|
|
|
|
"Returns the initial state of tacc-info"
|
|
|
|
"Returns the initial state of tacc-info"
|
|
|
|
`((history . ())
|
|
|
|
(copy-alist `((history . ())
|
|
|
|
(cycle . 0)
|
|
|
|
(cycle . 0)
|
|
|
|
(work-ts . nil)
|
|
|
|
(work-ts . nil)
|
|
|
|
(break-ts . nil)
|
|
|
|
(break-ts . nil)
|
|
|
|
(end-ts . nil)
|
|
|
|
(end-ts . nil)
|
|
|
|
(state . stop)
|
|
|
|
(state . stop)
|
|
|
|
(tag . "")))
|
|
|
|
(tag . ""))))
|
|
|
|
|
|
|
|
|
|
|
|
(defvar tacc-info (tacc-info-initial)
|
|
|
|
(defvar tacc-info (tacc-info-initial)
|
|
|
|
"State information related to the timer")
|
|
|
|
"State information related to the timer")
|
|
|
|
@ -287,29 +287,49 @@ registered" sym-name)
|
|
|
|
"Timer object controlling tacc's second-by-second update")
|
|
|
|
"Timer object controlling tacc's second-by-second update")
|
|
|
|
|
|
|
|
|
|
|
|
;; 05.2 State checks
|
|
|
|
;; 05.2 State checks
|
|
|
|
|
|
|
|
;; TODO: tacc-running? needs to be replaced by tacc-session? and tacc-live? depending on context
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun tacc-buffer ()
|
|
|
|
(defun tacc-buffer ()
|
|
|
|
"Gets the tacc-timer buffer if there is one"
|
|
|
|
"Gets the tacc-timer buffer if there is one"
|
|
|
|
(get-buffer tacc-buffer-name))
|
|
|
|
(get-buffer tacc-buffer-name))
|
|
|
|
|
|
|
|
|
|
|
|
(defun tacc-running? ()
|
|
|
|
(defun tacc-live-state? (state)
|
|
|
|
|
|
|
|
"Checks if the state supplied indicates a live timer"
|
|
|
|
|
|
|
|
(cond ((eq state 'pause) nil)
|
|
|
|
|
|
|
|
((eq state 'stop) nil)
|
|
|
|
|
|
|
|
((eq state 'work) t)
|
|
|
|
|
|
|
|
((eq state 'break) t)
|
|
|
|
|
|
|
|
('t (signal 'tacc-error-illegal-buffer-state state))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun tacc-live? ()
|
|
|
|
"Checks if there is a live timer running"
|
|
|
|
"Checks if there is a live timer running"
|
|
|
|
(timerp tacc-timer))
|
|
|
|
(timerp tacc-timer))
|
|
|
|
|
|
|
|
|
|
|
|
(defun tacc-running-state? (state)
|
|
|
|
(defun tacc-session-state? (state)
|
|
|
|
"Checks if the state supplied indicates a live timer"
|
|
|
|
"Checks if the state supplied indicates there should be session information"
|
|
|
|
(cond ((eq state 'pause) nil)
|
|
|
|
(cond ((eq state 'pause) t)
|
|
|
|
((eq state 'stop) nil)
|
|
|
|
((eq state 'stop) nil)
|
|
|
|
((eq state 'work) t)
|
|
|
|
((eq state 'work) t)
|
|
|
|
((eq state 'break) t)
|
|
|
|
((eq state 'break) t)
|
|
|
|
('t (signal 'tacc-error-illegal-buffer-state state))))
|
|
|
|
('t (signal 'tacc-error-illegal-buffer-state state))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun tacc-session? ()
|
|
|
|
|
|
|
|
"Checks if tacc session info indicates there should be session information"
|
|
|
|
|
|
|
|
(tacc-running-state? (alist-get 'state tacc-info)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun tacc-history? ()
|
|
|
|
|
|
|
|
"Checks if tacc session has history information"
|
|
|
|
|
|
|
|
(if (> 0 (length (alist-get 'history tacc-info)))
|
|
|
|
|
|
|
|
t
|
|
|
|
|
|
|
|
nil))
|
|
|
|
|
|
|
|
|
|
|
|
(defun tacc-invariant ()
|
|
|
|
(defun tacc-invariant ()
|
|
|
|
"Returns t if tacc is in a legal state for mutating tacc-info
|
|
|
|
"Returns t if tacc is in a legal state for mutating tacc-info
|
|
|
|
Note, if there is no tacc-buffer then you shouldn't be touching tacc-info"
|
|
|
|
Note, if there is no tacc-buffer then you shouldn't be touching tacc-info"
|
|
|
|
(if (bufferp (tacc-buffer))
|
|
|
|
(if (bufferp (tacc-buffer))
|
|
|
|
(if (and (timerp tacc-timer)
|
|
|
|
(if (and (tacc-running?)
|
|
|
|
(tacc-running-state? tacc-info))
|
|
|
|
(tacc-live?))
|
|
|
|
t)
|
|
|
|
t)
|
|
|
|
(signal 'tacc-error-illegal-buffer-state (tacc-buffer))))
|
|
|
|
(signal 'tacc-error-illegal-buffer-state (tacc-buffer))))
|
|
|
|
|
|
|
|
|
|
|
|
@ -359,6 +379,12 @@ Note, if there is no tacc-buffer then you shouldn't be touching tacc-info"
|
|
|
|
(funcall tacc-play-sound-file tacc-sound-chime))
|
|
|
|
(funcall tacc-play-sound-file tacc-sound-chime))
|
|
|
|
(t (funcall tacc-play-sound-file tacc-sound-tick))))))
|
|
|
|
(t (funcall tacc-play-sound-file tacc-sound-tick))))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun tacc-timer-buffer-redraw ()
|
|
|
|
|
|
|
|
(let ((now (current-time))
|
|
|
|
|
|
|
|
(state (alist-get 'state tacc-info)))
|
|
|
|
|
|
|
|
(tacc-timer-buffer-update state)))
|
|
|
|
|
|
|
|
;; TODO
|
|
|
|
|
|
|
|
|
|
|
|
(defun tacc-schedule ()
|
|
|
|
(defun tacc-schedule ()
|
|
|
|
"Note the time and schedule the first tick"
|
|
|
|
"Note the time and schedule the first tick"
|
|
|
|
(setcdr (assoc 'state tacc-info) 'work)
|
|
|
|
(setcdr (assoc 'state tacc-info) 'work)
|
|
|
|
@ -494,7 +520,8 @@ Note, if there is no tacc-buffer then you shouldn't be touching tacc-info"
|
|
|
|
|
|
|
|
|
|
|
|
(defun tacc-clock-glyph (state)
|
|
|
|
(defun tacc-clock-glyph (state)
|
|
|
|
"Returns the correct play or pause glyph for each state"
|
|
|
|
"Returns the correct play or pause glyph for each state"
|
|
|
|
(string (cond ((eq state 'work) tacc-run-glyph)
|
|
|
|
(string
|
|
|
|
|
|
|
|
(cond ((eq state 'work) tacc-run-glyph)
|
|
|
|
((eq state 'break) tacc-run-glyph)
|
|
|
|
((eq state 'break) tacc-run-glyph)
|
|
|
|
((eq state 'pause) tacc-pause-glyph)
|
|
|
|
((eq state 'pause) tacc-pause-glyph)
|
|
|
|
((eq state 'stop) tacc-pause-glyph))))
|
|
|
|
((eq state 'stop) tacc-pause-glyph))))
|
|
|
|
@ -679,7 +706,8 @@ Returns the current tag if no prompt is made"
|
|
|
|
(let ((state (alist-get 'state tacc-info)))
|
|
|
|
(let ((state (alist-get 'state tacc-info)))
|
|
|
|
(if (eq state 'pause)
|
|
|
|
(if (eq state 'pause)
|
|
|
|
(tacc-unpause-timer)
|
|
|
|
(tacc-unpause-timer)
|
|
|
|
(tacc-pause-timer))))
|
|
|
|
(tacc-pause-timer))
|
|
|
|
|
|
|
|
(tacc-timer-buffer-redraw)))
|
|
|
|
(message "There isn't a live timer session to pause/unpause"))
|
|
|
|
(message "There isn't a live timer session to pause/unpause"))
|
|
|
|
|
|
|
|
|
|
|
|
(defun tacc-end-timer ()
|
|
|
|
(defun tacc-end-timer ()
|
|
|
|
|