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

Really protect against unwanted indentation after undo #119

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Commits on Dec 13, 2019

  1. Really protect against unwanted indentation after undo

    When I am undoing changes to a region I really want the changes to be
    undone verbatim, that is, I want the buffer's contents to be like they
    were before the change that I want to undo occured.  This is the very
    definition of undo.
    
    It is probably the rationale for giving undo special treatment in
    aggressive-indent--internal-dont-indent-if in the first place.  It
    means that the undo command won't immediately cause reindentation.
    
    But it doesn't fix the whole problem, because changes performed by
    undo itself are still recorded into aggressive-indent--changed-list
    and the very next command, be it a move or an edit somewhere else,
    will still cause those regions to be indented.  Among other things,
    it's impossible in practice to use `undo' to undo an aggressive indent
    of a region.
    
    The proposed fix checks adds a function to the post-command hook to
    check for aggressive-indent-protected-commands and clear the change
    list if the current command is in that list.  This is safe if those
    changes can only have been performed by the command whose
    auto-indentation effects we want to prevent.
    
    * aggressive-indent.el (aggressive-indent--keep-track-of-changes):
    Check undo-in-progress.
    
    * aggressive-indent.el
    (aggressive-indent--internal-dont-indent-if): Remove check of
    aggressive-indent-protected-commands and undo-in-progress.
    (aggressive-indent--post-command): New helper.
    (aggressive-indent-mode): Put aggressive-indent--post-command in
    post-command-hook and remove it when exiting minor mode.
    joaotavora committed Dec 13, 2019
    Configuration menu
    Copy the full SHA
    9bd3a85 View commit details
    Browse the repository at this point in the history
  2. Be slightly more careful before clearing the changes list

    * aggressive-indent.el
    (aggressive-indent--pre-command-change-head): New variable.
    (aggressive-indent--pre-command): New function.
    (aggressive-indent-mode): Add aggressive-indent--pre-command to
    pre-command-hook and remove it when exiting minor mode.
    joaotavora committed Dec 13, 2019
    Configuration menu
    Copy the full SHA
    3f3add4 View commit details
    Browse the repository at this point in the history