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

Symex on Lithium #146

Open
wants to merge 5 commits into
base: 2.0-integration
Choose a base branch
from

Conversation

countvajhula
Copy link
Collaborator

@countvajhula countvajhula commented Sep 10, 2024

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:

(use-package lithium
  :straight
  (lithium
    :type git
    :host github
    :repo "countvajhula/lithium"))

See also: Companion PR on Rigpa.

Public Domain Dedication

  • In contributing, I relinquish any copyright claims on my contribution and freely release it into the public domain in the simple hope that it will provide value.

(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.)

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant