From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: haj@posteo.de (Harald =?UTF-8?Q?J=C3=B6rg?=) Newsgroups: gmane.emacs.bugs Subject: bug#26850: perl-mode and cperl-mode: Recognize regex after "return" Date: Mon, 16 Nov 2020 23:13:16 +0100 Message-ID: <87k0ulne6b.fsf@hajtower> References: <87ziendku7.fsf@jidanni.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="21169"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) To: 26850@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Nov 16 23:14:23 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kemlS-0005Oq-Tj for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 16 Nov 2020 23:14:23 +0100 Original-Received: from localhost ([::1]:46436 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kemlR-0005a0-KL for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 16 Nov 2020 17:14:21 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:38144) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1keml8-0005Zp-EM for bug-gnu-emacs@gnu.org; Mon, 16 Nov 2020 17:14:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:46056) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1keml8-0005Ar-4w for bug-gnu-emacs@gnu.org; Mon, 16 Nov 2020 17:14:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1keml7-0007de-V0 for bug-gnu-emacs@gnu.org; Mon, 16 Nov 2020 17:14:01 -0500 X-Loop: help-debbugs@gnu.org In-Reply-To: <87ziendku7.fsf@jidanni.org> Resent-From: haj@posteo.de (Harald =?UTF-8?Q?J=C3=B6rg?=) Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 16 Nov 2020 22:14:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 26850 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: confirmed Original-Received: via spool by 26850-submit@debbugs.gnu.org id=B26850.160556481029312 (code B ref 26850); Mon, 16 Nov 2020 22:14:01 +0000 Original-Received: (at 26850) by debbugs.gnu.org; 16 Nov 2020 22:13:30 +0000 Original-Received: from localhost ([127.0.0.1]:57601 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kemkb-0007ch-GC for submit@debbugs.gnu.org; Mon, 16 Nov 2020 17:13:29 -0500 Original-Received: from mout01.posteo.de ([185.67.36.65]:40150) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kemkV-0007cQ-MB for 26850@debbugs.gnu.org; Mon, 16 Nov 2020 17:13:27 -0500 Original-Received: from submission (posteo.de [89.146.220.130]) by mout01.posteo.de (Postfix) with ESMTPS id 4925216005F for <26850@debbugs.gnu.org>; Mon, 16 Nov 2020 23:13:17 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.de; s=2017; t=1605564797; bh=OXge4hPJ18cJrl0pKwbR8vCYNthcoOnDZ4aFXnwOCko=; h=From:To:Subject:Date:From; b=GV2bmcgeluRPTUhg+w7TiHHh+pVbxNw9o+7FWSSbalxpg9uy3057jX6hc6KtLVLaM TSsNXm768+EzqKiMABbE1QzKKNfOdDOrgfcJq3/QjArStu9OrCMsHBkq4kAeOSEbHI ALIgkEecSV3Ni9IIE7+BMJm9LBCFOdp3PaqHHa0gJi6ouKrSi8SETmeIcBXFJrNFJ9 SFU8k1/uP2HwwmScPF29DMWJRrcaFwZlIBImMQffCalJg60x967789fVkGQMnxUAex j5EiRgiLAcsSWz90FRhhusnf3Q7HBcYHITbcDmsqDioYUcJS54LuMDpDczoUGzgBT6 /mlo2bKUeS/vA== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4CZjy4549Qz9rxH for <26850@debbugs.gnu.org>; Mon, 16 Nov 2020 23:13:16 +0100 (CET) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:193489 Archived-At: --=-=-= Content-Type: text/plain merge 26850 26745 thanks I don't know whether I have the authority to merge bugs, but they clearly are the same issue, so I'll just give it a try. The apostrophe, as mentioned in the subject of Bug#26850, is irrelevant: The actual problem in both reports is the failure to recognize a regular expression after the keyword "return". The apostrophe just changes the interpretation of the text which follows. There are several workarounds: You could, for example, explicitly write the regexes as $_ =~ /.../; ... but of course, why would you do that, since $_ is superfluous. Alternatively, you could just omit the "return", which is also superfluous in the examples provided. Nevertheless, the patch fixes the issue, which happens in both perl-mode and cperl-mode. I guess that in neither mode the list of keywords which precede a regex is actually complete, but "return" is a use case relevant enough to be fixed. -- Cheers, haj --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-cperl-mode-perl-mode-Recognize-a-regular-expression-.patch Content-Description: Recognize regex after "return" >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