[Geany-Users] <DKIM> Re: How to place comment tags /* ... */ around selection ?
Lex Trotman
elextr at xxxxx
Fri Feb 2 23:33:30 UTC 2018
On 3 February 2018 at 04:24, Colomban Wendling
<lists.ban at herbesfolles.org> wrote:
> Le 02/02/2018 à 02:44, j.dunn at 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 :)
Although it probably shouldn't stop adding a dumb "comment/uncomment
selection" as new menu items, using comment start/stop, that just does
what its told and doesn't try to be smart.
It just needs "somebody" to do it.
Cheers
Lex
>
> Cheers,
> Colomban
> _______________________________________________
> Users mailing list
> Users at lists.geany.org
> https://lists.geany.org/cgi-bin/mailman/listinfo/users
More information about the Users
mailing list