From 63d04ebadbd5ae06c7dfa6d21d7b7261ea1c8ca6 Mon Sep 17 00:00:00 2001 From: Brady McDonough Date: Wed, 2 Aug 2023 11:21:53 -0600 Subject: [PATCH] Added cleanup invariant --- tacc.el | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) 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)