branch: master commit bc0cb0de7a47ed3b5210d11f738e1850575bb580 Author: Jackson Ray Hamilton <jack...@jacksonrayhamilton.com> Commit: Jackson Ray Hamilton <jack...@jacksonrayhamilton.com>
Pass lambda test with recursive colorizer. --- context-coloring.el | 56 ++++++++++++++++++++++++++-------------- test/context-coloring-test.el | 12 ++++---- 2 files changed, 42 insertions(+), 26 deletions(-) diff --git a/context-coloring.el b/context-coloring.el index 6aa2bbf..8972da9 100644 --- a/context-coloring.el +++ b/context-coloring.el @@ -477,13 +477,14 @@ provide visually \"instant\" updates at 60 frames per second.") (t 0)))) -(defun context-coloring-elisp-colorize-defun () +(defun context-coloring-elisp-colorize-defun (&optional anonymous-p) (let ((start (point)) end + stop syntax syntax-code - child-1-pos - child-1-end + defun-name-pos + defun-name-end arg-n-pos arg-n-end arg-n-string) @@ -491,24 +492,37 @@ provide visually \"instant\" updates at 60 frames per second.") ;; Color the whole sexp. (forward-sexp) (setq end (point)) - (context-coloring-colorize-region start end 1) + (context-coloring-colorize-region + start + end + (context-coloring-elisp-current-scope-level)) (goto-char start) ;; Skip past the "defun". (skip-syntax-forward "^w_") (forward-sexp) (skip-syntax-forward " ") - ;; Check for the defun's name. - (setq syntax (syntax-after (point))) - (setq syntax-code (syntax-class syntax)) + (setq stop nil) + (unless anonymous-p + ;; Check for the defun's name. + (setq syntax (syntax-after (point))) + (setq syntax-code (syntax-class syntax)) + (cond + ((or (= syntax-code context-coloring-WORD-CODE) + (= syntax-code context-coloring-SYMBOL-CODE)) + ;; Color the defun's name with the top-level color. + (setq defun-name-pos (point)) + (forward-sexp) + (setq defun-name-end (point)) + (context-coloring-colorize-region defun-name-pos defun-name-end 0) + (skip-syntax-forward " ")) + (t + (setq stop t)))) (cond - ((or (= syntax-code context-coloring-WORD-CODE) - (= syntax-code context-coloring-SYMBOL-CODE)) - ;; Color the defun's name with the top-level color. - (setq child-1-pos (point)) - (forward-sexp) - (setq child-1-end (point)) - (context-coloring-colorize-region child-1-pos child-1-end 0) - (skip-syntax-forward " ") + (stop + ;; Skip it. + (goto-char start) + (forward-sexp)) + (t (setq syntax (syntax-after (point))) (setq syntax-code (syntax-class syntax)) (cond @@ -545,13 +559,12 @@ provide visually \"instant\" updates at 60 frames per second.") (t ;; Skip it. (goto-char start) - (forward-sexp)))) - (t - ;; Skip it. - (goto-char start) - (forward-sexp))) + (forward-sexp))))) (context-coloring-elisp-pop-scope))) +(defun context-coloring-elisp-colorize-lambda () + (context-coloring-elisp-colorize-defun t)) + (defun context-coloring-elisp-colorize-sexp () (let ((start (point)) end @@ -581,6 +594,9 @@ provide visually \"instant\" updates at 60 frames per second.") ((string-match-p context-coloring-emacs-lisp-defun-regexp child-0-string) (goto-char start) (context-coloring-elisp-colorize-defun)) + ((string-match-p context-coloring-emacs-lisp-lambda-regexp child-0-string) + (goto-char start) + (context-coloring-elisp-colorize-lambda)) ;; Not a special form; just colorize the remaining region. (t (context-coloring-colorize-region diff --git a/test/context-coloring-test.el b/test/context-coloring-test.el index da6a8be..4b8a939 100644 --- a/test/context-coloring-test.el +++ b/test/context-coloring-test.el @@ -1086,12 +1086,12 @@ ssssssssssss0")) 111111 01 111111 111"))) -;; (context-coloring-test-deftest-emacs-lisp lambda -;; (lambda () -;; (context-coloring-test-assert-coloring " -;; 00000000 1111111 1111 -;; 11111111 11 2222222 2222 -;; 222 22 12 2221 111 0 00"))) +(context-coloring-test-deftest-emacs-lisp lambda + (lambda () + (context-coloring-test-assert-coloring " +00000000 1111111 1111 + 11111111 11 2222222 2222 + 222 22 12 2221 111 0 00"))) ;; (context-coloring-test-deftest-emacs-lisp quote ;; (lambda ()