[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master d2e08e8 62/79: Improve and test lazy coloring.
From: |
Jackson Ray Hamilton |
Subject: |
[elpa] master d2e08e8 62/79: Improve and test lazy coloring. |
Date: |
Sun, 14 Jun 2015 00:05:43 +0000 |
branch: master
commit d2e08e874ced07c2b3372df23f338910fda240c4
Author: Jackson Ray Hamilton <address@hidden>
Commit: Jackson Ray Hamilton <address@hidden>
Improve and test lazy coloring.
---
context-coloring.el | 20 ++++++++++++++------
test/context-coloring-test.el | 31 +++++++++++++++++++++++++++++++
test/fixtures/changed.el | 5 +++++
3 files changed, 50 insertions(+), 6 deletions(-)
diff --git a/context-coloring.el b/context-coloring.el
index 0d860ac..b57cfb3 100644
--- a/context-coloring.el
+++ b/context-coloring.el
@@ -951,12 +951,20 @@ scopes and variables."
(cond
;; Just colorize the changed region.
(context-coloring-changed-p
- (let ((start (progn (goto-char context-coloring-changed-start)
- (beginning-of-defun)
- (point)))
- (end (progn (goto-char context-coloring-changed-end)
- (end-of-defun)
- (point))))
+ (let* (;; Prevent `beginning-of-defun' from making poor assumptions.
+ (open-paren-in-column-0-is-defun-start nil)
+ ;; Seek the beginning and end of the previous and next offscreen
+ ;; defuns, so just enough is colored.
+ (start (progn (goto-char context-coloring-changed-start)
+ (while (and (< (point-min) (point))
+ (pos-visible-in-window-p))
+ (beginning-of-defun))
+ (point)))
+ (end (progn (goto-char context-coloring-changed-end)
+ (while (and (> (point-max) (point))
+ (pos-visible-in-window-p))
+ (end-of-defun))
+ (point))))
(context-coloring-elisp-colorize-region-initially start end)))
(t
(context-coloring-elisp-colorize-region-initially (point-min)
(point-max)))))))
diff --git a/test/context-coloring-test.el b/test/context-coloring-test.el
index 0d226ba..deb40fb 100644
--- a/test/context-coloring-test.el
+++ b/test/context-coloring-test.el
@@ -25,6 +25,7 @@
;;; Code:
+(require 'cl-lib)
(require 'context-coloring)
(require 'ert-async)
(require 'js2-mode)
@@ -1214,6 +1215,36 @@ cc `CC' `CC'
cc `CC' `CC'
nnnnnn n nnn"))))
+(context-coloring-test-deftest-emacs-lisp changed
+ (lambda ()
+ (context-coloring-test-remove-faces)
+ ;; Goto line 3.
+ (goto-char (point-min))
+ (forward-line (1- 3))
+ (insert " ")
+ ;; Mock `pos-visible-in-window-p' because in batch mode `get-buffer-window'
+ ;; returns nil. Emacs must not have a window in that environment.
+ (cl-letf (((symbol-function 'pos-visible-in-window-p)
+ (let ((calls 0))
+ (lambda ()
+ (prog1
+ ;; First and third calls start from center. Second and
+ ;; fourth calls are made immediately after moving past
+ ;; the first defun in either direction "off screen".
+ (cond
+ ((= calls 0) t)
+ ((= calls 1) nil)
+ ((= calls 2) t)
+ ((= calls 4) nil))
+ (setq calls (1+ calls)))))))
+ (context-coloring-colorize))
+ (context-coloring-test-assert-coloring "
+nnnn n nnn nnnnnnnn
+0000
+
+0000
+nnnnn n nnn nnnnnnnn")))
+
(provide 'context-coloring-test)
;;; context-coloring-test.el ends here
diff --git a/test/fixtures/changed.el b/test/fixtures/changed.el
new file mode 100644
index 0000000..28c9602
--- /dev/null
+++ b/test/fixtures/changed.el
@@ -0,0 +1,5 @@
+(l1) ; Not colored.
+(l2)
+
+(l4)
+(l5) ; Not colored.
- [elpa] master c2834f0 51/79: Add condition-case support., (continued)
- [elpa] master c2834f0 51/79: Add condition-case support., Jackson Ray Hamilton, 2015/06/13
- [elpa] master 2ee41c1 52/79: Add comments and strings to condition-case test., Jackson Ray Hamilton, 2015/06/13
- [elpa] master e387aaf 45/79: Merge branch 'server' into elisp, Jackson Ray Hamilton, 2015/06/13
- [elpa] master 77b075f 60/79: Space., Jackson Ray Hamilton, 2015/06/13
- [elpa] master 5857bc8 53/79: Refactor comments and strings coloring., Jackson Ray Hamilton, 2015/06/13
- [elpa] master 4bd7fc7 56/79: Make delays configurable at the dispatch level., Jackson Ray Hamilton, 2015/06/13
- [elpa] master f870598 59/79: Fix infinite loop when parsing let., Jackson Ray Hamilton, 2015/06/13
- [elpa] master 3c7a00d 55/79: Add lazy coloring., Jackson Ray Hamilton, 2015/06/13
- [elpa] master 08e2981 63/79: Swallow scan errors., Jackson Ray Hamilton, 2015/06/13
- [elpa] master ec9f04d 64/79: Update emacs lisp support in readme., Jackson Ray Hamilton, 2015/06/13
- [elpa] master d2e08e8 62/79: Improve and test lazy coloring.,
Jackson Ray Hamilton <=
- [elpa] master 46a9193 65/79: Find the edges of the screen more efficiently., Jackson Ray Hamilton, 2015/06/13
- [elpa] master fd4bc95 66/79: Add dolist support., Jackson Ray Hamilton, 2015/06/13
- [elpa] master 9edc6c3 69/79: Checkdoc cleanup., Jackson Ray Hamilton, 2015/06/13
- [elpa] master e2ceef9 57/79: Prepend function symbols with octothorpes., Jackson Ray Hamilton, 2015/06/13
- [elpa] master 22403b7 61/79: Cover parsing edge cases., Jackson Ray Hamilton, 2015/06/13
- [elpa] master 67576b5 72/79: Skip all insignificant expression prefixes., Jackson Ray Hamilton, 2015/06/13
- [elpa] master 306335e 71/79: Add defadvice support., Jackson Ray Hamilton, 2015/06/13
- [elpa] master acf15ae 70/79: Remove if., Jackson Ray Hamilton, 2015/06/13
- [elpa] master ed870d8 68/79: Refactor minor mode definition., Jackson Ray Hamilton, 2015/06/13
- [elpa] master 72a0998 73/79: Add quote and backquote function support., Jackson Ray Hamilton, 2015/06/13