nano-devel
[Top][All Lists]
Advanced

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

Re: [Nano-devel] python syntax: trying to not highlight print( and exec(


From: Benno Schulenberg
Subject: Re: [Nano-devel] python syntax: trying to not highlight print( and exec(
Date: Tue, 18 Sep 2018 18:12:47 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1

Op 18-09-18 om 07:52 schreef Ben Mintz:
> I'm working on a patch which would avoid highlighting the two 
> keywords-turned-functions in python 3. It assumes that print(x) is a function 
> invocation and print (x) is a statement. Here's what I have:
> 
> color brightcyan "\<(exec|print)\>[^\(]"
> 
>  This works fine until you have a line which just contains "print". In python
> 2, this prints a newline.
> 
> How can I get that to be highlighted?

I would suggest:

  color brightcyan "\<(exec|print)([[:blank:]]|$)"

The word "print" must be followed by whitespace or newline.

Of course, print"something" may be valid syntax, but it is
poor style, and I have no problem not coloring things that
are poor style.  Also, print{3} may be valid syntax, but
your regex would color also the opening brace, and probably
you don't want that.

(Also, a "(" is not special inside square brackets, so
a backslash is not needed.  Or do you mean that "print"
should not be highlighted either when followed by "\"?)

Benno

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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