Subject: bug#49192: cperl-mode: Syntax highlighting wrong for modifier "for /regex/" (patched)

From: "E. Choroba" <[email-masked]>
Date: Wed, 23 Jun 2021 19:05:59 +0200 (CEST)

The following lines are highlighted correctly:

  print while /./;
  print if /./;

But the following two aren't:

  print for /./;
  print foreach /./;

(In reality, probably only useful with /g).

Patch attached.

Ch.

From 30138fee85f28f6371fe4b726d8a29c839a2fc78 Mon Sep 17 00:00:00 2001
From: "E. Choroba" <[email-masked]>
Date: Wed, 23 Jun 2021 18:57:06 +0200
Subject: [PATCH] cperl-mode: Fix syntax highlighting for a regex after a for
 modifier

The following lines should be highlighted the same:

  print while /a/;
  print if /a/;
  print for /a/;

"for" behaved differently, the regex wasn't highlighted at all.
---
 lisp/progmodes/cperl-mode.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/progmodes/cperl-mode.el b/lisp/progmodes/cperl-mode.el
index fa384bcad6..3370df6491 100644
--- a/lisp/progmodes/cperl-mode.el
+++ b/lisp/progmodes/cperl-mode.el
@@ -3981,7 +3981,7 @@ the sections using `cperl-pod-head-face', `cperl-pod-face',
 					      (not (memq (preceding-char)
 							 '(?$ ?@ ?& ?%)))
 					      (looking-at
-					       "\\(while\\|if\\|unless\\|until\\|and\\|or\\|not\\|xor\\|split\\|grep\\|map\\|print\\|say\\|return\\)\\>"))))
+					       "\\(while\\|if\\|unless\\|until\\|for\\(each\\)?\\|and\\|or\\|not\\|xor\\|split\\|grep\\|map\\|print\\|say\\|return\\)\\>"))))
 				    (and (eq (preceding-char) ?.)
 					 (eq (char-after (- (point) 2)) ?.))
 				    (bobp))
-- 
2.26.2