Re: [R] [ESS] Indentation in R code

From: Göran Broström <gb_at_stat.umu.se>
Date: Tue 27 Sep 2005 - 03:05:33 EST

On Mon, Sep 26, 2005 at 09:27:56AM +0200, Martin Maechler wrote:
> I'm crossposting to the ESS-help mailing list which is slightly
> more appropriate here. [This may be a rare case where
> crossposting seems to make much sense.]
>
> >>>>> "PD" == Peter Dalgaard <p.dalgaard@biostat.ku.dk>
> >>>>> on 25 Sep 2005 19:40:45 +0200 writes:
>
> PD> Seth Falcon <sfalcon@fhcrc.org> writes:
>
> >> On 24 Sep 2005, goran.brostrom@gmail.com wrote:
> >>
> >> > I am using emacs-21.3 when writing R functions on Linux debian, and
> >> > I am trying to follow the advice i R-exts.pdf (2.1.1) regarding
> >> > indentation. That is, I set 'c-default-style' to "bsd" and
> >> > 'c-basic-offset' to 4. However, while this gives me the intended
> >> > indentation in C code, it doesn't change the behavior in R code; I
> >> > still get an indentation of size 2. This is my .emacs file after
> >> > customization:
> >> >
> >> > (require 'ess-site)
> >> > (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 "bsd"))
> >> > (custom-set-faces
> >> > ;; custom-set-faces was added by Custom -- don't edit or cut/paste it!
> >> > ;; Your init file should contain only one such instance.
> >> > )
> >>
> >> Not sure if this is the best way, but I have the following after
> >> loading ess-site:
> >>
> >> (setq ess-indent-level 4)
>
>
>
> PD> I have (I believe it stems from Martin M. originally):
>
> yes, most probably {IIRC, Kurt Hornik was involved too}.
>
> PD> (add-hook 'c-mode-hook '(lambda()
> PD> (c-set-style "stroustrup")))
>
> the above is not quite what I have or did recommend,
> which is rather "bsd" + "offset 4" as Göran has above
>
> In fact, Göran mentions the "R-exts" manual and that has
> the following *before* giving the emacs-lisp statements:
>
> >> (For GNU Emacs 20: for GNU Emacs 21 use
> >> customization to set the `c-default-style' to `"bsd"' and
> >> `c-basic-offset' to `4'.)
>
> and indeed, that's what Göran did and you should do with a
> current emacs, either customize via GUI or,
> in your ~/.emacs file, find the section '(custom-set-variables ...)' and add
> '(c-basic-offset 4)
> '(c-default-style "bsd")
>
> to the lines already there, or if there's no such section, add
>
> (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 "bsd")
> )
> to the end of your ~/.emacs file
[...]

but this is not sufficient to get correct (4) indentation (ess) in R functions. We need some reference to ess as well, right? Maybe another reference to the ESS manual is in order in 'R-exts'?

Thanks for all the help. I got it working now.

Göran



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Tue Sep 27 03:18:21 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:40:26 EST