nano-devel
[Top][All Lists]
Advanced

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

Re: [Nano-devel] [PATCH V2] syntax: c: change the highlighting of prepro


From: Benno Schulenberg
Subject: Re: [Nano-devel] [PATCH V2] syntax: c: change the highlighting of preprocessor directives
Date: Tue, 2 Apr 2019 19:10:25 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1

Op 02-04-19 om 17:16 schreef Liu Hao:
> 在 2019/4/2 20:46, Benno Schulenberg 写道:
>> +# Preprocessor directives.
>> +color brightcyan 
>> start="^[[:space:]]*#[[:space:]]*(if(n?def)?|elif|warning|error|pragma)\>" 
>> end="(\`|[^\\])$"
>> +color brightcyan 
>> "^[[:space:]]*#[[:space:]]*(define|else|endif|include(_next)?|undef)\>"
> 
> I would suggest moving `define` to the first group. In the so-called
> 'include guards' seen in common headers, which look like follows:
> 
> ```
> #ifndef FOO_H
> #define FOO_H
> 
> #endif
> ```
> 
> , the first `FOO_H` follows `#ifndef`, so it would be colored
> brightcyan; while the second `FOO_H` follows `#define` that only gets
> itself colored, so the very first syntax rule for 'constants' apply,
> which makes it colored `brightred`.  So in this example they would be
> colored differently, ending up in inconsistency.

I wouldn't call it inconsistency, but "jumping into the eye".  The
defines are kind of important, the surrounding conditions less so.
If the defines would be the same color for the whole line, such
guarded defines would just become one big soup, whereas now the
actual defines stand out.  It takes some getting used to, but I
like it.  Just like after an #include follows something in yellow,
after a #define follows something in red.

Also, would you want this whole line to be colored in cyan:
#define FLAGS(flag) flags[((flag) / (sizeof(unsigned) * 8))] ?

Furthermore, if #defines would be in the first group, then the
#undefs would need to be there to.

Benno

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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