-
Notifications
You must be signed in to change notification settings - Fork 23
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
Symex on Lithium #146
base: 2.0-integration
Are you sure you want to change the base?
Symex on Lithium #146
Conversation
9c43278
to
a6578b5
Compare
f77d6b3
to
99eefce
Compare
52f885b
to
95bf3a5
Compare
99eefce
to
9ca1ddb
Compare
95bf3a5
to
0ecfca9
Compare
c48f0ae
to
c9e8726
Compare
Just a proof of concept. We'll want to improve the implementation in Rigpa to be less magical in terms of expected function names, and also make the separation of entry actions and side effects (via hooks) more uniform across symex and the modes defined in Rigpa.
c9e8726
to
49b2ed4
Compare
I believe this is a leftover from when we used to use regions to "highlight" symexes. Nowadays we use an overlay for this, so there's no case I can think of (currently - in the future we may have selection of regions via drym-org#53) where the region would be active while in Symex mode.
Hullo @devcarbon-com ! FYI, I'm planning to merge this into the integration branch in the coming days. I'll probably just do a little more testing to record any remaining bugs to fix. This PR is one part of eliminating reliance on Evil -- the other, I think, is replacing any use of Btw once this is merged, the 2.0-integration branch as well as Rigpa will require Lithium to be installed, and that is currently not on MELPA:
Hope you're doing well! |
Looking at it more now, I think one component that may be tricky to replace is Also cc @j-shilling who implemented the awesome repeat functionality - in case you have any thoughts. |
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.)