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

Idempotence of null operations #98

Draft
wants to merge 81 commits into
base: 2.0-integration
Choose a base branch
from

Conversation

countvajhula
Copy link
Collaborator

@countvajhula countvajhula commented Mar 16, 2023

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 invoke undo, 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

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

@countvajhula countvajhula mentioned this pull request Mar 16, 2023
16 tasks
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.
@countvajhula countvajhula force-pushed the idempotence-of-null-operations branch from 5efb357 to 79b5a01 Compare March 22, 2023 23:59
@countvajhula countvajhula force-pushed the 2.0-integration branch 2 times, most recently from 52f885b to 95bf3a5 Compare September 20, 2024 23:39
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