Skip to content

Commit

Permalink
Really protect against unwanted indentation after undo
Browse files Browse the repository at this point in the history
When I am undoing changes to a region I really want the changes to be
undone verbatim.  This is probably the rationale for have
undo-in-progress in aggressive-indent--internal-dont-indent-if in the
first place.

But it doesn't fix the whole problem, because changes performed by
undo are still recorded into aggressive-indent--changed-list and the
very next command will indent those regions.  This means it's
impossible in practice to use `undo' to undo an aggressive indent of a
region.

The fix proposed here checks undo-in-progress before registering a
change.  It's possible that other elements (but maybe not all) in
aggressive-indent--internal-dont-indent-if merit this treatment, too.

* aggressive-indent.el (aggressive-indent--keep-track-of-changes):
Check undo-in-progress.
  • Loading branch information
joaotavora committed Nov 19, 2018
1 parent cc8da01 commit d17fd47
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion aggressive-indent.el
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,8 @@ typing, try tweaking this number."
(defun aggressive-indent--keep-track-of-changes (l r &rest _)
"Store the limits (L and R) of each change in the buffer."
(when aggressive-indent-mode
(push (list l r) aggressive-indent--changed-list)
(unless undo-in-progress
(push (list l r) aggressive-indent--changed-list))
(unless (timerp aggressive-indent--idle-timer)
(setq aggressive-indent--idle-timer
(run-with-idle-timer aggressive-indent-sit-for-time t #'aggressive-indent--indent-if-changed)))))
Expand Down

0 comments on commit d17fd47

Please sign in to comment.