[ESS] tip for navigating camelCase
Erik Iverson
eriki at ccbr.umn.edu
Sat Nov 6 02:16:19 CET 2010
Rodney,
Sorry I wasn't more clear. :)
I posted this after reading a couple of R style guides.
As I write more and more R code, I realized that
I really need to be more consistent, so set out to see
what others have come up with.
If anyone here has any further suggestions they use, I'd
love to hear them.
Google has an R style guide:
http://google-styleguide.googlecode.com/svn/trunk/google-r-style.html
Henrik Bengtsson has a draft of his style guide:
http://www1.maths.lth.se/help/R/RCC/
Hadley Wickham has his own style guide:
http://had.co.nz/stat405/resources/r-style-guide.html
Andrew Gelman has some comments on R code style:
http://www.stat.columbia.edu/~cook/movabletype/archives/2007/09/style_guide_for.html
The main R styles I have seen for function names are:
i) separate words with _ (underscore)
Hadley Wickam's style guide says GOOD
Google's R style guide says BAD
ii) separate word with case (camelCase)
Hadley's guide says BAD
Google's guide says GOOD
iii) separate words with .
I don't like this because I don't know if it's
an S3 method or not (e.g., calculate.matrix)
For variable names, Google's guide suggests
using (iii) above, the . method, where Hadley uses
underscores again.
For what it's worth, I've gone with Google's style guide
for the most part.
Hope that explains my rationale for including the
mixed case (aka camel case) discussion as it applies
to R using ESS!
--Erik
On 11/05/2010 04:32 PM, Rodney Sparapani wrote:
> On 11/ 5/10 01:04 PM, Erik Iverson wrote:
>> Hello,
>>
>> Just wanted to point out 2 minor-modes I discovered
>> today that help when navigating source files written
>> with camelCase variables.
>>
>> First, there is glasses-mode, which recognizes
>> camelCase names and optionally
>>
>> i) inserts a separator of your choice (e.g., _)
>> between successive words
>>
>> ii) makes the capital letters in the name a
>> different face (e.g., bold).
>>
>> *Note that the buffer is not actually changed,
>> the characters are inserted using overlays.*
>>
>> To get these, customize the variables
>> glasses-face and glasses-separator. There are
>> other glasses-* variables that may be of interest, too.
>> I set my glasses-separator to "", but use bold for the
>> face so that the capital letters stick out a bit more.
>>
>> The second minor-mode has to do with navigation,
>> not display. It is included in Emacs 23.2 as
>> subword-mode and will cause M-f and M-b to treat
>> camelCase identifiers as separate words, just as
>> if they had been separated with a '.' or '_'. I believe
>> this was called c-subword-mode in previous versions of
>> emacs, but have not tested that.
>>
>> I have both of these modes set for R-mode file via
>> hooks.
>>
>> Thought this might be possibly useful to others.
>>
>> --Erik
>>
>
> I was trying to figure out why Erik posted this since I thought
> he was talking about the camel language which, I think, is a
> descendant of Lisp. But, it's not about that (and it's spelled
> caml by the way). What he is talking about is camel case AKA
> Pascal case and possibly other names. Camel case is popular
> in certain languages like Pascal or certain programming paradigms
> like OS/2 and Windows. It just means that capital letters
> appear in the interior of words like PostScript, QuickTime,
> RealPlayer, etc. It gave me an idea. Maybe eSs or EsS is
> better than ESS :o)
>
> Rodney
>
> ______________________________________________
> 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