]> code.delx.au - gnu-emacs-elpa/blobdiff - aggressive-indent.el
Don't narrow-to-defun when checking parens
[gnu-emacs-elpa] / aggressive-indent.el
index 9aa82266ed10f19713c0fdb5e06394c5958d0350..7055f9cee77548b562010c09a3a86f61070b1ed9 100644 (file)
@@ -4,7 +4,7 @@
 
 ;; Author: Artur Malabarba <emacs@endlessparentheses.com>
 ;; URL: https://github.com/Malabarba/aggressive-indent-mode
-;; Version: 1.5.2
+;; Version: 1.5.3
 ;; Package-Requires: ((emacs "24.1") (cl-lib "0.5"))
 ;; Keywords: indent lisp maint tools
 ;; Prefix: aggressive-indent
@@ -349,9 +349,12 @@ or messages."
   "List of (left right) limit of regions changed in the last command loop.")
 (make-variable-buffer-local 'aggressive-indent--changed-list)
 
+(defvar-local aggressive-indent--balanced-parens t
+  "Non-nil if the current-buffer has balanced parens.")
+
 (defun aggressive-indent--indent-if-changed ()
   "Indent any region that changed in the last command loop."
-  (when aggressive-indent--changed-list
+  (when (and aggressive-indent--changed-list aggressive-indent--balanced-parens)
     (save-excursion
       (save-selected-window
         (unless (or (run-hook-wrapped 'aggressive-indent--internal-dont-indent-if #'eval)
@@ -368,18 +371,15 @@ or messages."
                 (setq aggressive-indent--changed-list
                       (cdr aggressive-indent--changed-list))))))))))
 
-(defvar-local aggressive-indent--balanced-parens t
-  "Non-nil if the current-buffer has balanced parens.")
-
 (defun aggressive-indent--check-parens ()
   "Check if parens are balanced in the current buffer.
 Store result in `aggressive-indent--balanced-parens'."
   (setq aggressive-indent--balanced-parens
-        (ignore-errors
-          (save-restriction
-            (narrow-to-defun)
-            (check-parens)
-            t))))
+        (save-excursion
+          (ignore-errors
+            (save-restriction
+              (check-parens)
+              t)))))
 
 (defun aggressive-indent--keep-track-of-changes (l r &rest _)
   "Store the limits (L and R) of each change in the buffer."