Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Lithium instead of Hydra and Evil #20

Open
wants to merge 68 commits into
base: main
Choose a base branch
from

Commits on Jul 26, 2024

  1. Use Lithium instead of Hydra in View mode

    Hydra was useful to prototype Rigpa modes, but we need more lifecycle
    hooks in order to ensure clean mode entry and exit. There were a
    number of hacks in Chimera (the modal interface abstraction layer that
    was introduced specifically to abstract such hacks and present a
    simple modal API) to achieve an approximation of the expected behavior
    with mode transitions, but there were still some corner cases that
    could not be addressed.
    
    With Lithium, we use Emacs's built-in minor modes to implement the
    more rigid Vim-style (and yet, "point-free," Symex-style) modes we're
    looking for. This allows us to benefit from all of the existing
    infrastructure available for minor modes, and keeps the overlying
    additions "lightweight." By having an in-house, dedicated, modal
    interface framework, we also gain the flexibility to add the lifecycle
    hooks we need and tailor the implementation, without having to work
    around design choices that may have been made for requirements
    different from our own.
    countvajhula committed Jul 26, 2024
    Configuration menu
    Copy the full SHA
    fa3f433 View commit details
    Browse the repository at this point in the history
  2. Update .emacs.d config for installing Rigpa in the README

    Mention including Lithium config as well since that package isn't on
    MELPA (or another package archive) either, and (as I understand it)
    cannot be declared as a dependency using `Package-Requires`.
    countvajhula committed Jul 26, 2024
    Configuration menu
    Copy the full SHA
    974ac42 View commit details
    Browse the repository at this point in the history
  3. remove unused require

    countvajhula committed Jul 26, 2024
    Configuration menu
    Copy the full SHA
    45d7652 View commit details
    Browse the repository at this point in the history
  4. Fix view mode exit

    countvajhula committed Jul 26, 2024
    Configuration menu
    Copy the full SHA
    4e1d97a View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    3225010 View commit details
    Browse the repository at this point in the history

Commits on Jul 29, 2024

  1. Move buffer mode entry actions into the entry hook

    As a convention, we'll avoid specifying anything beyond keybindings in
    the mode definition, leaving everything else to happen via state
    lifecycle hooks.
    countvajhula committed Jul 29, 2024
    Configuration menu
    Copy the full SHA
    a2027dc View commit details
    Browse the repository at this point in the history
  2. remove unused import

    countvajhula committed Jul 29, 2024
    Configuration menu
    Copy the full SHA
    b10d781 View commit details
    Browse the repository at this point in the history
  3. note a todo in line mode

    countvajhula committed Jul 29, 2024
    Configuration menu
    Copy the full SHA
    b07eb71 View commit details
    Browse the repository at this point in the history

Commits on Aug 7, 2024

  1. Configuration menu
    Copy the full SHA
    c436ba0 View commit details
    Browse the repository at this point in the history
  2. Rename enter-modeswitch-mode to highlight transition

    This runs exit hooks for the previous mode and entry hooks for the new
    mode. We also don't run any hooks for Lithium modes which do all their
    hooks internally and via their exposed API. We currently use
    `manage-hooks` as a proxy for "is this a Lithium mode?" Just a
    temporary bridge to something more explicit.
    countvajhula committed Aug 7, 2024
    Configuration menu
    Copy the full SHA
    e92a6fb View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    991233f View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    bc3f248 View commit details
    Browse the repository at this point in the history
  5. note some todos

    countvajhula committed Aug 7, 2024
    Configuration menu
    Copy the full SHA
    a80b0b2 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    1046964 View commit details
    Browse the repository at this point in the history
  7. Toggle evil supporting minor modes via lifecycle hooks

    This streamlines these actions so they're taken at the appropriate
    points in the mode transition lifecycle. Currently, some of these are
    no longer functioning correctly (e.g. keybindings no longer active in
    Symex state, #9), but we'll hopefully restore their functioning in a
    proper way as we go.
    countvajhula committed Aug 7, 2024
    Configuration menu
    Copy the full SHA
    8f2ff66 View commit details
    Browse the repository at this point in the history
  8. Use exit hook to disable supporting minor mode for evil states

    Rather than post-exit hook, as the latter is only called in the high
    level switch mode function and not the low level mode transitions used
    in enter-appropriate-mode.
    countvajhula committed Aug 7, 2024
    Configuration menu
    Copy the full SHA
    14a9b8c View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    37fe904 View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    b23e09c View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    afdb4a3 View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    e103240 View commit details
    Browse the repository at this point in the history
  13. Migrate Application mode from Hydra → Lithium

    Retain transparency menu in Hydra
    countvajhula committed Aug 7, 2024
    Configuration menu
    Copy the full SHA
    c73f6b4 View commit details
    Browse the repository at this point in the history
  14. Configuration menu
    Copy the full SHA
    40a91d5 View commit details
    Browse the repository at this point in the history
  15. Configuration menu
    Copy the full SHA
    8b54ebd View commit details
    Browse the repository at this point in the history
  16. Remove remaining Hydra modal provider code

    We now use Lithium for global modes as it provides the lifecycle hooks
    we need to be able to cleanly treat it as a modal interface provider.
    
    We still use Hydra for features where a menu-driven interface is
    desired and not formally a modal one.
    countvajhula committed Aug 7, 2024
    Configuration menu
    Copy the full SHA
    5d01c75 View commit details
    Browse the repository at this point in the history

Commits on Aug 14, 2024

  1. Use the new global Lithium mode macro

    Also disable Evil Normal state in these modes as that would otherwise
    take precedence over the Lithium mode bindings.
    countvajhula committed Aug 14, 2024
    Configuration menu
    Copy the full SHA
    0cafc9c View commit details
    Browse the repository at this point in the history
  2. Enter and exit corresponding evil states in all buffers

    For global modes, we need to do this to ensure that the mode reflects
    correctly in all buffers via the Evil state indicator, and all that
    these evil states don't take keybinding precedence over the active
    global Lithium mode.
    countvajhula committed Aug 14, 2024
    Configuration menu
    Copy the full SHA
    d737e55 View commit details
    Browse the repository at this point in the history

Commits on Aug 15, 2024

  1. add missing import

    countvajhula committed Aug 15, 2024
    Configuration menu
    Copy the full SHA
    7344b6e View commit details
    Browse the repository at this point in the history
  2. Don't run any actions in the minibuffer

    This avoids encountering a `nil' evil state in some post-exit
    actions that were being performed "for all buffers" (as I recall).
    countvajhula committed Aug 15, 2024
    Configuration menu
    Copy the full SHA
    4a39fcf View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    3a108f3 View commit details
    Browse the repository at this point in the history

Commits on Aug 20, 2024

  1. Incorporate wrapping hooks into low-level mode transitions

    We recently fixed an infinite recursion where post-exit hooks enter
    the "appropriate" mode which calls the main "switch mode" interface,
    which itself attempts to exit the current mode before entering the
    next, and thus triggers post-exit hooks again. To address that, we had
    the "appropriate" mode entry function call the low-level entry
    function instead of the main switch mode transition function, but this
    meant that these were no longer triggering the pre-entry hooks as part
    of mode entry.
    
    This moves the pre-entry and post-exit hooks into the low-level entry
    and exit functions, respectively, so that they are correctly triggered
    in either of these cases (while still avoiding the original infinite
    loop since we only _enter_ and do not _exit_ (again) as part of
    post-exit hooks, while still doing both in the high level "switch").
    
    We also need to explicitly call low level mode exit in on-demand mode
    transitions like "enter lower" and "escape higher" when in a non-local
    starting mode.
    countvajhula committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    8d65090 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    f44a206 View commit details
    Browse the repository at this point in the history
  3. Handle an odd corner case in view mode exit

    The built-in predicate for whether a buffer position is visible on
    screen returns true if we pass in a null buffer position, which is not
    what we expect here.
    countvajhula committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    d1f0501 View commit details
    Browse the repository at this point in the history
  4. Implement Line mode as a local Lithium mode

    Instead of using Evil. For the kind of simple
    point-free ("Rumpelstiltskin") modal interfaces used in Rigpa, Evil is
    more than we need.
    countvajhula committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    82374be View commit details
    Browse the repository at this point in the history

Commits on Aug 21, 2024

  1. Configuration menu
    Copy the full SHA
    0701bfa View commit details
    Browse the repository at this point in the history

Commits on Aug 24, 2024

  1. Configuration menu
    Copy the full SHA
    20577c2 View commit details
    Browse the repository at this point in the history

Commits on Aug 27, 2024

  1. consolidate line mode exit actions

    We don't need anything in pre-entry currently since it isn't
    evil-based anymore.
    countvajhula committed Aug 27, 2024
    Configuration menu
    Copy the full SHA
    18ba844 View commit details
    Browse the repository at this point in the history
  2. disable character cursor in line mode

    The line highlight itself is the relevant cursor in line mode.
    countvajhula committed Aug 27, 2024
    Configuration menu
    Copy the full SHA
    89ea161 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    c556f4c View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    bf23233 View commit details
    Browse the repository at this point in the history

Commits on Aug 29, 2024

  1. Configuration menu
    Copy the full SHA
    35dc30c View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    dcbb891 View commit details
    Browse the repository at this point in the history

Commits on Aug 30, 2024

  1. Configuration menu
    Copy the full SHA
    1968cd1 View commit details
    Browse the repository at this point in the history

Commits on Aug 31, 2024

  1. a comment

    countvajhula committed Aug 31, 2024
    Configuration menu
    Copy the full SHA
    1f9dde5 View commit details
    Browse the repository at this point in the history

Commits on Sep 2, 2024

  1. Use the enter and exit thunks defined by lithium

    Avoid defining these separately for each mode within Rigpa.
    countvajhula committed Sep 2, 2024
    Configuration menu
    Copy the full SHA
    69f4161 View commit details
    Browse the repository at this point in the history
  2. register modes with explicit lifecycle actions

    Don't rely on name-matching interning magic.
    countvajhula committed Sep 2, 2024
    Configuration menu
    Copy the full SHA
    ee2471f View commit details
    Browse the repository at this point in the history
  3. streamline hooks

    countvajhula committed Sep 2, 2024
    Configuration menu
    Copy the full SHA
    a210707 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    0e8e53e View commit details
    Browse the repository at this point in the history

Commits on Sep 3, 2024

  1. Configuration menu
    Copy the full SHA
    35db7a1 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    f550fcc View commit details
    Browse the repository at this point in the history

Commits on Sep 9, 2024

  1. Configuration menu
    Copy the full SHA
    4f5725b View commit details
    Browse the repository at this point in the history
  2. more robust current mode inference

    Checks if there is a lithium mode active, and otherwise uses evil
    state.
    countvajhula committed Sep 9, 2024
    Configuration menu
    Copy the full SHA
    362619a View commit details
    Browse the repository at this point in the history

Commits on Sep 10, 2024

  1. Don't exit current mode when entering another mode in some cases

    Now that Lithium supports mode "stacks," in some cases (i.e. native →
    foreign transition), we want the native mode to be preserved and the
    new one just pushed onto the mode stack. So in such cases, we do not
    exit the source mode before entering the target.
    countvajhula committed Sep 10, 2024
    Configuration menu
    Copy the full SHA
    0e226ab View commit details
    Browse the repository at this point in the history
  2. on foreign mode exit, just exit the mode

    Don't attempt to enter any other mode, as with the mode stack, there
    should already be an active mode once the foreign mode has been
    exited (popped).
    countvajhula committed Sep 10, 2024
    Configuration menu
    Copy the full SHA
    322c069 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    7c5334f View commit details
    Browse the repository at this point in the history
  4. On exiting foreign modes, only set the local evil state

    We no longer rely on the evil state as the source of truth on what the
    current mode is (except for evil-backed states, which currently are
    just the built-in evil states). But we do still rely on evil for UI
    feedback, to indicate visually which mode we are in, even for modes
    that are not evil-backed. We do this just because there is existing
    infrastructure for this for Evil, in the form of mode line
    enhancements and perhaps other things. Eventually we will likely want
    to move away from this, but for now, the only thing we still need to
    do upon exiting forreign modes is to enter the appropriate evil state
    for UI feedback purposes, which we do now instead of attempting to
    enter any particular local mode (which we don't need to do since there
    would still be a local mode on the stack upon foreign mode exit).
    countvajhula committed Sep 10, 2024
    Configuration menu
    Copy the full SHA
    73f8671 View commit details
    Browse the repository at this point in the history
  5. fix another spot where we were using the evil state

    We no longer want to rely on evil as the source of truth for the
    "current mode."
    countvajhula committed Sep 10, 2024
    Configuration menu
    Copy the full SHA
    c206488 View commit details
    Browse the repository at this point in the history
  6. remove outdated todo

    countvajhula committed Sep 10, 2024
    Configuration menu
    Copy the full SHA
    fd1fa6c View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    9afc33c View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    e9d4ce2 View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    e9e583d View commit details
    Browse the repository at this point in the history

Commits on Sep 11, 2024

  1. Merge pull request #22 from countvajhula/symex-on-lithium

    Support symex implemented as a lithium mode
    countvajhula authored Sep 11, 2024
    Configuration menu
    Copy the full SHA
    6f99d62 View commit details
    Browse the repository at this point in the history
  2. (history) move git-timemachine init to pre-entry hook

    This still ends up setting the evil state in the original buffer rather
    than the timemachine buffer, though the evil state is set post-entry.
    Not sure why.
    
    Note the evil state is purely for UI feedback purposes and has no
    functional effect.
    countvajhula committed Sep 11, 2024
    Configuration menu
    Copy the full SHA
    7524136 View commit details
    Browse the repository at this point in the history

Commits on Sep 12, 2024

  1. Configuration menu
    Copy the full SHA
    f447d8e View commit details
    Browse the repository at this point in the history
  2. 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.
    countvajhula committed Sep 12, 2024
    Configuration menu
    Copy the full SHA
    562f9ed View commit details
    Browse the repository at this point in the history

Commits on Sep 18, 2024

  1. Configuration menu
    Copy the full SHA
    11d83db View commit details
    Browse the repository at this point in the history
  2. escape to normal from replace state

    While in replace state, escaping was having no effect. As it is
    considered a foreign state, it attempts to only exit the mode, which
    for evil-backed modes is a no-op. Additionally, as it isn't a lithium
    mode, there isn't even a notion of a stack wherein exiting replace
    mode would reinstate any prior mode. Escaping to normal seems the most
    straightforward thing to do, but I'm not sure if there may be a more
    correct handling.
    countvajhula committed Sep 18, 2024
    Configuration menu
    Copy the full SHA
    aed4bd2 View commit details
    Browse the repository at this point in the history

Commits on Sep 19, 2024

  1. exit mode in meta levels prior to returning to ground

    Formerly I think with hydra we were implicitly exiting. With lithium,
    global modes like Buffer remain active even when the original buffer
    is killed, so we need to explicitly exit at the appropriate time.
    countvajhula committed Sep 19, 2024
    Configuration menu
    Copy the full SHA
    efe4ca3 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    484605c View commit details
    Browse the repository at this point in the history