From 3d48b53afea6070e9f9fbfc323bab57509ebc044 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20T=C3=A1vora?= Date: Mon, 19 Nov 2018 15:34:57 +0000 Subject: [PATCH] Improve on previous strategy for better protecting undo 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 --- aggressive-indent.el | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/aggressive-indent.el b/aggressive-indent.el index ce64240..828d777 100644 --- a/aggressive-indent.el +++ b/aggressive-indent.el @@ -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 @@ -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)))))