Skip to content
Prev 13 / 1236 Next

[R-gui] NEdit Highligth patterns for R


        
ernesto> On Fri, 2002-10-11 at 09:00, Philippe Grosjean wrote:
>> 1) It would be interesting to highlight in different colors functions and
    >> arguments... but they can have same name. Example: plot(x, col=2) -argument
    >> 'col' and col(x), function 'col'. For the moment, the only easy way I found
    >> is to define argument followed by = in the dictionnary, like 'col=' for the
    >> argument. However, space is allowed between 'col' and '=', and then the
    >> argument is not correctly coloured. So, I add an automatic correction that
    >> eliminates spaces before a single '=' sign. But now that '=' is also allowed
    >> as asignment, it is problematic: col = 1, with 'col' being the name of a
    >> variable (indeed, col <- 1) is now highlighted as an argument.

Look back through the ancient discussion (i.e. 1992 or so) on
font-locking with Emacs.  There are many good arguments against
turning your editor into "fruit-salad" (hence (X)Emacs provides
options for controling level of coloration/fontification variation). 

    >> 2) Of course, one could statically define the dictionnary with, let's say,
    >> all functions and arguments in the base and recommended packages. I would
    >> prefer a dynamic construction of the dictionnary: when a library is loaded,
    >> terms are added, when it is unloaded, they are eliminated. This is only
    >> possible with a bidirectionnal communication between the editor and the R
    >> calculation kernel. I got this in SciViews but how to do that in Nedit or
    >> other separate script editors?

ESS has been doing this forever, and I'm sure any modern editor with
extensibly scripting in a decent language can or already does this as
well (vim, alpha, etc...).

best,
-tony