From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Harald =?UTF-8?Q?J=C3=B6rg?= Newsgroups: gmane.emacs.bugs Subject: bug#42168: 26.1; cperl-mode: Bad interpretation of $a++ / $b Date: Thu, 13 Aug 2020 22:40:37 +0200 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------77300BFC19DA6A45DE5492E2" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="26068"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0 To: Stefan Kangas , 42168@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Aug 13 22:42:05 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 1k6K33-0006fz-IZ for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 13 Aug 2020 22:42:05 +0200 Original-Received: from localhost ([::1]:54620 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k6K32-0003wZ-Gq for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 13 Aug 2020 16:42:04 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:40930) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k6K24-0002xy-AM for bug-gnu-emacs@gnu.org; Thu, 13 Aug 2020 16:41:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:39691) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k6K23-0007pS-WF for bug-gnu-emacs@gnu.org; Thu, 13 Aug 2020 16:41:04 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1k6K21-0004WL-TV for bug-gnu-emacs@gnu.org; Thu, 13 Aug 2020 16:41:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Harald =?UTF-8?Q?J=C3=B6rg?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 13 Aug 2020 20:41:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 42168 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: confirmed Original-Received: via spool by 42168-submit@debbugs.gnu.org id=B42168.159735124917351 (code B ref 42168); Thu, 13 Aug 2020 20:41:01 +0000 Original-Received: (at 42168) by debbugs.gnu.org; 13 Aug 2020 20:40:49 +0000 Original-Received: from localhost ([127.0.0.1]:51237 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1k6K1o-0004Vm-K3 for submit@debbugs.gnu.org; Thu, 13 Aug 2020 16:40:48 -0400 Original-Received: from mout01.posteo.de ([185.67.36.65]:35390) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1k6K1l-0004VV-Mq for 42168@debbugs.gnu.org; Thu, 13 Aug 2020 16:40:47 -0400 Original-Received: from submission (posteo.de [89.146.220.130]) by mout01.posteo.de (Postfix) with ESMTPS id 2046E160060 for <42168@debbugs.gnu.org>; Thu, 13 Aug 2020 22:40:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.de; s=2017; t=1597351239; bh=FjEm3oXL2VquugJr67NrAJNvlcdRiImc+iTeGERoUO8=; h=Subject:To:From:Autocrypt:Date:From; b=EKnDptsgy+gDzDYm36rGhEagzP/bmGe7tEL6uQu1JduzrZIa/CdpBByapMaUkcxOK su3NY5iD1BOTnL5b6qMzTikQgQ3r3t9MvfggtUKZnJZaUmJvqJKa4TjuoxQUzFR7uu U9PdoTSVAelV8eFRCpraHSKa4mIV9rk5sIZRPjeOkpCNs616ajdi5WrGxhXMiRJmVi 8a8MRq9Y+pRQ1Jw+l3gTnovMdp88SOw3fX9/IL2NTdtsZyIDlrCt+MNssWL/H2MsmA 8LOmXFaKUnqsJmnpa1J9F5OPbiHqkY+ge2cJTYPwVxuv/ktjP3zTar0UMcIyTxxTxZ ha3UG3fJh/SEA== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4BSJP22tcjz6tmM; Thu, 13 Aug 2020 22:40:38 +0200 (CEST) Autocrypt: addr=haj@posteo.de; keydata= mQINBF0DVrIBEAC7TRlIilBg/5Dx7R2rV4FBDEavbyMT2cS2wWyksh7JA8e17LNmTdakf+Bm u6C2m6+frolteYRlkreoyAg0fj/5tDw/s5dJDw3tM0b+m/pj2HcwTSRpQSEy5lBiCg11E6Mt F9UngCfkGtJzu8PBWXc1RDQVBwRn5MZbpMZZatE8NOq9AA3Yg6sY11Ez3xIvYU2R7a4OSxmc RJV2+dhdQ4oOTBIGQ2urQSU81kyRtkx+/Yh8WefMrk9nF3nzYziLS53euCAXyzklwYmD6Li3 XSu7wYp5fISky9DK6DPFK7h4RXEL4GFAhy31ehrVnNTcGRohM1Dm9BV9dwXkwlaeT3q0X+nE SXVqPDHtv748bXNIg2WVCZ0WgShcA46XVlSE9Fm+w0HI/1m1L4BaMmQ7gyK5dEchbhxohkk0 AqC3hEJ4ULRidrsCoCWGMFKiOIb9rjeC00vhrUkVJDkPWEGLXjhnRQykb6cESko0rPrSDLqX 9YqaNQ6KO9Un6uogE7YnXYg35EXJ8ORdX257IbXNbFVpgM8FFsl48WV3Pl9WNdADhnnOrz3O wzyK58i/BTsnjVX8ghbWkQcPQ2Kprt+4YR2trEi7TM5Uqzzrg0vp7Oe/9KZBxdxCE67thV7h ElW3CHb4q6o31b4cFmLbtFesSy+hnUU4UymgHgi/hvhxioBxIQARAQABtBxIYXJhbGQgSsO2 cmcgPGhhakBwb3N0ZW8uZGU+iQJOBBMBCAA4FiEEIpYEZLQynxF8Q17KN4XzzzqAcpsFAl0D VrICGwMFCwkIBwIGFQgJCgsCBBYCAwECHgECF4AACgkQN In-Reply-To: Content-Language: en-US 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:185069 Archived-At: This is a multi-part message in MIME format. --------------77300BFC19DA6A45DE5492E2 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Hello Stefan, Thank you for your thorough review. I'm rather new to Emacs Lisp, and also to the Emacs development workflows, so this is highly appreciated. Here I've attached a new version of the patch. - Copyright notice is now as it should be (now that the paperwork permits it) - All the stuff you suggested to be removed has been removed - The test has been renamed as suggested In one place I've changed your suggestion: > For now, I think you should simply place the file directly at: > > lisp/progmodes/cperl-mode-tests.el I guess this was meant to read test/lisp/progmodes/cperl-mode-tests.el. Also, I've added a ChangeLog-style attachment, as suggested by Lars Ingebrigtsen in his comment to Bug#42355. -- Cheers, haj --------------77300BFC19DA6A45DE5492E2 Content-Type: text/x-patch; charset=UTF-8; name="postincrement_1.diff" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="postincrement_1.diff" diff --git a/lisp/progmodes/cperl-mode.el b/lisp/progmodes/cperl-mode.el index 6122caf518..2d2713a36a 100644 --- a/lisp/progmodes/cperl-mode.el +++ b/lisp/progmodes/cperl-mode.el @@ -3979,6 +3979,9 @@ cperl-find-pods-heres (and (eq (preceding-char) ?.) (eq (char-after (- (point) 2)) ?.)) (bobp)) + ;; { $a++ / $b } doesn't start a regex, nor does $a-- + (not (and (memq (preceding-char) '(?+ ?-)) + (eq (preceding-char) (char-before (1- (point)))))) ;; m|blah| ? foo : bar; (not (and (eq c ?\?) diff --git a/test/lisp/progmodes/cperl-mode-tests.el b/test/lisp/progmode= s/cperl-mode-tests.el new file mode 100644 index 0000000000..030bdbe3db --- /dev/null +++ b/test/lisp/progmodes/cperl-mode-tests.el @@ -0,0 +1,48 @@ +;;; cperl-mode-tests --- Test for cperl-mode -*- lexical-binding: t -*- + +;; Copyright (C) 2020 Free Software Foundation, Inc. + +;; Author: Harald J=C3=B6rg +;; Maintainer: Harald J=C3=B6rg +;; Keywords: internal +;; Homepage: https://github.com/HaraldJoerg/cperl-mode + +;;; Commentary: + +;; This is a collection of tests for the fontification of CPerl-mode. + +;; Run these tests interactively: +;; (ert-run-tests-interactively '(tag :fontification)) + +;;; Code: + +(defun cperl-test-face (text regexp) + "Returns the face of the first character matched by REGEXP in TEXT." + (interactive) + (with-temp-buffer + (insert text) + (cperl-mode) + (font-lock-fontify-buffer) + (goto-char (point-min)) + (re-search-forward regexp) + (get-text-property (match-beginning 0) 'face))) + +(ert-deftest cperl-mode-test-bug-42168 () + "Verify that '/' is a division after ++ or --, not a regexp. +Reported in https://github.com/jrockway/cperl-mode/issues/45. +If seen as regular expression, then the slash is displayed using +font-lock-constant-face. If seen as a division, then it doesn't +have a face property." + :tags '(:fontification) + ;; The next two Perl expressions have divisions. Perl "punctuation" + ;; operators don't get a face. + (let ((code "{ $a++ / $b }")) + (should (equal (cperl-test-face code "/" ) nil))) + (let ((code "{ $a-- / $b }")) + (should (equal (cperl-test-face code "/" ) nil))) + ;; The next two Perl expressions have regular expressions. The + ;; delimiter of a RE is fontified with font-lock-constant-face. + (let ((code "{ $a+ / $b } # /")) + (should (equal (cperl-test-face code "/" ) font-lock-constant-face))= ) + (let ((code "{ $a- / $b } # /")) + (should (equal (cperl-test-face code "/" ) font-lock-constant-face))= )) --------------77300BFC19DA6A45DE5492E2 Content-Type: text/plain; charset=UTF-8; name="ChangeLog.Bug42168" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="ChangeLog.Bug42168" MjAyMC0wOC0xMyAgSGFyYWxkIErDtnJnICA8aGFqQHBvc3Rlby5kZT4KCgkqIGxpc3AvcHJv Z21vZGVzL2NwZXJsLW1vZGUuZWwgKGNwZXJsLWZpbmQtcG9kcy1oZXJlcyk6IEZpeCAoQnVn IzQyMTY4KQoJUmVjb2duaXplIHskYSsrIC8gJGJ9IGNvcnJlY3RseSBhcyBkaXZpc2lvbi4K CgkqIHRlc3QvbGlzcC9wcm9nbW9kZXMvY3BlcmwtbW9kZS10ZXN0cy5lbDogTmV3IHRlc3Qg dmVyaWZ5aW5nIHRoZSBmaXgKCWZvciAoQnVnIzQyMTY4KS4KCg== --------------77300BFC19DA6A45DE5492E2--