GNOME Bugzilla – Bug 157370
add syntax highlighting for R scripts
Last modified: 2005-01-11 09:58:45 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.
Created attachment 33435 [details] [review] .lang file for R language
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.
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
Created attachment 35780 [details] Sample R source code file
Created attachment 35781 [details] Another sample R source code file
The release is today. No problem we will include it in the next release (for gnome 2.12).
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 on attachment 35780 [details] Sample R source code file This code is taken from R (www.r-project.org) source code.
Comment on attachment 35781 [details] Another sample R source code file This code is taken from R (www.r-project.org) source code.
Thanks for the patch. I have committed it with minor changes.