nano-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Nano-devel] [PATCH] syntax: perl: don't color the character after a


From: Benno Schulenberg
Subject: Re: [Nano-devel] [PATCH] syntax: perl: don't color the character after a variable name
Date: Thu, 8 Aug 2019 20:11:43 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0

Op 08-08-19 om 09:35 schreef Brand Huntsman:
> Yes, but the punctuation set and "\^[][A-Z^_?\]" are also valid inside braces.
> I tested it.
> 
> no braces = digits | ident | punct | \^[][A-Z^_?\] braces = digits | \^?ident
> | punct | \^[][A-Z^_?\]

Okay.  I've done that in the upcoming patch, but in a different order:

  identifier | digits| leading_caret | punctuation

> A new issue: https://perldoc.perl.org/perlref.html#Using-References
> 
> That $ after the 5 sigils is probably related to this. The braces can contain
> any valid variable ${$var} and even expressions ${$var{"key"}}. I don't know
> if we should handle any of those cases.

I don't think so.  We're overdoing it already, because nobody is using
nano to edit Perl scripts.  If there were, we'd have had a report about
the highlighting of a trailing character a long time ago.

> /^$FOO*$/ /^($FOO)*$/
> 
> The final *$/ is highlighted as a variable.

Yeah, the $ being an often-used anchor in regexes and a sigil in Perl
is giving a bunch of false positives.  In e2fs' wordwrap.pl script:

  next if (/^$/);     # skip blank lines

The $/ gets highlighted as if it were a variable.  :|

And (shortened):

  $word =~ s#\$\(srcdir\)#\$\(top_srcdir\)#;

The $\ gets colored as if were a variable.

Dropping \ and / from the punctuation set would prevent these particular
miscolorings.  Or... we could, as vim, color "find" (/.+/) and "substitution"
(s(.).*\1.*\1) expressions after coloring variable names.  But that will
probably cause new problems.

> Maybe we shouldn't highlight * sigils?

I've dropped it in the upcoming second version of the patch.

Benno

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]