unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Tomasz Konojacki <me@xenu.pl>
To: 49906@debbugs.gnu.org
Subject: bug#49906: perl-mode: variables that conflict with keywords aren't fontified properly
Date: Sat, 07 Aug 2021 11:33:24 +0200	[thread overview]
Message-ID: <20210807113320.3F63.5C4F47F8@xenu.pl> (raw)
In-Reply-To: <87v94h8vsc.fsf@gnus.org>

[-- Attachment #1: Type: text/plain, Size: 572 bytes --]

On Sat, 07 Aug 2021 11:10:43 +0200
Lars Ingebrigtsen <larsi@gnus.org> wrote:

> You can concatenate any number of lists with append, so I don't quite
> understand what you mean here.

You're right, I was confused. I was under the wrong impression that
append takes only two arguments. It was probably caused by the combination
of reading a tutorial[1] instead of the real documentation and
struggling with unrelated syntax errors. Obviously, I'm an elisp
beginner.

A revised patch is attached.

[1] - https://www.gnu.org/software/emacs/manual/html_node/eintr/append.html

[-- Attachment #2: 0001-perl-mode-fix-variable-fontification.patch --]
[-- Type: application/octet-stream, Size: 2128 bytes --]

From 79e3adb5d2958fbe76a5f03e6fd8fa9e78cb8a42 Mon Sep 17 00:00:00 2001
From: Tomasz Konojacki <me@xenu.pl>
Date: Sat, 7 Aug 2021 11:23:37 +0200
Subject: [PATCH] perl-mode: fix variable fontification

* lisp/progmodes/perl-mode.el: handle variables first to avoid
conflicting with keywords. This fixes cases like "$package".
(bug#49906)
---
 lisp/progmodes/perl-mode.el | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/lisp/progmodes/perl-mode.el b/lisp/progmodes/perl-mode.el
index f49ee4cb2b..4e14c30bc5 100644
--- a/lisp/progmodes/perl-mode.el
+++ b/lisp/progmodes/perl-mode.el
@@ -178,6 +178,14 @@
 
 (defconst perl-font-lock-keywords-2
   (append
+   '(;; Fontify function, variable and file name references. They have to be
+     ;; handled first because they might conflict with keywords.
+     ("&\\(\\sw+\\(::\\sw+\\)*\\)" 1 font-lock-function-name-face)
+     ;; Additionally fontify non-scalar variables.  `perl-non-scalar-variable'
+     ;; will underline them by default.
+     ("[$*]{?\\(\\sw+\\(::\\sw+\\)*\\)" 1 font-lock-variable-name-face)
+     ("\\([@%]\\|\\$#\\)\\(\\sw+\\(::\\sw+\\)*\\)"
+      (2 'perl-non-scalar-variable)))
    perl-font-lock-keywords-1
    `( ;; Fontify keywords, except those fontified otherwise.
      ,(concat "\\<"
@@ -188,15 +196,6 @@
      ;;
      ;; Fontify declarators and prefixes as types.
      ("\\<\\(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)
-     ;; Additionally fontify non-scalar variables.  `perl-non-scalar-variable'
-     ;; will underline them by default.
-     ;;'("[$@%*][#{]?\\(\\sw+\\)" 1 font-lock-variable-name-face)
-     ("[$*]{?\\(\\sw+\\(::\\sw+\\)*\\)" 1 font-lock-variable-name-face)
-     ("\\([@%]\\|\\$#\\)\\(\\sw+\\(::\\sw+\\)*\\)"
-      (2 'perl-non-scalar-variable))
      ("<\\(\\sw+\\)>" 1 font-lock-constant-face)
      ;;
      ;; Fontify keywords with/and labels as we do in `c++-font-lock-keywords'.
-- 
2.27.0.windows.1


  parent reply	other threads:[~2021-08-07  9:33 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-06  3:25 bug#49906: perl-mode: variables that conflict with keywords aren't fontified properly Tomasz Konojacki
2021-08-06  6:37 ` Tomasz Konojacki
2021-08-06 11:00   ` Lars Ingebrigtsen
2021-08-06 12:06     ` Tomasz Konojacki
2021-08-06 12:10       ` Tomasz Konojacki
2021-08-07  9:10       ` Lars Ingebrigtsen
2021-08-07  9:13         ` Lars Ingebrigtsen
2021-08-07  9:33         ` Tomasz Konojacki [this message]
2021-08-07 10:37           ` Lars Ingebrigtsen
2021-08-07 11:09             ` Tomasz Konojacki
2021-08-07 11:16               ` Lars Ingebrigtsen
2021-08-07 11:33                 ` Tomasz Konojacki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210807113320.3F63.5C4F47F8@xenu.pl \
    --to=me@xenu.pl \
    --cc=49906@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).