|
|
|
@ -53,7 +53,7 @@
|
|
|
|
;; ERROR: mapconcat doesn't seem to respect lexical binding which leaves me unable to use a closure for a ticker
|
|
|
|
;; ERROR: mapconcat doesn't seem to respect lexical binding which leaves me unable to use a closure for a ticker
|
|
|
|
;; For now the code which relies on this will be noop'd
|
|
|
|
;; For now the code which relies on this will be noop'd
|
|
|
|
;; ERROR: tacc-tick is returning a (wrong-number-of-arguments) error.
|
|
|
|
;; ERROR: tacc-tick is returning a (wrong-number-of-arguments) error.
|
|
|
|
;; ERROR: timer displays current time just fine, countdown is inverted, tag doesn't print
|
|
|
|
;; ERROR: tag doesn't print, countdown is ???
|
|
|
|
|
|
|
|
|
|
|
|
;; Optional
|
|
|
|
;; Optional
|
|
|
|
(require 'icicles nil t)
|
|
|
|
(require 'icicles nil t)
|
|
|
|
@ -265,7 +265,7 @@ registered" sym-name)
|
|
|
|
(define-derived-mode tacc-timer-mode
|
|
|
|
(define-derived-mode tacc-timer-mode
|
|
|
|
special-mode tacc-buffer-name
|
|
|
|
special-mode tacc-buffer-name
|
|
|
|
"Major mode for the tacc timer"
|
|
|
|
"Major mode for the tacc timer"
|
|
|
|
(setq-local lexical-binding t
|
|
|
|
(setq-local show-trailing-whitespace nil
|
|
|
|
tacc-locs `((clock-start . ,(copy-marker 0))
|
|
|
|
tacc-locs `((clock-start . ,(copy-marker 0))
|
|
|
|
(clock-end . ,(copy-marker 0))
|
|
|
|
(clock-end . ,(copy-marker 0))
|
|
|
|
(graph-start . ,(copy-marker 0))
|
|
|
|
(graph-start . ,(copy-marker 0))
|
|
|
|
@ -321,8 +321,8 @@ Note, if there is no tacc-buffer then you shouldn't be touching tacc-info"
|
|
|
|
(defun tacc-chime-p (countdown-ts)
|
|
|
|
(defun tacc-chime-p (countdown-ts)
|
|
|
|
"Should I play a chime on this second?"
|
|
|
|
"Should I play a chime on this second?"
|
|
|
|
(if (time-less-p countdown-ts 0)
|
|
|
|
(if (time-less-p countdown-ts 0)
|
|
|
|
(mod (time-to-seconds countdown-ts)
|
|
|
|
(= 0 (mod (time-to-seconds countdown-ts)
|
|
|
|
tacc-chime-interval)))
|
|
|
|
tacc-chime-interval))))
|
|
|
|
|
|
|
|
|
|
|
|
(defun tacc-work-period (cycle)
|
|
|
|
(defun tacc-work-period (cycle)
|
|
|
|
"How long is the current work period?"
|
|
|
|
"How long is the current work period?"
|
|
|
|
@ -341,9 +341,10 @@ Note, if there is no tacc-buffer then you shouldn't be touching tacc-info"
|
|
|
|
(defun tacc-est-ts (state cycle work-ts break-ts)
|
|
|
|
(defun tacc-est-ts (state cycle work-ts break-ts)
|
|
|
|
"Given the state and cycle, how long is the current time segment?"
|
|
|
|
"Given the state and cycle, how long is the current time segment?"
|
|
|
|
(let ((start-ts (tacc-start-ts state work-ts break-ts)))
|
|
|
|
(let ((start-ts (tacc-start-ts state work-ts break-ts)))
|
|
|
|
(if (eq state 'work)
|
|
|
|
(time-add start-ts
|
|
|
|
(tacc-work-period cycle)
|
|
|
|
(if (eq state 'work)
|
|
|
|
(tacc-break-period cycle))))
|
|
|
|
(tacc-work-period cycle)
|
|
|
|
|
|
|
|
(tacc-break-period cycle)))))
|
|
|
|
|
|
|
|
|
|
|
|
;; 05.3 State manipulation
|
|
|
|
;; 05.3 State manipulation
|
|
|
|
|
|
|
|
|
|
|
|
@ -351,17 +352,17 @@ Note, if there is no tacc-buffer then you shouldn't be touching tacc-info"
|
|
|
|
"Time marches on. Called every second while a tacc timer is running"
|
|
|
|
"Time marches on. Called every second while a tacc timer is running"
|
|
|
|
(let* ((now (current-time))
|
|
|
|
(let* ((now (current-time))
|
|
|
|
(state (alist-get 'state tacc-info))
|
|
|
|
(state (alist-get 'state tacc-info))
|
|
|
|
(cycle (funcall (alist-get 'cycle tacc-info)))
|
|
|
|
(cycle (funcall (alist-get 'cycle tacc-info) 't))
|
|
|
|
(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))
|
|
|
|
(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 now ) ;; HERE
|
|
|
|
(tacc-timer-buffer-update state start-ts est countdown now)
|
|
|
|
(if 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))
|
|
|
|
(t (funcall tacc-play-sound-file tacc-sound-tick))))))
|
|
|
|
(t (funcall tacc-play-sound-file tacc-sound-tick))))))
|
|
|
|
|
|
|
|
|
|
|
|
(defun tacc-schedule ()
|
|
|
|
(defun tacc-schedule ()
|
|
|
|
"Note the time and schedule the first tick"
|
|
|
|
"Note the time and schedule the first tick"
|
|
|
|
@ -491,7 +492,7 @@ Note, if there is no tacc-buffer then you shouldn't be touching tacc-info"
|
|
|
|
(set-marker .graph-end (point-max))
|
|
|
|
(set-marker .graph-end (point-max))
|
|
|
|
(tacc-insert-between
|
|
|
|
(tacc-insert-between
|
|
|
|
.graph-start .graph-end
|
|
|
|
.graph-start .graph-end
|
|
|
|
"Tag:\n"
|
|
|
|
"Tag: \n"
|
|
|
|
(tacc-graph-bar-render width 0.0 0.0 1.0)))))))
|
|
|
|
(tacc-graph-bar-render width 0.0 0.0 1.0)))))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -502,12 +503,9 @@ 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 est now)
|
|
|
|
(defun tacc-clock-render (state start countdown now)
|
|
|
|
"Draw the clock"
|
|
|
|
"Draw the clock"
|
|
|
|
(let* ((elapsed (time-subtract now start))
|
|
|
|
(let* ((overwork (time-less-p countdown 0))
|
|
|
|
(overwork (time-less-p elapsed est))
|
|
|
|
|
|
|
|
(countdown (if overwork (time-subtract elapsed est)
|
|
|
|
|
|
|
|
(time-subtract est elapsed)))
|
|
|
|
|
|
|
|
(count-fmt (if overwork "+%M:%S" "-%M:%S"))
|
|
|
|
(count-fmt (if overwork "+%M:%S" "-%M:%S"))
|
|
|
|
(count-face (cond (overwork 'tacc-overwork)
|
|
|
|
(count-face (cond (overwork 'tacc-overwork)
|
|
|
|
((eq state 'pause) 'tacc-clock-pause)
|
|
|
|
((eq state 'pause) 'tacc-clock-pause)
|
|
|
|
@ -517,42 +515,40 @@ Note, if there is no tacc-buffer then you shouldn't be touching tacc-info"
|
|
|
|
(propertize (format-time-string count-fmt countdown) 'face count-face)
|
|
|
|
(propertize (format-time-string count-fmt countdown) 'face count-face)
|
|
|
|
(propertize (tacc-clock-glyph state) 'face 'tacc-clock))))
|
|
|
|
(propertize (tacc-clock-glyph state) 'face 'tacc-clock))))
|
|
|
|
|
|
|
|
|
|
|
|
(defun tacc-current-tag-render ()
|
|
|
|
|
|
|
|
"Draw the tag name"
|
|
|
|
|
|
|
|
(concat "Tag: " (propertize (alist-get 'tag tacc-info "<None>")
|
|
|
|
|
|
|
|
'face 'tacc-tag)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun tacc-graph-bar-render (width work break void)
|
|
|
|
(defun tacc-graph-bar-render (width work break void)
|
|
|
|
"Return a graph bar width characters wide with the given proportions as \
|
|
|
|
"Return a graph bar width characters wide with the given proportions as \
|
|
|
|
float"
|
|
|
|
float"
|
|
|
|
(let ((width (- width 2)))
|
|
|
|
(let ((width (- width 5)))
|
|
|
|
(concat
|
|
|
|
(concat
|
|
|
|
""
|
|
|
|
" "
|
|
|
|
(propertize (make-string (round (* width work)) tacc-graph-char)
|
|
|
|
(propertize (make-string (round (* width work)) tacc-graph-char)
|
|
|
|
'face 'tacc-graph-work)
|
|
|
|
'face 'tacc-graph-work)
|
|
|
|
(propertize (make-string (round (* width break)) tacc-graph-char)
|
|
|
|
(propertize (make-string (round (* width break)) tacc-graph-char)
|
|
|
|
'face 'tacc-graph-break)
|
|
|
|
'face 'tacc-graph-break)
|
|
|
|
(propertize (make-string (round (* width void)) tacc-graph-char)
|
|
|
|
(propertize (make-string (round (* width void)) tacc-graph-char)
|
|
|
|
'face 'tacc-graph-void)
|
|
|
|
'face 'tacc-graph-void)
|
|
|
|
" \n")))
|
|
|
|
" \n")))
|
|
|
|
|
|
|
|
|
|
|
|
(defun tacc-timer-buffer-update (state now)
|
|
|
|
(defun tacc-timer-buffer-update (state start-ts 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 .work-ts .end-ts now)))
|
|
|
|
(tacc-clock-render state start-ts countdown now)))
|
|
|
|
(tacc-insert-between
|
|
|
|
(tacc-insert-between
|
|
|
|
.graph-start .graph-end
|
|
|
|
.graph-start .graph-end
|
|
|
|
(tacc-current-tag-render)
|
|
|
|
|
|
|
|
(let-alist tacc-info
|
|
|
|
(let-alist tacc-info
|
|
|
|
(let* ((end (if (> now .end-ts) now .end-ts))
|
|
|
|
(concat
|
|
|
|
(total (- end .work-ts))
|
|
|
|
" Tag: " (propertize (if (string= .tag "") "<None>" .tag)
|
|
|
|
(work-prop (/ (- (if .break-ts .break-ts now) .work-ts) total))
|
|
|
|
'face 'tacc-tag)
|
|
|
|
(break-prop (/ (if .break-ts (- now .break-ts) 0) total))
|
|
|
|
"\n"
|
|
|
|
(void-prop (- 1 (+ work-prop break-prop))))
|
|
|
|
(let* ((end (if (> now est-ts) now est-ts))
|
|
|
|
(tacc-graph-bar-render width work-prop break-prop void-prop))))))
|
|
|
|
(total (- end .work-ts))
|
|
|
|
|
|
|
|
(work-prop (/ (- (if .break-ts .break-ts now) .work-ts) total))
|
|
|
|
|
|
|
|
(break-prop (/ (if .break-ts (- now .break-ts) 0) total))
|
|
|
|
|
|
|
|
(void-prop (- 1 (+ work-prop break-prop))))
|
|
|
|
|
|
|
|
(tacc-graph-bar-render width work-prop break-prop void-prop)))))))
|
|
|
|
|
|
|
|
|
|
|
|
(defun tacc-new-graph-bar-render ()
|
|
|
|
(defun tacc-new-graph-bar-render ()
|
|
|
|
(tacc-render-with-buffer
|
|
|
|
(tacc-render-with-buffer
|
|
|
|
|