Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary of Changes
Use Lithium instead of Evil as the modal interface provider.
The needs of Symex are quite modest here -- we just need a persistent modal interface that maps to Symex commands. Evil includes something like this, but also comes with a lot more as it is a full Vim emulation (text objects, operators, Ex mode, ... good stuff! But none of it used in Symex), as @devcarbon-com and others have pointed out before.
We've tried other options in the past like Hydra, and there are other options like Transient.
With Hydra, it's quick and easy for temporary actions and provides a great UI, but as we are trying to use it in a more persistent way, it ends up being either too rigid by disallowing standard Emacs operations like saving the buffer or using the minibuffer, or too ethereal, disappearing each time we perform such operations thus needing to be resummoned. The lifecycle hooks it provides are also insufficient for this use case.
We haven't tried Transient as a modal provider, but it is unlikely to be what we need as it, too, is designed to be "transient" rather than persistent. It no longer seems worth it to try to shoehorn a technology with different design constraints into our simple, yet specialized, use case, as that has taken up a lot of extra time in the past.
What we need is something lightweight, modal, persistent, and extensible, with explicit modeling of state transitions.
So I made Lithium, which is just a thin wrapper around Emacs's built-in keymap machinery, including minor modes, globalized minor modes, and overriding maps, which provide us some of the controls we need. In addition to modal keybindings, Lithium also maintains a stack of modes in each buffer, which allows new modes to temporarily override prior modes and then be "popped" to restore the prior modes. This is a useful in Rigpa, where we occasionally enter Buffer mode or Window mode but would like to seamlessly return to Symex mode or Insert mode or whatever local mode upon exiting the global mode. This has proved challenging to achieve cleanly in the past due to the complexity of using lifecycle hooks that weren't always available, but the stack is a natural model for it and avoids the need for hooks here entirely.
Note that Lithium is not yet on MELPA, so once this PR is merged, we will need this in
.emacs.d
:See also: Companion PR on Rigpa.
Public Domain Dedication
(Why: The freely released, copyright-free work in this repository represents an investment in a better way of doing things called attribution-based economics. Attribution-based economics is based on the simple idea that we gain more by giving more, not by holding on to things that, truly, we could only create because we, in our turn, received from others. As it turns out, an economic system based on attribution -- where those who give more are more empowered -- is significantly more efficient than capitalism while also being stable and fair (unlike capitalism, on both counts), giving it transformative power to elevate the human condition and address the problems that face us today along with a host of others that have been intractable since the beginning. You can help make this a reality by releasing your work in the same way -- freely into the public domain in the simple hope of providing value. Learn more about attribution-based economics at drym.org, tell your friends, do your part.)