Replaced old state check

master
Brady McDonough 2 years ago
parent 483a088a77
commit 5ae038d2f5

@ -448,14 +448,14 @@ Note, if there is no tacc-buffer then you shouldn't be touching tacc-info"
(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"
(if (tacc-running?) (if (tacc-session?)
(yes-or-no-p "Are you sure you want to kill the timer buffer? This will\ (yes-or-no-p "Are you sure you want to kill the timer buffer? This will\
end the current timer session as well.") end the current timer session as well.")
t)) t))
(defun tacc-buffer-cleanup () (defun tacc-buffer-cleanup ()
"Save and cleanup the timer state if a timer is still live" "Save and cleanup the timer state if a timer is still live"
(if (tacc-running?) (if (tacc-session?)
(progn (tacc-deschedule) (progn (tacc-deschedule)
(tacc-push-current)))) (tacc-push-current))))
@ -660,7 +660,7 @@ Returns the current tag if no prompt is made"
(defun tacc-set-tag () (defun tacc-set-tag ()
"Sets a tag for live timer sessions going forward" "Sets a tag for live timer sessions going forward"
(interactive) (interactive)
(if (tacc-running?) (if (tacc-session?)
(setcdr (assoc 'tag tacc-info) (tacc-tag-prompt)) (setcdr (assoc 'tag tacc-info) (tacc-tag-prompt))
(message "There isn't a live timer session to tag"))) (message "There isn't a live timer session to tag")))
@ -674,7 +674,7 @@ Returns the current tag if no prompt is made"
(defun tacc-timer-state-forward () (defun tacc-timer-state-forward ()
"Move the tacc timer state forward" "Move the tacc timer state forward"
(interactive) (interactive)
(if (tacc-running?) (if (tacc-live?)
(let* ((state-place (assoc 'state tacc-info)) (let* ((state-place (assoc 'state tacc-info))
(state (cdr state-place)) (state (cdr state-place))
(work-ts (assoc 'work-ts tacc-info)) (work-ts (assoc 'work-ts tacc-info))
@ -695,7 +695,7 @@ Returns the current tag if no prompt is made"
(defun tacc-timer-state-skip () (defun tacc-timer-state-skip ()
"Move the tacc timer state to a new work cycle" "Move the tacc timer state to a new work cycle"
(interactive) (interactive)
(if (tacc-running?) (if (tacc-live?)
(let* ((state-place (assoc 'state tacc-info)) (let* ((state-place (assoc 'state tacc-info))
(work-ts (assoc 'work-ts tacc-info)) (work-ts (assoc 'work-ts tacc-info))
(end-ts (assoc 'end-ts tacc-info)) (end-ts (assoc 'end-ts tacc-info))
@ -721,7 +721,7 @@ Returns the current tag if no prompt is made"
(defun tacc-hold-timer () (defun tacc-hold-timer ()
"Pause/unpause the tacc timer session" "Pause/unpause the tacc timer session"
(interactive) (interactive)
(if (tacc-running?) (if (tacc-session?)
(let ((state (alist-get 'state tacc-info))) (let ((state (alist-get 'state tacc-info)))
(if (eq state 'pause) (if (eq state 'pause)
(tacc-unpause-timer) (tacc-unpause-timer)
@ -732,11 +732,13 @@ Returns the current tag if no prompt is made"
(defun tacc-end-timer () (defun tacc-end-timer ()
"Ends the current timer session, runs serialization and kills the buffer" "Ends the current timer session, runs serialization and kills the buffer"
(interactive) (interactive)
(tacc-deschedule) (if (tacc-session?)
(tacc-push-current) (progn
(tacc-save-record (assoc 'history tacc-info)) (tacc-deschedule)
(setcdr (assoc 'state tacc-info) 'stop) (tacc-push-current)
(kill-buffer (tacc-buffer))) (tacc-save-record (assoc 'history tacc-info))
(setcdr (assoc 'state tacc-info) 'stop)
(kill-buffer (tacc-buffer)))))
;; 09 Hooks setup ;; 09 Hooks setup
(add-hook 'after-init-hook 'tacc-load-tag-history) (add-hook 'after-init-hook 'tacc-load-tag-history)

Loading…
Cancel
Save