[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 338716d 161/271: Refactor.
From: |
Jackson Ray Hamilton |
Subject: |
[elpa] master 338716d 161/271: Refactor. |
Date: |
Thu, 05 Feb 2015 18:30:48 +0000 |
branch: master
commit 338716d1ddd2de60b4d78133d028dc4c31d4c8f3
Author: Jackson Ray Hamilton <address@hidden>
Commit: Jackson Ray Hamilton <address@hidden>
Refactor.
---
context-coloring.el | 50 ++++++++++++++++++++++----------------------------
1 files changed, 22 insertions(+), 28 deletions(-)
diff --git a/context-coloring.el b/context-coloring.el
index 97c391a..f189473 100644
--- a/context-coloring.el
+++ b/context-coloring.el
@@ -218,9 +218,9 @@ For example: \"context-coloring-level-1-face\"."
"Gets the level of SCOPE."
(let ((level 0)
enclosing-scope)
- (while (and (not (null scope))
- (not (null (js2-node-parent scope)))
- (not (null (setq enclosing-scope (js2-node-get-enclosing-scope
scope)))))
+ (while (and scope
+ (js2-node-parent scope)
+ (setq enclosing-scope (js2-node-get-enclosing-scope scope)))
(when (or context-coloring-block-scopes
(let ((type (js2-scope-type scope)))
(or (= type js2-SCRIPT)
@@ -252,6 +252,13 @@ For example: \"context-coloring-level-1-face\"."
; fail the
test.
start)))))))
+(defsubst context-coloring-js2-colorize-node (node level)
+ (let ((start (js2-node-abs-pos node)))
+ (context-coloring-colorize-region
+ start
+ (+ start (js2-node-len node)) ; End
+ level)))
+
(defun context-coloring-js2-colorize ()
(with-silent-modifications
;; (context-coloring-uncolorize-buffer)
@@ -261,33 +268,20 @@ For example: \"context-coloring-level-1-face\"."
(when (null end-p)
(cond
((js2-comment-node-p node)
- (let ((start (js2-node-abs-pos node)))
- (context-coloring-colorize-region
- start
- (+ start (js2-comment-node-len node)) ; End
- -1 ; Level
- )))
+ (context-coloring-js2-colorize-node
+ node
+ -1))
((js2-scope-p node)
- ;; TODO: Work on catch blocks.
- ;; (message "SCOPE: %s, SPOS: %s, EPOS: %s"
- ;; (js2-scope-type node)
- ;; (js2-node-abs-pos node)
- ;; (+ (js2-node-abs-pos node) (js2-scope-len node)))
- (let ((start (js2-node-abs-pos node)))
- (context-coloring-colorize-region
- start
- (+ start (js2-scope-len node)) ; End
- (context-coloring-js2-scope-level node) ; Level
- )))
+ (context-coloring-js2-colorize-node
+ node
+ (context-coloring-js2-scope-level node)))
((context-coloring-js2-local-name-node-p node)
- (let ((start (js2-node-abs-pos node)))
- (context-coloring-colorize-region
- start
- (+ start (js2-name-node-len node)) ; End
- (context-coloring-js2-scope-level ; Level
- (js2-get-defining-scope
- (js2-node-get-enclosing-scope node)
- (js2-name-node-name node)))))))
+ (context-coloring-js2-colorize-node
+ node
+ (context-coloring-js2-scope-level
+ (js2-get-defining-scope
+ (js2-node-get-enclosing-scope node)
+ (js2-name-node-name node))))))
;; The `t' indicates to search children.
t)))))
- [elpa] master a2b6a5a 112/271: Use defvar-local., (continued)
- [elpa] master a2b6a5a 112/271: Use defvar-local., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 6c8175e 153/271: Update compilation., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 4f57f0c 163/271: Improve global test., Jackson Ray Hamilton, 2015/02/05
- [elpa] master dc8e99c 130/271: Function name., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 2bb4d12 124/271: More cleanup., Jackson Ray Hamilton, 2015/02/05
- [elpa] master d301048 154/271: Update compilation again., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 1d9cf42 164/271: Refactor tests., Jackson Ray Hamilton, 2015/02/05
- [elpa] master a0ccc5c 162/271: Improve and pass catch test., Jackson Ray Hamilton, 2015/02/05
- [elpa] master c8fa33f 170/271: Improve async benchmarking., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 7954efc 110/271: Rename instances of depth to level., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 338716d 161/271: Refactor.,
Jackson Ray Hamilton <=
- [elpa] master fc81cf9 157/271: Don't use timers for js2-mode., Jackson Ray Hamilton, 2015/02/05
- [elpa] master b4c220a 159/271: Always remove hooks., Jackson Ray Hamilton, 2015/02/05
- [elpa] master e040ca0 181/271: Just use stable emacs., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 9e7ee77 155/271: Add catch test. Don't uncolorize., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 665a54a 167/271: Add more js-mode tests., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 43f2e3b 168/271: Increase reliability of async tests., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 28183e4 188/271: Readme., Jackson Ray Hamilton, 2015/02/05
- [elpa] master bdfdbe4 151/271: Improve benchmarks., Jackson Ray Hamilton, 2015/02/05
- [elpa] master d27f2fe 182/271: Fix callback removal., Jackson Ray Hamilton, 2015/02/05
- [elpa] master cb0644a 136/271: Cleanup JavaScript tests., Jackson Ray Hamilton, 2015/02/05