[ESS] Customizing syntax highlighting

Martin Maechler maechler at stat.math.ethz.ch
Sat Jul 31 20:42:50 CEST 2010


On Sat, Jul 31, 2010 at 09:06, Sven Hartenstein
<lists at svenhartenstein.de> wrote:
> Hi Steve, S. McKay Curtis, and others,
>
> thank you for posting this, I like this improved syntax highlighting a
> lot!
>
> Developers, how about making it the default in ESS?

It's all a matter of what you are used to.
I didn't look at your coloring, but I've always found TINN-R's
coloring excessive.
I'd prefer a scheme where most characters remain uncolored.
But then, I think we agree that this is a matter of taste primarily.

What would be desirable indeed, was to make this easily customizable,
and choosable possibly from a list of more than two options.
For all the long time ESS lovers (like myself), I'd prefer to keep the
many-years default; but then, once we'd have several options one can
easily chose from, we could still have a vote on changing the default
...

Martin

>
> Sven
>
>
> ------- start of forwarded message -------
> From: Steve Lianoglou <mailinglist.honeypot at gmail.com>
> Sender: ess-help-bounces at stat.math.ethz.ch
> To: "S. McKay Curtis" <smcurtis at stat.washington.edu>
> Cc: ESS-help at stat.math.ethz.ch
> Subject: Re: [ESS] Customizing syntax highlighting
> Date: Fri, 23 Jul 2010 12:33:27 -0400
>
> Hi S,
>
> Thanks for sharing this ... I made a small tweak to your regex for
> argument matching:
>
> On Thu, Jul 22, 2010 at 3:40 PM, S. McKay Curtis
> <smcurtis at stat.washington.edu> wrote:
>> Here's code that I added to my .emacs file to beef up the default syntax
>> highlighting.  It doesn't do exactly what you requested, but perhaps you can
>> make it work after playing around with it (I'd be interested to see what you
>> come up with...):
>>
>> (add-hook 'ess-mode-hook
>>  '(lambda()
>>     (font-lock-add-keywords nil
>>     '(("\\<\\(if\\|for\\|function\\|return\\)\\>[\n[:blank:]]*(" 1
>> font-lock-keyword-face) ; must go first to override highlighting below
>>       ("\\<\\([.A-Za-z][._A-Za-z0-9]*\\)[\n[:blank:]]*(" 1
>> font-lock-function-name-face) ; highlight function names
>>       ("[(,][\n[:blank:]]*\\([.A-Za-z][._A-Za-z0-9]*\\)[\n[:blank:]]*==" 1
>> font-lock-reference-face) ;highlight argument names
>>       ))
>>     ))
>
> Your last regex would, imho, erroneously highlight parts of `if`
> clauses, and not highlight the first argument in an argument list that
> continued to the next line. For example, in this function:
>
> test <- function(one=1, two=2,
>                 three=3, four=4, ...) {
>  if (a == 3) {
>
>  }
> }
>
> `three` is not highlighted, but `a` is.
>
> To try and fix this behavior, I changed your last regex to be:
>
>      ("\\([(,]\\|[\n[:blank:]]*\\)\\([.A-Za-z][._A-Za-z0-9]*\\)[\n[:blank:]]*==[^==]"
> 2
>       font-lock-reference-face) ;highlight argument names
>
> Which I think works a bit better, no?
>
> Thought I'd share,
> -steve
>
> --
>
> Steve Lianoglou
> Graduate Student: Computational Systems Biology
>  | Memorial Sloan-Kettering Cancer Center
>  | Weill Medical College of Cornell University
> Contact Info: http://cbio.mskcc.org/~lianos/contact
>
> ______________________________________________
> ESS-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/ess-help
> ------- end of forwarded message -------
>
> ______________________________________________
> 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