[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 92d3d12 01/12: Remove asynchronous support.
From: |
Jackson Ray Hamilton |
Subject: |
[elpa] master 92d3d12 01/12: Remove asynchronous support. |
Date: |
Sun, 21 Jun 2015 21:16:12 +0000 |
branch: master
commit 92d3d12b65d16adcf2501e1e9fe10f4fbb0e7b36
Author: Jackson Ray Hamilton <address@hidden>
Commit: Jackson Ray Hamilton <address@hidden>
Remove asynchronous support.
---
.travis.yml | 4 -
Cask | 1 -
Makefile | 4 -
README.md | 130 +----------
benchmark/context-coloring-benchmark.el | 184 ++++----------
context-coloring.el | 396 +++----------------------------
scopifier.png | Bin 2609 -> 0 bytes
test/binaries/noop | 5 -
test/binaries/outta-date | 5 -
test/context-coloring-test.el | 330 +++++++-------------------
10 files changed, 185 insertions(+), 874 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index 8a9d303..0c3a48d 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,8 +1,5 @@
language: emacs-lisp
-node_js:
- - "0.10"
-
env:
- EVM_EMACS=emacs-24.3-bin
- EVM_EMACS=emacs-24.4-bin
@@ -17,7 +14,6 @@ before_install:
- evm install ${EVM_EMACS} --use
- curl -fsSkL https://raw.github.com/cask/cask/master/go | python
- cask
- - npm install -g scopifier
script:
- emacs --version
diff --git a/Cask b/Cask
index db61c1c..b1535a9 100644
--- a/Cask
+++ b/Cask
@@ -5,5 +5,4 @@
(depends-on "js2-mode")
(development
- (depends-on "ert-async")
(depends-on "undercover"))
diff --git a/Makefile b/Makefile
index dfa219d..56a769d 100644
--- a/Makefile
+++ b/Makefile
@@ -1,8 +1,6 @@
EMACS = emacs
CASK = EMACS=${EMACS} cask
DEPENDENCIES = .cask/
-SCOPIFIER_PORT = $$(lsof -t -i :6969)
-KILL_SCOPIFIER = if [ -n "${SCOPIFIER_PORT}" ]; then kill ${SCOPIFIER_PORT}; fi
all: uncompile compile test
@@ -32,7 +30,6 @@ test: ${DEPENDENCIES}
${CASK} exec ${EMACS} -Q -batch \
-L . \
-l ert \
- -l ert-async \
-l test/context-coloring-coverage.el \
-f context-coloring-coverage-ci-init \
-l test/context-coloring-test.el \
@@ -43,7 +40,6 @@ cover: ${DEPENDENCIES}
${CASK} exec ${EMACS} -Q -batch \
-L . \
-l ert \
- -l ert-async \
-l test/context-coloring-coverage.el \
-f context-coloring-coverage-local-init \
-l test/context-coloring-test.el \
diff --git a/README.md b/README.md
index 6e8865f..bf6bd93 100644
--- a/README.md
+++ b/README.md
@@ -25,57 +25,18 @@ By default, comments and strings are still highlighted
syntactically.
## Installation
-Requires Emacs 24.3+.
+Requires Emacs 24.3+. JavaScript language support requires
+[js2-mode](https://github.com/mooz/js2-mode).
-JavaScript language support requires either [js2-mode][], or
-[Node.js 0.10+][node] and the [scopifier][] executable.
-
-### ELPA
-
-- `M-x package-install RET context-coloring RET`
-
-### Git
-
-- Clone this repository.
-
-```bash
-cd ~/.emacs.d/
-git clone https://github.com/jacksonrayhamilton/context-coloring.git
-```
-
-- Byte-compile the package for improved speed.
-
-```bash
-cd context-coloring/
-make compile
-```
-
-- Add the following to your init file:
+`M-x package-install RET context-coloring RET` and add the following to your
+init file:
```lisp
-(add-to-list 'load-path "~/.emacs.d/context-coloring")
-(require 'context-coloring)
-```
-
-### Dependencies (js-mode)
-
-```bash
-npm install -g scopifier
-```
-
-## Usage
-
-Add the following to your init file:
-
-```lisp
-;; js-mode:
-(add-hook 'js-mode-hook #'context-coloring-mode)
-
-;; js2-mode:
+;; JavaScript:
(add-to-list 'auto-mode-alist '("\\.js\\'" . js2-mode))
(add-hook 'js2-mode-hook #'context-coloring-mode)
-;; emacs-lisp-mode:
+;; Emacs Lisp:
(add-hook 'emacs-lisp-mode-hook #'context-coloring-mode)
;; eval-expression:
@@ -90,12 +51,10 @@ Add the following to your init file:
comments using `font-lock`.
- `context-coloring-syntactic-strings` (default: `t`): If non-nil, also color
strings using `font-lock`.
-- `context-coloring-default-delay` (default: `0.25`; supported modes:
`js-mode`,
- `js3-mode`): Default (sometimes overridden) delay between a buffer update and
- colorization.
-- `context-coloring-js-block-scopes` (default: `nil`; supported modes:
- `js2-mode`): If non-nil, also color block scopes in the scope hierarchy in
- JavaScript.
+- `context-coloring-default-delay` (default: `0.25`): Default delay between a
+ buffer update and colorization.
+- `context-coloring-javascript-block-scopes` (default: `nil`): If non-nil, also
+ color block scopes in the scope hierarchy in JavaScript.
### Color Schemes
@@ -123,72 +82,3 @@ You can define your own theme colors too:
```
See `C-h f context-coloring-define-theme` for more info on theme parameters.
-
-## Extending
-
-To add support for a new language, write a "scopifier" for it, and define a new
-coloring dispatch strategy with `context-coloring-define-dispatch`. Then the
-plugin should handle the rest. (See `C-h f context-coloring-define-dispatch`
-for more info on dispatch strategies.)
-
-A "scopifier" is a CLI program that reads a buffer's contents from stdin and
-writes a JSON array of numbers to stdout. Every three numbers in the array
-represent a range of color. For instance, if I fed the following string of
-JavaScript code to a scopifier
-
-```js
-var a = function () {};
-```
-
-then the scopifier would produce the following array
-
-```js
-[1,24,0,9,23,1]
-```
-
-where, for every three numbers, the first number is a 1-indexed start
[point][],
-the second number is an exclusive end point, and the third number is a scope
-level. The result of applying level 0 coloring to the range [1, 24) and
-then applying level 1 coloring to the range [9, 23) would result in the
-following coloring:
-
-<p align="center">
- <img alt="Screenshot of ranges [1, 24) and [9, 23)."
src="scopifier.png" title="Screenshot">
-</p>
-
-If there is an abstract syntax tree generator for your language, you can walk
-the syntax tree, find variables and scopes, and build their positions and
levels
-into an array like the one above.
-
-For example, a Ruby scopifier might be defined and implemented like this:
-
-```lisp
-(context-coloring-define-dispatch
- 'ruby
- :modes '(ruby-mode)
- :executable "ruby"
- :command "/home/username/scopifier")
-```
-
-```ruby
-#!/usr/bin/env ruby
-def scopifier(code)
- # Parse code.
- # Return an array.
-end
-print scopifier ARGF.read
-```
-
-When a `--version` argument is passed, a scopifier should print its version
-number and exit. This allows context-coloring to determine if an update is
-required.
-
-Alternatively, you could implement a "colorizer" in Emacs Lisp. A colorizer
-also handles the job of calling `context-coloring-colorize-region` to apply
-colors to a buffer. A colorizer may have better performance than a scopifier
-when parsing and coloring can be performed in the same pass.
-
-[js2-mode]: https://github.com/mooz/js2-mode
-[node]: http://nodejs.org/download/
-[scopifier]: https://github.com/jacksonrayhamilton/scopifier
-[point]: http://www.gnu.org/software/emacs/manual/html_node/elisp/Point.html
diff --git a/benchmark/context-coloring-benchmark.el
b/benchmark/context-coloring-benchmark.el
index 1f5885c..2256c31 100644
--- a/benchmark/context-coloring-benchmark.el
+++ b/benchmark/context-coloring-benchmark.el
@@ -38,46 +38,6 @@
"Resolve PATH from this file's directory."
(expand-file-name path context-coloring-benchmark-path))
-(defun context-coloring-benchmark-next-tick (callback)
- "Run CALLBACK in the next turn of the event loop."
- (run-with-timer nil nil callback))
-
-(defun context-coloring-benchmark-series (sequence callback)
- "Call each function in SEQUENCE, then call CALLBACK. Each
-function is passed a single callback parameter for it to call
-when it is done."
- (cond
- ((null sequence)
- (funcall callback))
- (t
- (funcall
- (car sequence)
- (lambda ()
- (context-coloring-benchmark-next-tick
- (lambda ()
- (context-coloring-benchmark-series
- (cdr sequence)
- callback))))))))
-
-(defun context-coloring-benchmark-mapc (sequence iteratee callback)
- "For each element in SEQUENCE, call ITERATEE, finally call
-CALLBACK. ITERATEE is passed the current element and a callback
-for it to call when it is done."
- (cond
- ((null sequence)
- (funcall callback))
- (t
- (funcall
- iteratee
- (car sequence)
- (lambda ()
- (context-coloring-benchmark-next-tick
- (lambda ()
- (context-coloring-benchmark-mapc
- (cdr sequence)
- iteratee
- callback))))))))
-
(defun context-coloring-benchmark-log-results (result-file fixture statistics)
"Log benchmarking results to RESULT-FILE for fixture FIXTURE
with STATISTICS."
@@ -111,17 +71,13 @@ with STATISTICS."
(buffer-substring-no-properties (point-min) (point-max)))
nil result-file)))
-(defun context-coloring-benchmark (title setup teardown fixtures callback)
- "Execute a benchmark titled TITLE with SETUP and TEARDOWN
-callbacks. Measure the performance of all FIXTURES, calling
-CALLBACK when all are done."
- (funcall setup)
+(defun context-coloring-benchmark (title fixtures)
+ "Execute a benchmark titled TITLE against FIXTURES."
(let ((result-file (context-coloring-benchmark-resolve-path
(format "./logs/results-%s-%s.log"
title (format-time-string "%s")))))
- (context-coloring-benchmark-mapc
- fixtures
- (lambda (path callback)
+ (mapc
+ (lambda (path)
(let ((fixture (context-coloring-benchmark-resolve-path path))
colorization-start-time
(colorization-times '())
@@ -130,83 +86,58 @@ CALLBACK when all are done."
advice
(let ((count 0))
(lambda (original-function)
- (funcall
- original-function
- (lambda ()
- (setq count (+ count 1))
- ;; First 5 runs are for gathering real coloring times,
- ;; unaffected by elp instrumentation.
- (when (<= count 5)
- (push (- (float-time) colorization-start-time)
colorization-times))
- (cond
- ((= count 10)
- (advice-remove #'context-coloring-colorize advice)
- (context-coloring-benchmark-log-results
- result-file
- fixture
- (list
- :file-size (nth 7 (file-attributes fixture))
- :lines (count-lines (point-min) (point-max))
- :words (count-words (point-min) (point-max))
- :colorization-times colorization-times
- :average-colorization-time (/ (apply #'+
colorization-times) 5)))
- (elp-restore-all)
- (kill-buffer)
- (funcall callback))
- ;; The last 5 runs are for gathering function call and
- ;; duration statistics.
- ((= count 5)
- (elp-instrument-package "context-coloring-")
- (context-coloring-colorize))
- (t
- (setq colorization-start-time (float-time))
- (context-coloring-colorize))))))))
+ (funcall original-function)
+ (setq count (+ count 1))
+ ;; First 5 runs are for gathering real coloring times,
+ ;; unaffected by elp instrumentation.
+ (when (<= count 5)
+ (push (- (float-time) colorization-start-time)
colorization-times))
+ (cond
+ ((= count 10)
+ (advice-remove #'context-coloring-colorize advice)
+ (context-coloring-benchmark-log-results
+ result-file
+ fixture
+ (list
+ :file-size (nth 7 (file-attributes fixture))
+ :lines (count-lines (point-min) (point-max))
+ :words (count-words (point-min) (point-max))
+ :colorization-times colorization-times
+ :average-colorization-time (/ (apply #'+ colorization-times)
5)))
+ (elp-restore-all)
+ (kill-buffer))
+ ;; The last 5 runs are for gathering function call and
+ ;; duration statistics.
+ ((= count 5)
+ (elp-instrument-package "context-coloring-")
+ (context-coloring-colorize))
+ (t
+ (setq colorization-start-time (float-time))
+ (context-coloring-colorize))))))
(advice-add #'context-coloring-colorize :around advice)
(setq colorization-start-time (float-time))
(find-file fixture)))
- (lambda ()
- (funcall teardown)
- (funcall callback)))))
+ fixtures)))
-(defconst context-coloring-benchmark-js-fixtures
+(defconst context-coloring-benchmark-javascript-fixtures
'("./fixtures/jquery-2.1.1.js"
"./fixtures/lodash-2.4.1.js"
"./fixtures/async-0.9.0.js"
"./fixtures/mkdirp-0.5.0.js")
"Arbitrary JavaScript files for performance scrutiny.")
-(defun context-coloring-benchmark-js-mode-run (callback)
- "Benchmark `js-mode', then call CALLBACK."
- (context-coloring-benchmark
- "js-mode"
- (lambda ()
- "Preparation logic for `js-mode'."
- (add-hook 'js-mode-hook #'context-coloring-mode))
- (lambda ()
- "Cleanup logic for `js-mode'."
- (remove-hook 'js-mode-hook #'context-coloring-mode))
- context-coloring-benchmark-js-fixtures
- callback))
-
-(defun context-coloring-benchmark-js2-mode-run (callback)
- "Benchmark `js2-mode', then call CALLBACK."
- (context-coloring-benchmark
- "js2-mode"
- (lambda ()
- "Preparation logic for `js2-mode'."
- (setq js2-mode-show-parse-errors nil)
- (setq js2-mode-show-strict-warnings nil)
- (add-to-list 'auto-mode-alist '("\\.js\\'" . js2-mode))
- (add-hook 'js2-mode-hook #'context-coloring-mode))
- (lambda ()
- "Cleanup logic for `js2-mode'."
- (remove-hook 'js2-mode-hook #'context-coloring-mode)
- (setq auto-mode-alist (delete '("\\.js\\'" . js2-mode)
- auto-mode-alist))
- (setq js2-mode-show-strict-warnings t)
- (setq js2-mode-show-parse-errors t))
- context-coloring-benchmark-js-fixtures
- callback))
+(defun context-coloring-benchmark-js2-mode-run ()
+ "Benchmark `js2-mode'."
+ (add-to-list 'auto-mode-alist '("\\.js\\'" . js2-mode))
+ (add-hook 'js2-mode-hook #'context-coloring-mode)
+ (let ((js2-mode-show-parse-errors nil)
+ (js2-mode-show-strict-warnings nil))
+ (context-coloring-benchmark
+ "js2-mode"
+ context-coloring-benchmark-javascript-fixtures))
+ (setq auto-mode-alist (delete '("\\.js\\'" . js2-mode)
+ auto-mode-alist))
+ (remove-hook 'js2-mode-hook #'context-coloring-mode))
(defconst context-coloring-benchmark-emacs-lisp-fixtures
'("./fixtures/lisp.el"
@@ -215,28 +146,19 @@ CALLBACK when all are done."
"./fixtures/simple.el")
"Arbitrary Emacs Lisp files for performance scrutiny.")
-(defun context-coloring-benchmark-emacs-lisp-mode-run (callback)
+(defun context-coloring-benchmark-emacs-lisp-mode-run ()
"Benchmark `emacs-lisp-mode', then call CALLBACK."
+ (add-hook 'emacs-lisp-mode-hook #'context-coloring-mode)
(context-coloring-benchmark
"emacs-lisp-mode"
- (lambda ()
- "Preparation logic for `emacs-lisp-mode'."
- (add-hook 'emacs-lisp-mode-hook #'context-coloring-mode))
- (lambda ()
- "Cleanup logic for `emacs-lisp-mode'."
- (remove-hook 'emacs-lisp-mode-hook #'context-coloring-mode))
- context-coloring-benchmark-emacs-lisp-fixtures
- callback))
+ context-coloring-benchmark-emacs-lisp-fixtures)
+ (remove-hook 'emacs-lisp-mode-hook #'context-coloring-mode))
(defun context-coloring-benchmark-run ()
"Benchmark all modes, then exit."
- (context-coloring-benchmark-series
- (list
- #'context-coloring-benchmark-js-mode-run
- #'context-coloring-benchmark-js2-mode-run
- #'context-coloring-benchmark-emacs-lisp-mode-run)
- (lambda ()
- (kill-emacs))))
+ (context-coloring-benchmark-js2-mode-run)
+ (context-coloring-benchmark-emacs-lisp-mode-run)
+ (kill-emacs))
(provide 'context-coloring-benchmark)
diff --git a/context-coloring.el b/context-coloring.el
index 327dbc3..5131040 100644
--- a/context-coloring.el
+++ b/context-coloring.el
@@ -43,22 +43,6 @@
"Join a list of STRINGS with the string DELIMITER."
(mapconcat #'identity strings delimiter))
-(defsubst context-coloring-trim-right (string)
- "Remove leading whitespace from STRING."
- (if (string-match "[ \t\n\r]+\\'" string)
- (replace-match "" t t string)
- string))
-
-(defsubst context-coloring-trim-left (string)
- "Remove trailing whitespace from STRING."
- (if (string-match "\\`[ \t\n\r]+" string)
- (replace-match "" t t string)
- string))
-
-(defsubst context-coloring-trim (string)
- "Remove leading and trailing whitespace from STRING."
- (context-coloring-trim-left (context-coloring-trim-right string)))
-
;;; Faces
@@ -142,7 +126,6 @@ being used.")
START, END and LENGTH are recorded for later use."
;; Tokenization is obsolete if there was a change.
- (context-coloring-cancel-scopification)
(setq context-coloring-changed-start start)
(setq context-coloring-changed-end end)
(setq context-coloring-changed-length length)
@@ -165,13 +148,10 @@ START, END and LENGTH are recorded for later use."
"The currently-running idle timer for unconditional coloring.")
(defcustom context-coloring-default-delay 0.25
- "Default (sometimes overridden) delay between a buffer update
-and colorization.
+ "Default delay between a buffer update and colorization.
Increase this if your machine is high-performing. Decrease it if
-it ain't.
-
-Supported modes: `js-mode', `js3-mode'"
+it ain't."
:group 'context-coloring)
(make-obsolete-variable
@@ -210,7 +190,6 @@ Supported modes: `js-mode', `js3-mode'"
(defun context-coloring-teardown-idle-change-detection ()
"Teardown idle change detection."
- (context-coloring-cancel-scopification)
(dolist (timer (list context-coloring-colorize-idle-timer
context-coloring-maybe-colorize-idle-timer))
(context-coloring-cancel-timer timer))
@@ -286,15 +265,18 @@ to the beginning of the buffer and MAX defaults to the
end."
"Associate `js2-scope' structures and with their scope
levels.")
-(defcustom context-coloring-js-block-scopes nil
+(defcustom context-coloring-javascript-block-scopes nil
"If non-nil, also color block scopes in the scope hierarchy in JavaScript.
The block-scoped `let' and `const' are introduced in ES6. Enable
-this for ES6 code; disable it elsewhere.
-
-Supported modes: `js2-mode'"
+this for ES6 code; disable it elsewhere."
:group 'context-coloring)
+(make-obsolete-variable
+ 'context-coloring-js-block-scopes
+ 'context-coloring-javascript-block-scopes
+ "7.0.0")
+
(defsubst context-coloring-js2-scope-level (scope)
"Return the level of SCOPE."
(cond ((gethash scope context-coloring-js2-scope-level-hash-table))
@@ -306,7 +288,7 @@ Supported modes: `js2-mode'"
(js2-node-parent current-scope)
(setq enclosing-scope
(js2-node-get-enclosing-scope current-scope)))
- (when (or context-coloring-js-block-scopes
+ (when (or context-coloring-javascript-block-scopes
(let ((type (js2-scope-type current-scope)))
(or (= type js2-SCRIPT)
(= type js2-FUNCTION)
@@ -1040,6 +1022,9 @@ scopes and variables."
(t
(context-coloring-elisp-colorize-region-initially (point-min)
(point-max)))))))
+
+;;; eval-expression colorization
+
(defun context-coloring-eval-expression-colorize ()
"Color the `eval-expression' minibuffer prompt as elisp."
(interactive)
@@ -1052,173 +1037,6 @@ scopes and variables."
(point-max)))))
-;;; Shell command scopification / colorization
-
-(defun context-coloring-apply-tokens (tokens)
- "Process a string of TOKENS to apply context-based coloring to
-the current buffer. Tokens are 3 integers: start, end, level. A
-new token occurrs after every 3rd element, and the elements are
-separated by commas."
- (let* ((tokens (mapcar #'string-to-number (split-string tokens ","))))
- (while tokens
- (context-coloring-colorize-region
- (pop tokens)
- (pop tokens)
- (pop tokens))))
- (context-coloring-colorize-comments-and-strings))
-
-(defun context-coloring-parse-array (array)
- "Parse ARRAY as a flat JSON array of numbers and use the tokens
-to colorize the buffer."
- (let* ((braceless (substring-no-properties (context-coloring-trim array) 1
-1)))
- (when (> (length braceless) 0)
- (with-silent-modifications
- (context-coloring-apply-tokens braceless)))))
-
-(defvar-local context-coloring-scopifier-cancel-function nil
- "Kills the current scopification process.")
-
-(defvar-local context-coloring-scopifier-process nil
- "The single scopifier process that can be running.")
-
-(defun context-coloring-cancel-scopification ()
- "Stop the currently-running scopifier from scopifying."
- (when context-coloring-scopifier-cancel-function
- (funcall context-coloring-scopifier-cancel-function)
- (setq context-coloring-scopifier-cancel-function nil))
- (when (not (null context-coloring-scopifier-process))
- (delete-process context-coloring-scopifier-process)
- (setq context-coloring-scopifier-process nil)))
-
-(defun context-coloring-shell-command (command callback)
- "Invoke COMMAND, read its response asynchronously and invoke
-CALLBACK with its output. Return the command process."
- (let ((process (start-process-shell-command "context-coloring-process" nil
command))
- (output ""))
- ;; The process may produce output in multiple chunks. This filter
- ;; accumulates the chunks into a message.
- (set-process-filter
- process
- (lambda (_process chunk)
- (setq output (concat output chunk))))
- ;; When the process's message is complete, this sentinel parses it as JSON
- ;; and applies the tokens to the buffer.
- (set-process-sentinel
- process
- (lambda (_process event)
- (when (equal "finished\n" event)
- (funcall callback output))))
- process))
-
-(defun context-coloring-scopify-shell-command (command callback)
- "Invoke a scopifier via COMMAND, read its response
-asynchronously and invoke CALLBACK with its output."
- ;; Prior running tokenization is implicitly obsolete if this function is
- ;; called.
- (context-coloring-cancel-scopification)
- ;; Start the process.
- (setq context-coloring-scopifier-process
- (context-coloring-shell-command command callback)))
-
-(defun context-coloring-send-buffer-to-scopifier ()
- "Give the scopifier process its input so it can begin
-scopifying."
- (process-send-region
- context-coloring-scopifier-process
- (point-min) (point-max))
- (process-send-eof
- context-coloring-scopifier-process))
-
-(defun context-coloring-start-scopifier-server (command host port callback)
- "Connect to or start a scopifier server with COMMAND, HOST and PORT.
-Invoke CALLBACK with a network stream when the server is ready
-for connections."
- (let* ((connect
- (lambda ()
- (let ((stream (open-network-stream "context-coloring-stream" nil
host port)))
- (funcall callback stream)))))
- ;; Try to connect in case a server is running, otherwise start one.
- (condition-case nil
- (progn
- (funcall connect))
- (error
- (let ((server (start-process-shell-command
- "context-coloring-scopifier-server" nil
- (context-coloring-join
- (list command
- "--server"
- "--host" host
- "--port" (number-to-string port))
- " ")))
- (output ""))
- ;; Connect as soon as the "listening" message is printed.
- (set-process-filter
- server
- (lambda (_process chunk)
- (setq output (concat output chunk))
- (when (string-match-p (format "^Scopifier listening at %s:%s$"
host port) output)
- (funcall connect)))))))))
-
-(defun context-coloring-send-buffer-to-scopifier-server (command host port
callback)
- "Send the current buffer to the scopifier server running with
-COMMAND, HOST and PORT. Invoke CALLBACK with the server's
-response (a stringified JSON array)."
- (context-coloring-start-scopifier-server
- command host port
- (lambda (process)
- (let* ((body (buffer-substring-no-properties (point-min) (point-max)))
- (header (concat "POST / HTTP/1.0\r\n"
- "Host: localhost\r\n"
- "Content-Type: application/x-www-form-urlencoded"
- "; charset=UTF8\r\n"
- (format "Content-Length: %d\r\n" (length body))
- "\r\n"))
- (output "")
- (active t))
- (set-process-filter
- process
- (lambda (_process chunk)
- (setq output (concat output chunk))))
- (set-process-sentinel
- process
- (lambda (_process event)
- (when (and (equal "connection broken by remote peer\n" event)
- active)
- ;; Strip the response headers.
- (string-match "\r\n\r\n" output)
- (setq output (substring-no-properties output (match-end 0)))
- (funcall callback output))))
- (process-send-string process (concat header body "\r\n"))
- (setq context-coloring-scopifier-cancel-function
- (lambda ()
- "Cancel this scopification."
- (setq active nil)))))))
-
-(defun context-coloring-scopify-and-colorize-server (command host port
&optional callback)
- "Color the current buffer via the server started with COMMAND,
-HOST and PORT. Invoke CALLBACK when complete."
- (let ((buffer (current-buffer)))
- (context-coloring-send-buffer-to-scopifier-server
- command host port
- (lambda (output)
- (with-current-buffer buffer
- (context-coloring-parse-array output))
- (when callback (funcall callback))))))
-
-(defun context-coloring-scopify-and-colorize (command &optional callback)
- "Color the current buffer via COMMAND. Invoke CALLBACK when
-complete."
- (let ((buffer (current-buffer)))
- (context-coloring-scopify-shell-command
- command
- (lambda (output)
- (with-current-buffer buffer
- (context-coloring-parse-array output))
- (setq context-coloring-scopifier-process nil)
- (when callback (funcall callback)))))
- (context-coloring-send-buffer-to-scopifier))
-
-
;;; Dispatch
(defvar context-coloring-dispatch-hash-table (make-hash-table :test #'eq)
@@ -1250,15 +1068,10 @@ lists, which contain details about the strategies.")
"Define a new dispatch named SYMBOL with PROPERTIES.
A \"dispatch\" is a property list describing a strategy for
-coloring a buffer. There are three possible strategies: Parse
-and color in a single function (`:colorizer'), parse with a shell
-command that returns scope data (`:command'), or parse with a
-server that returns scope data (`:command', `:host' and `:port').
-In the latter two cases, the scope data will be used to
-automatically color the buffer.
+coloring a buffer.
-PROPERTIES must include one of `:modes' or `:predicate', and one
-of `:colorizer' or `:command'.
+PROPERTIES must include one of `:modes' or `:predicate', and a
+`:colorizer'.
`:modes' - List of major modes this dispatch is valid for.
@@ -1267,25 +1080,9 @@ for any given state.
`:colorizer' - Function that parses and colors the buffer.
-`:executable' - Optional name of an executable required by
-`:command'.
-
-`:command' - Shell command to execute with the current buffer
-sent via stdin, and with a flat JSON array of start, end and
-level data returned via stdout.
-
-`:host' - Hostname of the scopifier server, e.g. \"localhost\".
-
-`:port' - Port number of the scopifier server, e.g. 80, 1337.
-
`:delay' - Delay between buffer update and colorization, to
override `context-coloring-default-delay'.
-`:version' - Minimum required version that should be printed when
-executing `:command' with a \"--version\" flag. The version
-should be numeric, e.g. \"2\", \"19700101\", \"1.2.3\",
-\"v1.2.3\" etc.
-
`:setup' - Arbitrary code to set up this dispatch when
`context-coloring-mode' is enabled.
@@ -1293,14 +1090,11 @@ should be numeric, e.g. \"2\", \"19700101\", \"1.2.3\",
`context-coloring-mode' is disabled."
(let ((modes (plist-get properties :modes))
(predicate (plist-get properties :predicate))
- (colorizer (plist-get properties :colorizer))
- (command (plist-get properties :command)))
- (when (null (or modes
- predicate))
+ (colorizer (plist-get properties :colorizer)))
+ (when (null (or modes predicate))
(error "No mode or predicate defined for dispatch"))
- (when (not (or colorizer
- command))
- (error "No colorizer or command defined for dispatch"))
+ (when (not colorizer)
+ (error "No colorizer defined for dispatch"))
(puthash symbol properties context-coloring-dispatch-hash-table)
(dolist (mode modes)
(puthash mode properties context-coloring-mode-hash-table))
@@ -1309,21 +1103,21 @@ should be numeric, e.g. \"2\", \"19700101\", \"1.2.3\",
(when (funcall predicate)
properties)) context-coloring-dispatch-predicates))))
+(defun context-coloring-dispatch ()
+ "Determine the optimal track for scopification / coloring of
+the current buffer, then execute it."
+ (let* ((dispatch (context-coloring-get-current-dispatch))
+ (colorizer (plist-get dispatch :colorizer)))
+ (catch 'interrupted
+ (funcall colorizer))))
-;;; Colorization
-
-(defvar context-coloring-colorize-hook nil
- "Hooks to run after coloring a buffer.")
-(defun context-coloring-colorize (&optional callback)
- "Color the current buffer by function context.
+;;; Colorization
-Invoke CALLBACK when complete; see `context-coloring-dispatch'."
+(defun context-coloring-colorize ()
+ "Color the current buffer by function context."
(interactive)
- (context-coloring-dispatch
- (lambda ()
- (when callback (funcall callback))
- (run-hooks 'context-coloring-colorize-hook))))
+ (context-coloring-dispatch))
(defun context-coloring-colorize-with-buffer (buffer)
"Color BUFFER."
@@ -1333,60 +1127,6 @@ Invoke CALLBACK when complete; see
`context-coloring-dispatch'."
(context-coloring-colorize))))
-;;; Versioning
-
-(defun context-coloring-parse-version (string)
- "Extract segments of a version STRING into a list. \"v1.0.0\"
-produces (1 0 0), \"19700101\" produces (19700101), etc."
- (let (version)
- (while (string-match "[0-9]+" string)
- (setq version (append version
- (list (string-to-number (match-string 0 string)))))
- (setq string (substring string (match-end 0))))
- version))
-
-(defun context-coloring-check-version (expected actual)
- "Check that version EXPECTED is less than or equal to ACTUAL."
- (let ((expected (context-coloring-parse-version expected))
- (actual (context-coloring-parse-version actual))
- (continue t)
- (acceptable t))
- (while (and continue expected)
- (let ((an-expected (car expected))
- (an-actual (car actual)))
- (cond
- ((> an-actual an-expected)
- (setq acceptable t)
- (setq continue nil))
- ((< an-actual an-expected)
- (setq acceptable nil)
- (setq continue nil))))
- (setq expected (cdr expected))
- (setq actual (cdr actual)))
- acceptable))
-
-(defvar context-coloring-check-scopifier-version-hook nil
- "Hooks to run after checking the scopifier version.")
-
-(defun context-coloring-check-scopifier-version (&optional callback)
- "Asynchronously invoke CALLBACK with a predicate indicating
-whether the current scopifier version satisfies the minimum
-version number required for the current major mode."
- (let ((dispatch (context-coloring-get-current-dispatch)))
- (when dispatch
- (let ((version (plist-get dispatch :version))
- (command (plist-get dispatch :command)))
- (context-coloring-shell-command
- (context-coloring-join (list command "--version") " ")
- (lambda (output)
- (cond
- ((context-coloring-check-version version output)
- (when callback (funcall callback t)))
- (t
- (when callback (funcall callback nil))))
- (run-hooks 'context-coloring-check-scopifier-version-hook)))))))
-
-
;;; Themes
(defvar context-coloring-theme-hash-table (make-hash-table :test #'eq)
@@ -1733,16 +1473,7 @@ precedence, i.e. the car of `custom-enabled-themes'."
;;; Built-in dispatches
(context-coloring-define-dispatch
- 'javascript-node
- :modes '(js-mode js3-mode)
- :executable "scopifier"
- :command "scopifier"
- :version "v1.2.1"
- :host "localhost"
- :port 6969)
-
-(context-coloring-define-dispatch
- 'javascript-js2
+ 'javascript
:modes '(js2-mode)
:colorizer #'context-coloring-js2-colorize
:setup
@@ -1775,33 +1506,6 @@ precedence, i.e. the car of `custom-enabled-themes'."
:setup #'context-coloring-setup-idle-change-detection
:teardown #'context-coloring-teardown-idle-change-detection)
-(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 (context-coloring-get-current-dispatch))
- (colorizer (plist-get dispatch :colorizer))
- (command (plist-get dispatch :command))
- (host (plist-get dispatch :host))
- (port (plist-get dispatch :port))
- interrupted-p)
- (cond
- (colorizer
- (setq interrupted-p
- (catch 'interrupted
- (funcall colorizer)))
- (when (and (not interrupted-p)
- callback)
- (funcall callback)))
- (command
- (cond
- ((and host port)
- (context-coloring-scopify-and-colorize-server command host port
callback))
- (t
- (context-coloring-scopify-and-colorize command callback)))))))
-
;;; Minor mode
@@ -1844,46 +1548,18 @@ Feature inspired by Douglas Crockford."
(let ((dispatch (context-coloring-get-current-dispatch)))
(cond
(dispatch
- (let ((command (plist-get dispatch :command))
- (version (plist-get dispatch :version))
- (executable (plist-get dispatch :executable))
- (setup (plist-get dispatch :setup))
- (colorize-initially-p t))
- (when command
- ;; Shell commands recolor on change, idly.
- (cond
- ((and executable
- (null (executable-find executable)))
- (message "Executable \"%s\" not found" executable)
- (setq colorize-initially-p nil))
- (version
- (context-coloring-check-scopifier-version
- (lambda (sufficient-p)
- (cond
- (sufficient-p
- (context-coloring-setup-idle-change-detection)
- (context-coloring-colorize))
- (t
- (message "Update to the minimum version of \"%s\" (%s)"
- executable version)))))
- (setq colorize-initially-p nil))
- (t
- (context-coloring-setup-idle-change-detection))))
+ (let ((setup (plist-get dispatch :setup)))
(when setup
(funcall setup))
;; Colorize once initially.
- (when colorize-initially-p
- (let ((context-coloring-parse-interruptable-p nil))
- (context-coloring-colorize)))))
+ (let ((context-coloring-parse-interruptable-p nil))
+ (context-coloring-colorize))))
(t
(message "Context coloring is not available for this major mode")))))
(t
(let ((dispatch (context-coloring-get-current-dispatch)))
(when dispatch
- (let ((command (plist-get dispatch :command))
- (teardown (plist-get dispatch :teardown)))
- (when command
- (context-coloring-teardown-idle-change-detection))
+ (let ((teardown (plist-get dispatch :teardown)))
(when teardown
(funcall teardown)))))
(font-lock-mode)
diff --git a/scopifier.png b/scopifier.png
deleted file mode 100644
index 1ec5d10..0000000
Binary files a/scopifier.png and /dev/null differ
diff --git a/test/binaries/noop b/test/binaries/noop
deleted file mode 100644
index a35b551..0000000
--- a/test/binaries/noop
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/usr/bin/env node
-
-'use strict';
-
-console.log(JSON.stringify([]));
diff --git a/test/binaries/outta-date b/test/binaries/outta-date
deleted file mode 100755
index 3ac2dd5..0000000
--- a/test/binaries/outta-date
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/usr/bin/env node
-
-'use strict';
-
-console.log('v2.0.4');
diff --git a/test/context-coloring-test.el b/test/context-coloring-test.el
index 39f2f80..3eb66bd 100644
--- a/test/context-coloring-test.el
+++ b/test/context-coloring-test.el
@@ -27,7 +27,7 @@
(require 'cl-lib)
(require 'context-coloring)
-(require 'ert-async)
+(require 'ert)
(require 'js2-mode)
@@ -51,32 +51,6 @@ buffer."
(insert (context-coloring-test-read-file ,fixture))
,@body)))
-(defun context-coloring-test-with-temp-buffer-async (callback)
- "Create a temporary buffer, and evaluate CALLBACK there. A
-teardown callback is passed to CALLBACK for it to invoke when it
-is done."
- (let ((previous-buffer (current-buffer))
- (temp-buffer (generate-new-buffer " *temp*")))
- (set-buffer temp-buffer)
- (funcall
- callback
- (lambda ()
- (and (buffer-name temp-buffer)
- (kill-buffer temp-buffer))
- (set-buffer previous-buffer)))))
-
-(defun context-coloring-test-with-fixture-async (fixture callback)
- "With the relative FIXTURE, evaluate CALLBACK in a temporary
-buffer. A teardown callback is passed to CALLBACK for it to
-invoke when it is done."
- (context-coloring-test-with-temp-buffer-async
- (lambda (done-with-temp-buffer)
- (insert (context-coloring-test-read-file fixture))
- (funcall
- callback
- (lambda ()
- (funcall done-with-temp-buffer))))))
-
;;; Test defining utilities
@@ -84,25 +58,19 @@ invoke when it is done."
&key mode
&key extension
&key no-fixture
- &key async
- &key post-colorization
&key
enable-context-coloring-mode
&key get-args
&key before-each
&key after-each)
- "Define a deftest defmacro for tests prefixed with NAME. MODE
+ "Define a deftest defmacro for tests prefixed with NAME. MODE
is called to set up tests' environments. EXTENSION denotes the
suffix for tests' fixture files. If NO-FIXTURE is non-nil, don't
-use a fixture. If ASYNC is non-nil, pass a callback to the
-defined tests' bodies for them to call when they are done. If
-POST-COLORIZATION is non-nil, the tests run after
-`context-coloring-colorize' finishes asynchronously. If
-ENABLE-CONTEXT-COLORING-MODE is non-nil, `context-coloring-mode'
-is activated before tests. GET-ARGS provides arguments to apply
-to BEFORE-EACH, AFTER-EACH, and each tests' body, before and
-after functions. Functions BEFORE-EACH and AFTER-EACH run before
-the major mode is activated before each test, and after each
-test, even if an error is signaled."
+use a fixture. If ENABLE-CONTEXT-COLORING-MODE is non-nil,
+`context-coloring-mode' is activated before tests. GET-ARGS
+provides arguments to apply to BEFORE-EACH, AFTER-EACH, and each
+tests' body, before and after functions. Functions BEFORE-EACH
+and AFTER-EACH run before the major mode is activated before each
+test, and after each test, even if an error is signaled."
(declare (indent defun))
(let ((macro-name (intern (format "context-coloring-test-deftest%s"
(cond
@@ -114,26 +82,6 @@ test, even if an error is signaled."
&key fixture
&key before
&key after)
- ,(format "Define a test for `%s' suffixed with NAME.
-
-Function BODY makes assertions.
-%s
-
-Functions BEFORE and AFTER run before and after the test, even if
-an error is signaled.
-
-BODY is run after `context-coloring-mode' is activated, or after
-initial colorization if colorization should occur."
- (cadr mode)
- (cond
- (no-fixture "
-There is no fixture, unless FIXTURE is specified.")
- (t
- (format "
-The default fixture has a filename matching NAME (plus the
-filetype extension, \"%s\"), unless FIXTURE is specified to
-override it."
- extension))))
(declare (indent defun))
;; Commas in nested backquotes are not evaluated. Binding the variables
;; here is probably the cleanest workaround.
@@ -152,68 +100,26 @@ override it."
(fixture (format "./fixtures/%s" fixture))
(,no-fixture "./fixtures/empty")
(t (format ,(format "./fixtures/%%s.%s" extension)
name)))))
- ,@(cond
- ((or async post-colorization)
- `((let ((post-colorization ,post-colorization))
- `(ert-deftest-async ,test-name (done)
- (let ((,args (funcall ,get-args)))
- (context-coloring-test-with-fixture-async
- ,fixture
- (lambda (done-with-fixture)
- (when ,before-each (apply ,before-each ,args))
- (,mode)
- (when ,before (apply ,before ,args))
- (cond
- (,post-colorization
- (context-coloring-colorize
- (lambda ()
- (unwind-protect
- (progn
- (apply ,body ,args))
- (when ,after (apply ,after ,args))
- (when ,after-each (apply ,after-each ,args))
- (funcall done-with-fixture))
- (funcall done))))
- (t
- ;; Leave error handling up to the user.
- (apply ,body (append
- (list (lambda ()
- (when ,after (apply ,after
,args))
- (when ,after-each (apply
,after-each ,args))
- (funcall done-with-fixture)
- (funcall done)))
- ,args)))))))))))
- (t
- `((let ((enable-context-coloring-mode
,enable-context-coloring-mode))
- `(ert-deftest ,test-name ()
- (let ((,args (funcall ,get-args)))
- (context-coloring-test-with-fixture
- ,fixture
- (when ,before-each (apply ,before-each ,args))
- (,mode)
- (when ,before (apply ,before ,args))
- (when ,enable-context-coloring-mode
(context-coloring-mode))
- (unwind-protect
- (progn
- (apply ,body ,args))
- (when ,after (apply ,after ,args))
- (when ,after-each (apply ,after-each
,args))))))))))))))
+ ,@`((let ((enable-context-coloring-mode
,enable-context-coloring-mode))
+ `(ert-deftest ,test-name ()
+ (let ((,args (funcall ,get-args)))
+ (context-coloring-test-with-fixture
+ ,fixture
+ (when ,before-each (apply ,before-each ,args))
+ (,mode)
+ (when ,before (apply ,before ,args))
+ (when ,enable-context-coloring-mode
(context-coloring-mode))
+ (unwind-protect
+ (progn
+ (apply ,body ,args))
+ (when ,after (apply ,after ,args))
+ (when ,after-each (apply ,after-each ,args))))))))))))
(context-coloring-test-define-deftest nil
:mode #'fundamental-mode
:no-fixture t)
-(context-coloring-test-define-deftest async
- :mode #'fundamental-mode
- :no-fixture t
- :async t)
-
-(context-coloring-test-define-deftest js
- :mode #'js-mode
- :extension "js"
- :post-colorization t)
-
-(context-coloring-test-define-deftest js2
+(context-coloring-test-define-deftest javascript
:mode #'js2-mode
:extension "js"
:enable-context-coloring-mode t
@@ -221,14 +127,6 @@ override it."
(setq js2-mode-show-parse-errors nil)
(setq js2-mode-show-strict-warnings nil)))
-(defmacro context-coloring-test-deftest-js-js2 (&rest args)
- "Simultaneously define the same test for js and js2 (with
-ARGS)."
- (declare (indent defun))
- `(progn
- (context-coloring-test-deftest-js ,@args)
- (context-coloring-test-deftest-js2 ,@args)))
-
(context-coloring-test-define-deftest emacs-lisp
:mode #'emacs-lisp-mode
:extension "el"
@@ -323,73 +221,59 @@ ARGS)."
;;; Miscellaneous tests
-(defun context-coloring-test-assert-trimmed (result expected)
- "Assert that RESULT is trimmed like EXPECTED."
- (when (not (string-equal result expected))
- (ert-fail "Expected string to be trimmed, but it wasn't.")))
-
-(context-coloring-test-deftest trim
- (lambda ()
- (context-coloring-test-assert-trimmed (context-coloring-trim "") "")
- (context-coloring-test-assert-trimmed (context-coloring-trim " ") "")
- (context-coloring-test-assert-trimmed (context-coloring-trim "a") "a")
- (context-coloring-test-assert-trimmed (context-coloring-trim " a") "a")
- (context-coloring-test-assert-trimmed (context-coloring-trim "a ") "a")
- (context-coloring-test-assert-trimmed (context-coloring-trim " a ") "a")))
-
-(context-coloring-test-deftest-async mode-startup
- (lambda (done)
- (js-mode)
- (add-hook
- 'context-coloring-colorize-hook
- (lambda ()
- ;; If this runs we are implicitly successful; this test only confirms
- ;; that colorization occurs on mode startup.
- (funcall done)))
- (context-coloring-mode))
- :after (lambda ()
- ;; TODO: This won't run if there is a timeout. Will probably have
to
- ;; roll our own `ert-deftest-async'.
- (setq context-coloring-colorize-hook nil)))
-
(defmacro context-coloring-test-define-derived-mode (name)
"Define a derived mode exclusively for any test with NAME."
(let ((name (intern (format "context-coloring-test-%s-mode" name))))
`(define-derived-mode ,name fundamental-mode "Testing")))
+(defmacro context-coloring-test-assert-causes-coloring (&rest body)
+ "Assert that BODY causes coloring."
+ (let ((colorized-p (make-symbol "colorized-p")))
+ `(let (,colorized-p)
+ (advice-add #'context-coloring-colorize
+ :after (lambda ()
+ (setq ,colorized-p t))
+ '((name . assert-causes-coloring)))
+ ,@body
+ (when (not ,colorized-p)
+ (ert-fail "Expected to have colorized, but it didn't.")))))
+
+(defun context-coloring-test-cleanup-assert-causes-coloring ()
+ (advice-remove #'context-coloring-colorize 'assert-causes-coloring))
+
+(context-coloring-test-define-derived-mode mode-startup)
+
+(context-coloring-test-deftest mode-startup
+ (lambda ()
+ (context-coloring-define-dispatch
+ 'mode-startup
+ :modes '(context-coloring-test-mode-startup-mode)
+ :colorizer #'ignore)
+ (context-coloring-test-mode-startup-mode)
+ (context-coloring-test-assert-causes-coloring
+ (context-coloring-mode)))
+ :after (lambda ()
+ (context-coloring-test-cleanup-assert-causes-coloring)))
+
(context-coloring-test-define-derived-mode change-detection)
-;; Simply cannot figure out how to trigger an idle timer; would much rather
test
-;; that. But (current-idle-time) always returns nil in these tests.
-(context-coloring-test-deftest-async change-detection
- (lambda (done)
+(context-coloring-test-deftest change-detection
+ (lambda ()
(context-coloring-define-dispatch
'idle-change
:modes '(context-coloring-test-change-detection-mode)
- :executable "node"
- :command "node test/binaries/noop")
+ :colorizer #'ignore
+ :setup #'context-coloring-setup-idle-change-detection
+ :teardown #'context-coloring-teardown-idle-change-detection)
(context-coloring-test-change-detection-mode)
- (add-hook
- 'context-coloring-colorize-hook
- (lambda ()
- (setq context-coloring-colorize-hook nil)
- (add-hook
- 'context-coloring-colorize-hook
- (lambda ()
- (funcall done)))
- (insert " ")
- (set-window-buffer (selected-window) (current-buffer))
- (context-coloring-maybe-colorize-with-buffer (current-buffer))))
- (context-coloring-mode))
+ (context-coloring-mode)
+ (context-coloring-test-assert-causes-coloring
+ (insert " ")
+ ;; Simply cannot figure out how to trigger an idle timer; would much
rather
+ ;; test that. But (current-idle-time) always returns nil in these tests.
+ (context-coloring-maybe-colorize-with-buffer (current-buffer))))
:after (lambda ()
- (setq context-coloring-colorize-hook nil)))
-
-(context-coloring-test-deftest check-version
- (lambda ()
- (when (not (context-coloring-check-version "2.1.3" "3.0.1"))
- (ert-fail "Expected version 3.0.1 to satisfy 2.1.3, but it didn't."))
- (when (context-coloring-check-version "3.0.1" "2.1.3")
- (ert-fail "Expected version 2.1.3 not to satisfy 3.0.1, but it did."))))
+ (context-coloring-test-cleanup-assert-causes-coloring)))
(context-coloring-test-deftest unsupported-mode
(lambda ()
@@ -420,66 +304,24 @@ ARGS)."
(context-coloring-define-dispatch
'define-dispatch-no-strategy
:modes '(context-coloring-test-define-dispatch-error-mode)))
- "No colorizer or command defined for dispatch")))
-
-(context-coloring-test-define-derived-mode missing-executable)
-
-(context-coloring-test-deftest missing-executable
- (lambda ()
- (context-coloring-define-dispatch
- 'scopifier
- :modes '(context-coloring-test-missing-executable-mode)
- :command ""
- :executable "__should_not_exist__")
- (context-coloring-test-missing-executable-mode)
- (context-coloring-mode)))
-
-(context-coloring-test-define-derived-mode unsupported-version)
-
-(context-coloring-test-deftest-async unsupported-version
- (lambda (done)
- (context-coloring-define-dispatch
- 'outta-date
- :modes '(context-coloring-test-unsupported-version-mode)
- :executable "node"
- :command "node test/binaries/outta-date"
- :version "v2.1.3")
- (context-coloring-test-unsupported-version-mode)
- (add-hook
- 'context-coloring-check-scopifier-version-hook
- (lambda ()
- (unwind-protect
- (progn
- ;; Normally the executable would be something like "outta-date"
- ;; rather than "node".
- (context-coloring-test-assert-message
- "Update to the minimum version of \"node\" (v2.1.3)"
- "*Messages*"))
- (funcall done))))
- (context-coloring-mode))
- :after (lambda ()
- (setq context-coloring-check-scopifier-version-hook nil)))
+ "No colorizer defined for dispatch")))
(context-coloring-test-define-derived-mode disable-mode)
-(context-coloring-test-deftest-async disable-mode
- (lambda (done)
+(context-coloring-test-deftest disable-mode
+ (lambda ()
(let (torn-down)
(context-coloring-define-dispatch
'disable-mode
:modes '(context-coloring-test-disable-mode-mode)
- :executable "node"
- :command "node test/binaries/noop"
+ :colorizer #'ignore
:teardown (lambda ()
(setq torn-down t)))
- (unwind-protect
- (progn
- (context-coloring-test-disable-mode-mode)
- (context-coloring-mode)
- (context-coloring-mode -1)
- (when (not torn-down)
- (ert-fail "Expected teardown function to have been called, but
it wasn't.")))
- (funcall done)))))
+ (context-coloring-test-disable-mode-mode)
+ (context-coloring-mode)
+ (context-coloring-mode -1)
+ (when (not torn-down)
+ (ert-fail "Expected teardown function to have been called, but it
wasn't.")))))
;;; Theme tests
@@ -957,7 +799,7 @@ other non-letters are guaranteed to always be discarded."
(forward-char)))
(setq index (1+ index)))))
-(context-coloring-test-deftest-js-js2 function-scopes
+(context-coloring-test-deftest-javascript function-scopes
(lambda ()
(context-coloring-test-assert-coloring "
000 0 0 11111111 11 110
@@ -966,14 +808,14 @@ other non-letters are guaranteed to always be discarded."
22222222 122 22
1")))
-(context-coloring-test-deftest-js-js2 global
+(context-coloring-test-deftest-javascript global
(lambda ()
(context-coloring-test-assert-coloring "
(xxxxxxxx () {
111 1 1 00000001xxx11
}());")))
-(context-coloring-test-deftest-js2 block-scopes
+(context-coloring-test-deftest-javascript block-scopes
(lambda ()
(context-coloring-test-assert-coloring "
(xxxxxxxx () {
@@ -983,11 +825,11 @@ other non-letters are guaranteed to always be discarded."
2
}());"))
:before (lambda ()
- (setq context-coloring-js-block-scopes t))
+ (setq context-coloring-javascript-block-scopes t))
:after (lambda ()
- (setq context-coloring-js-block-scopes nil)))
+ (setq context-coloring-javascript-block-scopes nil)))
-(context-coloring-test-deftest-js-js2 catch
+(context-coloring-test-deftest-javascript catch
(lambda ()
(context-coloring-test-assert-coloring "
(xxxxxxxx () {
@@ -999,7 +841,7 @@ other non-letters are guaranteed to always be discarded."
2
}());")))
-(context-coloring-test-deftest-js-js2 key-names
+(context-coloring-test-deftest-javascript key-names
(lambda ()
(context-coloring-test-assert-coloring "
(xxxxxxxx () {
@@ -1009,7 +851,7 @@ other non-letters are guaranteed to always be discarded."
11
}());")))
-(context-coloring-test-deftest-js-js2 property-lookup
+(context-coloring-test-deftest-javascript property-lookup
(lambda ()
(context-coloring-test-assert-coloring "
(xxxxxxxx () {
@@ -1018,7 +860,7 @@ other non-letters are guaranteed to always be discarded."
00000011111111111
}());")))
-(context-coloring-test-deftest-js-js2 key-values
+(context-coloring-test-deftest-javascript key-values
(lambda ()
(context-coloring-test-assert-coloring "
(xxxxxxxx () {
@@ -1030,7 +872,7 @@ other non-letters are guaranteed to always be discarded."
}());
}());")))
-(context-coloring-test-deftest-js-js2 syntactic-comments-and-strings
+(context-coloring-test-deftest-javascript syntactic-comments-and-strings
(lambda ()
(context-coloring-test-assert-coloring "
0000 00
@@ -1039,7 +881,7 @@ cccccccccc
ssssssssssss0"))
:fixture "comments-and-strings.js")
-(context-coloring-test-deftest-js-js2 syntactic-comments
+(context-coloring-test-deftest-javascript syntactic-comments
(lambda ()
(context-coloring-test-assert-coloring "
0000 00
@@ -1052,7 +894,7 @@ cccccccccc
:after (lambda ()
(setq context-coloring-syntactic-strings t)))
-(context-coloring-test-deftest-js-js2 syntactic-strings
+(context-coloring-test-deftest-javascript syntactic-strings
(lambda ()
(context-coloring-test-assert-coloring "
0000 00
@@ -1065,7 +907,7 @@ ssssssssssss0"))
:after (lambda ()
(setq context-coloring-syntactic-comments t)))
-(context-coloring-test-deftest-js2 unterminated-comment
+(context-coloring-test-deftest-javascript unterminated-comment
;; As long as `add-text-properties' doesn't signal an error, this test
passes.
(lambda ()))
- [elpa] master updated (afda2e6 -> 98073fe), Jackson Ray Hamilton, 2015/06/21
- [elpa] master f0bc797 04/12: Use old advice for Emacs 24.3., Jackson Ray Hamilton, 2015/06/21
- [elpa] master 89f862a 03/12: Minutia., Jackson Ray Hamilton, 2015/06/21
- [elpa] master 2487c3a 07/12: Fix eval-expression detection., Jackson Ray Hamilton, 2015/06/21
- [elpa] master b31aa52 05/12: Automatically determine the maximum face., Jackson Ray Hamilton, 2015/06/21
- [elpa] master 8d54c2e 08/12: Suppress unavailable messages in minibuffer., Jackson Ray Hamilton, 2015/06/21
- [elpa] master 32b276e 11/12: Version 7.0.0., Jackson Ray Hamilton, 2015/06/21
- [elpa] master ef0c4da 09/12: Cleanup refactoring artifacts., Jackson Ray Hamilton, 2015/06/21
- [elpa] master 354ac23 06/12: Checkdoc compliance., Jackson Ray Hamilton, 2015/06/21
- [elpa] master cbffe2a 02/12: Remove automatic theming., Jackson Ray Hamilton, 2015/06/21
- [elpa] master 92d3d12 01/12: Remove asynchronous support.,
Jackson Ray Hamilton <=
- [elpa] master 1bebaa4 10/12: Merge branch 'debt', Jackson Ray Hamilton, 2015/06/21
- [elpa] master 98073fe 12/12: Merge commit '32b276e96118f9e34f4cf9a5a2ae6cae3e772144' from context-coloring, Jackson Ray Hamilton, 2015/06/21