[Rd] C basic indentation
Göran Broström
gb at stat.umu.se
Wed Feb 18 08:45:43 CET 2009
Prof Brian Ripley wrote:
> This seems a question for the ESS-help list.
>
> But you should be using Emacs customization these days: I have in my .emacs
>
> '(c-basic-offset 4)
> '(c-default-style "bsd")
>
> in custom-set-variables, and that is what the 'R Internals' manual says
> for Emacs >= 21. (You can set that from the 'Customize Emacs' menu
> item, Programming, Languages, C group.)
>
>
> On Tue, 17 Feb 2009, Göran Broström wrote:
>
>> I use the recommendations in "R coding standards", i.e., I put
>
> Those are recommendations for Emacs < 21.
IMHO, this is not clear from the text, see below.
>
>> ;;; C
>> (add-hook 'c-mode-hook
>> (lambda () (c-set-style "bsd")))
>> ;;; ESS
>> (add-hook 'ess-mode-hook
>> (lambda ()
>> (ess-set-style 'C++ 'quiet)
>> (add-hook 'local-write-file-hooks
>> (lambda ()
>> (ess-nuke-trailing-whitespace)))))
>> (setq ess-nuke-trailing-whitespace-p 'ask)
>> ;;; Perl
>> (add-hook 'perl-mode-hook
>> (lambda () (setq perl-indent-level 4)))
>>
>> into my .emacs file. IIRC, back in 2005 it gave me a basic indentation
>> of 4 in C (good), but only 2 in R (not so good, but I fixed it with
>> the aid of this excellent list). But now it gives me a basic
>> indentation of eight (8!) in C code. This is not what I want. I think
>> I saw somewhere that the bsd standard actually has changed from four
>> to eight recently (but I cannot find it now).
>
>> Two points given that the standard really has changed: (i) The text in
>> "R coding standards" should be changed accordingly.
>
> It has been (long ago):
>
> Alternatively, (for @acronym{GNU} Emacs 21 or later),
> use customization to set the @code{c-default-style} to @code{"bsd"}
> and @code{c-basic-offset} to @code{4}.)
>
To me, the word "Alternatively" suggests that I can do it either way. My
suggestion was to change this sentence, maybe by simply deleting the
first word.
>
>> (ii) How do I get back to a basic indentation of 4 in C and R code?
>
> Follow the above.
>
Thanks for the help, as usual much appreciated!
Göran
More information about the R-devel
mailing list