From: Artur Malabarba Date: Fri, 8 Jan 2016 18:08:58 +0000 (+0000) Subject: Fix #67 - Avoid changing the selected window X-Git-Url: https://code.delx.au/gnu-emacs-elpa/commitdiff_plain/651812f8fca9c0beb337a04438949bbfb879b5f7 Fix #67 - Avoid changing the selected window --- diff --git a/aggressive-indent.el b/aggressive-indent.el index 89c528466..febbe4ff7 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."