From ripley at stats.ox.ac.uk  Wed Feb 18 05:50:59 2009
From: ripley at stats.ox.ac.uk (Prof Brian Ripley)
Date: Wed, 18 Feb 2009 04:50:59 +0000 (GMT)
Subject: [Rd] C basic indentation
In-Reply-To: <499B3446.1080505@stat.umu.se>
References: <499B3446.1080505@stat.umu.se>
Message-ID: <alpine.LFD.2.00.0902180438060.7442@gannet.stats.ox.ac.uk>

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.

>     ;;; 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}.)


> (ii) How do I get back to a 
> basic indentation of 4 in C and R code?

Follow the above.

>
> G?ran
>
>> sessionInfo()
> R version 2.8.1 Patched (2009-01-03 r47458)
> i686-pc-linux-gnu
>
> locale:
> LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en_US.UTF-8;
> LC_MONETARY=C;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NAME=C;LC_ADDRESS=C;
> LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=C
>
> attached base packages:
> [1] stats     graphics  grDevices utils     datasets  methods   base
>
> GNU Emacs 22.2.1 on Ubuntu 8.10 x64
> -- 
> G?ran Brostr?m               phone: 46 90 786 5223; 46 705 197 507
> Department of Statistics     fax: 46 90 786 6614
> Ume? University              email: gb at stat.umu.se
> SE-90187 Ume?, Sweden        http://tal.stat.umu.se/~gb
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595


[Rd] C basic indentation
Prof Brian Ripley