[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 16cee40 150/271: Pass test for block scopes.
From: |
Jackson Ray Hamilton |
Subject: |
[elpa] master 16cee40 150/271: Pass test for block scopes. |
Date: |
Thu, 05 Feb 2015 18:30:41 +0000 |
branch: master
commit 16cee407fe10692f34e7dae8478fcc100217e6fb
Author: Jackson Ray Hamilton <address@hidden>
Commit: Jackson Ray Hamilton <address@hidden>
Pass test for block scopes.
---
context-coloring.el | 37 ++++++++++++++++++++++++++++---------
1 files changed, 28 insertions(+), 9 deletions(-)
diff --git a/context-coloring.el b/context-coloring.el
index 8891c21..99c56a7 100644
--- a/context-coloring.el
+++ b/context-coloring.el
@@ -46,6 +46,23 @@
"This file's directory.")
+;;; Customizable options
+
+(defcustom context-coloring-delay 0.25
+ "Delay between a buffer update and colorization.
+
+Increase this if your machine is high-performing. Decrease it if it ain't."
+ :group 'context-coloring)
+
+(defcustom context-coloring-block-scopes nil
+ "If non-nil, add block scopes to the scope hierarchy.
+
+The block-scope-inducing `let' and `const' are introduced in
+ES6. If you are writing ES6 code, then turn this on; otherwise,
+confusion will ensue."
+ :group 'context-coloring)
+
+
;;; Local variables
(defvar-local context-coloring-buffer nil
@@ -196,11 +213,19 @@ For example: \"context-coloring-level-1-face\"."
(defsubst context-coloring-js2-scope-level (scope)
"Gets the level of SCOPE."
- (let ((level 0))
+ (let ((level 0)
+ enclosing-scope)
(while (and (not (null scope))
(not (null (js2-node-parent scope)))
- (not (null (setq scope (js2-node-get-enclosing-scope scope)))))
- (setq level (+ level 1)))
+ (not (null (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)
+ (= type js2-FUNCTION)
+ (= type js2-CATCH)
+ (= type js2-WITH))))
+ (setq level (+ level 1)))
+ (setq scope enclosing-scope))
level))
;; Obtained from js2-refactor.el/js2r-vars.el
@@ -360,12 +385,6 @@ of the current buffer, then does it."
;;; Colorization
-(defcustom context-coloring-delay 0.25
- "Delay between a buffer update and colorization.
-
-Increase this if your machine is high-performing. Decrease it if it ain't."
- :group 'context-coloring)
-
(defun context-coloring-colorize ()
"Colors the current buffer by function context."
(interactive)
- [elpa] master 5a7fc32 138/271: Documentation., (continued)
- [elpa] master 5a7fc32 138/271: Documentation., Jackson Ray Hamilton, 2015/02/05
- [elpa] master f77870d 137/271: Add language support documentation., Jackson Ray Hamilton, 2015/02/05
- [elpa] master faea355 123/271: Cleanup and improve tests., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 4b2e1db 140/271: Documentation., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 3f1bae9 142/271: Make js2-mode read-only., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 1ceb460 139/271: Documentation., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 1b7e0a5 122/271: Make context-coloring-face-count customizable. Add some dummy faces., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 459987e 131/271: Generalize for different major modes. Remove dirty benchmarking., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 2341708 132/271: Reorganize JavaScript files., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 4be9ec8 147/271: Documentation., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 16cee40 150/271: Pass test for block scopes.,
Jackson Ray Hamilton <=
- [elpa] master f7b5d33 143/271: Add skeletal support for js2-mode scopification., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 549e523 149/271: Add failing test for block scopes., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 9f87a03 148/271: Actually colorize complex files., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 76122df 144/271: Write js2 scopifier., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 5fcd757 146/271: Refactor to use more resilient dispatch strategy., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 8982c75 127/271: Merge branch 'feature/tests' into develop, Jackson Ray Hamilton, 2015/02/05
- [elpa] master e06fbe9 158/271: Add comment support for js2-mode., Jackson Ray Hamilton, 2015/02/05
- [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