Le 02/02/2018 à 02:44, j.d...@piments.com a écrit :
> On 02/02/18 09:15, Lex Trotman wrote:
>> […]
>>
>> In fact the commenting code does not understand the language at all,
>> it just applies the character sequences configured in the filetype as
>> text, single line comments for preference (after all the menu items
>> are "comment line") or open/close comments as a fallback.
> 
> This seems unnecessarily restrictive.  C has two comment formats :  //
> and /**/  ;  it would be good have a means of using either : presumably
> a secondary hot key.  That could also cover OP's requirement.

Geany will use multi-line comment style (with open and close sequences)
if there's no single-line sequences defined for that filetype.
The reason Geany prefers the single-line comments is that it's a lot
more robust: for example, if in C you try to wrap the following with
multi-line comments:

foo(); /* do something */

it will lead to

/* foo(); /* do something */ */

which is illegal syntax (the comment ends at the first "*/", not the
last one.
This is because C multi-line comments don't nest, and many languages
have the same issue.  However, single-line comments don't have that problem.

An even more interesting example could be

regex_replace(str, ".*/", "");

which would lead to the illegal and even more tricky

/* regex_replace(str, ".*/", ""); */


Also, the same problem applies to commenting a portion of a line,
because you need to use the "/* */" kind and its problems.  So
supporting that, while very nice, would be tricky and very
language-specific, and I can't even think of a perfect solution, as
you'd have to replace the "*/" sequences inside the commented area with
something else, yet restore it on uncommenting.

Anyway, that's a few reflection points :)

Cheers,
Colomban
_______________________________________________
Users mailing list
Users@lists.geany.org
https://lists.geany.org/cgi-bin/mailman/listinfo/users

Reply via email to