[ESS-bugs] ess-function-pattern not working for some valid functions

Martin Maechler maechler at stat.math.ethz.ch
Tue Mar 15 15:00:34 CET 2011


Dear Toby,
your attachment did not come through the filters  
     .. -> .. -> ESS-bugs -> ESS-core ->

but interestingly, somewhat simultaneously to your post to
ESS-bugs, there was one to ESS-help
from Keith Ponting.
see the list archive entry
    https://stat.ethz.ch/pipermail/ess-help/2011-March/006764.html
    (and then the attachment in there -- he used HTML in e-mail --)

where he writes

 > However the comments between the function keyword and the opening
 > parenthesis do not match ess-function-pattern. I realise that it is
 > already an extremely complicated regexp, but after a bit of tweaking I
 > found that the following change (which also allows the function argument
 > list opening parenthesis to be on a new line without any intervening
 > comments) appears to work: replace the trailing "function\\s-*(" with
 > "function\\s-*\\(?:\\(?:#.*\\)?\n\\s-*\\)*(". This modification can be
 > done locally in any number of ways (emacs file-local variables,
 > directory-local variables, ess-mode-hook etc.), but I wonder whether I
 > could propose the above as a modification to ESS?

and I haven't much tried his proposition yet, either.

I do know that I had spent too many numerous hours in the past,
fiddling with those regexps,
and the last few improvement attempts all had failed in sofar as
they  fixed one case  but  broke another one.

Have you guys both worked for several days with the *changed*
regexps? (I don't know yet Toby's changes).

Toby, could you show us your patch?

Thank you for your contributions; I'd definitely like to look
into.

Best regards,
Martin

Martin <Maechler at stat.math.ethz.ch>  http://stat.ethz.ch/people/maechler
Seminar für Statistik, ETH Zürich  HG G 16      Rämistrasse 101
CH-8092 Zurich, SWITZERLAND
phone: +41-44-632-3408       fax: ...-1228      <><


>>>>> Toby Dylan Hocking <Toby.Hocking at inria.fr>
>>>>>     on Thu, 10 Mar 2011 15:00:33 +0100 writes:

    > Dear ESS developers,
    > First of all, thank you very much for ESS, a great piece of free
    > software which I use every day!

    > I like using the C-c C-f key sequence to load individual
    > functions into an inferior R process, but I noticed that it
    > doesn't work for some syntactically-valid functions, such as

    > comments.and.ex <- structure(function
    > ### some docs
    > ### more
    > (arg,
    > arg2
    > ){
    > foo
    > ### value
    > },ex=function(){
    > some.code
    > })

    > To solve this problem, I propose a patch to ess-mode.el, which
    > simply updates the regular expression used to match functions.

    > I have attached the patch and some R code that illustrates
    > several example functions which are valid R code, but are not
    > currently matched by ess-function-pattern.

    > Does this patch pose any problem for you guys? Can you
    > incorporate it into the main ESS source code?

    > Thanks for the great package, and for your consideration,
    > Toby Dylan Hocking
    > http://cbio.ensmp.fr/~thocking/


    > ----------------------------------------------------------------------
    > testfun <- function(foo){ bar } testfun <- function (foo){ bar }
    > oneline <- function(foo)bar comments <- function ### some docs
    > ### more (arg, arg2 ){ foo
    > ###
    > }

    > comments.and.ex <- structure(function
    > ### some docs
    > ### more
    > (arg,
    > arg2
    > ){
    > foo
    > ###
    > },ex=function(){
    > some.code
    > })

    > ----------------------------------------------------------------------
    > _______________________________________________ ESS-bugs
    > ESS-bugs at r-project.org
    > https://stat.ethz.ch/mailman/listinfo/ess-bugs

    > ----------------------------------------------------------------------
    > _______________________________________________ ESS-core list:
    > https://stat.ethz.ch/mailman/listinfo/ess-core



More information about the ESS-bugs mailing list