From af54b79b2f7fd83be9f918cdc385f0b79a989798 Mon Sep 17 00:00:00 2001 From: Brady McDonough Date: Fri, 3 Mar 2023 00:13:56 -0700 Subject: [PATCH] Removed many unused bindings. Cleanup of some display logic --- tacc.el | 48 +++++++++++++++++++----------------------------- 1 file changed, 19 insertions(+), 29 deletions(-) diff --git a/tacc.el b/tacc.el index 95e4e24..07693ac 100644 --- a/tacc.el +++ b/tacc.el @@ -361,10 +361,9 @@ Note, if there is no tacc-buffer then you shouldn't be touching tacc-info" (cycle (alist-get 'cycle tacc-info)) (work-ts (alist-get 'work-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)) (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) (cond ((tacc-chime-p countdown) (funcall tacc-play-sound-file tacc-sound-chime)) @@ -402,7 +401,7 @@ Note, if there is no tacc-buffer then you shouldn't be touching tacc-info" stack))) (if break-cond (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) (end . ,end) (state . break) @@ -410,7 +409,7 @@ Note, if there is no tacc-buffer then you shouldn't be touching tacc-info" stack)))) (setcdr work-place nil) (setcdr break-place nil) - (setcdr end-ts nil))) + (setcdr end-place nil))) (defun tacc-kill-buffer-confirm () "Ask for confirmation if a timer is still running" @@ -435,24 +434,19 @@ Note, if there is no tacc-buffer then you shouldn't be touching tacc-info" (+ len (if (<= ticker rem) 1 0))))) (defun gradient-string (width chars) - ;; (mapconcat (let ((ticker 0) - ;; (rem (mod width (length chars))) - ;; (len (/ width (length chars)))) - ;; (lambda (c) - ;; (make-string (+ len (if (<= (setq ticker (1+ ticker)) rem) 1 0)) - ;; c))) - ;; chars "")) - (make-string width (aref chars 0))) + (mapconcat (let ((ticker 0) + (rem (mod width (length chars))) + (len (/ width (length chars)))) + (lambda (c) + (make-string (+ len (if (<= (setq ticker (1+ ticker)) rem) 1 0)) + c))) + chars "")) (defun tacc-header-render (width) "Returns a string for the header of the tacc timer" (propertize (gradient-string width "'\"'") ;▓░ ▒█ 'face 'shadow)) -(defun tacc-spacer-render (width) - "Returns a string for spacing vertically" - "\n") - (defmacro tacc-render-with-buffer (&rest body) "Executes the body in tacc-buffer with (let-alist tacc-info), suppress read only" `(let* ((buffer (tacc-buffer)) @@ -496,8 +490,8 @@ 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 - (tacc-clock-render 'work 0 1 0)) - (insert (tacc-spacer-render width)) + (tacc-clock-render 'work 1 0)) + (insert "\n") (set-marker .graph-start (point)) (set-marker .graph-end (point-max)) (tacc-insert-between @@ -513,7 +507,7 @@ Note, if there is no tacc-buffer then you shouldn't be touching tacc-info" ((eq state 'pause) 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" (let* ((overwork (time-less-p countdown 1)) (count-fmt (if overwork "+%M:%S" "-%M:%S")) @@ -545,20 +539,18 @@ float" 'face 'tacc-tag) "\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" (tacc-render-with-buffer (tacc-insert-between .clock-start .clock-end (let-alist tacc-info - (tacc-clock-render state start-ts countdown now))) + (tacc-clock-render state countdown now))) (tacc-insert-between .graph-start .graph-end (let-alist tacc-info (concat (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)) + (let* ((est-s (time-to-seconds est-ts)) (now-s (time-to-seconds now)) (end-s (if (< est-s now-s) now-s est-s)) (work-s (time-to-seconds .work-ts)) @@ -575,11 +567,10 @@ float" (save-restriction (narrow-to-region .graph-start .graph-start) (goto-char (point-min)) - (insert (tacc-tag-render .tag) - (tacc-graph-bar-render width 0 0 1) - "\n") + (insert "\n") (set-marker .graph-start (point-min)) - (set-marker .graph-end (point-max))))) + (set-marker .graph-end (point-max)) + (insert "\n")))) ;; 07 Init @@ -668,7 +659,6 @@ Returns the current tag if no prompt is made" (interactive) (if (tacc-running?) (let* ((state-place (assoc 'state tacc-info)) - (state (cdr state-place)) (work-ts (assoc 'work-ts tacc-info)) (end-ts (assoc 'end-ts tacc-info)) (ts (current-time)))