]> code.delx.au - gnu-emacs-elpa/commitdiff
Remove styling from faces.
authorJackson Ray Hamilton <jackson@jacksonrayhamilton.com>
Thu, 27 Nov 2014 20:18:05 +0000 (12:18 -0800)
committerJackson Ray Hamilton <jackson@jacksonrayhamilton.com>
Thu, 27 Nov 2014 20:18:05 +0000 (12:18 -0800)
README.md
bin/cli.js
context-coloring.el
scopifier.js

index b476f4190dfe60a5bd46f20be7c783d3aac1886a..2c28844b746053db3aa1feae02cf233601f7b748 100644 (file)
--- a/README.md
+++ b/README.md
@@ -10,8 +10,7 @@ Highlights JavaScript code according to function context.
   scope is a different color, and code within such functions is another color,
   and so on.
 - Identifiers retain the color of the scope in which they were declared.
-- Identifiers are bold when first declared.
-- Comments are gray and italic.
+- Comments are gray.
 
 JavaScript programmers often leverage closures to bind nearby data to
 functions. Lexical scope information at-a-glance can assist a programmer in
index 3453b3379caff4822d5c84edb935409e7919aeed..1a059bc0e7b6a7fd440237f3413a458919b098a9 100644 (file)
@@ -1,6 +1,6 @@
 // Reads a JavaScript file from stdin.
 
-// Writes an array of `[start, end, level, style]' tokens to stdout.
+// Writes an array of tokens to stdout.
 
 'use strict';
 
index b32ab352ff0675de79e8eceb87ddb9ae2d499170..9f21dfc213f8576f66ff178ddb23f28757e73e34 100644 (file)
   "Context coloring face, depth 6."
   :group 'context-coloring-faces)
 
-(defface context-coloring-depth--1-italic-face
-  '((default (:inherit context-coloring-depth--1-face :slant italic)))
-  "Context coloring face, depth -1; italic; comments."
-  :group 'context-coloring-faces)
-
-(defface context-coloring-depth-0-bold-face
-  '((default (:inherit context-coloring-depth-0-face :weight bold)))
-  "Context coloring face, depth 0; bold; global scope."
-  :group 'context-coloring-faces)
-
-(defface context-coloring-depth-1-bold-face
-  '((default (:inherit context-coloring-depth-1-face :weight bold)))
-  "Context coloring face, depth 1; bold."
-  :group 'context-coloring-faces)
-
-(defface context-coloring-depth-2-bold-face
-  '((default (:inherit context-coloring-depth-2-face :weight bold)))
-  "Context coloring face, depth 2; bold."
-  :group 'context-coloring-faces)
-
-(defface context-coloring-depth-3-bold-face
-  '((default (:inherit context-coloring-depth-3-face :weight bold)))
-  "Context coloring face, depth 3; bold."
-  :group 'context-coloring-faces)
-
-(defface context-coloring-depth-4-bold-face
-  '((default (:inherit context-coloring-depth-4-face :weight bold)))
-  "Context coloring face, depth 4; bold."
-  :group 'context-coloring-faces)
-
-(defface context-coloring-depth-5-bold-face
-  '((default (:inherit context-coloring-depth-5-face :weight bold)))
-  "Context coloring face, depth 5; bold."
-  :group 'context-coloring-faces)
-
-(defface context-coloring-depth-6-bold-face
-  '((default (:inherit context-coloring-depth-6-face :weight bold)))
-  "Context coloring face, depth 6; bold."
-  :group 'context-coloring-faces)
-
 (defconst context-coloring-face-count 7
   "Number of faces defined for highlighting delimiter levels.
 Determines depth at which to cycle through faces again.")
@@ -139,8 +99,8 @@ Determines depth at which to cycle through faces again.")
 
 ;;; Face functions
 
-(defsubst context-coloring-level-face (depth style)
-  "Return face-name for DEPTH and STYLE as a string \"context-coloring-depth-DEPTH-face\".
+(defsubst context-coloring-level-face (depth)
+  "Return face-name for DEPTH as a string \"context-coloring-depth-DEPTH-face\".
 For example: \"context-coloring-depth-1-face\"."
   (intern-soft
    (concat "context-coloring-depth-"
@@ -154,9 +114,6 @@ For example: \"context-coloring-depth-1-face\"."
              (+ 1
                 (mod (- depth 1)
                      (- context-coloring-face-count 1)))))
-           (cond ((= 1 style) "-bold")
-                 ((= 2 style) "-italic")
-                 (t ""))
            "-face")))
 
 
@@ -210,9 +167,9 @@ imply that it should be colorized again.")
 
 (defun context-coloring-apply-tokens (tokens)
   "Processes TOKENS to apply context-based coloring to the
-current buffer. Tokens are 4 integers: start, end, level, and
-style. The array is flat, with a new token occurring after every
-4th number."
+current buffer. Tokens are 3 integers: start, end, level. The
+array is flat, with a new token occurring after every 3rd
+number."
   (with-silent-modifications
     ;; Reset in case there should be uncolored areas.
     (remove-text-properties (point-min) (point-max) `(face nil rear-nonsticky nil))
@@ -222,10 +179,8 @@ style. The array is flat, with a new token occurring after every
         (add-text-properties
          (elt tokens i)
          (elt tokens (+ i 1))
-         `(face ,(context-coloring-level-face
-                  (elt tokens (+ i 2))
-                  (elt tokens (+ i 3))) rear-nonsticky t))
-        (setq i (+ i 4))))))
+         `(face ,(context-coloring-level-face (elt tokens (+ i 2))) rear-nonsticky t))
+        (setq i (+ i 3))))))
 
 (defsubst context-coloring-kill-scopifier ()
   "Kills the currently-running scopifier process for this
index 814550106e9087caec60fed2797d7e86fef00051..9e7c8ef4725700bb67d9dea3ebc9c2616494db48 100644 (file)
@@ -1,14 +1,9 @@
 'use strict';
 
 var escope = require('./lib/escope'),
-    esprima = require('./lib/esprima'),
+    esprima = require('./lib/esprima');
 
-    normal = 0,
-    bold = 1,
-    italic = 2;
-
-// Given code, returns an array of `[start, end, level, style]' tokens for
-// context-coloring.
+// Given code, returns an array of tokens for context-coloring.
 module.exports = function (code) {
     var analyzedScopes,
         ast,
@@ -65,8 +60,7 @@ module.exports = function (code) {
                 scopes.push(
                     range[0] + 1,
                     range[1] + 1,
-                    scope.level,
-                    normal
+                    scope.level
                 );
                 definitionsIndex = tokens.length;
                 definitionsCount = 0;
@@ -79,8 +73,7 @@ module.exports = function (code) {
                         tokens.push(
                             range[0] + 1,
                             range[1] + 1,
-                            scope.level,
-                            bold
+                            scope.level
                         );
                     }
                 }
@@ -93,7 +86,7 @@ module.exports = function (code) {
                     // declared and initialized simultaneously; this filters
                     // them.)
                     for (k = 0; k < definitionsCount; k += 1) {
-                        pointer = definitionsIndex + (k * 4);
+                        pointer = definitionsIndex + (k * 3);
                         if (tokens[pointer] === range[0] + 1 &&
                                 tokens[pointer + 1] === range[1] + 1) {
                             isDefined = true;
@@ -105,8 +98,7 @@ module.exports = function (code) {
                             // Handle global references too.
                             range[0] + 1,
                             range[1] + 1,
-                            reference.resolved ? reference.resolved.scope.level : 0,
-                            reference.__maybeImplicitGlobal ? bold : normal
+                            reference.resolved ? reference.resolved.scope.level : 0
                         );
                     }
                 }
@@ -120,8 +112,7 @@ module.exports = function (code) {
         tokens.push(
             range[0] + 1,
             range[1] + 1,
-            -1,
-            italic
+            -1
         );
     }