GNOME Bugzilla – Bug 497376
Improve PHP to handle identifier
Last modified: 2008-08-03 05:37:23 UTC
Please describe the problem: Hi, Currently, PHP lang file does not match identifier such as function, class, methods and properties. Steps to reproduce: 1. Open a PHP file Actual results: All function, class, properties and methods are in black. Expected results: I expect them to be highlighted following the styles scheme. Does this happen every time? Yes Other information: I fixed this, patch comming soon. Gedit rox ! thank you ! Étienne.
Created attachment 99208 [details] [review] Handle identifier and other improvements Hi, So here is the promised patch. I changed a bit the order of contextes in order to better handle array() (wich is a keyword not an identifier). I added two contexts : * 'identifier' for [a-zA-Z0-9-_]+ as specifyied in php documentation * 'brackets' for [\[\]\(\)\{\}] allowing to stylize brackets I added ',' in operators aside to ';'. I filled a changelog entry, but feel free to take the ownership of the changelog. Regards, Étienne.
Disclaimer: I do not know php That said dunno... I am not a fan of "rainbow style" highlighting :) That is I usually think that a keyword like 'if' or 'for' should be highlighted, but the name of a function or of a variable shouldn't, unless it is a special value or a builtin etc. because IMHO it doesn't provide any actual benefit (e.g. if you mispell a builtin can see it is not highlighted, but since function names and vars are named arbitrarily you do not have this benefit). What do other editors do? Does vim highlight functions etc?
Hi, Basically, this modification allow to provide full synthax highlighting like php_highlight function (see http://bersace03.free.fr/pub/GNOME/gtksourceview/php.png and e.g. http://fr3.php.net/manual/en/function.array-merge-recursive.php#71647 ). Emacs does not highlight function nor classes but variable. It also does not highlight php 5 keywords (try, catch, private, …). So this does not help that much. Emacs at least allow to specify a default color (for unmatched string) i didn't find how to for gtksourceview (in def.lang). Note that this is minor since 1/ gtksourceview allow to extends this extremly easily (see http://bersace03.free.fr/pub/GNOME/gtksourceview/) 2/ indentation issues are much more important. Emacs does a far more better job on indenting than gtksourceview/gedit. Regards, Étienne.
I have added the comma and parentheses, but I strongly oppose the idea of highlighting everything. Text Wrangler and Midnight Commander do not highlight everything. Reopen the bug if you strongly oppose my strong opposition. 2008-06-18 Yevgen Muntyan <muntyan@tamu.edu> * gtksourceview/language-specs/php.lang: added parentheses and comma to the operators list. Bug #497376, Étienne Bersac.
Your dislike of "rainbow highlighting" should extend only to the default color scheme. Why do you insist on restricting non-.lang-file-writers to only choosing colors for non-identifiers? Why do you insist on keeping .lang authors from matching identifiers when it best reflects the tokenizing that the language itself does?
(In reply to comment #5) > Your dislike of "rainbow highlighting" should extend only to the default color > scheme. Will mapping the style to nothing be okay? The patch mapped it to def:identifier, and that means the default color scheme users are affected. > Why do you insist on restricting non-.lang-file-writers to only > choosing colors for non-identifiers? Why do you insist on keeping .lang > authors from matching identifiers when it best reflects the tokenizing that the > language itself does? Oh please, I eat kittens too. See comment #4, the part about reopening the bug.
(In reply to comment #6) > (In reply to comment #5) > > Your dislike of "rainbow highlighting" should extend only to the default color > > scheme. > > Will mapping the style to nothing be okay? The patch mapped it to > def:identifier, and that means the default color scheme users are affected. > Yes. Mapping the style to no coloring is great. It keeps the default user out of rainbow-land but also allows users who want more colors to also get what they want, as well allowing tokenization strategies that grab whole identifiers.
Created attachment 115763 [details] picture New identifier context with bold blue style (default is none).
2008-08-02 Yevgen Muntyan <muntyan@tamu.edu> * gtksourceview/language-specs/php.lang: added 'identifier' context, bug #497376.