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

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

[elpa] master 6531b86 11/16: Use more agnostic names.


From: Jackson Ray Hamilton
Subject: [elpa] master 6531b86 11/16: Use more agnostic names.
Date: Sun, 18 Oct 2015 11:21:49 +0000

branch: master
commit 6531b86bd03b34b1944e1fe8714dd26698277e02
Author: Jackson Hamilton <address@hidden>
Commit: Jackson Hamilton <address@hidden>

    Use more agnostic names.
---
 context-coloring.el           |   16 +++++++++-------
 test/context-coloring-test.el |    8 ++++----
 2 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/context-coloring.el b/context-coloring.el
index 1f617b9..ef908fd 100644
--- a/context-coloring.el
+++ b/context-coloring.el
@@ -414,8 +414,10 @@ this for ES6 code; disable it elsewhere."
    "\\)")
   "Match a comment body hinting at a Node.js program.")
 
-(defun context-coloring-node-program-p ()
-  "Guess whether the current file is a Node.js program."
+;; TODO: Add ES6 module detection.
+(defun context-coloring-js2-top-level-local-p ()
+  "Guess whether top-level variables are local.
+For instance, the current file could be a Node.js program."
   (or
    ;; A shebang is a pretty obvious giveaway.
    (string-equal
@@ -472,17 +474,17 @@ this for ES6 code; disable it elsewhere."
        ;; Default to returning nil from the catch body.
        nil))))
 
-(defcustom context-coloring-detect-node t
-  "If non-nil, use file-level scope for variables in Node.js."
+(defcustom context-coloring-javascript-detect-top-level-scope t
+  "If non-nil, detect when to use file-level scope."
   :type 'boolean
   :group 'context-coloring)
 
 (defun context-coloring-js2-colorize ()
   "Color the buffer using the `js2-mode'."
   (cond
-   ;; Increase the initial level if we can detect Node.js.
-   ((and context-coloring-detect-node
-         (context-coloring-node-program-p))
+   ;; Increase the initial level if we should.
+   ((and context-coloring-javascript-detect-top-level-scope
+         (context-coloring-js2-top-level-local-p))
     (let ((context-coloring-initial-level 1))
       (context-coloring-js2-colorize-ast)))
    (t
diff --git a/test/context-coloring-test.el b/test/context-coloring-test.el
index 6cf78e4..f643e91 100644
--- a/test/context-coloring-test.el
+++ b/test/context-coloring-test.el
@@ -623,7 +623,7 @@ ssssssssssss0"))
   :after (lambda ()
            (setq context-coloring-initial-level 0)))
 
-(defun context-coloring-test-setup-detect-node (string)
+(defun context-coloring-test-setup-top-level-scope (string)
   "Make STRING the first line and colorize again."
   (goto-char (point-min))
   (kill-whole-line 0)
@@ -631,7 +631,7 @@ ssssssssssss0"))
   ;; Reparsing triggers recoloring.
   (js2-reparse))
 
-(context-coloring-test-deftest-javascript detect-node
+(context-coloring-test-deftest-javascript top-level-scope
   (lambda ()
     (let ((positive-indicators
            (list "#!/usr/bin/env node"
@@ -648,10 +648,10 @@ ssssssssssss0"))
                  "exports"
                  "var require; require('a')")))
       (dolist (indicator positive-indicators)
-        (context-coloring-test-setup-detect-node indicator)
+        (context-coloring-test-setup-top-level-scope indicator)
         (context-coloring-test-assert-javascript-elevated-level))
       (dolist (indicator negative-indicators)
-        (context-coloring-test-setup-detect-node indicator)
+        (context-coloring-test-setup-top-level-scope indicator)
         (context-coloring-test-assert-javascript-global-level))))
   :fixture "initial-level.js")
 



reply via email to

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