VDR User | 21 Aug 2011 22:08
Picon

About highlighting..

Hi.  I'm a debian linux user.  I've noticed a 'problem' with
highlight.  I'm not really sure if this is a bug so I didn't file a
bug report.  Further, if I'm posting this to the wrong nano mailing
list, my apologies in advance.

First, is the highlighting supposed to identify functions which have
no closing bracket?  And if so, is it broken?  Is it turned off by
default and would need to be turned on?  And example (bash):

some_function () { echo "this is fine"; }
some_function () { echo "this is NOT fine";

After a lot of changes, I had accidently left out the closing bracket
in a huge bash script.  When I tried to execute it, I got a "syntax
error: unexpected end of file".  Since highlighting (especially syntax
highlighting) should be useful is tracking down the problem, I figured
this issue could be applied to nano.

I did search for more about this particular 'problem' but didn't find
anything helpful so does anyone have an opinion about this?  Shouldn't
a check for properly closed functions be included in the syntax
highlighting in nano?

Best regards,
Derek
alpha | 21 Aug 2011 23:47

Re: About highlighting..

On Sun, 21 Aug 2011 13:08:15 -0700
VDR User <user.vdr <at> gmail.com> wrote:

> First, is the highlighting supposed to identify functions which have
> no closing bracket?  And if so, is it broken?  Is it turned off by
> default and would need to be turned on?  And example (bash):
> 
> some_function () { echo "this is fine"; }
> some_function () { echo "this is NOT fine";

This is not supported by nano's syntax highlighting engine. The rules can only highlight a pattern or
everything between two patterns.

color black,red "[][(){}]"
color yellow start="\[" end="\]"
color yellow start="\(" end="\)"
color yellow start="\{" end="\}"

If you place that at the top of the syntax file and then remove
all brackets from the existing rule you will see that it highlights your sample code just fine and catches
open brackets. The first problem is that it highlights everything between the brackets with the bracket
color. The second problem is that it doesn't work with nested brackets.

foo{ bar{}

It catches the open brackets until you type the final closing bracket, at which point the first opening
bracket matches with the closing bracket and everything in between is highlighted yellow.
VDR User | 22 Aug 2011 00:56
Picon

Re: About highlighting..

On Sun, Aug 21, 2011 at 2:47 PM,  <alpha <at> qzx.com> wrote:
>> First, is the highlighting supposed to identify functions which have
>> no closing bracket?  And if so, is it broken?  Is it turned off by
>> default and would need to be turned on?  And example (bash):
>>
>> some_function () { echo "this is fine"; }
>> some_function () { echo "this is NOT fine";
>
> This is not supported by nano's syntax highlighting engine. The rules can only highlight a pattern or
everything between two patterns.
>
> color black,red "[][(){}]"
> color yellow start="\[" end="\]"
> color yellow start="\(" end="\)"
> color yellow start="\{" end="\}"
>
> If you place that at the top of the syntax file and then remove
> all brackets from the existing rule you will see that it highlights your sample code just fine and catches
open brackets. The first problem is that it highlights everything between the brackets with the bracket
color. The second problem is that it doesn't work with nested brackets.
>
> foo{ bar{}
>
> It catches the open brackets until you type the final closing bracket, at which point the first opening
bracket matches with the closing bracket and everything in between is highlighted yellow.

Hi.  Thanks for your quick reply!  So _should_ nano highlighting
support nested brackets then?  It seems like a completely sane
expectation imo but I wonder if there are any good arguments against
it?
(Continue reading)


Gmane