[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 0836b9f 22/47: Add change hooks for elisp.
From: |
Jackson Ray Hamilton |
Subject: |
[elpa] master 0836b9f 22/47: Add change hooks for elisp. |
Date: |
Mon, 18 May 2015 09:51:52 +0000 |
branch: master
commit 0836b9f6ea7531d2d0be8fcd8a84418fc3fb09ad
Author: Jackson Ray Hamilton <address@hidden>
Commit: Jackson Ray Hamilton <address@hidden>
Add change hooks for elisp.
---
context-coloring.el | 103 +++++++++++++++++++++++++++++----------------------
1 files changed, 59 insertions(+), 44 deletions(-)
diff --git a/context-coloring.el b/context-coloring.el
index f217694..6c56d14 100644
--- a/context-coloring.el
+++ b/context-coloring.el
@@ -842,49 +842,6 @@ should be numeric, e.g. \"2\", \"19700101\", \"1.2.3\",
(when (null (gethash mode context-coloring-mode-hash-table))
(puthash mode properties context-coloring-mode-hash-table)))))
-(context-coloring-define-dispatch
- 'javascript-node
- :modes '(js-mode js3-mode)
- :executable "scopifier"
- :command "scopifier"
- :version "v1.1.1")
-
-(context-coloring-define-dispatch
- 'javascript-js2
- :modes '(js2-mode)
- :colorizer 'context-coloring-js2-colorize
- :setup
- (lambda ()
- (add-hook 'js2-post-parse-callbacks 'context-coloring-colorize nil t))
- :teardown
- (lambda ()
- (remove-hook 'js2-post-parse-callbacks 'context-coloring-colorize t)))
-
-(context-coloring-define-dispatch
- 'emacs-lisp
- :modes '(emacs-lisp-mode)
- :colorizer 'context-coloring-emacs-lisp-colorize)
-
-(defun context-coloring-dispatch (&optional callback)
- "Determine the optimal track for scopification / coloring of
-the current buffer, then execute it.
-
-Invoke CALLBACK when complete. It is invoked synchronously for
-elisp tracks, and asynchronously for shell command tracks."
- (let ((dispatch (gethash major-mode context-coloring-mode-hash-table))
- colorizer
- scopifier
- command)
- (cond
- ((setq colorizer (plist-get dispatch :colorizer))
- (funcall colorizer)
- (when callback (funcall callback)))
- ((setq scopifier (plist-get dispatch :scopifier))
- (context-coloring-apply-tokens (funcall scopifier))
- (when callback (funcall callback)))
- ((setq command (plist-get dispatch :command))
- (context-coloring-scopify-and-colorize command callback)))))
-
;;; Colorization
@@ -1316,7 +1273,7 @@ precedence, i.e. the car of `custom-enabled-themes'."
"#dca3a3"))
-;;; Minor mode
+;;; Change detection
(defvar-local context-coloring-colorize-idle-timer nil
"The currently-running idle timer.")
@@ -1340,6 +1297,64 @@ Supported modes: `js-mode', `js3-mode'"
t
'context-coloring-maybe-colorize)))
+
+;;; Built-in dispatches
+
+(context-coloring-define-dispatch
+ 'javascript-node
+ :modes '(js-mode js3-mode)
+ :executable "scopifier"
+ :command "scopifier"
+ :version "v1.1.1")
+
+(context-coloring-define-dispatch
+ 'javascript-js2
+ :modes '(js2-mode)
+ :colorizer 'context-coloring-js2-colorize
+ :setup
+ (lambda ()
+ (add-hook 'js2-post-parse-callbacks 'context-coloring-colorize nil t))
+ :teardown
+ (lambda ()
+ (remove-hook 'js2-post-parse-callbacks 'context-coloring-colorize t)))
+
+(context-coloring-define-dispatch
+ 'emacs-lisp
+ :modes '(emacs-lisp-mode)
+ :colorizer 'context-coloring-emacs-lisp-colorize
+ :setup
+ (lambda ()
+ (context-coloring-setup-idle-change-detection))
+ :teardown
+ (lambda ()
+ (when context-coloring-colorize-idle-timer
+ (cancel-timer context-coloring-colorize-idle-timer))
+ (remove-hook
+ 'after-change-functions 'context-coloring-change-function t)))
+
+(defun context-coloring-dispatch (&optional callback)
+ "Determine the optimal track for scopification / coloring of
+the current buffer, then execute it.
+
+Invoke CALLBACK when complete. It is invoked synchronously for
+elisp tracks, and asynchronously for shell command tracks."
+ (let ((dispatch (gethash major-mode context-coloring-mode-hash-table))
+ colorizer
+ scopifier
+ command)
+ (cond
+ ((setq colorizer (plist-get dispatch :colorizer))
+ (funcall colorizer)
+ (when callback (funcall callback)))
+ ((setq scopifier (plist-get dispatch :scopifier))
+ (context-coloring-apply-tokens (funcall scopifier))
+ (when callback (funcall callback)))
+ ((setq command (plist-get dispatch :command))
+ (context-coloring-scopify-and-colorize command callback)))))
+
+
+;;; Minor mode
+
;;;###autoload
(define-minor-mode context-coloring-mode
"Context-based code coloring, inspired by Douglas Crockford."
- [elpa] master dd8d491 12/47: Also color defsubst., (continued)
- [elpa] master dd8d491 12/47: Also color defsubst., Jackson Ray Hamilton, 2015/05/18
- [elpa] master 5acd088 10/47: Add non-recursive let* coloring., Jackson Ray Hamilton, 2015/05/18
- [elpa] master c830ae5 15/47: Fix let* test., Jackson Ray Hamilton, 2015/05/18
- [elpa] master b4072c1 14/47: Trivial refactoring for clarity., Jackson Ray Hamilton, 2015/05/18
- [elpa] master 926d74a 17/47: Include binding order in let* test., Jackson Ray Hamilton, 2015/05/18
- [elpa] master 29328af 18/47: Add let test., Jackson Ray Hamilton, 2015/05/18
- [elpa] master ea3ff31 16/47: Pass let* test., Jackson Ray Hamilton, 2015/05/18
- [elpa] master b28e896 19/47: Add complex nesting to let test., Jackson Ray Hamilton, 2015/05/18
- [elpa] master bd9c147 20/47: Ignore the dot., Jackson Ray Hamilton, 2015/05/18
- [elpa] master d7b2c92 21/47: Remove unused functions., Jackson Ray Hamilton, 2015/05/18
- [elpa] master 0836b9f 22/47: Add change hooks for elisp.,
Jackson Ray Hamilton <=
- [elpa] master 08bf3e4 23/47: Ignore question marks., Jackson Ray Hamilton, 2015/05/18
- [elpa] master 09ec36e 24/47: Add interruption mechanism., Jackson Ray Hamilton, 2015/05/18
- [elpa] master dc2f9a6 25/47: Refactor maybe-colorize-comments-and-strings., Jackson Ray Hamilton, 2015/05/18
- [elpa] master a556195 26/47: Tweak iteration values, add logging., Jackson Ray Hamilton, 2015/05/18
- [elpa] master 3fc5b20 27/47: Make dispatches fully redefinable., Jackson Ray Hamilton, 2015/05/18
- [elpa] master 89f20e4 28/47: Improve interruptability of syntactic coloring., Jackson Ray Hamilton, 2015/05/18
- [elpa] master d24de46 31/47: Add TODO., Jackson Ray Hamilton, 2015/05/18
- [elpa] master 07c5852 30/47: Add idle change teardown function., Jackson Ray Hamilton, 2015/05/18
- [elpa] master ef544ef 29/47: Fontify keywords., Jackson Ray Hamilton, 2015/05/18
- [elpa] master 5c5b429 32/47: Fix font-lock error., Jackson Ray Hamilton, 2015/05/18