From d4616c8caf03671ab62f452c7e86b60f9d4b1ec6 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Mon, 7 Jan 2019 19:15:56 -0200 Subject: [PATCH] Try a different method of keeping timers from getting out of hand Close #121 Another attempt at #112 --- aggressive-indent.el | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/aggressive-indent.el b/aggressive-indent.el index 5042f6f..5fc114a 100644 --- a/aggressive-indent.el +++ b/aggressive-indent.el @@ -417,13 +417,15 @@ typing, try tweaking this number." (defun aggressive-indent--indent-if-changed () "Indent any region that changed in the last command loop." - (when (and aggressive-indent-mode aggressive-indent--changed-list) - (save-excursion - (save-selected-window - (while-no-input - (aggressive-indent--proccess-changed-list-and-indent)))) - (when (timerp aggressive-indent--idle-timer) - (cancel-timer aggressive-indent--idle-timer)))) + (if (not (buffer-live-p (current-buffer))) + (cancel-timer aggressive-indent--idle-timer) + (when (and aggressive-indent-mode aggressive-indent--changed-list) + (save-excursion + (save-selected-window + (while-no-input + (aggressive-indent--proccess-changed-list-and-indent)))) + (when (timerp aggressive-indent--idle-timer) + (cancel-timer aggressive-indent--idle-timer))))) (defun aggressive-indent--keep-track-of-changes (l r &rest _) "Store the limits (L and R) of each change in the buffer."