Steve,

Fabulous!  Thanks for passing along the tip.  The fact that the first
argument name after a line break never highlighted with my old .emacs code
has been a minor irritant for a few months now.

Note, I also had to change the "1" following the regexp to a "2" as in

("\\([(,]\\|[\n[:blank:]]*\\)\\([.A-Za-z][._A-Za-z0-9]*\\)[\n[:blank:]]*=[^=]"
2 font-lock-reference-face)

But it works like a charm now.

Thanks again!

McKay



S. McKay Curtis
Postdoctoral Research Associate
University of Washington
Department of Statistics
Box 354320
Seattle, WA 98195-4320
(206) 543-6851


On Fri, Jul 23, 2010 at 9:33 AM, Steve Lianoglou <
mailinglist.honeypot@gmail.com> wrote:

> 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@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
>

	[[alternative HTML version deleted]]

