|
|
|
@ -270,16 +270,6 @@ registered" sym-name)
|
|
|
|
(graph-start . ,(copy-marker 0))
|
|
|
|
(graph-start . ,(copy-marker 0))
|
|
|
|
(graph-end . ,(copy-marker 0)))))
|
|
|
|
(graph-end . ,(copy-marker 0)))))
|
|
|
|
|
|
|
|
|
|
|
|
;; ERROR: It seems like this style of ticker doesn't work and I don't have time to look into it
|
|
|
|
|
|
|
|
;; more deeply. As far as I can tell I've copied the reference examples pretty closely.
|
|
|
|
|
|
|
|
;; In the meantime a "dumber" solution that works is being used
|
|
|
|
|
|
|
|
;; (defun cycle-ticker ()
|
|
|
|
|
|
|
|
;; "A closure with an internal count, only increments when fed 'break timer state"
|
|
|
|
|
|
|
|
;; (let ((ticker 0))
|
|
|
|
|
|
|
|
;; (lambda (&optional state)
|
|
|
|
|
|
|
|
;; (cond ((eq state 'break) (setq ticker (1+ ticker)))
|
|
|
|
|
|
|
|
;; ( 't ticker)))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun tacc-info-initial ()
|
|
|
|
(defun tacc-info-initial ()
|
|
|
|
"Returns the initial state of tacc-info"
|
|
|
|
"Returns the initial state of tacc-info"
|
|
|
|
`((history . ())
|
|
|
|
`((history . ())
|
|
|
|
@ -361,10 +351,9 @@ Note, if there is no tacc-buffer then you shouldn't be touching tacc-info"
|
|
|
|
(cycle (alist-get 'cycle tacc-info))
|
|
|
|
(cycle (alist-get 'cycle tacc-info))
|
|
|
|
(work-ts (alist-get 'work-ts tacc-info))
|
|
|
|
(work-ts (alist-get 'work-ts tacc-info))
|
|
|
|
(break-ts (alist-get 'break-ts tacc-info))
|
|
|
|
(break-ts (alist-get 'break-ts tacc-info))
|
|
|
|
(start-ts (tacc-start-ts state work-ts break-ts))
|
|
|
|
|
|
|
|
(est (tacc-est-ts state cycle work-ts break-ts))
|
|
|
|
(est (tacc-est-ts state cycle work-ts break-ts))
|
|
|
|
(countdown (time-subtract est now)))
|
|
|
|
(countdown (time-subtract est now)))
|
|
|
|
(tacc-timer-buffer-update state start-ts est countdown now)
|
|
|
|
(tacc-timer-buffer-update state est countdown now)
|
|
|
|
(if (functionp tacc-play-sound-file)
|
|
|
|
(if (functionp tacc-play-sound-file)
|
|
|
|
(cond ((tacc-chime-p countdown)
|
|
|
|
(cond ((tacc-chime-p countdown)
|
|
|
|
(funcall tacc-play-sound-file tacc-sound-chime))
|
|
|
|
(funcall tacc-play-sound-file tacc-sound-chime))
|
|
|
|
@ -402,7 +391,7 @@ Note, if there is no tacc-buffer then you shouldn't be touching tacc-info"
|
|
|
|
stack)))
|
|
|
|
stack)))
|
|
|
|
(if break-cond
|
|
|
|
(if break-cond
|
|
|
|
(let ((ts (time-to-seconds (cdr break-place)))
|
|
|
|
(let ((ts (time-to-seconds (cdr break-place)))
|
|
|
|
(end (time-to-seconds (cdr end-ts))))
|
|
|
|
(end (time-to-seconds (cdr end-place))))
|
|
|
|
(push `((ts . ,ts)
|
|
|
|
(push `((ts . ,ts)
|
|
|
|
(end . ,end)
|
|
|
|
(end . ,end)
|
|
|
|
(state . break)
|
|
|
|
(state . break)
|
|
|
|
@ -410,13 +399,14 @@ Note, if there is no tacc-buffer then you shouldn't be touching tacc-info"
|
|
|
|
stack))))
|
|
|
|
stack))))
|
|
|
|
(setcdr work-place nil)
|
|
|
|
(setcdr work-place nil)
|
|
|
|
(setcdr break-place nil)
|
|
|
|
(setcdr break-place nil)
|
|
|
|
(setcdr end-ts nil)))
|
|
|
|
(setcdr end-place nil)))
|
|
|
|
|
|
|
|
|
|
|
|
(defun tacc-kill-buffer-confirm ()
|
|
|
|
(defun tacc-kill-buffer-confirm ()
|
|
|
|
"Ask for confirmation if a timer is still running"
|
|
|
|
"Ask for confirmation if a timer is still running"
|
|
|
|
(if (tacc-running?)
|
|
|
|
(if (tacc-running?)
|
|
|
|
(yes-or-no-p "Are you sure you want to kill the timer buffer? This will\
|
|
|
|
(yes-or-no-p "Are you sure you want to kill the timer buffer? This will\
|
|
|
|
end the current timer session as well.")))
|
|
|
|
end the current timer session as well.")
|
|
|
|
|
|
|
|
t))
|
|
|
|
|
|
|
|
|
|
|
|
(defun tacc-buffer-cleanup ()
|
|
|
|
(defun tacc-buffer-cleanup ()
|
|
|
|
"Save and cleanup the timer state if a timer is still live"
|
|
|
|
"Save and cleanup the timer state if a timer is still live"
|
|
|
|
@ -435,24 +425,19 @@ Note, if there is no tacc-buffer then you shouldn't be touching tacc-info"
|
|
|
|
(+ len (if (<= ticker rem) 1 0)))))
|
|
|
|
(+ len (if (<= ticker rem) 1 0)))))
|
|
|
|
|
|
|
|
|
|
|
|
(defun gradient-string (width chars)
|
|
|
|
(defun gradient-string (width chars)
|
|
|
|
;; (mapconcat (let ((ticker 0)
|
|
|
|
(mapconcat (let ((ticker 0)
|
|
|
|
;; (rem (mod width (length chars)))
|
|
|
|
(rem (mod width (length chars)))
|
|
|
|
;; (len (/ width (length chars))))
|
|
|
|
(len (/ width (length chars))))
|
|
|
|
;; (lambda (c)
|
|
|
|
(lambda (c)
|
|
|
|
;; (make-string (+ len (if (<= (setq ticker (1+ ticker)) rem) 1 0))
|
|
|
|
(make-string (+ len (if (<= (setq ticker (1+ ticker)) rem) 1 0))
|
|
|
|
;; c)))
|
|
|
|
c)))
|
|
|
|
;; chars ""))
|
|
|
|
chars ""))
|
|
|
|
(make-string width (aref chars 0)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun tacc-header-render (width)
|
|
|
|
(defun tacc-header-render (width)
|
|
|
|
"Returns a string for the header of the tacc timer"
|
|
|
|
"Returns a string for the header of the tacc timer"
|
|
|
|
(propertize (gradient-string width "'\"'") ;▓░ ▒█
|
|
|
|
(propertize (gradient-string width "'\"'") ;▓░ ▒█
|
|
|
|
'face 'shadow))
|
|
|
|
'face 'shadow))
|
|
|
|
|
|
|
|
|
|
|
|
(defun tacc-spacer-render (width)
|
|
|
|
|
|
|
|
"Returns a string for spacing vertically"
|
|
|
|
|
|
|
|
"\n")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defmacro tacc-render-with-buffer (&rest body)
|
|
|
|
(defmacro tacc-render-with-buffer (&rest body)
|
|
|
|
"Executes the body in tacc-buffer with (let-alist tacc-info), suppress read only"
|
|
|
|
"Executes the body in tacc-buffer with (let-alist tacc-info), suppress read only"
|
|
|
|
`(let* ((buffer (tacc-buffer))
|
|
|
|
`(let* ((buffer (tacc-buffer))
|
|
|
|
@ -486,6 +471,7 @@ Note, if there is no tacc-buffer then you shouldn't be touching tacc-info"
|
|
|
|
tacc-display-buffer-window-settings))))
|
|
|
|
tacc-display-buffer-window-settings))))
|
|
|
|
(with-current-buffer buffer
|
|
|
|
(with-current-buffer buffer
|
|
|
|
(tacc-timer-mode)
|
|
|
|
(tacc-timer-mode)
|
|
|
|
|
|
|
|
(make-local-variable 'kill-buffer-query-functions)
|
|
|
|
(add-hook 'kill-buffer-query-functions 'tacc-kill-buffer-confirm)
|
|
|
|
(add-hook 'kill-buffer-query-functions 'tacc-kill-buffer-confirm)
|
|
|
|
(let ((width (window-total-width window 'floor))
|
|
|
|
(let ((width (window-total-width window 'floor))
|
|
|
|
(inhibit-read-only t))
|
|
|
|
(inhibit-read-only t))
|
|
|
|
@ -496,8 +482,8 @@ Note, if there is no tacc-buffer then you shouldn't be touching tacc-info"
|
|
|
|
(set-marker .clock-end (point-max))
|
|
|
|
(set-marker .clock-end (point-max))
|
|
|
|
(tacc-insert-between
|
|
|
|
(tacc-insert-between
|
|
|
|
.clock-start .clock-end
|
|
|
|
.clock-start .clock-end
|
|
|
|
(tacc-clock-render 'work 0 1 0))
|
|
|
|
(tacc-clock-render 'work 1 0))
|
|
|
|
(insert (tacc-spacer-render width))
|
|
|
|
(insert "\n")
|
|
|
|
(set-marker .graph-start (point))
|
|
|
|
(set-marker .graph-start (point))
|
|
|
|
(set-marker .graph-end (point-max))
|
|
|
|
(set-marker .graph-end (point-max))
|
|
|
|
(tacc-insert-between
|
|
|
|
(tacc-insert-between
|
|
|
|
@ -513,7 +499,7 @@ Note, if there is no tacc-buffer then you shouldn't be touching tacc-info"
|
|
|
|
((eq state 'pause) tacc-pause-glyph)
|
|
|
|
((eq state 'pause) tacc-pause-glyph)
|
|
|
|
((eq state 'stop) tacc-pause-glyph))))
|
|
|
|
((eq state 'stop) tacc-pause-glyph))))
|
|
|
|
|
|
|
|
|
|
|
|
(defun tacc-clock-render (state start countdown now)
|
|
|
|
(defun tacc-clock-render (state countdown now)
|
|
|
|
"Draw the clock"
|
|
|
|
"Draw the clock"
|
|
|
|
(let* ((overwork (time-less-p countdown 1))
|
|
|
|
(let* ((overwork (time-less-p countdown 1))
|
|
|
|
(count-fmt (if overwork "+%M:%S" "-%M:%S"))
|
|
|
|
(count-fmt (if overwork "+%M:%S" "-%M:%S"))
|
|
|
|
@ -545,20 +531,18 @@ float"
|
|
|
|
'face 'tacc-tag)
|
|
|
|
'face 'tacc-tag)
|
|
|
|
"\n"))
|
|
|
|
"\n"))
|
|
|
|
|
|
|
|
|
|
|
|
(defun tacc-timer-buffer-update (state start-ts est-ts countdown now)
|
|
|
|
(defun tacc-timer-buffer-update (state est-ts countdown now)
|
|
|
|
"Update the timer buffer rendering"
|
|
|
|
"Update the timer buffer rendering"
|
|
|
|
(tacc-render-with-buffer
|
|
|
|
(tacc-render-with-buffer
|
|
|
|
(tacc-insert-between
|
|
|
|
(tacc-insert-between
|
|
|
|
.clock-start .clock-end
|
|
|
|
.clock-start .clock-end
|
|
|
|
(let-alist tacc-info
|
|
|
|
(let-alist tacc-info
|
|
|
|
(tacc-clock-render state start-ts countdown now)))
|
|
|
|
(tacc-clock-render state countdown now)))
|
|
|
|
(tacc-insert-between
|
|
|
|
(tacc-insert-between
|
|
|
|
.graph-start .graph-end
|
|
|
|
.graph-start .graph-end
|
|
|
|
(let-alist tacc-info
|
|
|
|
(let-alist tacc-info
|
|
|
|
(concat (tacc-tag-render .tag)
|
|
|
|
(concat (tacc-tag-render .tag)
|
|
|
|
(let* ((start-s (time-to-seconds start-ts))
|
|
|
|
(let* ((est-s (time-to-seconds est-ts))
|
|
|
|
(est-s (time-to-seconds est-ts))
|
|
|
|
|
|
|
|
(count-s (time-to-seconds countdown))
|
|
|
|
|
|
|
|
(now-s (time-to-seconds now))
|
|
|
|
(now-s (time-to-seconds now))
|
|
|
|
(end-s (if (< est-s now-s) now-s est-s))
|
|
|
|
(end-s (if (< est-s now-s) now-s est-s))
|
|
|
|
(work-s (time-to-seconds .work-ts))
|
|
|
|
(work-s (time-to-seconds .work-ts))
|
|
|
|
@ -575,11 +559,10 @@ float"
|
|
|
|
(save-restriction
|
|
|
|
(save-restriction
|
|
|
|
(narrow-to-region .graph-start .graph-start)
|
|
|
|
(narrow-to-region .graph-start .graph-start)
|
|
|
|
(goto-char (point-min))
|
|
|
|
(goto-char (point-min))
|
|
|
|
(insert (tacc-tag-render .tag)
|
|
|
|
(insert "\n")
|
|
|
|
(tacc-graph-bar-render width 0 0 1)
|
|
|
|
|
|
|
|
"\n")
|
|
|
|
|
|
|
|
(set-marker .graph-start (point-min))
|
|
|
|
(set-marker .graph-start (point-min))
|
|
|
|
(set-marker .graph-end (point-max)))))
|
|
|
|
(set-marker .graph-end (point-max))
|
|
|
|
|
|
|
|
(insert "\n"))))
|
|
|
|
|
|
|
|
|
|
|
|
;; 07 Init
|
|
|
|
;; 07 Init
|
|
|
|
|
|
|
|
|
|
|
|
@ -632,8 +615,8 @@ Returns the current tag if no prompt is made"
|
|
|
|
"Sets a tag for live timer sessions going forward"
|
|
|
|
"Sets a tag for live timer sessions going forward"
|
|
|
|
(interactive)
|
|
|
|
(interactive)
|
|
|
|
(if (tacc-running?)
|
|
|
|
(if (tacc-running?)
|
|
|
|
(setcdr (assoc 'tag tacc-info) (tacc-tag-prompt)))
|
|
|
|
(setcdr (assoc 'tag tacc-info) (tacc-tag-prompt))
|
|
|
|
(message "There isn't a live timer session to tag"))
|
|
|
|
(message "There isn't a live timer session to tag")))
|
|
|
|
|
|
|
|
|
|
|
|
(defun tacc-cycle-increment (state)
|
|
|
|
(defun tacc-cycle-increment (state)
|
|
|
|
"Increments the cycle counter if the current state is a 'break"
|
|
|
|
"Increments the cycle counter if the current state is a 'break"
|
|
|
|
@ -668,7 +651,6 @@ Returns the current tag if no prompt is made"
|
|
|
|
(interactive)
|
|
|
|
(interactive)
|
|
|
|
(if (tacc-running?)
|
|
|
|
(if (tacc-running?)
|
|
|
|
(let* ((state-place (assoc 'state tacc-info))
|
|
|
|
(let* ((state-place (assoc 'state tacc-info))
|
|
|
|
(state (cdr state-place))
|
|
|
|
|
|
|
|
(work-ts (assoc 'work-ts tacc-info))
|
|
|
|
(work-ts (assoc 'work-ts tacc-info))
|
|
|
|
(end-ts (assoc 'end-ts tacc-info))
|
|
|
|
(end-ts (assoc 'end-ts tacc-info))
|
|
|
|
(ts (current-time)))
|
|
|
|
(ts (current-time)))
|
|
|
|
|