emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master 3b6a391 44/47: Minor cleanup.


From: Jackson Ray Hamilton
Subject: [elpa] master 3b6a391 44/47: Minor cleanup.
Date: Mon, 18 May 2015 09:52:08 +0000

branch: master
commit 3b6a3918ca329b1d836e492bd0b8403a1e696e65
Author: Jackson Ray Hamilton <address@hidden>
Commit: Jackson Ray Hamilton <address@hidden>

    Minor cleanup.
---
 context-coloring.el |   37 ++++++++++++++++++++++++-------------
 1 files changed, 24 insertions(+), 13 deletions(-)

diff --git a/context-coloring.el b/context-coloring.el
index 0249a5d..5c3b76f 100644
--- a/context-coloring.el
+++ b/context-coloring.el
@@ -364,6 +364,7 @@ generated by `js2-mode'."
   (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-emacs-lisp-identifier-syntax-p (syntax-code)
@@ -386,7 +387,7 @@ generated by `js2-mode'."
   ;; Same as (nth 0 ppss).
   (car ppss))
 
-(defsubst context-coloring-stack-depth-equal (stack depth)
+(defsubst context-coloring-at-stack-depth-p (stack depth)
   (= (plist-get (car stack) :depth) depth))
 
 (defsubst context-coloring-exact-regexp (word)
@@ -398,11 +399,20 @@ generated by `js2-mode'."
   (context-coloring-join
    (mapcar 'context-coloring-exact-regexp words) "\\|"))
 
-(defconst context-coloring-defun-regexp
+(defconst context-coloring-emacs-lisp-defun-regexp
   (context-coloring-exact-or-regexp
    '("defun" "defun*" "defsubst" "defmacro"
      "cl-defun" "cl-defsubst" "cl-defmacro")))
 
+(defconst context-coloring-emacs-lisp-lambda-regexp
+  (context-coloring-exact-regexp "lambda"))
+
+(defconst context-coloring-emacs-lisp-let-regexp
+  (context-coloring-exact-regexp "let"))
+
+(defconst context-coloring-emacs-lisp-let*-regexp
+  (context-coloring-exact-regexp "let*"))
+
 (defconst context-coloring-arglist-arg-regexp
   "\\`[^&:]")
 
@@ -423,7 +433,7 @@ 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.")
+provide visually \"instant\" updates at 60 frames per second.")
 
 (defun context-coloring-emacs-lisp-colorize ()
   "Color the current buffer by parsing emacs lisp sexps."
@@ -432,11 +442,11 @@ provide visually \"instant\" updates at ~60 frames per 
second.")
       ;; TODO: Can probably make this lazy to the nearest defun.
       (goto-char (point-min))
       (let* ((inhibit-point-motion-hooks t)
+             (end (point-max))
              (iteration-count 0)
              (last-fontified-position (point))
              beginning-of-current-defun
              end-of-current-defun
-             (end (point-max))
              (last-ppss-pos (point))
              (ppss (syntax-ppss))
              ppss-depth
@@ -565,7 +575,7 @@ provide visually \"instant\" updates at ~60 frames per 
second.")
                ;; Parse a var in a `let' varlist.
                ((and
                  let-varlist-stack
-                 (context-coloring-stack-depth-equal
+                 (context-coloring-at-stack-depth-p
                   let-varlist-stack
                   ;; 1- because we're inside the varlist.
                   (1- (context-coloring-ppss-depth ppss))))
@@ -574,14 +584,14 @@ provide visually \"instant\" updates at ~60 frames per 
second.")
                  (intern child-0-string))
                 (setq let-var-stack (cons (context-coloring-ppss-depth ppss)
                                           let-var-stack)))
-               ((string-match-p context-coloring-defun-regexp child-0-string)
+               ((string-match-p context-coloring-emacs-lisp-defun-regexp 
child-0-string)
                 (setq in-defun-p t))
-               ((string-match-p "\\`lambda\\'" child-0-string)
+               ((string-match-p context-coloring-emacs-lisp-lambda-regexp 
child-0-string)
                 (setq in-lambda-p t))
-               ((string-match-p "\\`let\\'" child-0-string)
+               ((string-match-p context-coloring-emacs-lisp-let-regexp 
child-0-string)
                 (setq in-let-p t)
                 (setq let-varlist-type 'let))
-               ((string-match-p "\\`let\\*\\'" child-0-string)
+               ((string-match-p context-coloring-emacs-lisp-let*-regexp 
child-0-string)
                 (setq in-let*-p t)
                 (setq let-varlist-type 'let*)))))
             (when (or in-defun-p
@@ -593,7 +603,8 @@ provide visually \"instant\" updates at ~60 frames per 
second.")
                                        (1+ (context-coloring-scope-get-level
                                             (car scope-stack))))
                                       scope-stack)))
-            ;; TODO: Probably redundant and wasteful.
+            ;; TODO: Maybe wasteful but doing this conditionally doesn't make
+            ;; much of a difference.
             (context-coloring-colorize-region token-pos
                                               (scan-sexps token-pos 1)
                                               (context-coloring-scope-get-level
@@ -682,7 +693,7 @@ provide visually \"instant\" updates at ~60 frames per 
second.")
                ;; Parse a `let' varlist's uninitialized var.
                ((and
                  let-varlist-stack
-                 (context-coloring-stack-depth-equal
+                 (context-coloring-at-stack-depth-p
                   let-varlist-stack
                   ;; 1- because we're inside the varlist.
                   (1- (context-coloring-ppss-depth ppss))))
@@ -712,7 +723,7 @@ provide visually \"instant\" updates at ~60 frames per 
second.")
             (setq last-ppss-pos (point))
             (setq ppss-depth (context-coloring-ppss-depth ppss))
             ;; TODO: Order might matter here but I'm not certain.
-            (when (context-coloring-stack-depth-equal scope-stack ppss-depth)
+            (when (context-coloring-at-stack-depth-p scope-stack ppss-depth)
               (setq scope-stack (cdr scope-stack)))
             (when (and
                    let-var-stack
@@ -724,7 +735,7 @@ provide visually \"instant\" updates at ~60 frames per 
second.")
                                    (car let-varlist-stack)))))
             (when (and
                    let-varlist-stack
-                   (context-coloring-stack-depth-equal let-varlist-stack 
ppss-depth))
+                   (context-coloring-at-stack-depth-p let-varlist-stack 
ppss-depth))
               (setq popped-vars (context-coloring-let-varlist-pop-vars
                                  (car let-varlist-stack)))
               (setq let-varlist-stack (cdr let-varlist-stack)))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]