After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 497376 - Improve PHP to handle identifier
Improve PHP to handle identifier
Status: RESOLVED FIXED
Product: gtksourceview
Classification: Platform
Component: Syntax files
git master
Other All
: Normal normal
: ---
Assigned To: GTK Sourceview maintainers
GTK Sourceview maintainers
Depends on:
Blocks:
 
 
Reported: 2007-11-16 13:40 UTC by Étienne Bersac
Modified: 2008-08-03 05:37 UTC
See Also:
GNOME target: ---
GNOME version: 2.19/2.20


Attachments
Handle identifier and other improvements (2.23 KB, patch)
2007-11-16 13:43 UTC, Étienne Bersac
none Details | Review
picture (42.45 KB, image/png)
2008-08-03 05:36 UTC, Yevgen Muntyan
  Details

Description Étienne Bersac 2007-11-16 13:40:16 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.
Comment 1 Étienne Bersac 2007-11-16 13:43:29 UTC
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.
Comment 2 Paolo Borelli 2007-11-17 14:10:47 UTC
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?
Comment 3 Étienne Bersac 2007-11-20 19:50:44 UTC
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.
Comment 4 Yevgen Muntyan 2008-06-20 05:02:11 UTC
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.
Comment 5 thelema 2008-06-20 14:06:27 UTC
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?
Comment 6 Yevgen Muntyan 2008-06-20 16:30:43 UTC
(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.
Comment 7 thelema 2008-06-21 20:52:37 UTC
(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.
Comment 8 Yevgen Muntyan 2008-08-03 05:36:58 UTC
Created attachment 115763 [details]
picture

New identifier context with bold blue style (default is none).
Comment 9 Yevgen Muntyan 2008-08-03 05:37:23 UTC
2008-08-02  Yevgen Muntyan  <muntyan@tamu.edu>

	* gtksourceview/language-specs/php.lang: added 'identifier'
	context, bug #497376.