[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master b4b86ac 033/271: Fix after-change-functions with add-hook.
From: |
Jackson Ray Hamilton |
Subject: |
[elpa] master b4b86ac 033/271: Fix after-change-functions with add-hook. Fix nulls. |
Date: |
Thu, 05 Feb 2015 18:29:34 +0000 |
branch: master
commit b4b86ac2d1bc6b9ad6039a3452026a9199735e25
Author: Jackson Ray Hamilton <address@hidden>
Commit: Jackson Ray Hamilton <address@hidden>
Fix after-change-functions with add-hook. Fix nulls.
---
context-coloring.el | 26 +++++++++++++++++---------
tokenizer.js | 4 ++++
2 files changed, 21 insertions(+), 9 deletions(-)
diff --git a/context-coloring.el b/context-coloring.el
index 8a4cbc9..42dc67a 100644
--- a/context-coloring.el
+++ b/context-coloring.el
@@ -114,7 +114,7 @@ For example: \"context-coloring-depth-1-face\"."
"-face")))
-;;; Path constants
+;;; Constants
(defconst context-coloring-path
(file-name-directory (or load-file-name buffer-file-name))
@@ -124,6 +124,9 @@ For example: \"context-coloring-depth-1-face\"."
(expand-file-name "./tokenizer.js" context-coloring-path)
"Path to the external tokenizer executable.")
+(defconst context-coloring-delay 0.25
+ "Time between colorization.")
+
;;; Tokenization functions
@@ -134,7 +137,7 @@ For example: \"context-coloring-depth-1-face\"."
(let ((start (cdr (assoc 's token)))
(end (cdr (assoc 'e token)))
(face (context-coloring-level-face (cdr (assoc 'l token)))))
- (add-text-properties start end `(font-lock-face ,face rear-nonsticky
t))))))
+ (add-text-properties start end `(face ,face rear-nonsticky t))))))
(defun context-coloring-kill-tokenizer ()
(when (not (null context-coloring-tokenizer-process))
@@ -175,8 +178,8 @@ calling FUNCTION with the parsed list of tokens."
(with-current-buffer buffer
(context-coloring-apply-tokens tokens))
(setq context-coloring-tokenizer-process nil)
- (message "Colorized (after %f seconds)."
- (- (float-time) start-time)))))))
+ ;; (message "Colorized (after %f seconds)." (-
(float-time) start-time))
+ )))))
;; Give the process its input.
(process-send-region context-coloring-tokenizer-process (point-min)
(point-max))
@@ -188,7 +191,7 @@ calling FUNCTION with the parsed list of tokens."
(defun context-coloring-colorize ()
(interactive)
(setq context-coloring-colorize-start-time (float-time))
- (message "%s" "Colorizing.")
+ ;;(message "%s" "Colorizing.")
(context-coloring-tokenize))
(defun context-coloring-change-function (start end length)
@@ -240,8 +243,12 @@ imply that it should be colorized again.")
nil " Context" nil
(if (not context-coloring-mode)
(progn
+ (context-coloring-kill-tokenizer)
(when (not (null 'context-coloring-colorize-idle-timer))
- (cancel-timer context-coloring-colorize-idle-timer)))
+ (cancel-timer context-coloring-colorize-idle-timer))
+ (remove-hook 'after-change-functions 'context-coloring-change-function
t)
+ (font-lock-mode)
+ (jit-lock-mode t))
(setq context-coloring-buffer (current-buffer))
@@ -249,12 +256,13 @@ imply that it should be colorized again.")
(context-coloring-colorize)
;; Only recolor on change. So watch for changes.
- (set (make-local-variable 'after-change-functions)
- '(context-coloring-change-function))
+ (font-lock-mode 0)
+ (jit-lock-mode nil)
+ (add-hook 'after-change-functions 'context-coloring-change-function nil t)
;; Only recolor idly.
(setq context-coloring-colorize-idle-timer
- (run-with-idle-timer 1 t 'context-coloring-maybe-colorize))))
+ (run-with-idle-timer context-coloring-delay t
'context-coloring-maybe-colorize))))
;;;###autoload
(defun context-coloring-mode-enable ()
diff --git a/tokenizer.js b/tokenizer.js
index 2f60dab..9ca02cc 100644
--- a/tokenizer.js
+++ b/tokenizer.js
@@ -121,6 +121,10 @@ process.stdin.on('end', function () {
previous.e === (total + token.from)) {
previous.e = cap(total + token.thru);
} else {
+ // IDK.
+ if (total === undefined) {
+ break;
+ }
out.push({
l: level,
s: cap(total + token.from),
- [elpa] master a72314c 008/271: Write temp files., (continued)
- [elpa] master a72314c 008/271: Write temp files., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 6a2a7df 018/271: Use idle timers instead of font lock., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 0a4248b 009/271: Update chunk size., Jackson Ray Hamilton, 2015/02/05
- [elpa] master ffd69f5 026/271: Minutia., Jackson Ray Hamilton, 2015/02/05
- [elpa] master f349ecb 027/271: Minutia., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 35453e0 015/271: Only color changed regions., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 222276b 001/271: Init., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 09166f9 021/271: Some progress, probably have to switch back to lexical., Jackson Ray Hamilton, 2015/02/05
- [elpa] master e448e2f 025/271: Cancelling working., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 97194c7 023/271: Apply tokens with lexically-bound buffer as current., Jackson Ray Hamilton, 2015/02/05
- [elpa] master b4b86ac 033/271: Fix after-change-functions with add-hook. Fix nulls.,
Jackson Ray Hamilton <=
- [elpa] master cce215d 030/271: Add readme., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 169b1f4 028/271: Set JSLint options to not care., Jackson Ray Hamilton, 2015/02/05
- [elpa] master df36161 031/271: Fix screenshot link., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 16e984c 039/271: Update installation instructions., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 3e6f2cf 037/271: Cleanup., Jackson Ray Hamilton, 2015/02/05
- [elpa] master bd8fc87 034/271: Restore test files. Start on uglify tokenizer., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 099e8c1 003/271: Write basic tokenizer cli., Jackson Ray Hamilton, 2015/02/05
- [elpa] master fef44f5 038/271: Fix broken link., Jackson Ray Hamilton, 2015/02/05
- [elpa] master e4ee2ec 042/271: Catch parse errors., Jackson Ray Hamilton, 2015/02/05
- [elpa] master d372de1 029/271: Clean up cruft., Jackson Ray Hamilton, 2015/02/05