From unknown Thu Jun 19 12:39:20 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#47112 <47112@debbugs.gnu.org> To: bug#47112 <47112@debbugs.gnu.org> Subject: Status: cperl-mode: Wrong highlighting of tr, y, q with _ Reply-To: bug#47112 <47112@debbugs.gnu.org> Date: Thu, 19 Jun 2025 19:39:20 +0000 retitle 47112 cperl-mode: Wrong highlighting of tr, y, q with _ reassign 47112 emacs submitter 47112 "E. Choroba" severity 47112 normal tag 47112 fixed thanks From debbugs-submit-bounces@debbugs.gnu.org Fri Mar 12 15:32:27 2021 Received: (at submit) by debbugs.gnu.org; 12 Mar 2021 20:32:27 +0000 Received: from localhost ([127.0.0.1]:58505 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lKoSQ-0001bp-Vc for submit@debbugs.gnu.org; Fri, 12 Mar 2021 15:32:27 -0500 Received: from lists.gnu.org ([209.51.188.17]:50804) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lKoSP-0001bh-IV for submit@debbugs.gnu.org; Fri, 12 Mar 2021 15:32:25 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:54156) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lKoSP-0007Xo-9r for bug-gnu-emacs@gnu.org; Fri, 12 Mar 2021 15:32:25 -0500 Received: from ufal-mail.mff.cuni.cz ([195.113.20.158]:46474) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lKoSI-0000HG-8C for bug-gnu-emacs@gnu.org; Fri, 12 Mar 2021 15:32:25 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by ufal-mail.mff.cuni.cz (Postfix) with ESMTP id 44F5A735579 for ; Fri, 12 Mar 2021 21:32:06 +0100 (CET) Received: from ufal-mail.mff.cuni.cz ([127.0.0.1]) by localhost (ufal-mail.mff.cuni.cz [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id jZm4i-2q-im9 for ; Fri, 12 Mar 2021 21:32:06 +0100 (CET) Received: from localhost (localhost.localdomain [127.0.0.1]) by ufal-mail.mff.cuni.cz (Postfix) with ESMTP id 3B835735578 for ; Fri, 12 Mar 2021 21:32:06 +0100 (CET) X-Virus-Scanned: amavisd-new at ufal.mff.cuni.cz Received: from ufal-mail.mff.cuni.cz ([127.0.0.1]) by localhost (ufal-mail.mff.cuni.cz [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id e1Yfr4QrjsaU for ; Fri, 12 Mar 2021 21:32:06 +0100 (CET) Received: from [192.168.0.200] (83-101-243-80.cust.centrio.cz [80.243.101.83]) by ufal-mail.mff.cuni.cz (Postfix) with ESMTPSA id 0909E7365C7 for ; Fri, 12 Mar 2021 21:32:05 +0100 (CET) Date: Fri, 12 Mar 2021 21:31:54 +0100 (CET) From: "E. Choroba" X-X-Sender: choroba@silent To: bug-gnu-emacs@gnu.org Subject: cperl-mode: Wrong highlighting of tr, y, q with _ Message-ID: User-Agent: Alpine 2.21 (LSU 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset=US-ASCII Received-SPF: none client-ip=195.113.20.158; envelope-from=choroba@matfyz.cz; helo=ufal-mail.mff.cuni.cz X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) The quote-like operators q, qq, qr, qw, qx, tr, y, m, and s can use word characters as quoting characters, but then they must be followed by whitespace. In Perl, "_" is also a word character, but cperl-mode doesn't follow this rule. E.g. sub y_max { is highlighted as if the y was the transliteration operator, but in fact "y_max" is a subroutine name, as there's no space after "y". Ch. From debbugs-submit-bounces@debbugs.gnu.org Fri Mar 12 19:27:27 2021 Received: (at 47112) by debbugs.gnu.org; 13 Mar 2021 00:27:27 +0000 Received: from localhost ([127.0.0.1]:58691 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lKs7r-00010S-5E for submit@debbugs.gnu.org; Fri, 12 Mar 2021 19:27:27 -0500 Received: from mout02.posteo.de ([185.67.36.66]:41171) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lKs7o-00010B-9O for 47112@debbugs.gnu.org; Fri, 12 Mar 2021 19:27:25 -0500 Received: from submission (posteo.de [89.146.220.130]) by mout02.posteo.de (Postfix) with ESMTPS id 711682400FB for <47112@debbugs.gnu.org>; Sat, 13 Mar 2021 01:27:17 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.de; s=2017; t=1615595237; bh=H2zhqhJfWiD4I7zxUegMjIAhIBu4J1Xwvq+se3t7uF0=; h=From:To:Subject:Date:From; b=YSoJr2fLMRptjCi/Rdeb/6b0vJg1uV/W4lRV/Bnjdzlu2snlYW6BWcVbKoLD9xAvd xzPtPdCSwHcNM2JEmJtMZvT1WkrHQVtNR/mt7QPyNt05+u1WKCajdqqJ3nOxhTliU7 XRGXHWB1l8ZZHWrjU5bjBIoPk27h0ho+LJq9nDh10Jl8++ytVkitFX6ZeXShVfFRb6 RyBMG+qiNIvxcUXsYwXavtCRtYsBM/v3ExjNP26qhxzKS+FsyrJZf6WnFFuzwcvPfe Ao8NfjGPv7eIMfKtm6NqyrUA+HdecEFcnPcSfYBBGMjZqcj836hpFcgin8joOJQBRG WeNbj4OretWHQ== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4Dy3R85xR1z9rxK for <47112@debbugs.gnu.org>; Sat, 13 Mar 2021 01:27:16 +0100 (CET) From: haj@posteo.de (Harald =?utf-8?Q?J=C3=B6rg?=) To: 47112@debbugs.gnu.org Subject: Don't interpret '_' as word boundary [PATCH] User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) Date: Sat, 13 Mar 2021 01:27:16 +0100 Message-ID: <87a6r7dhjv.fsf@hajtower> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 47112 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) --=-=-= Content-Type: text/plain This is a border case which affects several dark corners in CPerl mode. Per default, the '_' character is not a word character, but a symbol character in Perl. The bogus regexp in `cperl-find-pods-heres' checks the quote-like things for "ending in a word boundary". Per default there _is_ a word boundary between 'y' and '_', and from here it goes downward. It is wrong to change the search pattern to "symbol boundary" instead of "word boundary": The ':' character is also a symbol in CPerl mode and the regexp would then miss q:string: constructs. The patch is a small change to eliminate the false detection of quote constructs by yet another special case, plus some tests. -- Cheers, haj --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-cperl-mode-Don-t-interpret-y_-as-start-of-y-function.patch Content-Description: cperl-mode: No word boundary in "y_" >From c68e15dc4bfceb6e084645f987fc401edb87f7d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Harald=20J=C3=B6rg?= Date: Sat, 13 Mar 2021 00:57:30 +0100 Subject: [PATCH] ; cperl-mode: Don't interpret y_ as start of y// function. * lisp/progmodes/cperl-mode.el (cperl-find-pods-heres): Avoid treating underscores as word-terminators. * test/lisp/progmodes/cperl-mode-tests.el (cperl-test-bug-47112): Test case for that bug. --- lisp/progmodes/cperl-mode.el | 33 ++++++++++++++----------- test/lisp/progmodes/cperl-mode-tests.el | 26 +++++++++++++++++++ 2 files changed, 44 insertions(+), 15 deletions(-) diff --git a/lisp/progmodes/cperl-mode.el b/lisp/progmodes/cperl-mode.el index 734797b3ad..7e7327d986 100644 --- a/lisp/progmodes/cperl-mode.el +++ b/lisp/progmodes/cperl-mode.el @@ -3926,21 +3926,24 @@ cperl-find-pods-heres bb (char-after (1- (match-beginning b1))) ; tmp holder ;; bb == "Not a stringy" bb (if (eq b1 10) ; user variables/whatever - (and (memq bb (append "$@%*#_:-&>" nil)) ; $#y) - (cond ((eq bb ?-) (eq c ?s)) ; -s file test - ((eq bb ?\:) ; $opt::s - (eq (char-after - (- (match-beginning b1) 2)) - ?\:)) - ((eq bb ?\>) ; $foo->s - (eq (char-after - (- (match-beginning b1) 2)) - ?\-)) - ((eq bb ?\&) - (not (eq (char-after ; &&m/blah/ - (- (match-beginning b1) 2)) - ?\&))) - (t t))) + (or + ; false positive: "y_" has no word boundary + (save-match-data (looking-at "_")) + (and (memq bb (append "$@%*#_:-&>" nil)) ; $#y) + (cond ((eq bb ?-) (eq c ?s)) ; -s file test + ((eq bb ?\:) ; $opt::s + (eq (char-after + (- (match-beginning b1) 2)) + ?\:)) + ((eq bb ?\>) ; $foo->s + (eq (char-after + (- (match-beginning b1) 2)) + ?\-)) + ((eq bb ?\&) + (not (eq (char-after ; &&m/blah/ + (- (match-beginning b1) 2)) + ?\&))) + (t t)))) ;; or <$file> (and (eq c ?\<) ;; Do not stringify , <$fh> : diff --git a/test/lisp/progmodes/cperl-mode-tests.el b/test/lisp/progmodes/cperl-mode-tests.el index 61e4ece49b..f0e15022d0 100644 --- a/test/lisp/progmodes/cperl-mode-tests.el +++ b/test/lisp/progmodes/cperl-mode-tests.el @@ -447,4 +447,30 @@ cperl-test-bug-45255 ;; The yadda-yadda operator should not be in a string. (should (equal (nth 8 (cperl-test-ppss code "\\.")) nil)))) +(ert-deftest cperl-test-bug-47112 () + "Check that in a bareword starting with a quote-like operator +followed by an underscore is not interpreted as that quote-like +operator. Also check that a quote-like operator followed by a +colon (which is, like ?_, a symbol in CPerl mode) _is_ identified +as that quote like operator." + (with-temp-buffer + (funcall cperl-test-mode) + (insert "sub y_max { q:bar:; y _bar_foo_; }") + (goto-char (point-min)) + (cperl-update-syntaxification (point-max)) + (font-lock-fontify-buffer) + (search-forward "max") + (should (equal (get-text-property (match-beginning 0) 'face) + 'font-lock-function-name-face)) + (search-forward "bar") + (should (equal (get-text-property (match-beginning 0) 'face) + 'font-lock-string-face)) + ; perl-mode doesn't highlight + (when (eq cperl-test-mode #'cperl-mode) + (search-forward "_") + (should (equal (get-text-property (match-beginning 0) 'face) + (if (eq cperl-test-mode #'cperl-mode) + 'font-lock-constant-face + font-lock-string-face)))))) + ;;; cperl-mode-tests.el ends here -- 2.20.1 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Thu Mar 18 03:06:50 2021 Received: (at 47112) by debbugs.gnu.org; 18 Mar 2021 07:06:50 +0000 Received: from localhost ([127.0.0.1]:44805 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lMmk5-0002HQ-Vv for submit@debbugs.gnu.org; Thu, 18 Mar 2021 03:06:50 -0400 Received: from quimby.gnus.org ([95.216.78.240]:39968) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lMmk3-0002H9-SL for 47112@debbugs.gnu.org; Thu, 18 Mar 2021 03:06:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID :In-Reply-To:Date:References:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=emQmeR9G8aQKRa5A2DfyDu3iroGKxw34bLAlVHioqos=; b=TMGmx72/Ifl656j1YKa6cHsaHN CPlQ++vQmajItS2oVqqXS12TTcEA8jSYsXwH0slgsWvX2/0YIggdoZWIRmFZkB8wP4Zn4SSO0q/Bj ickGwwPDgv+Kh1WeeIpBMub/mkIlAorrEY5hNo0vhMwsarQRn7+XbgR1YKhM8Z882aY8=; Received: from cm-84.212.220.105.getinternet.no ([84.212.220.105] helo=xo) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lMmjn-0000rB-SR; Thu, 18 Mar 2021 08:06:41 +0100 From: Lars Ingebrigtsen To: haj@posteo.de (Harald =?utf-8?Q?J=C3=B6rg?=) Subject: Re: bug#47112: cperl-mode: Wrong highlighting of tr, y, q with _ References: <87a6r7dhjv.fsf@hajtower> X-Now-Playing: Prince's _Sign 'O' the Times (5): Vault Tracks II_: "Train" Date: Thu, 18 Mar 2021 08:06:30 +0100 In-Reply-To: <87a6r7dhjv.fsf@hajtower> ("Harald =?utf-8?Q?J=C3=B6rg=22's?= message of "Sat, 13 Mar 2021 01:27:16 +0100") Message-ID: <87zgz1q6tl.fsf_-_@gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: haj@posteo.de (Harald Jörg) writes: > The patch is a small change to eliminate the false detection of > quote constructs by yet another special case, plus some tests. Thanks; applied to Emacs 28. Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 47112 Cc: 47112@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) haj@posteo.de (Harald J=C3=B6rg) writes: > The patch is a small change to eliminate the false detection of > quote constructs by yet another special case, plus some tests. Thanks; applied to Emacs 28. --=20 (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no From debbugs-submit-bounces@debbugs.gnu.org Thu Mar 18 03:06:55 2021 Received: (at control) by debbugs.gnu.org; 18 Mar 2021 07:06:55 +0000 Received: from localhost ([127.0.0.1]:44808 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lMmkB-0002Hk-8a for submit@debbugs.gnu.org; Thu, 18 Mar 2021 03:06:55 -0400 Received: from quimby.gnus.org ([95.216.78.240]:39982) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lMmk9-0002HH-9N for control@debbugs.gnu.org; Thu, 18 Mar 2021 03:06:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Subject:From:To:Message-Id:Date:Sender:Reply-To:Cc: MIME-Version:Content-Type:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=TtB8s/Le+jNYJcHK5wKFymj/fsmBlgs4Ci3iNNsDUkw=; b=HL8L1no+CpnE1Y+Px7JElehdkc k0qa5IIMX+d9RQHvQV+/A+M8mVLptnjMdRb4PnOmFVLfl1O5Ln+lxMPF3zX9eApIDXXZrc42olF4Q COdDwxtnmlabwOCUmbJJw7N7m8veNQRxHBdtXty+DSEXw7SHd0MlF7GTpNoAqZq7WOac=; Received: from cm-84.212.220.105.getinternet.no ([84.212.220.105] helo=xo) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lMmk1-0000rL-Mp for control@debbugs.gnu.org; Thu, 18 Mar 2021 08:06:47 +0100 Date: Thu, 18 Mar 2021 08:06:44 +0100 Message-Id: <87y2elq6t7.fsf@gnus.org> To: control@debbugs.gnu.org From: Lars Ingebrigtsen Subject: control message for bug #47112 X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: tags 47112 fixed close 47112 28.1 quit Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) tags 47112 fixed close 47112 28.1 quit From unknown Thu Jun 19 12:39:20 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Thu, 15 Apr 2021 11:24:06 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator