[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master c81c3fd 068/271: Make declarations bold.
From: |
Jackson Ray Hamilton |
Subject: |
[elpa] master c81c3fd 068/271: Make declarations bold. |
Date: |
Thu, 05 Feb 2015 18:29:50 +0000 |
branch: master
commit c81c3fd9370b0f758637370e4078fdbf769271d8
Author: Jackson Ray Hamilton <address@hidden>
Commit: Jackson Ray Hamilton <address@hidden>
Make declarations bold.
---
bin/cli.js | 2 +-
context-coloring.el | 46 ++++++++++++++++++++++++++++++++++++++++++----
scopifier.js | 20 ++++++++++++++------
test/fixtures/monad.js | 47 +++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 104 insertions(+), 11 deletions(-)
diff --git a/bin/cli.js b/bin/cli.js
index 9fdea5c..721dae0 100644
--- a/bin/cli.js
+++ b/bin/cli.js
@@ -4,7 +4,7 @@
'use strict';
-var scopifier = require('../scopifier-microoptimized'),
+var scopifier = require('../scopifier'),
whole = '';
process.stdin.setEncoding('utf8');
diff --git a/context-coloring.el b/context-coloring.el
index 436cf4a..018a94e 100644
--- a/context-coloring.el
+++ b/context-coloring.el
@@ -42,8 +42,9 @@
;;; Faces
(defface context-coloring-depth--1-face
- '((((background light)) (:foreground "#7f7f7f" :slant italic))
- (((background dark)) (:foreground "#7f7f7f" :slant italic)))
+ '((default (:slant italic))
+ (((background light)) (:foreground "#7f7f7f"))
+ (((background dark)) (:foreground "#7f7f7f")))
"Nested blocks face, depth -1; comments."
:group 'context-coloring-faces)
@@ -93,10 +94,45 @@
"Number of faces defined for highlighting delimiter levels.
Determines depth at which to cycle through faces again.")
+(defface context-coloring-depth-0-bold-face
+ '((default (:inherit context-coloring-depth-0-face :weight bold)))
+ "Nested blocks 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)))
+ "Nested blocks face, depth 1; bold; global scope."
+ :group 'context-coloring-faces)
+
+(defface context-coloring-depth-2-bold-face
+ '((default (:inherit context-coloring-depth-2-face :weight bold)))
+ "Nested blocks face, depth 2; bold; global scope."
+ :group 'context-coloring-faces)
+
+(defface context-coloring-depth-3-bold-face
+ '((default (:inherit context-coloring-depth-3-face :weight bold)))
+ "Nested blocks face, depth 3; bold; global scope."
+ :group 'context-coloring-faces)
+
+(defface context-coloring-depth-4-bold-face
+ '((default (:inherit context-coloring-depth-4-face :weight bold)))
+ "Nested blocks face, depth 4; bold; global scope."
+ :group 'context-coloring-faces)
+
+(defface context-coloring-depth-5-bold-face
+ '((default (:inherit context-coloring-depth-5-face :weight bold)))
+ "Nested blocks face, depth 5; bold; global scope."
+ :group 'context-coloring-faces)
+
+(defface context-coloring-depth-6-bold-face
+ '((default (:inherit context-coloring-depth-6-face :weight bold)))
+ "Nested blocks face, depth 6; bold; global scope."
+ :group 'context-coloring-faces)
+
;;; Face utility functions
-(defun context-coloring-level-face (depth)
+(defun context-coloring-level-face (depth style)
"Return face-name for DEPTH as a string
\"context-coloring-depth-DEPTH-face\".
For example: \"context-coloring-depth-1-face\"."
(intern-soft
@@ -111,6 +147,8 @@ For example: \"context-coloring-depth-1-face\"."
(+ 1
(mod (- depth 1)
(- context-coloring-face-count 1)))))
+ (cond ((= 1 style) "-bold")
+ (t ""))
"-face")))
@@ -143,7 +181,7 @@ For example: \"context-coloring-depth-1-face\"."
(len (length tokens)))
(while (< i len)
(let ((token (elt tokens i)))
- (let ((face (context-coloring-level-face (elt token 0)))
+ (let ((face (context-coloring-level-face (elt token 0) (elt token
3)))
(start (elt token 1))
(end (elt token 2)))
(add-text-properties start end `(face ,face rear-nonsticky t))))
diff --git a/scopifier.js b/scopifier.js
index c1ccff2..7e4c64e 100644
--- a/scopifier.js
+++ b/scopifier.js
@@ -12,7 +12,10 @@ var escope = require('escope'),
return definition[1] === range[0] &&
definition[2] === range[1];
});
- };
+ },
+
+ normal = 0,
+ bold = 1;
// Given code, returns an array of `[level, start, end]' tokens for
// context-coloring.
@@ -62,7 +65,8 @@ module.exports = function (code) {
scopes = scopes.concat([[
scope.level,
scope.block.range[0],
- scope.block.range[1]
+ scope.block.range[1],
+ normal
]]);
definitions = scope.variables.reduce(function (definitions, variable) {
var mappedDefinitions = variable.defs.map(function (definition) {
@@ -70,7 +74,8 @@ module.exports = function (code) {
return [
scope.level,
range[0],
- range[1]
+ range[1],
+ bold
];
});
return definitions.concat(mappedDefinitions);
@@ -84,7 +89,8 @@ module.exports = function (code) {
// Handle global references too.
reference.resolved ? reference.resolved.scope.level : 0,
range[0],
- range[1]
+ range[1],
+ normal
]]);
}, []);
symbols = symbols.concat(definitions).concat(references);
@@ -96,7 +102,8 @@ module.exports = function (code) {
return [
-1,
range[0],
- range[1]
+ range[1],
+ normal
];
});
@@ -108,7 +115,8 @@ module.exports = function (code) {
return [
token[0],
token[1] + 1,
- token[2] + 1
+ token[2] + 1,
+ token[3]
];
});
diff --git a/test/fixtures/monad.js b/test/fixtures/monad.js
new file mode 100644
index 0000000..cd625db
--- /dev/null
+++ b/test/fixtures/monad.js
@@ -0,0 +1,47 @@
+// The MONAD function is a macroid that produces monad constructor functions.
+// It can take an optional modifier function, which is a function that is
+// allowed to modify new monads at the end of the construction processes.
+
+// A monad constructor (sometimes called 'unit' or 'return' in some
mythologies)
+// comes with three methods, lift, lift_value, and method, all of which can add
+// methods and properties to the monad's prototype.
+
+// A monad has a 'bind' method that takes a function that receives a value and
+// is usually expected to return a monad.
+
+function MONAD(modifier) {
+ 'use strict';
+ var prototype = Object.create(null);
+ prototype.is_monad = true;
+ function unit(value) {
+ var monad = Object.create(prototype);
+ monad.bind = function (func, args) {
+ return func.apply(
+ undefined,
+ [value].concat(Array.prototype.slice.apply(args || []))
+ );
+ };
+ if (typeof modifier === 'function') {
+ value = modifier(monad, value);
+ }
+ return monad;
+ }
+ unit.method = function (name, func) {
+ prototype[name] = func;
+ return unit;
+ };
+ unit.lift_value = function (name, func) {
+ prototype[name] = function () {
+ return this.bind(func, arguments);
+ };
+ return unit;
+ };
+ unit.lift = function (name, func) {
+ prototype[name] = function () {
+ var result = this.bind(func, arguments);
+ return result && result.is_monad === true ? result : unit(result);
+ };
+ return unit;
+ };
+ return unit;
+}
- [elpa] master eb2e6b3 070/271: Formalize italic support., (continued)
- [elpa] master eb2e6b3 070/271: Formalize italic support., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 67637bf 072/271: Update test fixture., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 65e4763 065/271: Just push to a single tokens array., Jackson Ray Hamilton, 2015/02/05
- [elpa] master cb8b1f2 066/271: Add light color scheme., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 7a49f9f 067/271: Make comments italic., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 07fe42c 078/271: Vconcat., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 28667b8 075/271: Move microoptimized scopifier into the limelight., Jackson Ray Hamilton, 2015/02/05
- [elpa] master c1f9f11 063/271: Switch to concat., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 183ac4e 081/271: Add emacs benchmark., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 59b1c99 074/271: Documentation and cleanup., Jackson Ray Hamilton, 2015/02/05
- [elpa] master c81c3fd 068/271: Make declarations bold.,
Jackson Ray Hamilton <=
- [elpa] master f9eb4a1 080/271: Revert "Use alist of faces.", Jackson Ray Hamilton, 2015/02/05
- [elpa] master ea3fd79 071/271: Make implicit global variables bold., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 1039a74 073/271: Update microoptimized version., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 18e35dd 069/271: Shift token properties., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 49f5e3e 079/271: Use alist of faces., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 8615688 089/271: Create tests., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 10d7726 077/271: Use custom JSON parser., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 099f434 082/271: Add optimizations for byte-compilation., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 0bfdbcd 085/271: Remove naive timers., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 4874e1e 086/271: Improve documentation and Makefile., Jackson Ray Hamilton, 2015/02/05