perl-mode: Recognize "when"/"given" keywords
* lisp/progmodes/perl-mode.el (perl-font-lock-keywords-2): Add keywords "when", "given" and "default". (Bug#10560) (perl--syntax-exp-intro-keywords): Add "printf". * test/manual/indent/perl.perl: Add test for "when"/"given".
This commit is contained in:
parent
d9977018e0
commit
f522a064cf
2 changed files with 16 additions and 2 deletions
|
@ -191,7 +191,9 @@
|
|||
,(concat "\\<"
|
||||
(regexp-opt '("if" "until" "while" "elsif" "else" "unless"
|
||||
"do" "dump" "for" "foreach" "exit" "die"
|
||||
"BEGIN" "END" "return" "exec" "eval") t)
|
||||
"BEGIN" "END" "return" "exec" "eval"
|
||||
"when" "given" "default")
|
||||
t)
|
||||
"\\>")
|
||||
;;
|
||||
;; Fontify declarators and prefixes as types.
|
||||
|
@ -212,7 +214,7 @@
|
|||
|
||||
(eval-and-compile
|
||||
(defconst perl--syntax-exp-intro-keywords
|
||||
'("split" "if" "unless" "until" "while" "print"
|
||||
'("split" "if" "unless" "until" "while" "print" "printf"
|
||||
"grep" "map" "not" "or" "and" "for" "foreach" "return"))
|
||||
|
||||
(defconst perl--syntax-exp-intro-regexp
|
||||
|
|
|
@ -95,3 +95,15 @@ END
|
|||
s #lmn#opq#g; # FIXME: this should be a comment starting with "#lmn"
|
||||
/lmn/rst/g; # and this is the actual regular expression
|
||||
print; # prints "rstrst\n"
|
||||
|
||||
given ($num) {
|
||||
when ($num>10) {
|
||||
printf "number is greater than 10\n";
|
||||
}
|
||||
when ($num<10) {
|
||||
printf "number is less than 10\n";
|
||||
}
|
||||
default {
|
||||
printf "number is equal to 10\n";
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue