]> code.delx.au - gnu-emacs-elpa/commitdiff
Refactor defun / defadvice name handling.
authorJackson Ray Hamilton <jackson@jacksonrayhamilton.com>
Sat, 13 Jun 2015 21:19:01 +0000 (14:19 -0700)
committerJackson Ray Hamilton <jackson@jacksonrayhamilton.com>
Sat, 13 Jun 2015 21:19:01 +0000 (14:19 -0700)
context-coloring.el

index b1bede58abbe41b48dcc132e7fb6ffd3882062ae..77c2d55c6858df511a4fb837c8f694abe6cfbe20 100644 (file)
@@ -641,8 +641,9 @@ no header, skip past the sexp at START."
     (goto-char start)
     (context-coloring-elisp-forward-sexp))))
 
-(defun context-coloring-elisp-colorize-defun ()
-  "Color the `defun' at point."
+(defun context-coloring-elisp-colorize-defun-like (callback)
+  "Color the defun-like function at point, parsing the header
+with CALLBACK."
   (let ((start (point)))
     (context-coloring-elisp-colorize-scope
      (lambda ()
@@ -655,48 +656,35 @@ no header, skip past the sexp at START."
                  (point))
           0)
          (context-coloring-elisp-forward-sws)
-         (context-coloring-elisp-parse-header
-          'context-coloring-elisp-parse-arglist start))
+         (context-coloring-elisp-parse-header callback start))
         (t
          ;; Skip it.
          (goto-char start)
          (context-coloring-elisp-forward-sexp)))))))
 
+(defun context-coloring-elisp-colorize-defun ()
+  "Color the `defun' at point."
+  (context-coloring-elisp-colorize-defun-like
+   'context-coloring-elisp-parse-arglist))
+
 (defun context-coloring-elisp-colorize-defadvice ()
   "Color the `defadvice' at point."
-  (let ((start (point)))
-    (context-coloring-elisp-colorize-scope
-     (lambda ()
-       (cond
-        ((context-coloring-elisp-identifier-p (context-coloring-get-syntax-code))
-         ;; Color the advised function's name with the top-level color.
-         (context-coloring-colorize-region
-          (point)
-          (progn (forward-sexp)
-                 (point))
-          0)
-         (context-coloring-elisp-forward-sws)
-         (context-coloring-elisp-parse-header
-          (lambda ()
-            (let (syntax-code)
-              ;; Enter.
-              (forward-char)
-              (while (/= (setq syntax-code (context-coloring-get-syntax-code))
-                         context-coloring-CLOSE-PARENTHESIS-CODE)
-                (cond
-                 ((= syntax-code context-coloring-OPEN-PARENTHESIS-CODE)
-                  (context-coloring-elisp-parse-arglist))
-                 (t
-                  ;; Ignore artifacts.
-                  (context-coloring-elisp-forward-sexp)))
-                (context-coloring-elisp-forward-sws))
-              ;; Exit.
-              (forward-char)))
-          start))
-        (t
-         ;; Skip it.
-         (goto-char start)
-         (context-coloring-elisp-forward-sexp)))))))
+  (context-coloring-elisp-colorize-defun-like
+   (lambda ()
+     (let (syntax-code)
+       ;; Enter.
+       (forward-char)
+       (while (/= (setq syntax-code (context-coloring-get-syntax-code))
+                  context-coloring-CLOSE-PARENTHESIS-CODE)
+         (cond
+          ((= syntax-code context-coloring-OPEN-PARENTHESIS-CODE)
+           (context-coloring-elisp-parse-arglist))
+          (t
+           ;; Ignore artifacts.
+           (context-coloring-elisp-forward-sexp)))
+         (context-coloring-elisp-forward-sws))
+       ;; Exit.
+       (forward-char)))))
 
 (defun context-coloring-elisp-colorize-lambda-like (callback)
   "Color the lambda-like function at point, parsing the header