[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 59a6c8e 34/47: Fix timer disposal and timer buffer detecti
From: |
Jackson Ray Hamilton |
Subject: |
[elpa] master 59a6c8e 34/47: Fix timer disposal and timer buffer detection. |
Date: |
Mon, 18 May 2015 09:52:01 +0000 |
branch: master
commit 59a6c8eac76fe32a2ae07e3b9c76668b3a81e907
Author: Jackson Ray Hamilton <address@hidden>
Commit: Jackson Ray Hamilton <address@hidden>
Fix timer disposal and timer buffer detection.
---
context-coloring.el | 22 +++++++++-------------
test/context-coloring-test.el | 2 +-
2 files changed, 10 insertions(+), 14 deletions(-)
diff --git a/context-coloring.el b/context-coloring.el
index bf1d533..ae5ed90 100644
--- a/context-coloring.el
+++ b/context-coloring.el
@@ -47,12 +47,6 @@
(require 'js2-mode)
-;;; Local variables
-
-(defvar-local context-coloring-buffer nil
- "Reference to this buffer (for timers).")
-
-
;;; Utilities
(defun context-coloring-join (strings delimiter)
@@ -811,7 +805,7 @@ read the scopifier's response asynchronously and apply a
parsed
list of tokens to `context-coloring-apply-tokens'.
Invoke CALLBACK when complete."
- (let ((buffer context-coloring-buffer))
+ (let ((buffer (current-buffer)))
(context-coloring-scopify-shell-command
command
(lambda (output)
@@ -913,9 +907,9 @@ used.")
(context-coloring-kill-scopifier)
(setq context-coloring-changed t))
-(defun context-coloring-maybe-colorize ()
+(defun context-coloring-maybe-colorize (buffer)
"Colorize the current buffer if it has changed."
- (when (and (eq context-coloring-buffer (window-buffer (selected-window)))
+ (when (and (eq buffer (current-buffer))
context-coloring-changed)
(setq context-coloring-changed nil)
(context-coloring-colorize)))
@@ -1334,11 +1328,14 @@ Supported modes: `js-mode', `js3-mode'"
"Setup idle change detection."
(add-hook
'after-change-functions 'context-coloring-change-function nil t)
+ (add-hook
+ 'kill-buffer-hook 'context-coloring-teardown-idle-change-detection nil t)
(setq context-coloring-colorize-idle-timer
(run-with-idle-timer
context-coloring-delay
t
- 'context-coloring-maybe-colorize)))
+ 'context-coloring-maybe-colorize
+ (current-buffer))))
(defun context-coloring-teardown-idle-change-detection ()
"Teardown idle change detection."
@@ -1346,6 +1343,8 @@ Supported modes: `js-mode', `js3-mode'"
(when context-coloring-colorize-idle-timer
(cancel-timer context-coloring-colorize-idle-timer))
(remove-hook
+ 'kill-buffer-hook 'context-coloring-teardown-idle-change-detection t)
+ (remove-hook
'after-change-functions 'context-coloring-change-function t))
@@ -1424,9 +1423,6 @@ elisp tracks, and asynchronously for shell command
tracks."
(font-lock-mode)
(jit-lock-mode t))
- ;; Remember this buffer. This value should not be dynamically-bound.
- (setq context-coloring-buffer (current-buffer))
-
;; Font lock is incompatible with this mode; the converse is also true.
(font-lock-mode 0)
(jit-lock-mode nil)
diff --git a/test/context-coloring-test.el b/test/context-coloring-test.el
index 9573119..5007c3c 100644
--- a/test/context-coloring-test.el
+++ b/test/context-coloring-test.el
@@ -474,7 +474,7 @@ FOREGROUND. Apply ARGUMENTS to
(funcall done)))
(insert " ")
(set-window-buffer (selected-window) (current-buffer))
- (context-coloring-maybe-colorize)))
+ (context-coloring-maybe-colorize (current-buffer))))
(context-coloring-mode))))
(ert-deftest context-coloring-test-check-version ()
- [elpa] master 09ec36e 24/47: Add interruption mechanism., (continued)
- [elpa] master 09ec36e 24/47: Add interruption mechanism., Jackson Ray Hamilton, 2015/05/18
- [elpa] master dc2f9a6 25/47: Refactor maybe-colorize-comments-and-strings., Jackson Ray Hamilton, 2015/05/18
- [elpa] master a556195 26/47: Tweak iteration values, add logging., Jackson Ray Hamilton, 2015/05/18
- [elpa] master 3fc5b20 27/47: Make dispatches fully redefinable., Jackson Ray Hamilton, 2015/05/18
- [elpa] master 89f20e4 28/47: Improve interruptability of syntactic coloring., Jackson Ray Hamilton, 2015/05/18
- [elpa] master d24de46 31/47: Add TODO., Jackson Ray Hamilton, 2015/05/18
- [elpa] master 07c5852 30/47: Add idle change teardown function., Jackson Ray Hamilton, 2015/05/18
- [elpa] master ef544ef 29/47: Fontify keywords., Jackson Ray Hamilton, 2015/05/18
- [elpa] master 5c5b429 32/47: Fix font-lock error., Jackson Ray Hamilton, 2015/05/18
- [elpa] master c0a6689 33/47: Only set defaults when the mode is enabled., Jackson Ray Hamilton, 2015/05/18
- [elpa] master 59a6c8e 34/47: Fix timer disposal and timer buffer detection.,
Jackson Ray Hamilton <=
- [elpa] master 88a921f 35/47: Improve defun regexp., Jackson Ray Hamilton, 2015/05/18
- [elpa] master 438cb33 36/47: Fix incorrect last fontified position., Jackson Ray Hamilton, 2015/05/18
- [elpa] master 1d7761c 37/47: Add constant comment test., Jackson Ray Hamilton, 2015/05/18
- [elpa] master 4ff6e82 39/47: Remove verbose parsing., Jackson Ray Hamilton, 2015/05/18
- [elpa] master 4bbce56 38/47: Add test for interruption., Jackson Ray Hamilton, 2015/05/18
- [elpa] master 6392d1f 40/47: Bind optional parameters earlier., Jackson Ray Hamilton, 2015/05/18
- [elpa] master 5051a70 42/47: Update documentation for emacs lisp., Jackson Ray Hamilton, 2015/05/18
- [elpa] master 6a4ad31 43/47: Add derived mode support., Jackson Ray Hamilton, 2015/05/18
- [elpa] master 3b6a391 44/47: Minor cleanup., Jackson Ray Hamilton, 2015/05/18
- [elpa] master 708276e 41/47: Compiler micro-optimizations., Jackson Ray Hamilton, 2015/05/18