[ESS] Font-locking
S. McKay Curtis
smcurtis at stat.washington.edu
Fri Apr 3 06:05:20 CEST 2009
Hi David,
Here's a hack that worked for me. It will require editing the file
"ess-cust.el". I would prefer to have something in my ".emacs" file
to do this rather than editing an actual ess file, but I haven't been
able to get anything to work that way. Maybe somebody else knows
how...
The tricky part to this whole hack was figuring out how to get R to
tell me all of the function names in the base package. You can do
that with the following commands:
base.obj <- objects("package:base",all.names=TRUE)
base.obj[-grep("(^[^.[:alpha:][:digit:]]|<-|__)",base.obj)] ## remove
the "weird" functions (like "%*%") that are already font-locked.
Once I had a list of quoted commands from the R base package (which I
"cleaned" up by using keyboard macros, etc.), I did the following:
1) Open the file ess-cust.el
2) Comment out the lines
(defvar ess-R-keywords
'("while" "for" "in" "repeat" "if" "else" "switch" "break" "next"
"function" "return" "message" "warning" "stop"))
3) Add the following lines to "ess-cust.el"
(defvar ess-R-keywords
'(".Alias" ".ArgsEnv" ".AutoloadEnv" <<THE REST OF THE REALLY LONG
LIST OF QUOTED COMMAND NAMES FROM R GOES HERE>> "xpdrows.data.frame"
"zapsmall"))
Obviously, you'd need to include the whole list of R functions, but
you get the idea.
4) Restart emacs and enjoy.
I'm still hoping somebody will show me a more elegant way, but the way
above works for now.
Regards,
McKay
On Wed, Apr 1, 2009 at 7:46 PM, David Scott <d.scott at auckland.ac.nz> wrote:
>
> I had a request from a student for a more colourful font locking for ESS.
> This is for Emacs on Windows. I imagine one change which the student might
> like would be a different colour for standard functions, which is what
> Tinn-R does.
>
> Does anyone have a customization of this type?
>
> David Scott
>
> _________________________________________________________________
> David Scott Department of Statistics
> The University of Auckland, PB 92019
> Auckland 1142, NEW ZEALAND
> Phone: +64 9 373 7599 ext 85055 Fax: +64 9 373 7018
> Email: d.scott at auckland.ac.nz
>
> Graduate Officer, Department of Statistics
> Director of Consulting, Department of Statistics
>
> ______________________________________________
> ESS-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/ess-help
>
More information about the ESS-help
mailing list