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 157370 - add syntax highlighting for R scripts
add syntax highlighting for R scripts
Status: RESOLVED FIXED
Product: gtksourceview
Classification: Platform
Component: Syntax files
1.0.x
Other All
: Normal enhancement
: ---
Assigned To: GTK Sourceview maintainers
GTK Sourceview maintainers
Depends on:
Blocks:
 
 
Reported: 2004-11-04 17:45 UTC by Vaidotas Zemlys
Modified: 2005-01-11 09:58 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
.lang file for R language (2.05 KB, patch)
2004-11-04 17:46 UTC, Vaidotas Zemlys
needs-work Details | Review
Sample R source code file (10.90 KB, text/plain)
2005-01-10 10:59 UTC, Vaidotas Zemlys
  Details
Another sample R source code file (890 bytes, text/plain)
2005-01-10 11:02 UTC, Vaidotas Zemlys
  Details
Improved .lang file (2.23 KB, patch)
2005-01-11 09:03 UTC, Vaidotas Zemlys
none Details | Review

Description Vaidotas Zemlys 2004-11-04 17:45:30 UTC
R (www.r-project.org) is a language and environment for statistical computing
and graphics. It would be nice to have syntax highlighting for it. I'm attaching
the .lang file.
Comment 1 Vaidotas Zemlys 2004-11-04 17:46:07 UTC
Created attachment 33435 [details] [review]
.lang file for R language
Comment 2 Paolo Maggi 2005-01-07 19:48:40 UTC
Comment on attachment 33435 [details] [review]
.lang file for R language

Sorry for the late reply.
I'd like to add this file to the next release of GtkSourceView.

Here some comments to your file.

><?xml version="1.0" encoding="UTF-8" standalone="yes"?>
><!DOCTYPE language SYSTEM "language.dtd">
><language _name="R" version="1.0" _section="Scripts" mimetypes="text/x-R">

Are you sure about the mime type. 

>  <keyword-list _name="Reserved words" style="Keyword" case-sensitive="TRUE">

What about calling them simply "Keyword".

>    <keyword-list _name="Reserved words 2" style="Data Type" case-sensitive="TRUE">

What about calling them "Data Type"? Or "Type"?

>	<keyword>data.frame</keyword>

I don't think "data.frame" is highlighted in the right way. Have you tested it?

Could you please attach a couple of R files so I can test you R.lang file.
Comment 3 Vaidotas Zemlys 2005-01-10 10:58:28 UTC
Hi,

> Sorry for the late reply.
> I'd like to add this file to the next release of GtkSourceView.

Thanks! When are you planning to release it? 

> Are you sure about the mime type. 
I'm not sure at all.  I filed a bug at freedesktop.org :

https://freedesktop.org/bugzilla/show_bug.cgi?id=1782

and people there suggested that R should provide the mimetype when installed. I
asked about it in r-devel list, but got no response. Maybe it should be
text/x-Rsrc like c source code mimetype? Or maybe it is possible not to use the
mimetype? For example Rkward (http://rkward.sf.net) provides r.xml file for
syntax highlighting in Kate, and it mentions only the extension, leaving
mimetype blank. Does gtksourceview support syntax highlighting depending not
only on file mimetype, but on file extension too?

>  <keyword-list _name="Reserved words" style="Keyword" case-sensitive="TRUE">
>What about calling them simply "Keyword".
>>    <keyword-list _name="Reserved words 2" style="Data Type"  
case-sensitive="TRUE">
> What about calling them "Data Type"? Or "Type"?

Yes it makes sense. I created this file using c language file as model, so I was
more worried about choosing styles, not names. 

>>	<keyword>data.frame</keyword>
> I don't think "data.frame" is highlighted in the right way. Have you tested it?

No, since I tested with my code only, and I rarely use data.frames:) I will test
 it, when I get back home, the computer I'm using now, does not have linux.

> Could you please attach a couple of R files so I can test you R.lang file.
No problem, if you need more R files, you can download R source code from 
http://cran.r-project.org  

Comment 4 Vaidotas Zemlys 2005-01-10 10:59:53 UTC
Created attachment 35780 [details]
Sample R source code file
Comment 5 Vaidotas Zemlys 2005-01-10 11:02:09 UTC
Created attachment 35781 [details]
Another sample R source code file
Comment 6 Paolo Maggi 2005-01-10 22:45:14 UTC
The release is today.
No problem we will include it in the next release (for gnome 2.12).
Comment 7 Vaidotas Zemlys 2005-01-11 09:03:16 UTC
Created attachment 35817 [details] [review]
Improved .lang file

Here is the improved syntax file. I've changed the names according to your
suggestions and R syntax. I've also added more keywords. Now the syntax file is
at sync with vim syntax file, albeit with one improvement (keyword factor
instead of keyword category, as category is deprecated in latest R version 2.0)
Comment 8 Vaidotas Zemlys 2005-01-11 09:04:53 UTC
Comment on attachment 35780 [details]
Sample R source code file

This code is taken from R (www.r-project.org) source code.
Comment 9 Vaidotas Zemlys 2005-01-11 09:05:46 UTC
Comment on attachment 35781 [details]
Another sample R source code file

This code is taken from R (www.r-project.org) source code.
Comment 10 Paolo Maggi 2005-01-11 09:58:45 UTC
Thanks for the patch.
I have committed it with minor changes.