From bab7a88cb14d9b464f2d976094f46eae46500c0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Harald=20J=C3=B6rg?= Date: Mon, 16 Nov 2020 22:47:31 +0100 Subject: [PATCH] ; cperl-mode, perl-mode: Recognize a regular expression after "return" * lisp/progmodes/perl-mode.el (defconst): Add "return" to 'perl--syntax-exp-intro-keywords' (Bug#26850). * lisp/progmodes/cperl-mode.el (cperl-find-pods-heres): Add "return" to the keywords which start a regex. * test/lisp/progmodes/cperl-mode-tests.el (cperl-test-bug-28650): New test. --- lisp/progmodes/cperl-mode.el | 2 +- lisp/progmodes/perl-mode.el | 2 +- .../cperl-mode-resources/cperl-bug-26850.pl | 16 ++++++++++++++++ test/lisp/progmodes/cperl-mode-tests.el | 15 +++++++++++++++ 4 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 test/lisp/progmodes/cperl-mode-resources/cperl-bug-26850.pl diff --git a/lisp/progmodes/cperl-mode.el b/lisp/progmodes/cperl-mode.el index a42ace105a..0dc45515d4 100644 --- a/lisp/progmodes/cperl-mode.el +++ b/lisp/progmodes/cperl-mode.el @@ -3959,7 +3959,7 @@ cperl-find-pods-heres (not (memq (preceding-char) '(?$ ?@ ?& ?%))) (looking-at - "\\(while\\|if\\|unless\\|until\\|and\\|or\\|not\\|xor\\|split\\|grep\\|map\\|print\\|say\\)\\>"))))) + "\\(while\\|if\\|unless\\|until\\|and\\|or\\|not\\|xor\\|split\\|grep\\|map\\|print\\|say\\|return\\)\\>"))))) (and (eq (preceding-char) ?.) (eq (char-after (- (point) 2)) ?.)) (bobp)) diff --git a/lisp/progmodes/perl-mode.el b/lisp/progmodes/perl-mode.el index 7265aeee45..bb19436cda 100644 --- a/lisp/progmodes/perl-mode.el +++ b/lisp/progmodes/perl-mode.el @@ -209,7 +209,7 @@ perl-quote-like-pairs (eval-and-compile (defconst perl--syntax-exp-intro-keywords '("split" "if" "unless" "until" "while" "print" - "grep" "map" "not" "or" "and" "for" "foreach")) + "grep" "map" "not" "or" "and" "for" "foreach" "return")) (defconst perl--syntax-exp-intro-regexp (concat "\\(?:\\(?:^\\|[^$@&%[:word:]]\\)" diff --git a/test/lisp/progmodes/cperl-mode-resources/cperl-bug-26850.pl b/test/lisp/progmodes/cperl-mode-resources/cperl-bug-26850.pl new file mode 100644 index 0000000000..a02ea29fe9 --- /dev/null +++ b/test/lisp/progmodes/cperl-mode-resources/cperl-bug-26850.pl @@ -0,0 +1,16 @@ +sub interesting { + $_ = shift; + return + />Today is .+\'s birthday\. likes? your comment: / + || /&birthdays=.*birthdays?\.<\/a>/; +} + +sub boring { + return + / likes? your post in