From a1f7ada981ec9cc0339ee05a32214a7a52d50003 Mon Sep 17 00:00:00 2001 From: Brady McDonough Date: Tue, 28 Feb 2023 17:30:21 -0700 Subject: [PATCH] Cleaned up `tacc-push-current`, also pom*i*doro --- tacc.el | 54 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 30 insertions(+), 24 deletions(-) diff --git a/tacc.el b/tacc.el index a4b785f..95e4e24 100644 --- a/tacc.el +++ b/tacc.el @@ -3,7 +3,7 @@ ;; Author: Brady McDonough ;; URL: git.bradymcd.ca/brady/tacc -;; Keywords: tools, time, pomodoro, accountability +;; Keywords: tools, time, pomidoro, accountability ;; Version: 0.0.1 ;; @@ -89,7 +89,7 @@ (+ secs (* 60 mins))) (defcustom tacc-work-seconds (m:s 30 0) - "The length of a base pomodoro round" + "The length of a base pomidoro round" :type 'integer :group 'tacc) (defcustom tacc-work-seconds-increment 0 @@ -383,28 +383,34 @@ Note, if there is no tacc-buffer then you shouldn't be touching tacc-info" (defun tacc-push-current () "Push the current period into the record" - (let* ((stack (assoc 'history tacc-info)) - (work-ts (assoc 'work-ts tacc-info)) - (break-ts (assoc 'break-ts tacc-info)) - (end-ts (assoc 'end-ts tacc-info)) - (tag (alist-get 'tag tacc-info))) - (if work-ts - (push `((ts . ,work-ts) - (end . ,(if (cdr break-ts) - (time-seconds (cdr break-ts)) - (cdr end-ts))) - (state . work) - (tag . ,tag)) - (cdr stack))) - (if break-ts - (push `((ts . ,(cdr break-ts)) - (end . ,(cdr end-ts)) - (state . break) - (tag . ,tag)) - (cdr stack))) - (setcdr work-ts nil) - (setcdr break-ts nil) - (setcdr end-ts nil))) + (let* ((stack (assoc 'history tacc-info)) + (work-place (assoc 'work-ts tacc-info)) + (break-place (assoc 'break-ts tacc-info)) + (end-place (assoc 'end-ts tacc-info)) + (tag (alist-get 'tag tacc-info ""))) + (let ((work-cond (if (cdr work-place) 't nil)) + (break-cond (if (cdr break-place) 't nil))) + (if work-cond + (let ((ts (time-to-seconds (cdr work-place))) + (end (time-to-seconds (if break-cond + (cdr break-place) + (cdr end-place))))) + (push `((ts . ,ts) + (end . ,end) + (state . work) + (tag . ,tag)) + stack))) + (if break-cond + (let ((ts (time-to-seconds (cdr break-place))) + (end (time-to-seconds (cdr end-ts)))) + (push `((ts . ,ts) + (end . ,end) + (state . break) + (tag . ,tag)) + stack)))) + (setcdr work-place nil) + (setcdr break-place nil) + (setcdr end-ts nil))) (defun tacc-kill-buffer-confirm () "Ask for confirmation if a timer is still running"