From f522a064cf1ec8804fb938886b10bc82650e1a68 Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Mon, 27 Dec 2021 03:07:50 +0100 Subject: [PATCH] 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". --- lisp/progmodes/perl-mode.el | 6 ++++-- test/manual/indent/perl.perl | 12 ++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/lisp/progmodes/perl-mode.el b/lisp/progmodes/perl-mode.el index 20834dd2e1e..d4e4f07b76b 100644 --- a/lisp/progmodes/perl-mode.el +++ b/lisp/progmodes/perl-mode.el @@ -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 diff --git a/test/manual/indent/perl.perl b/test/manual/indent/perl.perl index 6ec04303b4f..db94552a928 100755 --- a/test/manual/indent/perl.perl +++ b/test/manual/indent/perl.perl @@ -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"; + } +} -- 2.39.2