Cleaned up `tacc-push-current`, also pom*i*doro

master
Brady McDonough 3 years ago
parent 4d63057d52
commit a1f7ada981

@ -3,7 +3,7 @@
;; Author: Brady McDonough <me@bradymcd.ca> ;; Author: Brady McDonough <me@bradymcd.ca>
;; URL: git.bradymcd.ca/brady/tacc ;; URL: git.bradymcd.ca/brady/tacc
;; Keywords: tools, time, pomodoro, accountability ;; Keywords: tools, time, pomidoro, accountability
;; Version: 0.0.1 ;; Version: 0.0.1
;; ;;
@ -89,7 +89,7 @@
(+ secs (* 60 mins))) (+ secs (* 60 mins)))
(defcustom tacc-work-seconds (m:s 30 0) (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) :type 'integer :group 'tacc)
(defcustom tacc-work-seconds-increment 0 (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 () (defun tacc-push-current ()
"Push the current period into the record" "Push the current period into the record"
(let* ((stack (assoc 'history tacc-info)) (let* ((stack (assoc 'history tacc-info))
(work-ts (assoc 'work-ts tacc-info)) (work-place (assoc 'work-ts tacc-info))
(break-ts (assoc 'break-ts tacc-info)) (break-place (assoc 'break-ts tacc-info))
(end-ts (assoc 'end-ts tacc-info)) (end-place (assoc 'end-ts tacc-info))
(tag (alist-get 'tag tacc-info))) (tag (alist-get 'tag tacc-info "")))
(if work-ts (let ((work-cond (if (cdr work-place) 't nil))
(push `((ts . ,work-ts) (break-cond (if (cdr break-place) 't nil)))
(end . ,(if (cdr break-ts) (if work-cond
(time-seconds (cdr break-ts)) (let ((ts (time-to-seconds (cdr work-place)))
(cdr end-ts))) (end (time-to-seconds (if break-cond
(state . work) (cdr break-place)
(tag . ,tag)) (cdr end-place)))))
(cdr stack))) (push `((ts . ,ts)
(if break-ts (end . ,end)
(push `((ts . ,(cdr break-ts)) (state . work)
(end . ,(cdr end-ts)) (tag . ,tag))
(state . break) stack)))
(tag . ,tag)) (if break-cond
(cdr stack))) (let ((ts (time-to-seconds (cdr break-place)))
(setcdr work-ts nil) (end (time-to-seconds (cdr end-ts))))
(setcdr break-ts nil) (push `((ts . ,ts)
(setcdr end-ts nil))) (end . ,end)
(state . break)
(tag . ,tag))
stack))))
(setcdr work-place nil)
(setcdr break-place nil)
(setcdr end-ts 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"

Loading…
Cancel
Save