unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#30549: 25.2; perl-mode: font lock improvement
@ 2018-02-20 16:19 Evgeni Kolev
  2018-03-03 11:09 ` Eli Zaretskii
  0 siblings, 1 reply; 2+ messages in thread
From: Evgeni Kolev @ 2018-02-20 16:19 UTC (permalink / raw)
  To: 30549

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

I'm reporting an issue with perl-mode's font lock for perl keywords, and
suggesting a fix.

To reproduce:

- emacs -Q
- clear the scratch buffer
- M-x perl-mode
- enter the following text:

    use Fake;
    my $use = 123;
    my $var = 123;

- observe the issue: `$use` is incorrectly highlighted - it should be
highlighted with the same color as `$var`, but it's highlighted with the
same color as `use` (on the first line).

The fix I suggest is borrowed from cperl-mode - extend the font lock regex
to *not* match keywords if they start with a perl sigil.

The diff is below, please let me know if it can be improved. I've signed
the copyright assignment.

From 8d1977cfc6c4884b231270c33c3bdabbd16b14aa Mon Sep 17 00:00:00 2001
From: Evgeni Kolev <evgenysw@gmail.com>
Date: Tue, 20 Feb 2018 18:14:29 +0200
Subject: [PATCH] lisp/progmodes/perl-mode.el: keyword regex must not match
 sigils

---
 lisp/progmodes/perl-mode.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/progmodes/perl-mode.el b/lisp/progmodes/perl-mode.el
index 9948078..c1d94ac 100644
--- a/lisp/progmodes/perl-mode.el
+++ b/lisp/progmodes/perl-mode.el
@@ -165,7 +165,7 @@ perl-font-lock-keywords-1
     ;; Fontify function and package names in declarations.
     ("\\<\\(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.")

--
2.9.0

[-- Attachment #2: Type: text/html, Size: 2340 bytes --]

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* bug#30549: 25.2; perl-mode: font lock improvement
  2018-02-20 16:19 bug#30549: 25.2; perl-mode: font lock improvement Evgeni Kolev
@ 2018-03-03 11:09 ` Eli Zaretskii
  0 siblings, 0 replies; 2+ messages in thread
From: Eli Zaretskii @ 2018-03-03 11:09 UTC (permalink / raw)
  To: Evgeni Kolev; +Cc: 30549-done

> From: Evgeni Kolev <evgeni.d.kolev@gmail.com>
> Date: Tue, 20 Feb 2018 18:19:55 +0200
> 
> I'm reporting an issue with perl-mode's font lock for perl keywords, and
> suggesting a fix.
> 
> To reproduce:
> 
> - emacs -Q
> - clear the scratch buffer
> - M-x perl-mode
> - enter the following text:
> 
>     use Fake;
>     my $use = 123;
>     my $var = 123;
> 
> - observe the issue: `$use` is incorrectly highlighted - it should be
> highlighted with the same color as `$var`, but it's highlighted with the
> same color as `use` (on the first line).
> 
> The fix I suggest is borrowed from cperl-mode - extend the font lock regex
> to *not* match keywords if they start with a perl sigil.

Thanks, pushed to the master branch.

In the future, please accompany your contributions with a Git log
message formatted like ChangeLog, see CONTRIBUTE for the details.





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-03-03 11:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-20 16:19 bug#30549: 25.2; perl-mode: font lock improvement Evgeni Kolev
2018-03-03 11:09 ` Eli Zaretskii

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).