* bug#27147: perl-mode print STDERR <<EOF; not colored
@ 2017-05-30 12:22 積丹尼 Dan Jacobson
2019-11-08 1:41 ` Stefan Kangas
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: 積丹尼 Dan Jacobson @ 2017-05-30 12:22 UTC (permalink / raw)
To: 27147
STDERR throws off coloration:
print <<EOF;
ZZZ
EOF
print STDERR <<EOF;
ZZZ
EOF
print <<EOF;
ZZZ
EOF
^ permalink raw reply [flat|nested] 5+ messages in thread
* bug#27147: perl-mode print STDERR <<EOF; not colored
2017-05-30 12:22 bug#27147: perl-mode print STDERR <<EOF; not colored 積丹尼 Dan Jacobson
@ 2019-11-08 1:41 ` Stefan Kangas
2022-10-18 23:21 ` Mauro Aranda
2022-10-20 10:48 ` Mauro Aranda
2 siblings, 0 replies; 5+ messages in thread
From: Stefan Kangas @ 2019-11-08 1:41 UTC (permalink / raw)
To: 積丹尼 Dan Jacobson; +Cc: 27147
found 27147 27.0.50
tags 27147 + confirmed
thanks
積丹尼 Dan Jacobson <jidanni@jidanni.org> writes:
> STDERR throws off coloration:
>
> print <<EOF;
> ZZZ
> EOF
>
> print STDERR <<EOF;
> ZZZ
> EOF
>
> print <<EOF;
> ZZZ
> EOF
I can reproduce this on Emacs 27. The problem is that there are no
colors on the STDERR example given above.
Best regards,
Stefan Kangas
^ permalink raw reply [flat|nested] 5+ messages in thread
* bug#27147: perl-mode print STDERR <<EOF; not colored
2017-05-30 12:22 bug#27147: perl-mode print STDERR <<EOF; not colored 積丹尼 Dan Jacobson
2019-11-08 1:41 ` Stefan Kangas
@ 2022-10-18 23:21 ` Mauro Aranda
2022-10-19 5:57 ` Stefan Kangas
2022-10-20 10:48 ` Mauro Aranda
2 siblings, 1 reply; 5+ messages in thread
From: Mauro Aranda @ 2022-10-18 23:21 UTC (permalink / raw)
To: 27147; +Cc: 積丹尼 Dan Jacobson
[-- Attachment #1: Type: text/plain, Size: 307 bytes --]
tags 27147 patch
quit
積丹尼 Dan Jacobson <jidanni@jidanni.org> writes:
> STDERR throws off coloration:
>
> print <<EOF;
> ZZZ
> EOF
>
> print STDERR <<EOF;
> ZZZ
> EOF
>
> print <<EOF;
> ZZZ
> EOF
I attach a patch to fix this bug and improve HERE documents
identification in perl-mode.
[-- Attachment #2: 0001-Improve-HERE-document-detection-in-perl-mode.patch --]
[-- Type: text/x-patch, Size: 3631 bytes --]
From bbcbb2acdc44dbd219bd989469c1d41ddfe024df Mon Sep 17 00:00:00 2001
From: Mauro Aranda <maurooaranda@gmail.com>
Date: Tue, 18 Oct 2022 19:49:09 -0300
Subject: [PATCH] Improve HERE document detection in perl-mode
* lisp/progmodes/perl-mode.el (perl-syntax-propertize-function):
Detect indented HERE documents when using a bare identifier.
(perl--syntax-exp-intro-keywords): Recognize HERE documents that come
after die, warn and eval.
(perl--syntax-exp-intro-regexp): Identify HERE documents when printing
to a filehandle with printf? and when they appear after a fat comma.
* test/lisp/progmodes/cperl-mode-resources/here-docs.pl: Add more tests.
---
lisp/progmodes/perl-mode.el | 9 ++-
.../cperl-mode-resources/here-docs.pl | 66 +++++++++++++++++++
2 files changed, 73 insertions(+), 2 deletions(-)
diff --git a/lisp/progmodes/perl-mode.el b/lisp/progmodes/perl-mode.el
index 7b7a2cdf01..c5d5d703fc 100644
--- a/lisp/progmodes/perl-mode.el
+++ b/lisp/progmodes/perl-mode.el
@@ -215,11 +215,16 @@ perl-quote-like-pairs
(eval-and-compile
(defconst perl--syntax-exp-intro-keywords
'("split" "if" "unless" "until" "while" "print" "printf"
- "grep" "map" "not" "or" "and" "for" "foreach" "return"))
+ "grep" "map" "not" "or" "and" "for" "foreach" "return" "die"
+ "warn" "eval"))
(defconst perl--syntax-exp-intro-regexp
(concat "\\(?:\\(?:^\\|[^$@&%[:word:]]\\)"
(regexp-opt perl--syntax-exp-intro-keywords)
+ ;; A HERE document as an argument to printf?
+ ;; when printing to a filehandle.
+ "\\|printf?[ \t]*$?[_[:alpha:]][_[:alnum:]]*"
+ "\\|=>"
"\\|[?:.,;|&*=!~({[]"
"\\|[^-+][-+]" ;Bug#42168: `+' is intro but `++' isn't!
"\\|\\(^\\)\\)[ \t\n]*")))
@@ -335,7 +340,7 @@ perl-syntax-propertize-function
"<<\\(~\\)?[ \t]*\\('[^'\n]*'\\|\"[^\"\n]*\"\\|\\\\[[:alpha:]][[:alnum:]]*\\)"
;; The <<EOF case which needs perl--syntax-exp-intro-regexp, to
;; disambiguate with the left-bitshift operator.
- "\\|" perl--syntax-exp-intro-regexp "<<\\(?2:\\sw+\\)\\)"
+ "\\|" perl--syntax-exp-intro-regexp "<<\\(?1:~\\)?\\(?2:\\sw+\\)\\)"
".*\\(\n\\)")
(4 (let* ((eol (match-beginning 4))
(st (get-text-property eol 'syntax-table))
diff --git a/test/lisp/progmodes/cperl-mode-resources/here-docs.pl b/test/lisp/progmodes/cperl-mode-resources/here-docs.pl
index bb3d4871a9..13d879bf76 100644
--- a/test/lisp/progmodes/cperl-mode-resources/here-docs.pl
+++ b/test/lisp/progmodes/cperl-mode-resources/here-docs.pl
@@ -140,4 +140,70 @@ =head2 Test case 6
. 'indent-level'; # Continuation, should be indented
+=head2 Test case 7
+
+An indented HERE document using a bare identifier.
+
+=cut
+
+## test case
+
+$text = <<~HERE;
+look-here
+HERE
+
+$noindent = "New statement in this line";
+
+=head2 Test case 8
+
+A HERE document as an argument to print when printing to a filehandle.
+
+=cut
+
+## test case
+
+print $fh <<~HERE;
+look-here
+HERE
+
+$noindent = "New statement in this line";
+
+=head2 Test case 9
+
+A HERE document as a hash value.
+
+=cut
+
+my %foo = (
+ text => <<~HERE
+look-here
+HERE
+ );
+
+$noindent = "New statement in this line";
+
+=head2 Test case 10
+
+A HERE document as an argument to die.
+
+=cut
+
+1 or die <<HERE;
+look-here
+HERE
+
+$noindent = "New statement in this line";
+
+=head2 Test case 11
+
+A HERE document as an argument to warn.
+
+=cut
+
+1 or warn <<HERE;
+look-here
+HERE
+
+$noindent = "New statement in this line";
+
__END__
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* bug#27147: perl-mode print STDERR <<EOF; not colored
2022-10-18 23:21 ` Mauro Aranda
@ 2022-10-19 5:57 ` Stefan Kangas
0 siblings, 0 replies; 5+ messages in thread
From: Stefan Kangas @ 2022-10-19 5:57 UTC (permalink / raw)
To: Mauro Aranda, 27147; +Cc: 積丹尼 Dan Jacobson
Mauro Aranda <maurooaranda@gmail.com> writes:
> I attach a patch to fix this bug and improve HERE documents
> identification in perl-mode.
LGTM.
^ permalink raw reply [flat|nested] 5+ messages in thread
* bug#27147: perl-mode print STDERR <<EOF; not colored
2017-05-30 12:22 bug#27147: perl-mode print STDERR <<EOF; not colored 積丹尼 Dan Jacobson
2019-11-08 1:41 ` Stefan Kangas
2022-10-18 23:21 ` Mauro Aranda
@ 2022-10-20 10:48 ` Mauro Aranda
2 siblings, 0 replies; 5+ messages in thread
From: Mauro Aranda @ 2022-10-20 10:48 UTC (permalink / raw)
To: Stefan Kangas; +Cc: 27147, 積丹尼 Dan Jacobson
close 27147 29.1
quit
Stefan Kangas <stefankangas@gmail.com> writes:
> Mauro Aranda <maurooaranda@gmail.com> writes:
>
>> I attach a patch to fix this bug and improve HERE documents
>> identification in perl-mode.
>
> LGTM.
Pushed, thanks for taking a look.
Oh, I see I didn't add Bug#27147 to the commit message. I think I lost
it in a git squash or something, sorry.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-10-20 10:48 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-30 12:22 bug#27147: perl-mode print STDERR <<EOF; not colored 積丹尼 Dan Jacobson
2019-11-08 1:41 ` Stefan Kangas
2022-10-18 23:21 ` Mauro Aranda
2022-10-19 5:57 ` Stefan Kangas
2022-10-20 10:48 ` Mauro Aranda
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.