-
Notifications
You must be signed in to change notification settings - Fork 24
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
User context handling #102
base: 2.0-integration
Are you sure you want to change the base?
User context handling #102
Conversation
@devcarbon-com This is an early prototype of the context handling mechanism we talked about. If you want to try writing the
... calling Then, once that's working, you can register the context handler using:
... and in theory, at that point, entering Symex within an Elisp literal code block should work for evaluation ( |
@countvajhula Nice! I'll take a look. |
This is intended to encapsulate any setup and teardown actions that in general would need to be performed with any symex transformation, such as re-indenting, whitespace elimination, etc. It should also avoid the need to rely on advice for some of these actions, and also therefore make it easier for developers (including third parties) to define such transformations, as all such logistical concerns can be taken care of internally in the macro.
Similar to `symex-define-command`, this will take care of entering an insertion state at the end, so that the implementation of the command only needs to take care of the core operation and placing point at the right place (without entering an insertion state).
Handle additional cases of empty lists to help ensure that motion does not attempt to enter empty expressions.
This fixes some indentation bugs in pasting multiple yanked expressions and in pasting with a quantifier, and also simplifies the code by sharing functionality common to pasting before and after.
Eliminate special cases by using generic region indenting. Also add the abilty to specify a quantifier/count.
dbcdc96
to
824be59
Compare
Infer user context by setting buffer-local variables that guide the operation of the Symex runtime (currently only evaluation). The user context inference is done via (predicate, handler) pairs that may be registered for any context category, triggering desired custom behavior based on conditions at any desired point in user operation, e.g. at entry into Symex state to set the appropriate runtime functions that should be used in evaluating and otherwise running the indicated code. Note: there is currently a bug related to setting function-valued variables, and this doesn't quite work yet.
4b3fa35
to
a355b7a
Compare
bab9c37
to
9c43278
Compare
52f885b
to
95bf3a5
Compare
95bf3a5
to
0ecfca9
Compare
Summary of Changes
This is a prototype for generalized "user context" handling. The idea is that there are many elements that inform the configuration when we enter Symex state, and for many of them, it doesn't make sense to handle them explicitly in Symex. Instead, we need some kind of "glue" layer that allows users to customize the interactions with other extensions and contexts. The present PR is one possible way to implement this layer. I haven't thought through all the ramifications yet and for now it only implements the
eval
functionality (default binding:e
) using this approach.The first and most obvious element that informs the Symex runtime context is the major mode of the buffer. If it is ELisp, we want to employ ELisp runtime functions for evaluation, doc lookups, etc. If it is Racket, then we want to use Racket functions for these, and so on.
But there are cases where a source major mode isn't sufficient context to determine whether Symex mode is even applicable. In these cases there may be additional context that could be used, such as point being within a code block in an Org buffer (#95 ). Contradistinctively, there are cases where the major mode alone isn't enough to determine the appropriate configuration even if it suggests that Symex is applicable. For instance, if we are in an Elisp buffer but point is within a comment or a string, we would want to configure Symex differently or perhaps avoid entering Symex altogether, as we might do in a Rigpa setting, where we might prefer to skip over Symex to enter Normal state directly in Rigpa's Lisp tower.
In all of these cases, it seems we are looking for a way to infer "user context" -- distinguishing features of the user's current configuration -- that will allow us to apply the appropriate configuration in a tailored rather than one-size-fits-all way. Since this seems like a general need, it might make the most sense to have this as a separate Emacs extension. For now, this module uses the identifier prefix
contextualize-
to differentiate it from Symex-specific functionality that uses the prefixsymex-
.Next steps
Normal ↔ Symex ↔ Insert
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.)