branch: master commit 221b58312f0ae5a2ba857ebb4e1a66bb09ba6ace Author: Jackson Ray Hamilton <jack...@jacksonrayhamilton.com> Commit: Jackson Ray Hamilton <jack...@jacksonrayhamilton.com>
Update hooking strategy. --- context-coloring.el | 14 +++++++++++--- 1 files changed, 11 insertions(+), 3 deletions(-) diff --git a/context-coloring.el b/context-coloring.el index 5d58ff2..61d3807 100644 --- a/context-coloring.el +++ b/context-coloring.el @@ -438,7 +438,11 @@ colorizing would be redundant." (context-coloring-kill-scopifier) (when (not (null 'context-coloring-colorize-idle-timer)) (cancel-timer context-coloring-colorize-idle-timer)) - (remove-hook 'after-change-functions 'context-coloring-change-function t) + (cond + ((equal major-mode 'js2-mode) + (remove-hook 'js2-post-parse-callbacks 'context-coloring-change-function t)) + (t + (remove-hook 'after-change-functions 'context-coloring-change-function t))) (font-lock-mode) (jit-lock-mode t)) @@ -451,11 +455,15 @@ colorizing would be redundant." ;; Colorize once initially. ;; (let ((start-time (float-time))) - (context-coloring-colorize) + (context-coloring-colorize) ;; (message "Elapsed time: %f" (- (float-time) start-time))) ;; Only recolor on change. - (add-hook 'after-change-functions 'context-coloring-change-function nil t) + (cond + ((equal major-mode 'js2-mode) + (add-hook 'js2-post-parse-callbacks 'context-coloring-change-function nil t)) + (t + (add-hook 'after-change-functions 'context-coloring-change-function nil t))) ;; Only recolor idly. (setq context-coloring-colorize-idle-timer