diff options
author | Artur Malabarba <bruce.connor.am@gmail.com> | 2016-01-08 18:08:58 +0000 |
---|---|---|
committer | Artur Malabarba <bruce.connor.am@gmail.com> | 2016-01-15 22:14:29 +0000 |
commit | 651812f8fca9c0beb337a04438949bbfb879b5f7 (patch) | |
tree | cc1e55086166adfac8c25cdbfd46e4e9206c31cb | |
parent | 0cf12ad0cc6868b26618100fb72e98b21b377e25 (diff) |
Fix #67 - Avoid changing the selected window
-rw-r--r-- | aggressive-indent.el | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/aggressive-indent.el b/aggressive-indent.el index 89c5284..febbe4f 100644 --- a/aggressive-indent.el +++ b/aggressive-indent.el @@ -352,19 +352,21 @@ or messages." (defun aggressive-indent--indent-if-changed () "Indent any region that changed in the last command loop." (when aggressive-indent--changed-list - (unless (or (run-hook-wrapped 'aggressive-indent--internal-dont-indent-if #'eval) - (aggressive-indent--run-user-hooks)) - (while-no-input - (redisplay) - (let ((inhibit-modification-hooks t) - (inhibit-point-motion-hooks t) - (indent-function - (if (cl-member-if #'derived-mode-p aggressive-indent-modes-to-prefer-defun) - #'aggressive-indent--softly-indent-defun #'aggressive-indent--softly-indent-region-and-on))) - (while aggressive-indent--changed-list - (apply indent-function (car aggressive-indent--changed-list)) - (setq aggressive-indent--changed-list - (cdr aggressive-indent--changed-list)))))))) + (save-excursion + (save-selected-window + (unless (or (run-hook-wrapped 'aggressive-indent--internal-dont-indent-if #'eval) + (aggressive-indent--run-user-hooks)) + (while-no-input + (redisplay) + (let ((inhibit-modification-hooks t) + (inhibit-point-motion-hooks t) + (indent-function + (if (cl-member-if #'derived-mode-p aggressive-indent-modes-to-prefer-defun) + #'aggressive-indent--softly-indent-defun #'aggressive-indent--softly-indent-region-and-on))) + (while aggressive-indent--changed-list + (apply indent-function (car aggressive-indent--changed-list)) + (setq aggressive-indent--changed-list + (cdr aggressive-indent--changed-list)))))))))) (defun aggressive-indent--keep-track-of-changes (l r &rest _) "Store the limits (L and R) of each change in the buffer." |