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. It would have been helpful to have it in the R-ints manual section as well ... thanks Ben Bolker -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 252 bytes Desc: OpenPGP digital signature Url : https://stat.ethz.ch/pipermail/r-devel/attachments/20071221/851bc573/attachment.bin
request for addition to R-int
5 messages · Ben Bolker, Bjørn-Helge Mevik, Martin Maechler
1 day later
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
1 day later
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
____
I guess, but since I was using emacs 21 I followed the instructions to use customization instead -- and I guess the customization steps don't include this hook ? Ben
View this message in context: http://www.nabble.com/request-for-addition-to-R-int-tp14457818p14482966.html Sent from the R devel mailing list archive at Nabble.com.
"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
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