Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Make the idle timer not be buffer local" #121

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions aggressive-indent.el
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ If you feel aggressive-indent is causing Emacs to hang while
typing, try tweaking this number."
:type 'float)

(defvar aggressive-indent--idle-timer nil
(defvar-local aggressive-indent--idle-timer nil
"Idle timer used for indentation")

(defun aggressive-indent--indent-if-changed ()
Expand All @@ -421,15 +421,18 @@ typing, try tweaking this number."
(save-excursion
(save-selected-window
(while-no-input
(aggressive-indent--proccess-changed-list-and-indent))))))
(aggressive-indent--proccess-changed-list-and-indent))))
(when (timerp aggressive-indent--idle-timer)
(cancel-timer aggressive-indent--idle-timer))))

(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)
(unless (timerp aggressive-indent--idle-timer)
(setq aggressive-indent--idle-timer
(run-with-idle-timer aggressive-indent-sit-for-time t #'aggressive-indent--indent-if-changed)))))
(when (timerp aggressive-indent--idle-timer)
(cancel-timer aggressive-indent--idle-timer))
(setq aggressive-indent--idle-timer
(run-with-idle-timer aggressive-indent-sit-for-time t #'aggressive-indent--indent-if-changed))))

;;; Minor modes
;;;###autoload
Expand Down Expand Up @@ -462,8 +465,7 @@ typing, try tweaking this number."
(add-hook 'before-save-hook #'aggressive-indent--proccess-changed-list-and-indent nil 'local))
;; Clean the hooks
(when (timerp aggressive-indent--idle-timer)
(cancel-timer aggressive-indent--idle-timer)
(setq aggressive-indent--idle-timer nil))
(cancel-timer aggressive-indent--idle-timer))
(remove-hook 'after-change-functions #'aggressive-indent--keep-track-of-changes 'local)
(remove-hook 'before-save-hook #'aggressive-indent--proccess-changed-list-and-indent 'local)
(remove-hook 'post-command-hook #'aggressive-indent--softly-indent-defun 'local)))
Expand Down