diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2016-04-04 09:56:06 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2016-04-04 09:56:06 -0700 |
commit | 0a0c05da3fbfb85bfabac5b4a75309ed5b5fa755 (patch) | |
tree | cf870dcdb746fcecc6499c1235c4f7535e6b17be | |
parent | a9d2bebda47d53bb64abc3a588604fbb81c57fc7 (diff) | |
parent | 456c40803432b34842e43ceda66cdd105fbf8866 (diff) |
Merge tag '1.5.2'
-rw-r--r-- | aggressive-indent.el | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/aggressive-indent.el b/aggressive-indent.el index 764a332..9aa8226 100644 --- a/aggressive-indent.el +++ b/aggressive-indent.el @@ -4,7 +4,7 @@ ;; Author: Artur Malabarba <emacs@endlessparentheses.com> ;; URL: https://github.com/Malabarba/aggressive-indent-mode -;; Version: 1.5.1 +;; Version: 1.5.2 ;; Package-Requires: ((emacs "24.1") (cl-lib "0.5")) ;; Keywords: indent lisp maint tools ;; Prefix: aggressive-indent @@ -368,10 +368,24 @@ 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)))) + (defun aggressive-indent--keep-track-of-changes (l r &rest _) "Store the limits (L and R) of each change in the buffer." (when aggressive-indent-mode - (push (list l r) aggressive-indent--changed-list))) + (push (list l r) aggressive-indent--changed-list) + (aggressive-indent--check-parens))) ;;; Minor modes ;;;###autoload @@ -393,11 +407,12 @@ or messages." (memq major-mode '(text-mode fundamental-mode)) buffer-read-only)) (aggressive-indent-mode -1) - ;; Should electric indent be ON or OFF? + ;; Should electric indent be ON or OFF? (if (or (eq aggressive-indent-dont-electric-modes t) (cl-member-if #'derived-mode-p aggressive-indent-dont-electric-modes)) (aggressive-indent--local-electric nil) (aggressive-indent--local-electric t)) + (aggressive-indent--check-parens) (add-hook 'after-change-functions #'aggressive-indent--keep-track-of-changes nil 'local) (add-hook 'post-command-hook #'aggressive-indent--indent-if-changed nil 'local)) ;; Clean the hooks |