From a6635e36d067e49f44fdef15010524003c346b85 Mon Sep 17 00:00:00 2001 From: Brady McDonough Date: Sat, 11 Feb 2023 22:52:18 -0700 Subject: [PATCH] Many small errors in waiting fixed, I'm too used to lazy if conditions --- tacc.el | 43 +++++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/tacc.el b/tacc.el index 85feaaf..3490085 100644 --- a/tacc.el +++ b/tacc.el @@ -1,7 +1,7 @@ ;;; tacc.el --- A pomidoro timer supporting tags and customizable export ;; Author: Brady McDonough -;; URL: git.bradymcd.ca/tacc +;; URL: git.bradymcd.ca/brady/tacc ;; Keywords: tools, time, pomodoro, accountability ;; Version: 0.0.1 ;; @@ -52,13 +52,11 @@ ;; TODOS: ;; 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 -;; ERROR: tacc-tick is returning a (wrong-number-of-arguments) error. -;; ERROR: tag doesn't print, ;; BUG : Countdown was ??? because 0 doesn't default to zero but "now". ;; That does leave an edgecase in the countdown display I'll need to explicitly check for ;; ERROR: timer shutdown seems to leave things in a wrong state and buffer doesn't die properly -;; ERROR: Current error is a wrong argument error where we're expecting a marker or position -;; Strictly before printing the graph bar and it gets fed a quadruple, constantly changes +;; Check on the logic of push-current, needs predicates rather than lazy if conditions +;; I'm not calling anything to destroy the buffer on desched ;; Optional (require 'icicles nil t) @@ -492,8 +490,7 @@ Note, if there is no tacc-buffer then you shouldn't be touching tacc-info" (set-marker .clock-end (point-max)) (tacc-insert-between .clock-start .clock-end - (let ((ts (current-time))) - (tacc-clock-render 'work ts ts ts))) + (tacc-clock-render 'work 0 1 0)) (insert (tacc-spacer-render width)) (set-marker .graph-start (point)) (set-marker .graph-end (point-max)) @@ -512,7 +509,7 @@ Note, if there is no tacc-buffer then you shouldn't be touching tacc-info" (defun tacc-clock-render (state start countdown now) "Draw the clock" - (let* ((overwork (time-less-p countdown 0)) + (let* ((overwork (time-less-p countdown 1)) (count-fmt (if overwork "+%M:%S" "-%M:%S")) (count-face (cond (overwork 'tacc-overwork) ((eq state 'pause) 'tacc-clock-pause) @@ -552,14 +549,20 @@ float" (tacc-insert-between .graph-start .graph-end (let-alist tacc-info - (concat - (tacc-tag-render .tag) - (let* ((end (if (> now est-ts) now est-ts)) - (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))))))) + (tacc-tag-render .tag) + (let* ((start-s (time-to-seconds start-ts)) + (est-s (time-to-seconds est-ts)) + (count-s (time-to-seconds countdown)) + (now-s (time-to-seconds now)) + (end-s (if (< est-s now-s) now-s est-s)) + (work-s (time-to-seconds .work-ts)) + (break-s (time-to-seconds .break-ts)) + + (total (- end-s work-s)) + (work-prop (/ (- (if (numberp break-s) break-s now-s) work-s) total)) + (break-prop (/ (if (numberp break-s) (- now-s break-s) 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 () (tacc-render-with-buffer @@ -589,9 +592,9 @@ float" (alist-get 'tag tacc-info) nil)) (completions (append (flatten-tree - (apply 'eval (if tacc-tag-completion-functions - tacc-tag-completion-functions - `(,(lambda () ""))))) + (apply 'funcall (if tacc-tag-completion-functions + tacc-tag-completion-functions + `(,(lambda () ""))))) tacc-tag-history))) (completing-read (concat "Enter a tag name" (if (< (length last-tag) 0) @@ -698,7 +701,7 @@ Returns the current tag if no prompt is made" (tacc-push-current) (tacc-save-record (assoc 'history tacc-info)) (setcdr (assoc 'state tacc-info) 'stop) - (kill-buffer)) + (kill-buffer (tacc-buffer))) ;; 09 Hooks setup (add-hook 'after-init-hook 'tacc-load-tag-history)