-
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
Idempotence of null operations #98
Draft
countvajhula
wants to merge
81
commits into
drym-org:2.0-integration
Choose a base branch
from
countvajhula:idempotence-of-null-operations
base: 2.0-integration
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Idempotence of null operations #98
countvajhula
wants to merge
81
commits into
drym-org:2.0-integration
from
countvajhula:idempotence-of-null-operations
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This was formerly encountering an unhandled error.
countvajhula
force-pushed
the
2.0-integration
branch
from
March 22, 2023 23:24
dbcdc96
to
824be59
Compare
countvajhula
force-pushed
the
idempotence-of-null-operations
branch
from
March 22, 2023 23:59
5efb357
to
79b5a01
Compare
countvajhula
force-pushed
the
2.0-integration
branch
from
June 15, 2024 03:05
bab9c37
to
9c43278
Compare
countvajhula
force-pushed
the
2.0-integration
branch
2 times, most recently
from
September 20, 2024 23:39
52f885b
to
95bf3a5
Compare
countvajhula
force-pushed
the
2.0-integration
branch
from
December 6, 2024 00:50
95bf3a5
to
0ecfca9
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
Certain operations like
I
,A
,O
(among others) insert spaces or change the local region in the buffer in some way in preparation for the change we are about to make. This is typically desirable when we do actually continue. But sometimes we may do this accidentally or change our minds, and in these cases, the buffer is left in a changed state even though we didn't actually do anything. We call these "null" operations, and we'd like them to be idempotent in the sense that they should leave the buffer unchanged. See #92 for additional context.At present this PR takes the approach of detecting that an edit was attempted but no change was made, and then inverting the preparatory change by using
undo
. This seems to work fairly well, but as it does invokeundo
, any potential bugs in this area could be fraught with the risk of undoing actual user changes.One improvement could be to, at the time of initiating the preparatory change, construct and store the inverse operation (e.g. as quoted code) in some kind of stack that could then be applied as a fresh change, which would undo the change without actually using undo. In this option, we'd also need to pop off the top two items on the actual undo stack so that they aren't encountered when the user actually attempts to undo (but this once again involves mutating the undo list!).
Another possibility is for these operations to not actually change the buffer to begin with, but only seem to, by showing some kind of preview of what the buffer would look like if the user continued with the change. I'm not sure if Emacs offers any facilities for this. Could overlays be used?
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.)