[elpa] master 580a1b6: Respect .elpaignore when compiling and optimize compilation.
branch: master commit 580a1b6b5d440f8fa1a29d6d1ee52d1513fa588b Author: Jackson Ray Hamilton Commit: Jackson Ray Hamilton Respect .elpaignore when compiling and optimize compilation. --- GNUmakefile | 24 ++-- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index 7d6d100..6d57fae 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -144,9 +144,22 @@ $(foreach al, $(autoloads), $(eval $(call RULE-srcdeps, $(al \"$$(pwd)\")" # Put into elcs the set of elc files we need to keep up-to-date. -# I.e. one for each .el file except for the -pkg.el, the -autoloads.el, and -# the .el files that are marked "no-byte-compile". -els := $(call FILTER-nonsrc, $(wildcard packages/*/*.el)) +# I.e. one for each .el file in each package root, except for the -pkg.el, +# the -autoloads.el, the .el files that are marked "no-byte-compile", and +# files matching patterns in packages' .elpaignore files. +included_els := $(shell \ + for pt in packages/*; do \ + if [ -d $$pt ]; then \ + if [ -f "$${pt}/.elpaignore" ]; then \ + tar -ch $$pt/*.el --no-recursion \ + --exclude-vcs -X "$${pt}/.elpaignore"\ +| tar --list; \ + else \ + ls -1 $$pt/*.el; \ + fi; \ + fi; \ + done) +els := $(call FILTER-nonsrc, $(included_els)) naive_elcs := $(patsubst %.el, %.elc, $(els)) current_elcs := $(wildcard packages/*/*.elc) @@ -184,9 +197,8 @@ pkg_descs:=$(foreach pkg, $(pkgs), $(pkg)/$(notdir $(pkg))-pkg.el) --eval '(package-generate-description-file d "$@")' .PHONY: all-in-place -all-in-place: $(extra_elcs) $(autoloads) $(pkg_descs) - # Do them in a sub-make, so that autoloads are done first. - $(MAKE) elcs +# Use order-only prerequisites, so that autoloads are done first. +all-in-place: | $(extra_elcs) $(autoloads) $(pkg_descs) elcs ### Rules to prepare the externals
[elpa] master 54593e5 11/21: Add Emacs 25.1 to the build matrix.
branch: master commit 54593e534c807964d6803dc49537deadc865e0fa Author: Jackson Ray Hamilton Commit: Jackson Ray Hamilton Add Emacs 25.1 to the build matrix. --- .travis.yml |1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index ba959a9..70d1f6d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,7 @@ env: - EVM_EMACS=emacs-24.3-travis - EVM_EMACS=emacs-24.4-travis - EVM_EMACS=emacs-24.5-travis + - EVM_EMACS=emacs-25.1-travis before_install: - export PATH="/home/travis/.evm/bin:$PATH"
[elpa] master c79499a 02/21: Remove erroneous block scope assertion.
branch: master commit c79499a31ba5bf048a0b8d8a7ccad718d368b88e Author: Jackson Ray Hamilton Commit: Jackson Ray Hamilton Remove erroneous block scope assertion. --- context-coloring-test.el |9 - fixtures/test/block-scopes.js |9 - 2 files changed, 18 deletions(-) diff --git a/context-coloring-test.el b/context-coloring-test.el index 1655496..ab77254 100644 --- a/context-coloring-test.el +++ b/context-coloring-test.el @@ -485,15 +485,6 @@ other non-letters are guaranteed to always be discarded." 11 111 2 222 12 222 22 -2 12 -2 -}()); - -( () { -'xxx xx'; -11 111 2 -222 12 -222 22 2 22 2 }());")) diff --git a/fixtures/test/block-scopes.js b/fixtures/test/block-scopes.js index 86e4a13..34a40ba 100644 --- a/fixtures/test/block-scopes.js +++ b/fixtures/test/block-scopes.js @@ -5,12 +5,3 @@ const c; } }()); - -(function () { -'use strict'; -if (1) { -var a; -let b; -const c; -} -}());
[elpa] master 60fca70 03/21: Fix quoting problem in docstring.
branch: master commit 60fca7060ac405c6bb8a21eb6f4e5df2844a9655 Author: Jackson Ray Hamilton Commit: Jackson Ray Hamilton Fix quoting problem in docstring. --- context-coloring.el |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/context-coloring.el b/context-coloring.el index fd7a816..06830fd 100644 --- a/context-coloring.el +++ b/context-coloring.el @@ -279,7 +279,7 @@ KEYWORDS-P is non-nil, also color keywords from MIN to MAX." "Scope level at which to start coloring. If top-level variables and functions do not become global, but -are scoped to a file (as in Node.js), set this to `1'." +are scoped to a file (as in Node.js), set this to 1." :type 'integer :safe #'integerp :group 'context-coloring)
[elpa] master 4836dd0 10/21: Add tests for prettifying symbols.
branch: master commit 4836dd069b8d328f994810bd38962e917c274b00 Author: Jackson Ray Hamilton Commit: Jackson Ray Hamilton Add tests for prettifying symbols. --- context-coloring-test.el | 23 +++ fixtures/test/prettify-symbols.el |1 + 2 files changed, 24 insertions(+) diff --git a/context-coloring-test.el b/context-coloring-test.el index ab77254..5ab7d60 100644 --- a/context-coloring-test.el +++ b/context-coloring-test.el @@ -344,6 +344,29 @@ signaled." '(context-coloring-level-0-face nil)) (disable-theme 'context-coloring-test-custom-theme))) +(defun context-coloring-test-assert-prettify-symbols-text-properties () + (unless (and (get-text-property 2 'prettify-symbols-start) + (get-text-property 2 'prettify-symbols-end)) +(ert-fail "Expected buffer to have it's symbols prettified, but it didn't."))) + +(context-coloring-test-deftest prettify-symbols-enabled-before + (lambda () +(context-coloring-test-with-fixture + "./fixtures/test/prettify-symbols.el" + (emacs-lisp-mode) + (prettify-symbols-mode) + (context-coloring-mode) + (context-coloring-test-assert-prettify-symbols-text-properties + +(context-coloring-test-deftest prettify-symbols-enabled-after + (lambda () +(context-coloring-test-with-fixture + "./fixtures/test/prettify-symbols.el" + (emacs-lisp-mode) + (context-coloring-mode) + (prettify-symbols-mode) + (context-coloring-test-assert-prettify-symbols-text-properties + ;;; Coloring tests diff --git a/fixtures/test/prettify-symbols.el b/fixtures/test/prettify-symbols.el new file mode 100644 index 000..52295a6 --- /dev/null +++ b/fixtures/test/prettify-symbols.el @@ -0,0 +1 @@ +(lambda ())
[elpa] master 550e61b 08/21: Merge branch 'master' into prettify-symbols
branch: master commit 550e61bac97e69b66de4a50bf36e963c7eb4c01c Merge: 26f48c5 5fe3695 Author: Jackson Ray Hamilton Commit: Jackson Ray Hamilton Merge branch 'master' into prettify-symbols --- context-coloring.el |1 - 1 file changed, 1 deletion(-) diff --git a/context-coloring.el b/context-coloring.el index 0d5b72c..f7104ed 100644 --- a/context-coloring.el +++ b/context-coloring.el @@ -501,7 +501,6 @@ Feature inspired by Douglas Crockford." (let ((teardown (plist-get dispatch :teardown))) (when teardown (funcall teardown) -(kill-local-variable 'font-lock-syntactic-face-function) (turn-on-font-lock-if-desired (provide 'context-coloring)
[elpa] master b3ea138 19/21: Remove no-byte-compile from development files.
branch: master commit b3ea138a154dbe91da8248ad93e81bd7d846411f Author: Jackson Ray Hamilton Commit: Jackson Ray Hamilton Remove no-byte-compile from development files. `no-byte-compile' used to be necessary to prevent compilation errors on ELPA, but since committing 580a1b6 to ELPA, these files shouldn't be compiled any more. The advantage to removing this line is that the files can now be checked by Flycheck again. --- context-coloring-benchmark.el |2 +- context-coloring-coverage.el |2 +- context-coloring-test.el |2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/context-coloring-benchmark.el b/context-coloring-benchmark.el index 0c38e85..dafc959 100644 --- a/context-coloring-benchmark.el +++ b/context-coloring-benchmark.el @@ -1,4 +1,4 @@ -;;; context-coloring-benchmark.el --- Benchmarks for context coloring -*- lexical-binding: t; no-byte-compile: t; -*- +;;; context-coloring-benchmark.el --- Benchmarks for context coloring -*- lexical-binding: t; -*- ;; Copyright (C) 2014-2016 Free Software Foundation, Inc. diff --git a/context-coloring-coverage.el b/context-coloring-coverage.el index c63dc6b..fe990d9 100644 --- a/context-coloring-coverage.el +++ b/context-coloring-coverage.el @@ -1,4 +1,4 @@ -;;; context-coloring-coverage.el --- Test coverage for context coloring -*- lexical-binding: t; no-byte-compile: t; -*- +;;; context-coloring-coverage.el --- Test coverage for context coloring -*- lexical-binding: t; -*- ;; Copyright (C) 2014-2016 Free Software Foundation, Inc. diff --git a/context-coloring-test.el b/context-coloring-test.el index 32080bb..fabf55b 100644 --- a/context-coloring-test.el +++ b/context-coloring-test.el @@ -1,4 +1,4 @@ -;;; context-coloring-test.el --- Tests for context coloring -*- lexical-binding: t; no-byte-compile: t; -*- +;;; context-coloring-test.el --- Tests for context coloring -*- lexical-binding: t; -*- ;; Copyright (C) 2014-2016 Free Software Foundation, Inc.
[elpa] master 269a382 15/21: Ensure coloring still works after prettification.
branch: master commit 269a382630abbf405cebaab4dee790450cb375a7 Author: Jackson Ray Hamilton Commit: Jackson Ray Hamilton Ensure coloring still works after prettification. --- context-coloring-test.el | 10 -- context-coloring.el |4 fixtures/test/prettify-symbols.el |2 +- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/context-coloring-test.el b/context-coloring-test.el index fef12d5..0d1f539 100644 --- a/context-coloring-test.el +++ b/context-coloring-test.el @@ -346,6 +346,10 @@ signaled." (when (fboundp 'prettify-symbols-mode) + (defun context-coloring-test-assert-prettify-symbols-coloring () +(context-coloring-test-assert-coloring " +(11 () (22 ()))")) + (defun context-coloring-test-assert-prettify-symbols-text-properties () (unless (cond ((version< emacs-version "25.0") @@ -362,7 +366,8 @@ signaled." (emacs-lisp-mode) (prettify-symbols-mode) (context-coloring-mode) - (context-coloring-test-assert-prettify-symbols-text-properties + (context-coloring-test-assert-prettify-symbols-text-properties) + (context-coloring-test-assert-prettify-symbols-coloring (context-coloring-test-deftest prettify-symbols-enabled-after (lambda () @@ -371,7 +376,8 @@ signaled." (emacs-lisp-mode) (context-coloring-mode) (prettify-symbols-mode) - (context-coloring-test-assert-prettify-symbols-text-properties) + (context-coloring-test-assert-prettify-symbols-text-properties) + (context-coloring-test-assert-prettify-symbols-coloring) ;;; Coloring tests diff --git a/context-coloring.el b/context-coloring.el index 784fdbb..a64b6a9 100644 --- a/context-coloring.el +++ b/context-coloring.el @@ -468,6 +468,10 @@ Feature inspired by Douglas Crockford." ;; Lock's automatic fontification to apply it's changes on mode change, ;; so Context Coloring has to make those changes manually. (add-hook 'prettify-symbols-mode-hook #'context-coloring-maybe-fontify-keywords nil t) +;; Furthermore, on Emacs < 25.0, `prettify-symbols-mode' calls +;; `font-lock-fontify-buffer-function' which would overwrite context +;; coloring, so make it a no-op. +(set (make-local-variable 'font-lock-fontify-buffer-function) (lambda ())) (let ((setup (plist-get dispatch :setup))) (when setup (funcall setup)) diff --git a/fixtures/test/prettify-symbols.el b/fixtures/test/prettify-symbols.el index 52295a6..0863230 100644 --- a/fixtures/test/prettify-symbols.el +++ b/fixtures/test/prettify-symbols.el @@ -1 +1 @@ -(lambda ()) +(lambda () (lambda ()))
[elpa] master 1b30a28 20/21: Version 8.1.0.
branch: master commit 1b30a28857727202d1f6a027f83ad66151fb1e92 Author: Jackson Ray Hamilton Commit: Jackson Ray Hamilton Version 8.1.0. --- context-coloring.el |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/context-coloring.el b/context-coloring.el index a64b6a9..ac24364 100644 --- a/context-coloring.el +++ b/context-coloring.el @@ -3,7 +3,7 @@ ;; Copyright (C) 2014-2016 Free Software Foundation, Inc. ;; Author: Jackson Ray Hamilton -;; Version: 8.0.1 +;; Version: 8.1.0 ;; Keywords: convenience faces tools ;; Package-Requires: ((emacs "24.3")) ;; URL: https://github.com/jacksonrayhamilton/context-coloring
[elpa] master 6a2c6fe 04/21: Clean up local variable.
branch: master commit 6a2c6fee3eb0bdc896e5fdf7e673192b4ebe778a Author: Jackson Ray Hamilton Commit: Jackson Ray Hamilton Clean up local variable. --- context-coloring.el |1 + 1 file changed, 1 insertion(+) diff --git a/context-coloring.el b/context-coloring.el index 06830fd..2e4e867 100644 --- a/context-coloring.el +++ b/context-coloring.el @@ -442,6 +442,7 @@ Feature inspired by Douglas Crockford." (let ((teardown (plist-get dispatch :teardown))) (when teardown (funcall teardown) +(kill-local-variable 'font-lock-syntactic-face-function) (turn-on-font-lock-if-desired (provide 'context-coloring)
[elpa] master edbb191 13/21: Feature-detect prettify-symbols-mode for Emacs 24.3 compat.
branch: master commit edbb1919960d10c74e8ee3d7ad59493ba50538bf Author: Jackson Ray Hamilton Commit: Jackson Ray Hamilton Feature-detect prettify-symbols-mode for Emacs 24.3 compat. --- context-coloring-test.el | 46 -- context-coloring.el |2 +- 2 files changed, 25 insertions(+), 23 deletions(-) diff --git a/context-coloring-test.el b/context-coloring-test.el index 5ab7d60..79e5f23 100644 --- a/context-coloring-test.el +++ b/context-coloring-test.el @@ -344,28 +344,30 @@ signaled." '(context-coloring-level-0-face nil)) (disable-theme 'context-coloring-test-custom-theme))) -(defun context-coloring-test-assert-prettify-symbols-text-properties () - (unless (and (get-text-property 2 'prettify-symbols-start) - (get-text-property 2 'prettify-symbols-end)) -(ert-fail "Expected buffer to have it's symbols prettified, but it didn't."))) - -(context-coloring-test-deftest prettify-symbols-enabled-before - (lambda () -(context-coloring-test-with-fixture - "./fixtures/test/prettify-symbols.el" - (emacs-lisp-mode) - (prettify-symbols-mode) - (context-coloring-mode) - (context-coloring-test-assert-prettify-symbols-text-properties - -(context-coloring-test-deftest prettify-symbols-enabled-after - (lambda () -(context-coloring-test-with-fixture - "./fixtures/test/prettify-symbols.el" - (emacs-lisp-mode) - (context-coloring-mode) - (prettify-symbols-mode) - (context-coloring-test-assert-prettify-symbols-text-properties +(when (fboundp 'prettify-symbols-mode) + + (defun context-coloring-test-assert-prettify-symbols-text-properties () +(unless (and (get-text-property 2 'prettify-symbols-start) + (get-text-property 2 'prettify-symbols-end)) + (ert-fail "Expected buffer to have it's symbols prettified, but it didn't."))) + + (context-coloring-test-deftest prettify-symbols-enabled-before + (lambda () + (context-coloring-test-with-fixture +"./fixtures/test/prettify-symbols.el" +(emacs-lisp-mode) +(prettify-symbols-mode) +(context-coloring-mode) + (context-coloring-test-assert-prettify-symbols-text-properties + + (context-coloring-test-deftest prettify-symbols-enabled-after + (lambda () + (context-coloring-test-with-fixture +"./fixtures/test/prettify-symbols.el" +(emacs-lisp-mode) +(context-coloring-mode) +(prettify-symbols-mode) + (context-coloring-test-assert-prettify-symbols-text-properties) ;;; Coloring tests diff --git a/context-coloring.el b/context-coloring.el index 1429f66..784fdbb 100644 --- a/context-coloring.el +++ b/context-coloring.el @@ -381,7 +381,7 @@ completes.") (defvar context-coloring-fontify-keywords-predicates (list - (lambda () prettify-symbols-mode)) + (lambda () (and (boundp 'prettify-symbols-mode) prettify-symbols-mode))) "Cases where the whole buffer should have keywords fontified. Necessary in cases where a mode relies on fontifications in regions where Context Coloring doesn't happen to touch.")
[elpa] master ce29abd 17/21: Don't color before or beyond the buffer.
branch: master commit ce29abde4df0df0c4462e1baf3ed94965f7bafa1 Author: Jackson Ray Hamilton Commit: Jackson Ray Hamilton Don't color before or beyond the buffer. --- context-coloring-javascript.el| 23 +++ context-coloring-test.el |9 + fixtures/test/narrow-to-region.js |3 +++ 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/context-coloring-javascript.el b/context-coloring-javascript.el index d145184..29bafb8 100644 --- a/context-coloring-javascript.el +++ b/context-coloring-javascript.el @@ -73,26 +73,33 @@ this for ES6 code; disable it elsewhere." ;; `js2-prop-get-node', so this always works. (eq node (js2-prop-get-node-right parent +(defvar-local context-coloring-point-min nil + "Cached value of `point-min'.") + (defvar-local context-coloring-point-max nil "Cached value of `point-max'.") +(defsubst context-coloring-js2-bounded-point (point) + "Make POINT safe to set text properties. +POINT may be unsafe if a JS2 node extends beyond the end of the +buffer (in the case of an unterminated multiline comment). The +region could also be narrowed and the node thus obscured." + (min (max point context-coloring-point-min) context-coloring-point-max)) + (defsubst context-coloring-js2-colorize-node (node level) "Color NODE with the color for LEVEL." - (let ((start (js2-node-abs-pos node))) + (let* ((start (js2-node-abs-pos node)) + (end (+ start (js2-node-len node (context-coloring-colorize-region - start - (min - ;; End - (+ start (js2-node-len node)) - ;; Somes nodes (like the ast when there is an unterminated multiline - ;; comment) will stretch to the value of `point-max'. - context-coloring-point-max) + (context-coloring-js2-bounded-point start) + (context-coloring-js2-bounded-point end) level))) (defun context-coloring-js2-colorize-ast () "Color the buffer using the `js2-mode' abstract syntax tree." ;; Reset the hash table; the old one could be obsolete. (setq context-coloring-js2-scope-level-hash-table (make-hash-table :test #'eq)) + (setq context-coloring-point-min (point-min)) (setq context-coloring-point-max (point-max)) (with-silent-modifications (js2-visit-ast diff --git a/context-coloring-test.el b/context-coloring-test.el index 0d1f539..32080bb 100644 --- a/context-coloring-test.el +++ b/context-coloring-test.el @@ -663,6 +663,15 @@ 0")) (context-coloring-test-assert-javascript-global-level :fixture "initial-level.js") +(context-coloring-test-deftest-javascript narrow-to-region + (lambda () +(context-coloring-test-assert-coloring " +111 0 11 11 + 0 11 11 + 0 11 1")) + :before (lambda () +(narrow-to-region (+ (point-min) 1) (- (point-max) 2 + (context-coloring-test-deftest-emacs-lisp defun (lambda () (context-coloring-test-assert-coloring " diff --git a/fixtures/test/narrow-to-region.js b/fixtures/test/narrow-to-region.js new file mode 100644 index 000..29f9aef --- /dev/null +++ b/fixtures/test/narrow-to-region.js @@ -0,0 +1,3 @@ +function a () {} +function b () {} +function c () {}
[elpa] master updated (580a1b6 -> 5402f35)
jackson pushed a change to branch master. from 580a1b6 Respect .elpaignore when compiling and optimize compilation. new c847b0f Mention tern-context-coloring in README. new c79499a Remove erroneous block scope assertion. new 60fca70 Fix quoting problem in docstring. new 6a2c6fe Clean up local variable. new a1a6256 Set up post-colorize hooks. new 26f48c5 Improve Font Lock integration. new 5fe3695 Revert "Clean up local variable." new 550e61b Merge branch 'master' into prettify-symbols new 3985437 Use a mode hook for detecting entering Prettify Symbols mode. new 4836dd0 Add tests for prettifying symbols. new 54593e5 Add Emacs 25.1 to the build matrix. new 2de2dd8 Make binaries configurable in Makefile. new edbb191 Feature-detect prettify-symbols-mode for Emacs 24.3 compat. new abded5f Check for compositions on old Emacsen. new 269a382 Ensure coloring still works after prettification. new 45b5ad0 Merge pull request #5 from jacksonrayhamilton/prettify-symbols new ce29abd Don't color before or beyond the buffer. new 3e778f6 Merge pull request #6 from jacksonrayhamilton/narrow-to-region new b3ea138 Remove no-byte-compile from development files. new 1b30a28 Version 8.1.0. new 5402f35 Merge commit '1b30a28857727202d1f6a027f83ad66151fb1e92' from context-coloring Summary of changes: packages/context-coloring/.travis.yml |1 + packages/context-coloring/Makefile |4 +- packages/context-coloring/README.md|4 +- .../context-coloring/context-coloring-benchmark.el |2 +- .../context-coloring/context-coloring-coverage.el |2 +- .../context-coloring-javascript.el | 23 --- packages/context-coloring/context-coloring-test.el | 55 ++--- packages/context-coloring/context-coloring.el | 65 +--- .../context-coloring/fixtures/test/block-scopes.js |9 --- .../fixtures/test/narrow-to-region.js |3 + .../fixtures/test/prettify-symbols.el |1 + 11 files changed, 127 insertions(+), 42 deletions(-) create mode 100644 packages/context-coloring/fixtures/test/narrow-to-region.js create mode 100644 packages/context-coloring/fixtures/test/prettify-symbols.el
[elpa] master 5402f35 21/21: Merge commit '1b30a28857727202d1f6a027f83ad66151fb1e92' from context-coloring
branch: master commit 5402f3573c0b5b4535e65fa5008c47754a43defc Merge: 580a1b6 1b30a28 Author: Jackson Ray Hamilton Commit: Jackson Ray Hamilton Merge commit '1b30a28857727202d1f6a027f83ad66151fb1e92' from context-coloring --- packages/context-coloring/.travis.yml |1 + packages/context-coloring/Makefile |4 +- packages/context-coloring/README.md|4 +- .../context-coloring/context-coloring-benchmark.el |2 +- .../context-coloring/context-coloring-coverage.el |2 +- .../context-coloring-javascript.el | 23 --- packages/context-coloring/context-coloring-test.el | 55 ++--- packages/context-coloring/context-coloring.el | 65 +--- .../context-coloring/fixtures/test/block-scopes.js |9 --- .../fixtures/test/narrow-to-region.js |3 + .../fixtures/test/prettify-symbols.el |1 + 11 files changed, 127 insertions(+), 42 deletions(-) diff --git a/packages/context-coloring/.travis.yml b/packages/context-coloring/.travis.yml index ba959a9..70d1f6d 100644 --- a/packages/context-coloring/.travis.yml +++ b/packages/context-coloring/.travis.yml @@ -6,6 +6,7 @@ env: - EVM_EMACS=emacs-24.3-travis - EVM_EMACS=emacs-24.4-travis - EVM_EMACS=emacs-24.5-travis + - EVM_EMACS=emacs-25.1-travis before_install: - export PATH="/home/travis/.evm/bin:$PATH" diff --git a/packages/context-coloring/Makefile b/packages/context-coloring/Makefile index 4519b70..9763be1 100644 --- a/packages/context-coloring/Makefile +++ b/packages/context-coloring/Makefile @@ -1,5 +1,5 @@ -EMACS = emacs -CASK = EMACS=${EMACS} cask +EMACS ?= emacs +CASK ?= EMACS=${EMACS} cask DEPENDENCIES = .cask/ SOURCE_FILES = \ context-coloring.el \ diff --git a/packages/context-coloring/README.md b/packages/context-coloring/README.md index 21f1eb5..bfbb4fb 100644 --- a/packages/context-coloring/README.md +++ b/packages/context-coloring/README.md @@ -25,7 +25,9 @@ By default, comments and strings are still highlighted syntactically. ## Installation Requires Emacs 24.3+. JavaScript language support requires -[js2-mode](https://github.com/mooz/js2-mode). +[js2-mode](https://github.com/mooz/js2-mode) (or, if you use +[Tern](http://ternjs.net/), you may be interested in +[tern-context-coloring](https://github.com/jacksonrayhamilton/tern-context-coloring)). To install, run the command `M-x package-install RET context-coloring RET`, and then add the following to your init file: diff --git a/packages/context-coloring/context-coloring-benchmark.el b/packages/context-coloring/context-coloring-benchmark.el index 0c38e85..dafc959 100644 --- a/packages/context-coloring/context-coloring-benchmark.el +++ b/packages/context-coloring/context-coloring-benchmark.el @@ -1,4 +1,4 @@ -;;; context-coloring-benchmark.el --- Benchmarks for context coloring -*- lexical-binding: t; no-byte-compile: t; -*- +;;; context-coloring-benchmark.el --- Benchmarks for context coloring -*- lexical-binding: t; -*- ;; Copyright (C) 2014-2016 Free Software Foundation, Inc. diff --git a/packages/context-coloring/context-coloring-coverage.el b/packages/context-coloring/context-coloring-coverage.el index c63dc6b..fe990d9 100644 --- a/packages/context-coloring/context-coloring-coverage.el +++ b/packages/context-coloring/context-coloring-coverage.el @@ -1,4 +1,4 @@ -;;; context-coloring-coverage.el --- Test coverage for context coloring -*- lexical-binding: t; no-byte-compile: t; -*- +;;; context-coloring-coverage.el --- Test coverage for context coloring -*- lexical-binding: t; -*- ;; Copyright (C) 2014-2016 Free Software Foundation, Inc. diff --git a/packages/context-coloring/context-coloring-javascript.el b/packages/context-coloring/context-coloring-javascript.el index d145184..29bafb8 100644 --- a/packages/context-coloring/context-coloring-javascript.el +++ b/packages/context-coloring/context-coloring-javascript.el @@ -73,26 +73,33 @@ this for ES6 code; disable it elsewhere." ;; `js2-prop-get-node', so this always works. (eq node (js2-prop-get-node-right parent +(defvar-local context-coloring-point-min nil + "Cached value of `point-min'.") + (defvar-local context-coloring-point-max nil "Cached value of `point-max'.") +(defsubst context-coloring-js2-bounded-point (point) + "Make POINT safe to set text properties. +POINT may be unsafe if a JS2 node extends beyond the end of the +buffer (in the case of an unterminated multiline comment). The +region could also be narrowed and the node thus obscured." + (min (max point context-coloring-point-min) context-coloring-point-max)) + (defsubst context-coloring-js2-colorize-node (node level) "Color NODE with the color for LEVEL." - (let ((start (js2-node-abs-pos node))) + (let* ((start (js2-node-abs-pos node)) + (end (+ start (js2-node-len node (context-col
[elpa] master 2de2dd8 12/21: Make binaries configurable in Makefile.
branch: master commit 2de2dd805ae82178a963cf8293c0d0fba4211606 Author: Jackson Ray Hamilton Commit: Jackson Ray Hamilton Make binaries configurable in Makefile. This makes it easier to test programs that might not be on the PATH by setting temporary environment variables, if that's how you like to work. --- Makefile |4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 4519b70..9763be1 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ -EMACS = emacs -CASK = EMACS=${EMACS} cask +EMACS ?= emacs +CASK ?= EMACS=${EMACS} cask DEPENDENCIES = .cask/ SOURCE_FILES = \ context-coloring.el \
[elpa] master 5fe3695 07/21: Revert "Clean up local variable."
branch: master commit 5fe3695baeeae04761828ff36b391a77edefdfe9 Author: Jackson Ray Hamilton Commit: Jackson Ray Hamilton Revert "Clean up local variable." This reverts commit 6a2c6fee3eb0bdc896e5fdf7e673192b4ebe778a. This broke Emacs Lisp docstring fontification. --- context-coloring.el |1 - 1 file changed, 1 deletion(-) diff --git a/context-coloring.el b/context-coloring.el index 2e4e867..06830fd 100644 --- a/context-coloring.el +++ b/context-coloring.el @@ -442,7 +442,6 @@ Feature inspired by Douglas Crockford." (let ((teardown (plist-get dispatch :teardown))) (when teardown (funcall teardown) -(kill-local-variable 'font-lock-syntactic-face-function) (turn-on-font-lock-if-desired (provide 'context-coloring)
[elpa] master 45b5ad0 16/21: Merge pull request #5 from jacksonrayhamilton/prettify-symbols
branch: master commit 45b5ad0158985fc50992bb8636ff388b170f3112 Merge: 5fe3695 269a382 Author: Jackson Ray Hamilton Commit: GitHub Merge pull request #5 from jacksonrayhamilton/prettify-symbols Prettify symbols --- .travis.yml |1 + Makefile |4 +-- context-coloring-test.el | 35 + context-coloring.el | 63 +++-- fixtures/test/prettify-symbols.el |1 + 5 files changed, 93 insertions(+), 11 deletions(-) diff --git a/.travis.yml b/.travis.yml index ba959a9..70d1f6d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,7 @@ env: - EVM_EMACS=emacs-24.3-travis - EVM_EMACS=emacs-24.4-travis - EVM_EMACS=emacs-24.5-travis + - EVM_EMACS=emacs-25.1-travis before_install: - export PATH="/home/travis/.evm/bin:$PATH" diff --git a/Makefile b/Makefile index 4519b70..9763be1 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ -EMACS = emacs -CASK = EMACS=${EMACS} cask +EMACS ?= emacs +CASK ?= EMACS=${EMACS} cask DEPENDENCIES = .cask/ SOURCE_FILES = \ context-coloring.el \ diff --git a/context-coloring-test.el b/context-coloring-test.el index ab77254..0d1f539 100644 --- a/context-coloring-test.el +++ b/context-coloring-test.el @@ -344,6 +344,41 @@ signaled." '(context-coloring-level-0-face nil)) (disable-theme 'context-coloring-test-custom-theme))) +(when (fboundp 'prettify-symbols-mode) + + (defun context-coloring-test-assert-prettify-symbols-coloring () +(context-coloring-test-assert-coloring " +(11 () (22 ()))")) + + (defun context-coloring-test-assert-prettify-symbols-text-properties () +(unless (cond + ((version< emacs-version "25.0") + (get-text-property 2 'composition)) + (t + (and (get-text-property 2 'prettify-symbols-start) + (get-text-property 2 'prettify-symbols-end + (ert-fail "Expected buffer to have it's symbols prettified, but it didn't."))) + + (context-coloring-test-deftest prettify-symbols-enabled-before + (lambda () + (context-coloring-test-with-fixture +"./fixtures/test/prettify-symbols.el" +(emacs-lisp-mode) +(prettify-symbols-mode) +(context-coloring-mode) + (context-coloring-test-assert-prettify-symbols-text-properties) + (context-coloring-test-assert-prettify-symbols-coloring + + (context-coloring-test-deftest prettify-symbols-enabled-after + (lambda () + (context-coloring-test-with-fixture +"./fixtures/test/prettify-symbols.el" +(emacs-lisp-mode) +(context-coloring-mode) +(prettify-symbols-mode) + (context-coloring-test-assert-prettify-symbols-text-properties) + (context-coloring-test-assert-prettify-symbols-coloring) + ;;; Coloring tests diff --git a/context-coloring.el b/context-coloring.el index 06830fd..a64b6a9 100644 --- a/context-coloring.el +++ b/context-coloring.el @@ -41,6 +41,14 @@ "Join a list of STRINGS with the string DELIMITER." (mapconcat #'identity strings delimiter)) +(defun context-coloring-check-predicates (predicates) + "Call PREDICATES until one returns t, otherwise return nil." + (let ((satisfied-p nil)) +(while (and predicates +(not satisfied-p)) + (setq satisfied-p (funcall (pop predicates +satisfied-p)) + ;;; Faces @@ -311,7 +319,11 @@ override `context-coloring-default-delay'. `context-coloring-mode' is enabled. `:teardown' - Arbitrary code to tear down this dispatch when -`context-coloring-mode' is disabled.") +`context-coloring-mode' is disabled. + +`:async-p' - Hint that code will be colorized asynchronously. +Please call `context-coloring-after-colorize' when colorization +completes.") (defun context-coloring-find-dispatch (predicate) "Find the first dispatch satisfying PREDICATE." @@ -345,18 +357,46 @@ override `context-coloring-default-delay'. "Set up environment for colorization." (context-coloring-update-maximum-face)) +(defvar context-coloring-after-colorize-hook nil + "Functions to run after colorizing.") + +(defun context-coloring-after-colorize () + "Do final business after colorization." + (run-hooks 'context-coloring-after-colorize-hook)) + (defun context-coloring-dispatch () "Determine how to color the current buffer, and color it." (let* ((dispatch (context-coloring-get-current-dispatch)) - (colorizer (plis
[elpa] master c847b0f 01/21: Mention tern-context-coloring in README.
branch: master commit c847b0f1fb865199dc8676f19b786df443888123 Author: Jackson Ray Hamilton Commit: Jackson Ray Hamilton Mention tern-context-coloring in README. --- README.md |4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 21f1eb5..bfbb4fb 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,9 @@ By default, comments and strings are still highlighted syntactically. ## Installation Requires Emacs 24.3+. JavaScript language support requires -[js2-mode](https://github.com/mooz/js2-mode). +[js2-mode](https://github.com/mooz/js2-mode) (or, if you use +[Tern](http://ternjs.net/), you may be interested in +[tern-context-coloring](https://github.com/jacksonrayhamilton/tern-context-coloring)). To install, run the command `M-x package-install RET context-coloring RET`, and then add the following to your init file:
[elpa] master 3985437 09/21: Use a mode hook for detecting entering Prettify Symbols mode.
branch: master commit 398543707c0845353290ee0f1911ba15c1349a59 Author: Jackson Ray Hamilton Commit: Jackson Ray Hamilton Use a mode hook for detecting entering Prettify Symbols mode. --- context-coloring.el | 28 +--- 1 file changed, 5 insertions(+), 23 deletions(-) diff --git a/context-coloring.el b/context-coloring.el index f7104ed..1429f66 100644 --- a/context-coloring.el +++ b/context-coloring.el @@ -427,24 +427,6 @@ permissible.") (defvar context-coloring-interruptable-p t "When non-nil, coloring may be interrupted by user input.") -(defvar context-coloring-mode) - -(defun context-coloring-around-font-lock-flush (oldfun &rest r) - "Advice around `font-lock-flush' for this mode only." - (if context-coloring-mode - (apply #'context-coloring-font-lock-flush r) -(apply oldfun r))) - -(defun context-coloring-font-lock-flush (&optional start end) - "Reimplementation of `font-lock-flush' for this mode. -The original relies on Font Lock variables that would be messy to -maintain here." - (let* ((start (or start (point-min))) - (end (or end (point-max))) - (length (- end start))) -(context-coloring-change-function start end length) -(context-coloring-maybe-colorize-with-buffer (current-buffer - ;;;###autoload (define-minor-mode context-coloring-mode "Toggle contextual code coloring. @@ -482,11 +464,10 @@ Feature inspired by Douglas Crockford." (font-lock-set-defaults) ;; Safely change the value of this function as necessary. (make-local-variable 'font-lock-syntactic-face-function) -;; Improve integration with modes relying on Font Lock. Here, attempts -;; to refontify in Font Lock contexts will instead refontifiy in Context -;; Coloring contexts. This is necessary for `prettify-symbols-mode' -;; integration. -(advice-add #'font-lock-flush :around #'context-coloring-around-font-lock-flush) +;; Improve integration with `prettify-symbols-mode'. It relies on Font +;; Lock's automatic fontification to apply it's changes on mode change, +;; so Context Coloring has to make those changes manually. +(add-hook 'prettify-symbols-mode-hook #'context-coloring-maybe-fontify-keywords nil t) (let ((setup (plist-get dispatch :setup))) (when setup (funcall setup)) @@ -501,6 +482,7 @@ Feature inspired by Douglas Crockford." (let ((teardown (plist-get dispatch :teardown))) (when teardown (funcall teardown) +(remove-hook 'prettify-symbols-mode-hook #'context-coloring-maybe-fontify-keywords t) (turn-on-font-lock-if-desired (provide 'context-coloring)
[elpa] master 3e778f6 18/21: Merge pull request #6 from jacksonrayhamilton/narrow-to-region
branch: master commit 3e778f607e72cc5dee7a4f1aa445d6780b8cc1dd Merge: 45b5ad0 ce29abd Author: Jackson Ray Hamilton Commit: GitHub Merge pull request #6 from jacksonrayhamilton/narrow-to-region Don't color before or beyond the buffer. --- context-coloring-javascript.el| 23 +++ context-coloring-test.el |9 + fixtures/test/narrow-to-region.js |3 +++ 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/context-coloring-javascript.el b/context-coloring-javascript.el index d145184..29bafb8 100644 --- a/context-coloring-javascript.el +++ b/context-coloring-javascript.el @@ -73,26 +73,33 @@ this for ES6 code; disable it elsewhere." ;; `js2-prop-get-node', so this always works. (eq node (js2-prop-get-node-right parent +(defvar-local context-coloring-point-min nil + "Cached value of `point-min'.") + (defvar-local context-coloring-point-max nil "Cached value of `point-max'.") +(defsubst context-coloring-js2-bounded-point (point) + "Make POINT safe to set text properties. +POINT may be unsafe if a JS2 node extends beyond the end of the +buffer (in the case of an unterminated multiline comment). The +region could also be narrowed and the node thus obscured." + (min (max point context-coloring-point-min) context-coloring-point-max)) + (defsubst context-coloring-js2-colorize-node (node level) "Color NODE with the color for LEVEL." - (let ((start (js2-node-abs-pos node))) + (let* ((start (js2-node-abs-pos node)) + (end (+ start (js2-node-len node (context-coloring-colorize-region - start - (min - ;; End - (+ start (js2-node-len node)) - ;; Somes nodes (like the ast when there is an unterminated multiline - ;; comment) will stretch to the value of `point-max'. - context-coloring-point-max) + (context-coloring-js2-bounded-point start) + (context-coloring-js2-bounded-point end) level))) (defun context-coloring-js2-colorize-ast () "Color the buffer using the `js2-mode' abstract syntax tree." ;; Reset the hash table; the old one could be obsolete. (setq context-coloring-js2-scope-level-hash-table (make-hash-table :test #'eq)) + (setq context-coloring-point-min (point-min)) (setq context-coloring-point-max (point-max)) (with-silent-modifications (js2-visit-ast diff --git a/context-coloring-test.el b/context-coloring-test.el index 0d1f539..32080bb 100644 --- a/context-coloring-test.el +++ b/context-coloring-test.el @@ -663,6 +663,15 @@ 0")) (context-coloring-test-assert-javascript-global-level :fixture "initial-level.js") +(context-coloring-test-deftest-javascript narrow-to-region + (lambda () +(context-coloring-test-assert-coloring " +111 0 11 11 + 0 11 11 + 0 11 1")) + :before (lambda () +(narrow-to-region (+ (point-min) 1) (- (point-max) 2 + (context-coloring-test-deftest-emacs-lisp defun (lambda () (context-coloring-test-assert-coloring " diff --git a/fixtures/test/narrow-to-region.js b/fixtures/test/narrow-to-region.js new file mode 100644 index 000..29f9aef --- /dev/null +++ b/fixtures/test/narrow-to-region.js @@ -0,0 +1,3 @@ +function a () {} +function b () {} +function c () {}
[elpa] master 26f48c5 06/21: Improve Font Lock integration.
branch: master commit 26f48c5ffa4fb7e5ce672f1e308a892482ba404f Author: Jackson Ray Hamilton Commit: Jackson Ray Hamilton Improve Font Lock integration. Advising this function, which does nothing when Context Coloring is enabled, allows for modes that would normally flush Font Lock to instead trigger Context Coloring colorization. In particular, when prettify-symbols-mode is enabled after context-coloring-mode, the buffer's symbols will immediately be prettified. --- context-coloring.el | 23 +++ 1 file changed, 23 insertions(+) diff --git a/context-coloring.el b/context-coloring.el index 814466b..0d5b72c 100644 --- a/context-coloring.el +++ b/context-coloring.el @@ -427,6 +427,24 @@ permissible.") (defvar context-coloring-interruptable-p t "When non-nil, coloring may be interrupted by user input.") +(defvar context-coloring-mode) + +(defun context-coloring-around-font-lock-flush (oldfun &rest r) + "Advice around `font-lock-flush' for this mode only." + (if context-coloring-mode + (apply #'context-coloring-font-lock-flush r) +(apply oldfun r))) + +(defun context-coloring-font-lock-flush (&optional start end) + "Reimplementation of `font-lock-flush' for this mode. +The original relies on Font Lock variables that would be messy to +maintain here." + (let* ((start (or start (point-min))) + (end (or end (point-max))) + (length (- end start))) +(context-coloring-change-function start end length) +(context-coloring-maybe-colorize-with-buffer (current-buffer + ;;;###autoload (define-minor-mode context-coloring-mode "Toggle contextual code coloring. @@ -464,6 +482,11 @@ Feature inspired by Douglas Crockford." (font-lock-set-defaults) ;; Safely change the value of this function as necessary. (make-local-variable 'font-lock-syntactic-face-function) +;; Improve integration with modes relying on Font Lock. Here, attempts +;; to refontify in Font Lock contexts will instead refontifiy in Context +;; Coloring contexts. This is necessary for `prettify-symbols-mode' +;; integration. +(advice-add #'font-lock-flush :around #'context-coloring-around-font-lock-flush) (let ((setup (plist-get dispatch :setup))) (when setup (funcall setup))
[elpa] master abded5f 14/21: Check for compositions on old Emacsen.
branch: master commit abded5f8b0eb4b56753b97fab742f873f0481beb Author: Jackson Ray Hamilton Commit: Jackson Ray Hamilton Check for compositions on old Emacsen. Prettify Symbols Mode used to use the `composition' text property for prettification. --- context-coloring-test.el |8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/context-coloring-test.el b/context-coloring-test.el index 79e5f23..fef12d5 100644 --- a/context-coloring-test.el +++ b/context-coloring-test.el @@ -347,8 +347,12 @@ signaled." (when (fboundp 'prettify-symbols-mode) (defun context-coloring-test-assert-prettify-symbols-text-properties () -(unless (and (get-text-property 2 'prettify-symbols-start) - (get-text-property 2 'prettify-symbols-end)) +(unless (cond + ((version< emacs-version "25.0") + (get-text-property 2 'composition)) + (t + (and (get-text-property 2 'prettify-symbols-start) + (get-text-property 2 'prettify-symbols-end (ert-fail "Expected buffer to have it's symbols prettified, but it didn't."))) (context-coloring-test-deftest prettify-symbols-enabled-before
[elpa] master a1a6256 05/21: Set up post-colorize hooks.
branch: master commit a1a62560ac27bd4eefe50de1e0a5df691f646fef Author: Jackson Ray Hamilton Commit: Jackson Ray Hamilton Set up post-colorize hooks. In particular, this allows for symbol prettification post-colorize while prettify-symbols-mode is enabled. Generally, it may allow for other modes utilizing Font Lock to apply their fontifications too. --- context-coloring.el | 54 ++- 1 file changed, 45 insertions(+), 9 deletions(-) diff --git a/context-coloring.el b/context-coloring.el index 2e4e867..814466b 100644 --- a/context-coloring.el +++ b/context-coloring.el @@ -41,6 +41,14 @@ "Join a list of STRINGS with the string DELIMITER." (mapconcat #'identity strings delimiter)) +(defun context-coloring-check-predicates (predicates) + "Call PREDICATES until one returns t, otherwise return nil." + (let ((satisfied-p nil)) +(while (and predicates +(not satisfied-p)) + (setq satisfied-p (funcall (pop predicates +satisfied-p)) + ;;; Faces @@ -311,7 +319,11 @@ override `context-coloring-default-delay'. `context-coloring-mode' is enabled. `:teardown' - Arbitrary code to tear down this dispatch when -`context-coloring-mode' is disabled.") +`context-coloring-mode' is disabled. + +`:async-p' - Hint that code will be colorized asynchronously. +Please call `context-coloring-after-colorize' when colorization +completes.") (defun context-coloring-find-dispatch (predicate) "Find the first dispatch satisfying PREDICATE." @@ -345,18 +357,46 @@ override `context-coloring-default-delay'. "Set up environment for colorization." (context-coloring-update-maximum-face)) +(defvar context-coloring-after-colorize-hook nil + "Functions to run after colorizing.") + +(defun context-coloring-after-colorize () + "Do final business after colorization." + (run-hooks 'context-coloring-after-colorize-hook)) + (defun context-coloring-dispatch () "Determine how to color the current buffer, and color it." (let* ((dispatch (context-coloring-get-current-dispatch)) - (colorizer (plist-get dispatch :colorizer))) + (colorizer (plist-get dispatch :colorizer)) + (async-p (plist-get dispatch :async-p))) (context-coloring-before-colorize) (when colorizer (catch 'interrupted -(funcall colorizer) +(funcall colorizer))) +(unless async-p + (context-coloring-after-colorize ;;; Colorization +(defvar context-coloring-fontify-keywords-predicates + (list + (lambda () prettify-symbols-mode)) + "Cases where the whole buffer should have keywords fontified. +Necessary in cases where a mode relies on fontifications in +regions where Context Coloring doesn't happen to touch.") + +(defun context-coloring-maybe-fontify-keywords () + "Determine if the buffer ought to have keywords fontified." + (when (context-coloring-check-predicates + context-coloring-fontify-keywords-predicates) +(with-silent-modifications + (save-excursion +(font-lock-fontify-keywords-region (point-min) (point-max)) + +(add-hook 'context-coloring-after-colorize-hook + #'context-coloring-maybe-fontify-keywords) + (defun context-coloring-colorize () "Color the current buffer by function context." (interactive) @@ -381,12 +421,8 @@ permissible.") (defun context-coloring-ignore-unavailable-message-p () "Determine if the unavailable message should be silenced." - (let ((predicates context-coloring-ignore-unavailable-predicates) -(ignore-p nil)) -(while (and predicates -(not ignore-p)) - (setq ignore-p (funcall (pop predicates -ignore-p)) + (context-coloring-check-predicates + context-coloring-ignore-unavailable-predicates)) (defvar context-coloring-interruptable-p t "When non-nil, coloring may be interrupted by user input.")