From bolker at ufl.edu  Mon Dec 24 17:38:45 2007
From: bolker at ufl.edu (Ben Bolker)
Date: Mon, 24 Dec 2007 16:38:45 +0000 (UTC)
Subject: [Rd] re quest for addition to R-int
References: <476BE28C.2010203@zoo.ufl.edu>
	<m0abo28wyx.fsf@bar.nemo-project.org>
	<14482966.post@talk.nabble.com>
	<18287.44937.608015.137096@ada-stat.math.ethz.ch>
Message-ID: <loom.20071224T155047-209@post.gmane.org>

Martin Maechler <maechler <at> stat.math.ethz.ch> writes:

> 
> >>>>> "BB" == Ben Bolker <bolker <at> ufl.edu>
> >>>>>     on Sun, 23 Dec 2007 15:31:23 -0800 (PST) writes:
> 
>     BB> Bj?rn-Helge Mevik wrote:
>     >> 
>     >> Ben Bolker wrote:
>     >> 
>     >>> http://cran.r-project.org/doc/manuals/R-ints.html#R-coding-standards
>     >>> 
>     >>> gives detailed advice on how to set the indentation level for
>     >>> C code to 4, but it took me a bit of poking around in the archives
>     >>> to find the
>     >>> 
>     >>> (setq ess-indent-level 4)
>     >>> 
>     >>> incantation for getting the R indentation right as well.
>     >> 
>     >> I'm confused.  Doesn't the suggested code 
>     >> 
>     >> (add-hook 'ess-mode-hook
>     >>  (lambda ()
>     >>   (ess-set-style 'C++)
>     >> ...
>     >> 
>     >> implicitly set ess-indent-level to 4?  At least for me, using the
>     >> suggested code gives indentation steps of 4 in R code.
>     >> 
>     >> -- 
>     >> Bj?rn-Helge Mevik
>     >> 
>     >> ____
>     >> 
> 
>     BB> I guess, but since I was using emacs 21 I followed the
>     BB> instructions to use customization instead -- and I guess
>     BB> the customization steps don't include this hook ?
> 
> I'm confused, too, Ben.
> 
> Why exactly are you not willing to use the above (add-hook ...) ?
> 
> Is this an "unfortunate" wording of the "Writing R Ext.." manual?
> 
> Regards,
> Martin

 The current paragraph says:
   
    It is also important that code is written in a way that allows others to
understand it. This
is particularly helpful for fixing problems, and includes using self-descriptive
variable names,
commenting the code, and also formatting it properly. The R Core Team recommends
to use a
basic indentation of 4 for R and C (and most likely also Perl) code, and 2 for
documentation in
Rd format. Emacs users can implement this indentation style by putting the
following in one
of their startup files. (For GNU Emacs 20: for GNU Emacs 21 or later use
customization to set
the c-default-style to "bsd" and c-basic-offset to 4.)

  [followed by emacs code, including the ESS stuff]

  I read the paragraph above and assumed that I could (and
should) use the customization hooks in Emacs 21 rather than
putting the code in my .emacs file by hand.  In fact, I'm
a little confused; the customization recommended appears to
have set the following ...

(custom-set-variables
  ;; custom-set-variables was added by Custom -- don't edit or cut/paste it!
  ;; Your init file should contain only one such instance.
 '(c-basic-offset 4)
 '(c-default-style (quote ((c-mode . "bsd") (java-mode . "java") (other . "gnu")))))

  which takes care of the C mode stuff but doesn't do anything
for ESS or Perl?

 Perhaps change the last sentence to

  (In GNU Emacs 21 or later one can instead use customization to set
the c-default-style to "bsd" and c-basic-offset to 4, although
the ESS and Perl styles still need to be set manually.)

  ?

  Ben



[Rd] re quest for addition to R-int
Ben Bolker