]> git.eshelyaron.com Git - emacs.git/commitdiff
perl-mode: Recognize "when"/"given" keywords
authorStefan Kangas <stefan@marxist.se>
Mon, 27 Dec 2021 02:07:50 +0000 (03:07 +0100)
committerStefan Kangas <stefan@marxist.se>
Mon, 27 Dec 2021 02:19:25 +0000 (03:19 +0100)
* 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".

lisp/progmodes/perl-mode.el
test/manual/indent/perl.perl

index 20834dd2e1e9bfbdf345400c94fe375241762f03..d4e4f07b76ba1f21360d8fb5cba1caecbe90ce7e 100644 (file)
      ,(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.
 
 (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
index 6ec04303b4f4c362ed6746cadb1f59e550b6c12a..db94552a92899c18712253a4b01d976eab780e96 100755 (executable)
@@ -95,3 +95,15 @@ s#ijk#lmn#g;  # This is a regular expression sustitution.
 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";
+    }
+}