Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add support for MooseX::Declare and MooseX::MultiMethods keywords:

  * method declarators
    + method
    + before / after / around / augment / override
    + multi method

  * class / role declarators
    + class
    + role
    + with / extends

     "class Foo extends Bar with Baz with Quux { }"
     (supports this form across multiple lines)

  * moose sugar
    + has
    + requires (in roles)

note that "traditional moose" still parses OK
  • Loading branch information...
commit ee93df9ff319c6ec090dee9a83e36ead36acfda7 1 parent e7591e4
@jrockway authored
Showing with 19 additions and 11 deletions.
  1. +19 −11 cperl-mode.el
View
30 cperl-mode.el
@@ -1453,7 +1453,7 @@ the last)."
;;; Tired of editing this in 8 places every time I remember that there
;;; is another method-defining keyword
(defvar cperl-sub-keywords
- '("sub"))
+ '("sub" "multi method" "method" "before" "after" "around" "override" "augment"))
(defvar cperl-sub-regexp (regexp-opt cperl-sub-keywords))
@@ -3745,10 +3745,14 @@ the sections using `cperl-pod-head-face', `cperl-pod-face',
;; 1+6+2+1+1+6=17 extra () before this:
"\\$\\(['{]\\)" ; $' or ${foo}
"\\|"
- ;; 1+6+2+1+1+6+1=18 extra () before this (old pack'var syntax;
- ;; we do not support intervening comments...):
+ ;; 1+6+2+1+1+6+1=18 extra () before this (old pack'var
+ ;; syntax; we do not support intervening comments...):
+ ;; -
+ ;; note: don't put any Moose sugar
+ ;; (before/after/around) here, this is for very old
+ ;; perl that you shouldn't be writing.
"\\(\\<sub[ \t\n\f]+\\|[&*$@%]\\)[a-zA-Z0-9_]*'"
- ;; 1+6+2+1+1+6+1+1=19 extra () before this:
+ ;; 1+6+2+1+1+6+1+1=19 extra () before this:
"\\|"
"__\\(END\\|DATA\\)__" ; __END__ or __DATA__
;; 1+6+2+1+1+6+1+1+1=20 extra () before this:
@@ -5643,7 +5647,7 @@ indentation and initial hashes. Behaves usually outside of comment."
"Face for things which should stand out"))
;;(setq font-lock-constant-face 'font-lock-constant-face)
)
-
+; (cperl-init-faces)
(defun cperl-init-faces ()
(condition-case errs
(progn
@@ -5670,6 +5674,7 @@ indentation and initial hashes. Behaves usually outside of comment."
"unless" "for"
"foreach" "continue" "exit" "die" "last" "goto" "next"
"redo" "return" "local" "exec"
+ "class" "role" "with" "extends"
"do" "dump"
"use" "our"
"require" "package" "eval" "my" "state"
@@ -5755,18 +5760,18 @@ indentation and initial hashes. Behaves usually outside of comment."
;; "AUTOLOAD" "BEGIN" "CHECK" "DESTROY" "END" "INIT" "UNITCHECK" "__END__" "chomp"
;; "break" "chop" "default" "defined" "delete" "do" "each" "else" "elsif"
;; "eval" "exists" "for" "foreach" "format" "given" "goto"
- ;; "grep" "if" "keys" "last" "local" "map" "my" "next"
+ ;; "grep" "has" "if" "keys" "last" "local" "map" "my" "next"
;; "no" "our" "package" "pop" "pos" "print" "printf" "push"
- ;; "q" "qq" "qw" "qx" "redo" "return" "say" "scalar" "shift"
+ ;; "q" "qq" "qw" "qx" "redo" "return" "requires" "say" "scalar" "shift"
;; "sort" "splice" "split" "state" "study" "sub" "tie" "tr"
;; "undef" "unless" "unshift" "untie" "until" "use"
;; "when" "while" "y"
- "AUTOLOAD\\|BEGIN\\|\\(UNIT\\)?CHECK\\|break\\|cho\\(p\\|mp\\)\\|d\\(e\\(f\\(ault|ined\\)\\|lete\\)\\|"
+ "AUTOLOAD\\|BEGIN\\|\\(UNIT\\)?CHECK\\|break\\|cho\\(p\\|mp\\)\\|d\\(e\\(f\\(ault\\|ined\\)\\|lete\\)\\|"
"o\\)\\|DESTROY\\|e\\(ach\\|val\\|xists\\|ls\\(e\\|if\\)\\)\\|"
- "END\\|for\\(\\|each\\|mat\\)\\|g\\(iven\\|rep\\|oto\\)\\|INIT\\|if\\|keys\\|"
+ "END\\|for\\(\\|each\\|mat\\)\\|g\\(iven\\|rep\\|oto\\)\\|INIT\\|has\\|if\\|keys\\|"
"l\\(ast\\|ocal\\)\\|m\\(ap\\|y\\)\\|n\\(ext\\|o\\)\\|our\\|"
"p\\(ackage\\|rint\\(\\|f\\)\\|ush\\|o\\(p\\|s\\)\\)\\|"
- "q\\(\\|q\\|w\\|x\\|r\\)\\|re\\(turn\\|do\\)\\|s\\(ay\\|pli\\(ce\\|t\\)\\|"
+ "q\\(\\|q\\|w\\|x\\|r\\)\\|re\\(turn\\|do\\|quires\\)\\|s\\(ay\\|pli\\(ce\\|t\\)\\|"
"calar\\|t\\(ate\\|udy\\)\\|ub\\|hift\\|ort\\)\\|t\\(r\\|ie\\)\\|"
"u\\(se\\|n\\(shift\\|ti\\(l\\|e\\)\\|def\\|less\\)\\)\\|"
"wh\\(en\\|ile\\)\\|y\\|__\\(END\\|DATA\\)__" ;__DATA__ added manually
@@ -5803,7 +5808,10 @@ indentation and initial hashes. Behaves usually outside of comment."
(if (eq (char-after (cperl-1- (match-end 0))) ?\{ )
'font-lock-function-name-face
'font-lock-variable-name-face))))
- '("\\<\\(package\\|require\\|use\\|import\\|no\\|bootstrap\\)[ \t]+\\([a-zA-z_][a-zA-z_0-9:]*\\)[ \t;]" ; require A if B;
+ ;; XXX: i think this is redundant for the sub-alikes, but
+ ;; it will fix a corner case where the prototype has
+ ;; nested parens in it.
+ '("\\<\\(package\\|require\\|use\\|import\\|no\\|bootstrap\\|class\\|with\\|extends\\|role\\|\\(?:multi \\)?method\\|before\\|after\\|around\\|override\\|augment\\)[ \t]+\\(?:#.+\n\\|[ \t]*\n\\)?[ \t]*\\([a-zA-z_][a-zA-z_0-9:]*\\)\\([ \t;]\\|$\\)" ; require A if B;
2 font-lock-function-name-face)
'("^[ \t]*format[ \t]+\\([a-zA-z_][a-zA-z_0-9:]*\\)[ \t]*=[ \t]*$"
1 font-lock-function-name-face)

0 comments on commit ee93df9

Please sign in to comment.
Something went wrong with that request. Please try again.