[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 5e34bec 04/47: Cover malformed defun cases.
From: |
Jackson Ray Hamilton |
Subject: |
[elpa] master 5e34bec 04/47: Cover malformed defun cases. |
Date: |
Mon, 18 May 2015 09:51:38 +0000 |
branch: master
commit 5e34bec7fcfaaaf9c7bd34bd718ea52d2f991dfe
Author: Jackson Ray Hamilton <address@hidden>
Commit: Jackson Ray Hamilton <address@hidden>
Cover malformed defun cases.
---
context-coloring.el | 36 ++++++++++++++++++------------------
test/context-coloring-test.el | 6 +++++-
test/fixtures/defun.el | 3 +++
3 files changed, 26 insertions(+), 19 deletions(-)
diff --git a/context-coloring.el b/context-coloring.el
index 7787cb5..6954b10 100644
--- a/context-coloring.el
+++ b/context-coloring.el
@@ -420,24 +420,24 @@ generated by `js2-mode'."
((context-coloring-emacs-lisp-identifier-syntax-p
child-1-syntax-code)
(setq child-1-end (scan-sexps child-1-pos 1))
;; defuns are global so use level 0
- (context-coloring-colorize-region child-1-pos child-1-end 0)))
- (goto-char child-1-end)
- ;; Lookahead for parameters
- (skip-syntax-forward " " end)
- (when (= 4 (logand #xFFFF (car (syntax-after (point)))))
- (setq child-2-end (scan-sexps (point) 1))
- (setq defun-arglist (read (buffer-substring-no-properties
- (point)
- child-2-end)))
- (while defun-arglist
- (setq defun-arg (car defun-arglist))
- (when (and (symbolp defun-arg)
- (string-match-p "\\`[^&:]" (symbol-name
defun-arg)))
- (context-coloring-scope-add-variable
- (car scope-stack)
- defun-arg))
- (setq defun-arglist (cdr defun-arglist))))
- (goto-char child-2-end)
+ (context-coloring-colorize-region child-1-pos child-1-end 0)
+ (goto-char child-1-end)
+ ;; Lookahead for parameters
+ (skip-syntax-forward " " end)
+ (when (= 4 (logand #xFFFF (car (syntax-after (point)))))
+ (setq child-2-end (scan-sexps (point) 1))
+ (setq defun-arglist (read (buffer-substring-no-properties
+ (point)
+ child-2-end)))
+ (while defun-arglist
+ (setq defun-arg (car defun-arglist))
+ (when (and (symbolp defun-arg)
+ (string-match-p "\\`[^&:]" (symbol-name
defun-arg)))
+ (context-coloring-scope-add-variable
+ (car scope-stack)
+ defun-arg))
+ (setq defun-arglist (cdr defun-arglist)))
+ (goto-char child-2-end))))
;; Cleanup
(setq in-defun-p nil))
(t
diff --git a/test/context-coloring-test.el b/test/context-coloring-test.el
index 8bd91fd..393b4c7 100644
--- a/test/context-coloring-test.el
+++ b/test/context-coloring-test.el
@@ -1015,7 +1015,11 @@ see that function."
(context-coloring-test-assert-region-level 40 53 1) ; def ghi jkl
(context-coloring-test-assert-region-level 53 57 0) ; free
(context-coloring-test-assert-region-level 57 59 1) ; ))
- (context-coloring-test-assert-region-level 61 72 0)) ; (abc 1 2 3)
+ (context-coloring-test-assert-region-level 61 72 0) ; (abc 1 2 3)
+ (context-coloring-test-assert-region-level 74 81 1) ; (defun
+ (context-coloring-test-assert-region-level 81 82 0) ; a
+ (context-coloring-test-assert-region-level 82 83 1) ; )
+ (context-coloring-test-assert-region-level 84 94 1)) ; (defun ())
(provide 'context-coloring-test)
diff --git a/test/fixtures/defun.el b/test/fixtures/defun.el
index 9ed7b7b..a5bd039 100644
--- a/test/fixtures/defun.el
+++ b/test/fixtures/defun.el
@@ -2,3 +2,6 @@
(+ def ghi jkl free))
(abc 1 2 3)
+
+(defun a)
+(defun ())
- [elpa] master updated (e42b97b -> b525e2d), Jackson Ray Hamilton, 2015/05/18
- [elpa] master 056be97 01/47: Add URL to header., Jackson Ray Hamilton, 2015/05/18
- [elpa] master eb429df 02/47: Use lowercase for hex codes., Jackson Ray Hamilton, 2015/05/18
- [elpa] master 5e34bec 04/47: Cover malformed defun cases.,
Jackson Ray Hamilton <=
- [elpa] master d9d901f 03/47: Add basic elisp defun coloring., Jackson Ray Hamilton, 2015/05/18
- [elpa] master 8919acd 05/47: Add lambda coloring., Jackson Ray Hamilton, 2015/05/18
- [elpa] master 62506ae 06/47: Add quote and number coloring., Jackson Ray Hamilton, 2015/05/18
- [elpa] master 284cfa6 08/47: Don't treat unbindables like variables., Jackson Ray Hamilton, 2015/05/18
- [elpa] master 636e6b9 07/47: Add elisp comments and strings support., Jackson Ray Hamilton, 2015/05/18
- [elpa] master 3e3141f 09/47: Refactor elisp tests to use visual assertions., Jackson Ray Hamilton, 2015/05/18
- [elpa] master 171883f 13/47: Add let coloring., Jackson Ray Hamilton, 2015/05/18
- [elpa] master 58b7474 11/47: Don't color function calls as level 0., Jackson Ray Hamilton, 2015/05/18
- [elpa] master dd8d491 12/47: Also color defsubst., Jackson Ray Hamilton, 2015/05/18
- [elpa] master 5acd088 10/47: Add non-recursive let* coloring., Jackson Ray Hamilton, 2015/05/18