From 562f9ed529171b74ee7e3807a9526c91056cd2b0 Mon Sep 17 00:00:00 2001 From: Siddhartha Date: Wed, 11 Sep 2024 17:30:27 -0700 Subject: [PATCH] don't rely on evil state when reconciling level This is a general step towards maintaining a distinct notion of a current mode within Rigpa, which may use the current mode reported by Evil or Lithium as part of its operation. But it also is in response to a bug where [u]ndo'ing while in Symex mode causes the level to be reconciled to the level of Normal in the current tower (e.g. 2), even though we remain in Symex state. This seems to happen because as of emacs-evil/evil#1888, undoing explicitly goes into Normal state first, and then returns to whatever the original state was. In Rigpa, Normal is backed by Evil but Symex is backed by Lithium, even though it sets the Evil state for UI feedback purposes. As a result, we only watch the Evil state transition to reconcile the level when entering Normal state, but not Symex state, since we do not expect the Evil state transition to be the way in which Symex state is entered (it's rather just an effect of Symex mode entry via Lithium). As a result, during the undo operation, we see the transition to Normal and reconcile the level to 2, but do not see the transition back to (evil) Symex state, and thus do not reconcile the level back again to 1. This fix alleviates the bug because even though `rigpa--reconcile-level` is still only called upon Normal state entry, it does not result in the level actually changing because Rigpa's determination of current mode now first checks whether a Lithium mode is active, before checking the evil state. So even though the latter has changed during the undo operation, the mode remains the same as before, as the former has not changed. --- rigpa-mode-mode.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rigpa-mode-mode.el b/rigpa-mode-mode.el index 7aabea5..fac6240 100644 --- a/rigpa-mode-mode.el +++ b/rigpa-mode-mode.el @@ -202,7 +202,8 @@ Priority: (1) provided mode if admissible (i.e. present in tower) [TODO] If the current mode is present in the current tower, ensure that the current level reflects the mode's position in the tower." (interactive) - (let* ((mode-name (symbol-name evil-state)) + (let* ((mode (rigpa-current-mode)) + (mode-name (when mode (chimera-mode-name mode))) (level-number (rigpa-ensemble-member-position-by-name (rigpa--local-tower) mode-name)))