Skip to content

Commit

Permalink
Improve on previous strategy for better protecting undo
Browse files Browse the repository at this point in the history
This protects against other similar "indent on very next command"
problems similar to the one described in #119.

* aggressive-indent.el
(aggressive-indent--proccess-changed-list-and-indent): Clear
aggressive-indent--changed-list.
(aggressive-indent--keep-track-of-changes): Don't check undo-in-progress
  • Loading branch information
joaotavora committed Nov 19, 2018
1 parent d17fd47 commit 3d48b53
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions aggressive-indent.el
Original file line number Diff line number Diff line change
Expand Up @@ -389,8 +389,9 @@ or messages."

(defun aggressive-indent--proccess-changed-list-and-indent ()
"Indent the regions in `aggressive-indent--changed-list'."
(unless (or (run-hook-wrapped 'aggressive-indent--internal-dont-indent-if #'eval)
(aggressive-indent--run-user-hooks))
(if (or (run-hook-wrapped 'aggressive-indent--internal-dont-indent-if #'eval)
(aggressive-indent--run-user-hooks))
(setq aggressive-indent--changed-list nil) ;; forget any past changes
(let ((inhibit-modification-hooks t)
(inhibit-point-motion-hooks t)
(indent-function
Expand Down Expand Up @@ -426,8 +427,7 @@ 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
(unless undo-in-progress
(push (list l r) aggressive-indent--changed-list))
(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 3d48b53

Please sign in to comment.