[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master aaf4835 20/79: Remove let-varlist data structure. Cleanup.
From: |
Jackson Ray Hamilton |
Subject: |
[elpa] master aaf4835 20/79: Remove let-varlist data structure. Cleanup. |
Date: |
Sun, 14 Jun 2015 00:05:23 +0000 |
branch: master
commit aaf48357875c366c652eb842229e0c284e98566b
Author: Jackson Ray Hamilton <address@hidden>
Commit: Jackson Ray Hamilton <address@hidden>
Remove let-varlist data structure. Cleanup.
---
context-coloring.el | 147 ++++++++++++++-------------------------------------
1 files changed, 40 insertions(+), 107 deletions(-)
diff --git a/context-coloring.el b/context-coloring.el
index 674d669..174edde 100644
--- a/context-coloring.el
+++ b/context-coloring.el
@@ -276,36 +276,24 @@ generated by `js2-mode'."
;;; Emacs Lisp colorization
-(defsubst context-coloring-forward-sws ()
- "Move forward through whitespace and comments."
- (while (forward-comment 1)))
-
-(defsubst context-coloring-forward-sexp-position ()
- "Like vanilla `forward-sexp', but just return the position."
- (scan-sexps (point) 1))
-
-(defsubst context-coloring-elisp-identifier-syntax-p (syntax-code)
- (or (= 2 syntax-code)
- (= 3 syntax-code)))
-
-(defsubst context-coloring-open-parenthesis-p (syntax-code)
- (= 4 syntax-code))
-
-(defsubst context-coloring-close-parenthesis-p (syntax-code)
- (= 5 syntax-code))
+(defvar context-coloring-parse-interruptable-p t
+ "Set this to nil to force parse to continue until finished.")
-(defsubst context-coloring-expression-prefix-p (syntax-code)
- (= 6 syntax-code))
+(defconst context-coloring-elisp-iterations-per-pause 1000
+ "Pause after this many iterations to check for user input.
+If user input is pending, stop the parse. This makes for a
+smoother user experience for large files.
-(defsubst context-coloring-at-open-parenthesis-p ()
- (= 4 (logand #xFFFF (car (syntax-after (point))))))
+As of this writing, emacs lisp colorization seems to run at about
+60,000 iterations per second. A default value of 1000 should
+provide visually \"instant\" updates at 60 frames per second.")
-(defsubst context-coloring-ppss-depth (ppss)
- ;; Same as (nth 0 ppss).
- (car ppss))
+(defsubst context-coloring-forward-sws ()
+ "Move forward through whitespace and comments."
+ (while (forward-comment 1)))
-(defsubst context-coloring-at-stack-depth-p (stack depth)
- (= (plist-get (car stack) :depth) depth))
+(defsubst context-coloring-get-syntax-code ()
+ (syntax-class (syntax-after (point))))
(defsubst context-coloring-exact-regexp (word)
"Create a regexp that matches exactly WORD."
@@ -351,36 +339,21 @@ generated by `js2-mode'."
(defconst context-coloring-COMMA-CHAR (string-to-char ","))
(defconst context-coloring-BACKTICK-CHAR (string-to-char "`"))
-(defvar context-coloring-parse-interruptable-p t
- "Set this to nil to force parse to continue until finished.")
-
-(defconst context-coloring-elisp-iterations-per-pause 1000
- "Pause after this many iterations to check for user input.
-If user input is pending, stop the parse. This makes for a
-smoother user experience for large files.
-
-As of this writing, emacs lisp colorization seems to run at about
-60,000 iterations per second. A default value of 1000 should
-provide visually \"instant\" updates at 60 frames per second.")
-
-(defun context-coloring-get-syntax-code ()
- (syntax-class (syntax-after (point))))
-
(defvar context-coloring-elisp-scope-stack '())
(defsubst context-coloring-elisp-make-scope (level)
(list
:level level
- :variables (make-hash-table :test 'equal)))
+ :variables '()))
(defsubst context-coloring-elisp-scope-get-level (scope)
(plist-get scope :level))
(defsubst context-coloring-elisp-scope-add-variable (scope variable)
- (puthash variable t (plist-get scope :variables)))
+ (plist-put scope :variables (cons variable (plist-get scope :variables))))
-(defsubst context-coloring-elisp-scope-get-variable (scope variable)
- (gethash variable (plist-get scope :variables)))
+(defsubst context-coloring-elisp-scope-has-variable (scope variable)
+ (member variable (plist-get scope :variables)))
(defsubst context-coloring-elisp-get-variable-level (variable)
(let* ((scope-stack context-coloring-elisp-scope-stack)
@@ -389,69 +362,32 @@ provide visually \"instant\" updates at 60 frames per
second.")
(while (and scope-stack (not level))
(setq scope (car scope-stack))
(cond
- ((context-coloring-elisp-scope-get-variable scope variable)
+ ((context-coloring-elisp-scope-has-variable scope variable)
(setq level (context-coloring-elisp-scope-get-level scope)))
(t
(setq scope-stack (cdr scope-stack)))))
;; Assume a global variable.
(or level 0)))
-(defun context-coloring-elisp-push-scope ()
+(defsubst context-coloring-elisp-current-scope-level ()
+ (cond
+ ((car context-coloring-elisp-scope-stack)
+ (context-coloring-elisp-scope-get-level (car
context-coloring-elisp-scope-stack)))
+ (t
+ 0)))
+
+(defsubst context-coloring-elisp-push-scope ()
(push (context-coloring-elisp-make-scope
(1+ (context-coloring-elisp-current-scope-level)))
context-coloring-elisp-scope-stack))
-(defun context-coloring-elisp-pop-scope ()
+(defsubst context-coloring-elisp-pop-scope ()
(pop context-coloring-elisp-scope-stack))
-(defun context-coloring-elisp-add-variable (variable)
- (let ((current-scope (car context-coloring-elisp-scope-stack)))
- (context-coloring-elisp-scope-add-variable current-scope variable)))
-
-(defun context-coloring-elisp-current-scope-level ()
- (let ((current-scope (car context-coloring-elisp-scope-stack)))
- (cond
- (current-scope
- (context-coloring-elisp-scope-get-level current-scope))
- (t
- 0))))
-
-(defsubst context-coloring-elisp-make-let-varlist (type)
- (list
- :type type
- :vars '()))
-
-(defsubst context-coloring-elisp-let-varlist-get-type (let-varlist)
- (plist-get let-varlist :type))
-
-(defsubst context-coloring-elisp-let-varlist-get-vars (let-varlist)
- (plist-get let-varlist :vars))
-
-(defsubst context-coloring-elisp-let-varlist-set-vars (let-varlist vars)
- (plist-put let-varlist :vars vars))
-
-(defsubst context-coloring-elisp-let-varlist-add-var (let-varlist var)
- (plist-put let-varlist :vars (cons var (plist-get let-varlist :vars))))
-
-(defsubst context-coloring-elisp-let-varlist-pop-vars (let-varlist)
- (let* ((type (context-coloring-elisp-let-varlist-get-type let-varlist))
- (vars (context-coloring-elisp-let-varlist-get-vars let-varlist))
- (popped (cond
- ;; `let' binds all at once at the end.
- ((eq type 'let)
- (prog1
- vars
- (context-coloring-elisp-let-varlist-set-vars
- let-varlist '())))
- ;; `let*' binds incrementally.
- ((eq type 'let*)
- (prog1
- (list (car vars))
- (context-coloring-elisp-let-varlist-set-vars
- let-varlist (cdr vars)))))))
- (while popped
- (context-coloring-elisp-add-variable (car popped))
- (setq popped (cdr popped)))))
+(defsubst context-coloring-elisp-add-variable (variable)
+ (context-coloring-elisp-scope-add-variable
+ (car context-coloring-elisp-scope-stack)
+ variable))
(defun context-coloring-elisp-parse-arg (callback)
(let (arg-pos
@@ -469,13 +405,11 @@ provide visually \"instant\" updates at 60 frames per
second.")
(funcall callback arg-string))))
(defun context-coloring-elisp-parse-let-varlist (type)
- (let ((let-varlist (context-coloring-elisp-make-let-varlist type))
+ (let ((varlist '())
syntax-code)
;; Enter.
(forward-char)
- (while (/= (progn
- (setq syntax-code (context-coloring-get-syntax-code))
- syntax-code)
+ (while (/= (setq syntax-code (context-coloring-get-syntax-code))
context-coloring-CLOSE-PARENTHESIS-CODE)
(cond
((= syntax-code context-coloring-OPEN-PARENTHESIS-CODE)
@@ -486,7 +420,7 @@ provide visually \"instant\" updates at 60 frames per
second.")
(= syntax-code context-coloring-SYMBOL-CODE))
(context-coloring-elisp-parse-arg
(lambda (var)
- (context-coloring-elisp-let-varlist-add-var let-varlist var)))
+ (push var varlist)))
(context-coloring-forward-sws)
(setq syntax-code (context-coloring-get-syntax-code))
(when (/= syntax-code context-coloring-CLOSE-PARENTHESIS-CODE)
@@ -498,12 +432,13 @@ provide visually \"instant\" updates at 60 frames per
second.")
(= syntax-code context-coloring-SYMBOL-CODE))
(context-coloring-elisp-parse-arg
(lambda (var)
- (context-coloring-elisp-let-varlist-add-var let-varlist var)))))
+ (push var varlist)))))
(when (eq type 'let*)
- (context-coloring-elisp-let-varlist-pop-vars let-varlist))
+ (context-coloring-elisp-add-variable (pop varlist)))
(context-coloring-forward-sws))
(when (eq type 'let)
- (context-coloring-elisp-let-varlist-pop-vars let-varlist))
+ (while varlist
+ (context-coloring-elisp-add-variable (pop varlist))))
;; Exit.
(forward-char)))
@@ -511,9 +446,7 @@ provide visually \"instant\" updates at 60 frames per
second.")
(let (syntax-code)
;; Enter.
(forward-char)
- (while (/= (progn
- (setq syntax-code (context-coloring-get-syntax-code))
- syntax-code)
+ (while (/= (setq syntax-code (context-coloring-get-syntax-code))
context-coloring-CLOSE-PARENTHESIS-CODE)
(cond
((or (= syntax-code context-coloring-WORD-CODE)
- [elpa] master 1f474d9 11/79: Reorganize functions., (continued)
- [elpa] master 1f474d9 11/79: Reorganize functions., Jackson Ray Hamilton, 2015/06/13
- [elpa] master 92166ba 13/79: Add no-fixture option., Jackson Ray Hamilton, 2015/06/13
- [elpa] master 8ea8c9c 15/79: Pass defun test with recursive colorizer., Jackson Ray Hamilton, 2015/06/13
- [elpa] master ea6b4ef 14/79: Increase test documentation., Jackson Ray Hamilton, 2015/06/13
- [elpa] master 7975003 18/79: Pass ignored test with recursive colorizer., Jackson Ray Hamilton, 2015/06/13
- [elpa] master d8b5f03 12/79: Remove before-all and after-all., Jackson Ray Hamilton, 2015/06/13
- [elpa] master bc0cb0d 16/79: Pass lambda test with recursive colorizer., Jackson Ray Hamilton, 2015/06/13
- [elpa] master 6090eb3 17/79: Pass quote test with recursive colorizer., Jackson Ray Hamilton, 2015/06/13
- [elpa] master f1ed39f 21/79: Pass comment and string tests with recursive colorizer., Jackson Ray Hamilton, 2015/06/13
- [elpa] master d146af8 23/79: Fix string coloring., Jackson Ray Hamilton, 2015/06/13
- [elpa] master aaf4835 20/79: Remove let-varlist data structure. Cleanup.,
Jackson Ray Hamilton <=
- [elpa] master 49265ab 25/79: Simplify comment and string parsing., Jackson Ray Hamilton, 2015/06/13
- [elpa] master 52383b5 26/79: Handle octothorpes., Jackson Ray Hamilton, 2015/06/13
- [elpa] master a283883 24/79: Always colorize the remaining region., Jackson Ray Hamilton, 2015/06/13
- [elpa] master 3d3c693 22/79: Pass interrupt test with recursive colorizer., Jackson Ray Hamilton, 2015/06/13
- [elpa] master 966bd20 31/79: Add test for escape characters., Jackson Ray Hamilton, 2015/06/13
- [elpa] master 7ab01e3 30/79: Fix ignored test., Jackson Ray Hamilton, 2015/06/13
- [elpa] master f88e21c 29/79: Ignore escaped characters., Jackson Ray Hamilton, 2015/06/13
- [elpa] master e06f1a6 27/79: Color comments and strings inside quotes., Jackson Ray Hamilton, 2015/06/13
- [elpa] master 5a8186b 34/79: Color comments and strings inside defuns., Jackson Ray Hamilton, 2015/06/13
- [elpa] master 4b25191 28/79: Refactor benchmarks. Improve benchmark reliability., Jackson Ray Hamilton, 2015/06/13