]> code.delx.au - gnu-emacs-elpa/blobdiff - packages/aggressive-indent/aggressive-indent.el
Merge commit '97eaa5778ce0cd596a0807ef2e676d2681aabf84'
[gnu-emacs-elpa] / packages / aggressive-indent / aggressive-indent.el
index 006114b6594e783deeb8dca8a9def28913c82813..22647d14c0ecbad03678bbbdae3f6d86c54faafa 100644 (file)
@@ -4,7 +4,7 @@
 
 ;; Author: Artur Malabarba <emacs@endlessparentheses.com>
 ;; URL: https://github.com/Malabarba/aggressive-indent-mode
-;; Version: 1.5.3
+;; Version: 1.6
 ;; 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,19 +371,14 @@ 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
         (save-excursion
           (ignore-errors
-            (save-restriction
-              (narrow-to-defun)
-              (check-parens)
-              t)))))
+            (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."