* bug#49906: perl-mode: variables that conflict with keywords aren't fontified properly
@ 2021-08-06 3:25 Tomasz Konojacki
2021-08-06 6:37 ` Tomasz Konojacki
0 siblings, 1 reply; 12+ messages in thread
From: Tomasz Konojacki @ 2021-08-06 3:25 UTC (permalink / raw)
To: 49906
For example, "$package" is fontified like a keyword.
^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#49906: perl-mode: variables that conflict with keywords aren't fontified properly
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
0 siblings, 1 reply; 12+ messages in thread
From: Tomasz Konojacki @ 2021-08-06 6:37 UTC (permalink / raw)
To: 49906
[-- Attachment #1: Type: text/plain, Size: 166 bytes --]
On Fri, 06 Aug 2021 05:25:30 +0200
Tomasz Konojacki <me@xenu.pl> wrote:
> For example, "$package" is fontified like a keyword.
The attached patch fixes the problem.
[-- Attachment #2: 0001-perl-mode-fix-variable-fontification.patch --]
[-- Type: application/octet-stream, Size: 2440 bytes --]
From 429f002c619b3d7efd2928dba14cd23e0f381955 Mon Sep 17 00:00:00 2001
From: Tomasz Konojacki <me@xenu.pl>
Date: Fri, 6 Aug 2021 08:34:09 +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".
cl-lib has to be required at runtime, because cl-concatenate isn't a
macro. (bug#49906)
---
lisp/progmodes/perl-mode.el | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/lisp/progmodes/perl-mode.el b/lisp/progmodes/perl-mode.el
index f49ee4cb2b..281f106776 100644
--- a/lisp/progmodes/perl-mode.el
+++ b/lisp/progmodes/perl-mode.el
@@ -87,7 +87,7 @@
;;; Code:
-(eval-when-compile (require 'cl-lib))
+(require 'cl-lib)
(defgroup perl nil
"Major mode for editing Perl code."
@@ -177,7 +177,16 @@
"Subdued level highlighting for Perl mode.")
(defconst perl-font-lock-keywords-2
- (append
+ (cl-concatenate
+ 'list
+ '(;; 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 +197,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
^ permalink raw reply related [flat|nested] 12+ messages in thread
* bug#49906: perl-mode: variables that conflict with keywords aren't fontified properly
2021-08-06 6:37 ` Tomasz Konojacki
@ 2021-08-06 11:00 ` Lars Ingebrigtsen
2021-08-06 12:06 ` Tomasz Konojacki
0 siblings, 1 reply; 12+ messages in thread
From: Lars Ingebrigtsen @ 2021-08-06 11:00 UTC (permalink / raw)
To: Tomasz Konojacki; +Cc: 49906
Tomasz Konojacki <me@xenu.pl> writes:
>> For example, "$package" is fontified like a keyword.
In what context, and in which Emacs version?
$package = foo;
is fontified like a variable in Emacs 28.
> (defconst perl-font-lock-keywords-2
> - (append
> + (cl-concatenate
> + 'list
Any particular reason to change from append to cl-concatenate here?
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#49906: perl-mode: variables that conflict with keywords aren't fontified properly
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
0 siblings, 2 replies; 12+ messages in thread
From: Tomasz Konojacki @ 2021-08-06 12:06 UTC (permalink / raw)
To: 49906
[-- Attachment #1: Type: text/plain, Size: 575 bytes --]
On Fri, 06 Aug 2021 13:00:30 +0200
Lars Ingebrigtsen <larsi@gnus.org> wrote:
> Tomasz Konojacki <me@xenu.pl> writes:
>
> >> For example, "$package" is fontified like a keyword.
>
> In what context, and in which Emacs version?
>
> $package = foo;
>
> is fontified like a variable in Emacs 28.
See the attached screenshot. Are you sure you aren't using cperl-mode?
> > (defconst perl-font-lock-keywords-2
> > - (append
> > + (cl-concatenate
> > + 'list
>
> Any particular reason to change from append to cl-concatenate here?
Because I'm concatenating three lists.
[-- Attachment #2: screenshot.png --]
[-- Type: image/png, Size: 43053 bytes --]
^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#49906: perl-mode: variables that conflict with keywords aren't fontified properly
2021-08-06 12:06 ` Tomasz Konojacki
@ 2021-08-06 12:10 ` Tomasz Konojacki
2021-08-07 9:10 ` Lars Ingebrigtsen
1 sibling, 0 replies; 12+ messages in thread
From: Tomasz Konojacki @ 2021-08-06 12:10 UTC (permalink / raw)
To: 49906
[-- Attachment #1: Type: text/plain, Size: 201 bytes --]
On Fri, 06 Aug 2021 14:06:33 +0200
Tomasz Konojacki <me@xenu.pl> wrote:
> See the attached screenshot. Are you sure you aren't using cperl-mode?
Oops, a corrected screenshot is attached to this post.
[-- Attachment #2: screenshot2.png --]
[-- Type: image/png, Size: 44536 bytes --]
^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#49906: perl-mode: variables that conflict with keywords aren't fontified properly
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
1 sibling, 2 replies; 12+ messages in thread
From: Lars Ingebrigtsen @ 2021-08-07 9:10 UTC (permalink / raw)
To: Tomasz Konojacki; +Cc: 49906
[-- Attachment #1: Type: text/plain, Size: 119 bytes --]
Tomasz Konojacki <me@xenu.pl> writes:
> See the attached screenshot. Are you sure you aren't using cperl-mode?
Yup:
[-- Attachment #2: Type: image/png, Size: 55182 bytes --]
[-- Attachment #3: Type: text/plain, Size: 356 bytes --]
What Emacs version are you using?
>> Any particular reason to change from append to cl-concatenate here?
>
> Because I'm concatenating three lists.
You can concatenate any number of lists with append, so I don't quite
understand what you mean here.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#49906: perl-mode: variables that conflict with keywords aren't fontified properly
2021-08-07 9:10 ` Lars Ingebrigtsen
@ 2021-08-07 9:13 ` Lars Ingebrigtsen
2021-08-07 9:33 ` Tomasz Konojacki
1 sibling, 0 replies; 12+ messages in thread
From: Lars Ingebrigtsen @ 2021-08-07 9:13 UTC (permalink / raw)
To: Tomasz Konojacki; +Cc: 49906
Lars Ingebrigtsen <larsi@gnus.org> writes:
>> See the attached screenshot. Are you sure you aren't using cperl-mode?
>
> Yup:
Oops. That sure wasn't cperl-mode -- it was python mode instead. :-/
Yes, with perl-mode I'm able to reproduce the problem.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#49906: perl-mode: variables that conflict with keywords aren't fontified properly
2021-08-07 9:10 ` Lars Ingebrigtsen
2021-08-07 9:13 ` Lars Ingebrigtsen
@ 2021-08-07 9:33 ` Tomasz Konojacki
2021-08-07 10:37 ` Lars Ingebrigtsen
1 sibling, 1 reply; 12+ messages in thread
From: Tomasz Konojacki @ 2021-08-07 9:33 UTC (permalink / raw)
To: 49906
[-- 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
^ permalink raw reply related [flat|nested] 12+ messages in thread
* bug#49906: perl-mode: variables that conflict with keywords aren't fontified properly
2021-08-07 9:33 ` Tomasz Konojacki
@ 2021-08-07 10:37 ` Lars Ingebrigtsen
2021-08-07 11:09 ` Tomasz Konojacki
0 siblings, 1 reply; 12+ messages in thread
From: Lars Ingebrigtsen @ 2021-08-07 10:37 UTC (permalink / raw)
To: Tomasz Konojacki; +Cc: 49906
Tomasz Konojacki <me@xenu.pl> writes:
> A revised patch is attached.
Thanks; looks good to me (and the test cases seem to work fine), so I've
pushed it to Emacs 28.
This change was small enough to apply without assigning copyright to the
FSF, but for future patches you want to submit, it might make sense to
get the paperwork started now, so that subsequent patches can be applied
speedily. Would you be willing to sign such paperwork?
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#49906: perl-mode: variables that conflict with keywords aren't fontified properly
2021-08-07 10:37 ` Lars Ingebrigtsen
@ 2021-08-07 11:09 ` Tomasz Konojacki
2021-08-07 11:16 ` Lars Ingebrigtsen
0 siblings, 1 reply; 12+ messages in thread
From: Tomasz Konojacki @ 2021-08-07 11:09 UTC (permalink / raw)
To: 49906
On Sat, 07 Aug 2021 12:37:00 +0200
Lars Ingebrigtsen <larsi@gnus.org> wrote:
> This change was small enough to apply without assigning copyright to the
> FSF, but for future patches you want to submit, it might make sense to
> get the paperwork started now, so that subsequent patches can be applied
> speedily. Would you be willing to sign such paperwork?
Sure, I'd appreciate it if you could send me the forms.
^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#49906: perl-mode: variables that conflict with keywords aren't fontified properly
2021-08-07 11:09 ` Tomasz Konojacki
@ 2021-08-07 11:16 ` Lars Ingebrigtsen
2021-08-07 11:33 ` Tomasz Konojacki
0 siblings, 1 reply; 12+ messages in thread
From: Lars Ingebrigtsen @ 2021-08-07 11:16 UTC (permalink / raw)
To: Tomasz Konojacki; +Cc: 49906
Tomasz Konojacki <me@xenu.pl> writes:
> Sure, I'd appreciate it if you could send me the forms.
Great; here's the form to get started:
Please email the following information to assign@gnu.org, and we
will send you the assignment form for your past and future changes.
Please use your full legal name (in ASCII characters) as the subject
line of the message.
----------------------------------------------------------------------
REQUEST: SEND FORM FOR PAST AND FUTURE CHANGES
[What is the name of the program or package you're contributing to?]
Emacs
[Did you copy any files or text written by someone else in these changes?
Even if that material is free software, we need to know about it.]
[Do you have an employer who might have a basis to claim to own
your changes? Do you attend a school which might make such a claim?]
[For the copyright registration, what country are you a citizen of?]
[What year were you born?]
[Please write your email address here.]
[Please write your postal address here.]
[Which files have you changed so far, and which new files have you written
so far?]
^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#49906: perl-mode: variables that conflict with keywords aren't fontified properly
2021-08-07 11:16 ` Lars Ingebrigtsen
@ 2021-08-07 11:33 ` Tomasz Konojacki
0 siblings, 0 replies; 12+ messages in thread
From: Tomasz Konojacki @ 2021-08-07 11:33 UTC (permalink / raw)
To: 49906
On Sat, 07 Aug 2021 13:16:09 +0200
Lars Ingebrigtsen <larsi@gnus.org> wrote:
> Great; here's the form to get started:
>
> Please email the following information to assign@gnu.org, and we
> will send you the assignment form for your past and future changes.
Done, thank you!
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2021-08-07 11:33 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.