Permalink
Browse files

FINALLY highlight "with (Foo::Bar, Baz)" correctly

  • Loading branch information...
1 parent 1536bfb commit 46b4babbac2b32760cca18c9083ff293b4115c59 @jrockway committed Mar 22, 2010
Showing with 17 additions and 1 deletion.
  1. +17 −1 cperl-mode.el
View
@@ -5874,8 +5874,14 @@ indentation and initial hashes. Behaves usually outside of comment."
;; nested parens in it.
'("\\<\\(package\\|require\\|use\\|import\\|no\\|bootstrap\\|class\\|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)
- '("\\<\\(?:with\\|extends\\)[ \t](?\\(?:\\([a-zA-z_][a-zA-z_0-9:]*\\) ?,? ?\\)+)?"
+ '("\\<\\(?:with\\|extends\\)[ \t]\\([a-zA-z_][a-zA-z_0-9:]*\\)"
1 font-lock-function-name-face)
+
+ '("\\<\\(?:with\\|extends\\)[ \t]?("
+ (cperl-next-with-or-extends
+ nil nil
+ (1 font-lock-function-name-face t)))
+
'("^[ \t]*format[ \t]+\\([a-zA-z_][a-zA-z_0-9:]*\\)[ \t]*=[ \t]*$"
1 font-lock-function-name-face)
(cond ((featurep 'font-lock-extra)
@@ -6256,6 +6262,16 @@ indentation and initial hashes. Behaves usually outside of comment."
(setq cperl-faces-init t))
(error (message "cperl-init-faces (ignored): %s" errs))))
+(defun cperl-next-with-or-extends (end)
+ "Find the module names after with or extends.
+
+END is the bound passed by the font-lock machinery."
+ (let ((bound
+ (or (save-match-data
+ (save-excursion ;; don't search past the closing paren
+ (re-search-forward ")" (line-end-position) t)))
+ end)))
+ (re-search-forward "\\([a-zA-Z0-9_:]+\\)[, \t ]*" bound t)))
(defun cperl-ps-print-init ()
"Initialization of `ps-print' components for faces used in CPerl."

0 comments on commit 46b4bab

Please sign in to comment.