Evergreen and ruby symbols (1719/3257/1.6.0_13-b03/Linux 2.6.35.13-weta-20110808/amd64 x2)

2 views
Skip to first unread message

Chris Reece

unread,
Oct 4, 2011, 6:23:59 PM10/4/11
to evergre...@googlegroups.com
Evergreen seems to mis-highlight symbols that resemble keywords. See attached
image, demonstrating highlighting of the "and" portion of ":and". It seems
that I might want to avoid naming symbols after keywords, but this appears to
be valid.

Cheers,

Chris.

--
http://www.jessies.org/~car/

evergreen_and.png

Elliott Hughes

unread,
Oct 4, 2011, 6:47:42 PM10/4/11
to evergre...@googlegroups.com
you'll want to override getKeywordRegularExpression in PRubyTextStyler
to disallow a leading :. see PPhpTextStyler for a similar example
(where $blah is special).

> --
> You received this message because you are subscribed to the Google Groups "evergreen-users" group.
> To post to this group, send email to evergre...@googlegroups.com.
> To unsubscribe from this group, send email to evergreen-use...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/evergreen-users?hl=en.
>
>

--
Elliott Hughes - http://www.jessies.org/~enh/

Chris Reece

unread,
Oct 4, 2011, 7:25:19 PM10/4/11
to evergre...@googlegroups.com, evergre...@googlegroups.com
> you'll want to override getKeywordRegularExpression in PRubyTextStyler
> to disallow a leading :. see PPhpTextStyler for a similar example
> (where $blah is special).

This appears to achieve that end:

car@surfing:~/Projects/salma-hayek$ svn diff
Index: src/e/ptextarea/PRubyTextStyler.java
===================================================================
--- src/e/ptextarea/PRubyTextStyler.java (revision 3257)
+++ src/e/ptextarea/PRubyTextStyler.java (working copy)
@@ -5,6 +5,11 @@
super(textArea);
}

+ @Override protected String getKeywordRegularExpression() {
+ // Ruby symbols begin with a :, and for any keyword k, :k is a valid
identifier.
+ return "\\b(?<!:)([A-Za-z_]+)\\b";
+ }
+
@Override public void initStyleApplicators() {
super.initStyleApplicators();
// An approximate attempt to recognize Ruby regular expression literals.


But it's an almost direct copy of the example from PHP's styler. The : match
part's a gimme, but I'm not confident that the remaining part of the regex
exactly right. It appears to capture all of the keywords... I can commit
this if you're happy, otherwise I'm happy wait until I've got time to dig a
little further.

Cheers,

Chris.

Elliott Hughes

unread,
Oct 4, 2011, 7:46:18 PM10/4/11
to evergre...@googlegroups.com
it looks like what i was expecting to see. what bit are you
uncomfortable about exactly?

Martin Dorey

unread,
Oct 4, 2011, 8:19:51 PM10/4/11
to evergre...@googlegroups.com
I think you should just commit it, Chris, mentioning your uncertainty. In the vanishingly unlikely event that it bites us, we'll know not to blame you.
Reply all
Reply to author
Forward
0 new messages