diff --git a/tacc.el b/tacc.el index 1334860..1edd66e 100644 --- a/tacc.el +++ b/tacc.el @@ -53,11 +53,12 @@ ;; Split buffer update into clock and graph sections ;; - As it is, pausing the timer can't draw a full buffer and ends up ;; erasing the previous time graph +;; The buffer could render in smoother, just set points don't render empty data +;; Center the clock-countdown display ;; -;; ERROR: timer shutdown seems to leave things in a wrong state and buffer doesn't die properly -;; 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 -;; BUG: The buffer is immortal? +;; ERROR: Check on the logic of push-current, needs predicates rather than lazy if conditions +;; history field is not populating +;; BUG: Break timer displays wrong time and sign ;; ;; Optional @@ -657,6 +658,18 @@ Returns the current tag if no prompt is made" (alist-get 'tag tacc-info) (tacc-tag-prompt))) +(defun tacc-end-session () + "Ends the current timer session, runs serialization and kills the buffer" + (if (tacc-session?) + (progn + (if (tacc-live?) + (progn (tacc-deschedule) + (tacc-push-current))) + (tacc-save-record (assoc 'history tacc-info)) + (setq tacc-info (tacc-info-initial)) + (kill-buffer (tacc-buffer)) + (tacc-cleanup-invariant)))) + ;; 08.2 Interactive (defun tacc-start-timer () @@ -741,19 +754,23 @@ Returns the current tag if no prompt is made" (defun tacc-end-timer () "Ends the current timer session, runs serialization and kills the buffer" (interactive) - (if (tacc-session?) - (progn - (tacc-deschedule) - (tacc-push-current) - (tacc-save-record (assoc 'history tacc-info)) - (setq tacc-info (tacc-info-initial)) - (kill-buffer (tacc-buffer)) - (tacc-cleanup-invariant)))) + (tacc-end-session)) + + ;; 09 Hooks setup + +(defun tacc-kill-emacs-confirm () + "Ask for confirmation if a timer is still running" + (if (and (tacc-session?) ;; Redundant, but more re-use this way + (yes-or-no-p "You still have a work timer running, are you sure you want\ + to quit emacs?")) + (tacc-end-session) + t)) -;; 09 Hooks setup (add-hook 'after-init-hook 'tacc-load-tag-history) +(add-hook 'kill-emacs-query-functions 'tacc-kill-emacs-confirm) (add-hook 'kill-emacs-hook 'tacc-save-tag-history) + ;; 10 Provides (provide 'tacc)