Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information