emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master e448e2f 025/271: Cancelling working.


From: Jackson Ray Hamilton
Subject: [elpa] master e448e2f 025/271: Cancelling working.
Date: Thu, 05 Feb 2015 18:29:30 +0000

branch: master
commit e448e2f01287f9b92efde533c6352c43fa91ffb2
Author: Jackson Ray Hamilton <address@hidden>
Commit: Jackson Ray Hamilton <address@hidden>

    Cancelling working.
---
 context-coloring.el |   15 +++++++++++----
 1 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/context-coloring.el b/context-coloring.el
index 2a0acb7..33defb5 100644
--- a/context-coloring.el
+++ b/context-coloring.el
@@ -100,15 +100,19 @@ For example: \"context-coloring-depth-1-face\"."
             (face (context-coloring-level-face (cdr (assoc 'l token)))))
         (add-text-properties start end `(font-lock-face ,face rear-nonsticky 
t))))))
 
+(defun context-coloring-kill-tokenizer ()
+  (when (not (null context-coloring-tokenizer-process))
+    (delete-process context-coloring-tokenizer-process)
+    (setq context-coloring-tokenizer-process nil)))
+
 (defun context-coloring-tokenize ()
   "Invokes the external tokenizer with the current buffer's
 contents, reading the tokenizer's response asynchronously and
 calling FUNCTION with the parsed list of tokens."
 
-  ;; Cancel a running process because it is implicitly obsolete if we are
-  ;; calling this function.
-  (when (not (null context-coloring-tokenizer-process))
-    (delete-process context-coloring-tokenizer-process))
+  ;; Prior running tokenization is implicitly obsolete if this function is
+  ;; called.
+  (context-coloring-kill-tokenizer)
 
   ;; Start the process.
   (setq context-coloring-tokenizer-process
@@ -133,6 +137,7 @@ calling FUNCTION with the parsed list of tokens."
                                               (json-read-from-string output))))
                                 (with-current-buffer buffer
                                   (context-coloring-apply-tokens tokens))
+                                (setq context-coloring-tokenizer-process nil)
                                 (message "Colorized (after %f seconds)."
                                          (- (float-time) start-time)))))))
 
@@ -150,6 +155,8 @@ calling FUNCTION with the parsed list of tokens."
   (context-coloring-tokenize))
 
 (defun context-coloring-change-function (start end length)
+  ;; Tokenization is obsolete if there was a change.
+  (context-coloring-kill-tokenizer)
   (setq context-coloring-changed t))
 
 (defun context-coloring-maybe-colorize ()



reply via email to

[Prev in Thread] Current Thread [Next in Thread]