[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master f7b5d33 143/271: Add skeletal support for js2-mode scopifi
From: |
Jackson Ray Hamilton |
Subject: |
[elpa] master f7b5d33 143/271: Add skeletal support for js2-mode scopification. |
Date: |
Thu, 05 Feb 2015 18:30:37 +0000 |
branch: master
commit f7b5d33a3cef38b3f771f1b36cf4ac3e4859c983
Author: Jackson Ray Hamilton <address@hidden>
Commit: Jackson Ray Hamilton <address@hidden>
Add skeletal support for js2-mode scopification.
---
context-coloring.el | 68 ++++++++++++++++++++++++++++++--------------------
1 files changed, 41 insertions(+), 27 deletions(-)
diff --git a/context-coloring.el b/context-coloring.el
index b492288..aec467d 100644
--- a/context-coloring.el
+++ b/context-coloring.el
@@ -159,26 +159,6 @@ For example: \"context-coloring-level-1-face\"."
"This file's directory.")
-;;; Customizable variables
-
-(let ((javascript-scopifier `(:type shell-command
- :executable "node"
- :command ,(expand-file-name
- "./languages/javascript/bin/scopifier"
- context-coloring-path))))
- (defcustom context-coloring-scopifier-plist
- `(js-mode ,javascript-scopifier
- js2-mode ,javascript-scopifier
- js3-mode ,javascript-scopifier)
- "Property list mapping major modes to scopification programs."))
-
-(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)
-
-
;;; Local variables
(defvar-local context-coloring-buffer nil
@@ -196,8 +176,30 @@ is a reference to that one process.")
imply that it should be colorized again.")
+;;; js2-mode Scopification
+
+;; Potentially useful functions: js2-visit-ast js2-node-get-enclosing-scope
+;; js2-get-defining-scope js2-visit-ast-root
+
+(defun context-coloring-js2-mode-scopifier ()
+ (vector))
+
+
;;; Scopification
+(let ((javascript-scopifier `(:type shell-command
+ :executable "node"
+ :command ,(expand-file-name
+ "./languages/javascript/bin/scopifier"
+ context-coloring-path)))
+ (js2-mode-scopifier `(:type elisp
+ :scopifier context-coloring-js2-mode-scopifier)))
+ (defcustom context-coloring-scopifier-plist
+ `(js-mode ,javascript-scopifier
+ js2-mode ,js2-mode-scopifier
+ js3-mode ,javascript-scopifier)
+ "Property list mapping major modes to scopification programs."))
+
(defun context-coloring-apply-tokens (tokens)
"Processes TOKENS to apply context-based coloring to the
current buffer. Tokens are 3 integers: start, end, level. The
@@ -268,17 +270,29 @@ parsed list of tokens to `context-coloring-apply-tokens'."
"Determines the optimal track for scopification of the current
buffer, then scopifies the current buffer."
(let ((scopifier (plist-get context-coloring-scopifier-plist major-mode)))
- (cond ((null scopifier)
- (message "%s" "Context coloring is not available for this major
mode"))
- ((eq (plist-get scopifier :type) 'shell-command)
- (let ((executable (plist-get scopifier :executable)))
- (if (null (executable-find executable))
- (message "Context coloring executable \"%s\" not found"
executable)
- (context-coloring-scopify-shell-command (plist-get scopifier
:command))))))))
+ (cond
+ ((null scopifier)
+ (message "%s" "Context coloring is not available for this major mode"))
+ (t
+ (let ((type (plist-get scopifier :type)))
+ (cond
+ ((eq type 'elisp)
+ (context-coloring-apply-tokens (funcall (plist-get scopifier
:scopifier))))
+ ((eq type 'shell-command)
+ (let ((executable (plist-get scopifier :executable)))
+ (if (null (executable-find executable))
+ (message "Context coloring executable \"%s\" not found"
executable)
+ (context-coloring-scopify-shell-command (plist-get scopifier
:command)))))))))))
;;; 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 f77870d 137/271: Add language support documentation., (continued)
- [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, 2015/02/05
- [elpa] master f7b5d33 143/271: Add skeletal support for js2-mode scopification.,
Jackson Ray Hamilton <=
- [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
- [elpa] master dc8e99c 130/271: Function name., Jackson Ray Hamilton, 2015/02/05