diff --git a/tacc.el b/tacc.el index eba06b8..a867201 100644 --- a/tacc.el +++ b/tacc.el @@ -325,17 +325,30 @@ registered" sym-name) nil)) (defun tacc-invariant () - "Returns t if tacc is in a legal state for mutating tacc-info + "Returns t if tacc is in a legal state for mutating tacc-info, signal an error otherwise Note, if there is no tacc-buffer then you shouldn't be touching tacc-info" (if (bufferp (tacc-buffer)) (if (tacc-live?) (if (tacc-live-state?) t - (signal 'tacc-error-illegal-buffer-state (tacc-buffer))) ;; Timer running without logical knowledge + ;; Timer running without reason in logic + (signal 'tacc-error-illegal-buffer-state (tacc-buffer))) (if (tacc-session-state?) t - (signal 'tacc-error-illegal-buffer-state (tacc-buffer)))) ;; Buffer live without logical reason - (signal 'tacc-error-illegal-buffer-state (tacc-buffer)))) ;; We shouldn't be calling this when the buffer is dead + ;; Buffer is live without reason in logic + (signal 'tacc-error-illegal-buffer-state (tacc-buffer)))) + ;; We shouldn't be calling this when the buffer is dead + (signal 'tacc-error-illegal-buffer-state (tacc-buffer)))) + +(defun tacc-cleanup-invariant () + "Returns t if tacc is in a cleaned up state, signals an error otherwise" + (if (bufferp (tacc-buffer)) + (signal 'tacc-dirty-state (tacc-buffer)) + (if (tacc-live?) + (signal 'tacc-dirty-state tacc-timer) + (if (tacc-session?) + (signal 'tacc-dirty-state tacc-info) + t)))) ;; 05.3 Predicates and helpers (defun tacc-chime-p (countdown-ts)