From unknown Sat Jun 14 19:19:18 2025 X-Loop: help-debbugs@gnu.org Subject: bug#47345: perl-mode: Fix some regexps for fontification [PATCH] 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: Tue, 23 Mar 2021 14:58:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 47345 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: 47345@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.161651147428246 (code B ref -1); Tue, 23 Mar 2021 14:58:02 +0000 Received: (at submit) by debbugs.gnu.org; 23 Mar 2021 14:57:54 +0000 Received: from localhost ([127.0.0.1]:60953 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lOiTi-0007LV-BE for submit@debbugs.gnu.org; Tue, 23 Mar 2021 10:57:54 -0400 Received: from lists.gnu.org ([209.51.188.17]:46938) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lOiTg-0007LN-51 for submit@debbugs.gnu.org; Tue, 23 Mar 2021 10:57:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54128) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOiTf-0000oL-71 for bug-gnu-emacs@gnu.org; Tue, 23 Mar 2021 10:57:51 -0400 Received: from mout01.posteo.de ([185.67.36.65]:34557) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOiTc-0006ma-BS for bug-gnu-emacs@gnu.org; Tue, 23 Mar 2021 10:57:50 -0400 Received: from submission (posteo.de [89.146.220.130]) by mout01.posteo.de (Postfix) with ESMTPS id 9D93E160068 for ; Tue, 23 Mar 2021 15:57:43 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.de; s=2017; t=1616511463; bh=Zzy+w7BgQXP/QhA4RRsa6c5fiDmfiLoKodnzi3CYPX0=; h=From:To:Subject:Date:From; b=HKU70VnEoOj1D3VIrliXCO6oik66VT1zAx7rOGsI8YCqCh7HFRBo4QRi4jTjJDsKI uxX73FqVgRPDlcFCEkZujqe3RLZ6nRSphBPM4kYROpQ4mh8q40smObcX+k7Aekl88Q ggkyDLzFT36JQ70F0i5fIv+WxZ9ILLlK55glrYCwVQXNoshfRoE+LIOBMU0DQsZEme wmsqRF4F5UnrFRP93F1R5fmJljGg1OmF/dp0GxqS73pkxVjO2kM5Jc/H4Dqu8M0x5I gVCGwOIxX8DPSKyyGEDKdT4GxFBXn5sGv0RKnqJODZxt+hErpaq/JI4gv0TqsVF9ko kqVfmiYPQA3Sg== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4F4ZGt1nwTz6tn4 for ; Tue, 23 Mar 2021 15:57:42 +0100 (CET) From: haj@posteo.de (Harald =?UTF-8?Q?J=C3=B6rg?=) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) Date: Tue, 23 Mar 2021 15:57:36 +0100 Message-ID: <874kh1zzmn.fsf@hajtower> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=185.67.36.65; envelope-from=haj@posteo.de; helo=mout01.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) 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: -2.3 (--) --=-=-= Content-Type: text/plain Severity: minor Following a discussion with Stefan Monnier on the developer list: - In "use Package;" the package name is now captured for fontifying as intended - The declarators "my" etc. now use font-lock-keyword-face for better consistency with other programming modes - As a by-catch, now all components of package names like "Long::Package::Name" are fontified. This was a known issue of little importance, not yet reported as a bug. - A test is included as well. -- Cheers, haj --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-perl-mode-Fix-regexps-for-fontification.patch Content-Description: Perl mode: Fix some regexps for fontification >From 8bb05c1364e59f1ad83c64c7f86735a6d6c0e0cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Harald=20J=C3=B6rg?= Date: Tue, 23 Mar 2021 15:45:51 +0100 Subject: [PATCH] ; perl-mode: Fix regexps for fontification * lisp/progmodes/perl-mode.el (perl-font-lock-keywords-1): pick correct capture groups for "use Pack::Age;" Fontify all components of "Pack::Age", not just "Pack" (perl-font-lock-keywords-2): Use keyword-face for declarators * test/lisp/progmodes/cperl-mode-tests.el (cperl-test-fontify-declarations): New test to ensure consistency between perl-mode.el and cperl-mode.el --- lisp/progmodes/perl-mode.el | 6 +++--- test/lisp/progmodes/cperl-mode-tests.el | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/lisp/progmodes/perl-mode.el b/lisp/progmodes/perl-mode.el index c7fa5ab84b..fd23683bc0 100644 --- a/lisp/progmodes/perl-mode.el +++ b/lisp/progmodes/perl-mode.el @@ -170,9 +170,9 @@ perl-font-lock-keywords-1 ;; (1 font-lock-constant-face) (2 font-lock-variable-name-face nil t)) ;; ;; Fontify function and package names in declarations. - ("\\<\\(package\\|sub\\)\\>[ \t]*\\(\\sw+\\)?" + ("\\<\\(package\\|sub\\)\\>[ \t]*\\(\\(?:\\sw\\|::\\)+\\)?" (1 font-lock-keyword-face) (2 font-lock-function-name-face nil t)) - ("\\(^\\|[^$@%&\\]\\)\\<\\(import\\|no\\|require\\|use\\)\\>[ \t]*\\(\\sw+\\)?" + ("\\(?:^\\|[^$@%&\\]\\)\\<\\(import\\|no\\|require\\|use\\)\\>[ \t]*\\(\\(?:\\sw\\|::\\)+\\)?" (1 font-lock-keyword-face) (2 font-lock-constant-face nil t))) "Subdued level highlighting for Perl mode.") @@ -187,7 +187,7 @@ perl-font-lock-keywords-2 "\\>") ;; ;; Fontify declarators and prefixes as types. - ("\\<\\(has\\|local\\|my\\|our\\|state\\)\\>" . font-lock-type-face) ; declarators + ("\\<\\(has\\|local\\|my\\|our\\|state\\)\\>" . font-lock-keyword-face) ; declarators ;; ;; Fontify function, variable and file name references. ("&\\(\\sw+\\(::\\sw+\\)*\\)" 1 font-lock-function-name-face) diff --git a/test/lisp/progmodes/cperl-mode-tests.el b/test/lisp/progmodes/cperl-mode-tests.el index 8078e9c9fa..14bc48b92f 100644 --- a/test/lisp/progmodes/cperl-mode-tests.el +++ b/test/lisp/progmodes/cperl-mode-tests.el @@ -135,6 +135,25 @@ cperl-test-fontify-punct-vars (should (equal (nth 3 (syntax-ppss)) nil)) (should (equal (nth 4 (syntax-ppss)) t)))))) +(ert-deftest cperl-test-fontify-declarations () + "Test that declarations and package usage use consistent fontification." + (with-temp-buffer + (funcall cperl-test-mode) + (insert "package Foo::Bar;\n") + (insert "use Fee::Fie::Foe::Foo\n;") + (insert "my $xyzzy = 'PLUGH';\n") + (goto-char (point-min)) + (font-lock-ensure) + (search-forward "Bar") + (should (equal (get-text-property (match-beginning 0) 'face) + 'font-lock-function-name-face)) + (search-forward "use") ; This was buggy in perl-mode + (should (equal (get-text-property (match-beginning 0) 'face) + 'font-lock-keyword-face)) + (search-forward "my") + (should (equal (get-text-property (match-beginning 0) 'face) + 'font-lock-keyword-face)))) + (defvar perl-continued-statement-offset) (defvar perl-indent-level) -- 2.20.1 --=-=-=-- From unknown Sat Jun 14 19:19:18 2025 X-Loop: help-debbugs@gnu.org Subject: bug#47345: perl-mode: Fix some regexps for fontification [PATCH] Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 24 Mar 2021 16:07:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 47345 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: haj@posteo.de (Harald =?UTF-8?Q?J=C3=B6rg?=) Cc: 47345@debbugs.gnu.org Received: via spool by 47345-submit@debbugs.gnu.org id=B47345.161660201813260 (code B ref 47345); Wed, 24 Mar 2021 16:07:02 +0000 Received: (at 47345) by debbugs.gnu.org; 24 Mar 2021 16:06:58 +0000 Received: from localhost ([127.0.0.1]:35936 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lP626-0003Rn-MC for submit@debbugs.gnu.org; Wed, 24 Mar 2021 12:06:58 -0400 Received: from quimby.gnus.org ([95.216.78.240]:40922) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lP624-0003RW-Me for 47345@debbugs.gnu.org; Wed, 24 Mar 2021 12:06:57 -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=nhA7g4MuS4Bf3rWeGNPGurwGBqR7dNF71Bs8JN5kHzE=; b=udO22oKWorlFxl4LMae2TspehH r9r2snJ2E9HaM/6xwaPZiMu1U7TrkP9c2sUae54Kpq2T81PU3bHNEprBk2iV0vh8e+lz6BM7Bh0Y/ orhm51nzqj6ofdPD6Z0yF+0jABa6mM7QJhx+in+hTuQc9uITYYE0qqkMvte0c0Xq47VM=; 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 1lP61t-0002MA-1Z; Wed, 24 Mar 2021 17:06:49 +0100 From: Lars Ingebrigtsen References: <874kh1zzmn.fsf@hajtower> X-Now-Playing: Girls's _Reunion_: "Pedestrian Walk" Date: Wed, 24 Mar 2021 17:06:44 +0100 In-Reply-To: <874kh1zzmn.fsf@hajtower> ("Harald =?UTF-8?Q?J=C3=B6rg?="'s message of "Tue, 23 Mar 2021 15:57:36 +0100") Message-ID: <878s6cbkob.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 =?UTF-8?Q?J=C3=B6rg?=) writes: > Following a discussion with Stefan Monnier on the developer list: > > - In "use Package;" the package name is now captured for fontifying > as intended > > - The declarators "my" etc. now use font-l [...] 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-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: > Following a discussion with Stefan Monnier on the developer list: > > - In "use Package;" the package name is now captured for fontifying > as intended > > - The declarators "my" etc. now use font-lock-keyword-face for better > consistency with other programming modes > > - As a by-catch, now all components of package names like > "Long::Package::Name" are fontified. This was a known issue of > little importance, not yet reported as a bug. > > - A test is included as well. Thanks; looks good to me. Pushed now 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 Wed Mar 24 12:07:02 2021 Received: (at control) by debbugs.gnu.org; 24 Mar 2021 16:07:02 +0000 Received: from localhost ([127.0.0.1]:35939 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lP629-0003S8-T4 for submit@debbugs.gnu.org; Wed, 24 Mar 2021 12:07:02 -0400 Received: from quimby.gnus.org ([95.216.78.240]:40936) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lP628-0003Re-Oq for control@debbugs.gnu.org; Wed, 24 Mar 2021 12:07:01 -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=GLMO2XBd2l+bz5lSnualmGp0Ok5Sb8Mx43+yKonkAws=; b=IGKlb8e2DPmW6lRG7Gr/myFsda S85xoMDTehp5SteUyKc/ZMwG/By2RwaDszQaEfYbbHawWUnfWyrtWpYZV1KpibK5xzmoJoddn6t3j emvr+69g8/W6oedTySjG8PdU5VCwzHoi8KZyQ7B6lIMFwuSE9N3+GIjJhCX4YJC+Oa7c=; 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 1lP621-0002MJ-AG for control@debbugs.gnu.org; Wed, 24 Mar 2021 17:06:55 +0100 Date: Wed, 24 Mar 2021 17:06:52 +0100 Message-Id: <877dlwbko3.fsf@gnus.org> To: control@debbugs.gnu.org From: Lars Ingebrigtsen Subject: control message for bug #47345 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 47345 fixed close 47345 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 47345 fixed close 47345 28.1 quit