[ESS] Indentation level
David Scott
d.scott at auckland.ac.nz
Wed May 12 06:02:40 CEST 2010
Martin Maechler wrote:
> On Tue, May 11, 2010 at 16:32, Rodney Sparapani <rsparapa at mcw.edu> wrote:
>
>> On 05/11/10 09:11 AM, gerald.jean at dgag.ca wrote:
>>
>>> for me the default is 4 as well and setting it in whatever fashion has not
>>> effect on the local buffer.
>>>
>>> ess-indent-level is a variable defined in `ess-custom.el'.
>>> Its value is 4
>>> Local in buffer DataPrep.q; global value is 2
>>>
>>> I setted it as recommanded by Rich and yes, I restarted Emacs.
>>>
>>> Gérald Jean
>>>
>>>
>> Hi Gerald:
>>
>> But the sources say 2 and that is what I see as well. AFAICT, it
>> hasn't changed recently either. Is everybody running 5.8?
>>
>
> Yes, the default is definitely 2 and has always been so.
> As R-core, we've set "our default" to 4, and indeed I have been preferring
> that myself;
> but nonetheless, the ESS default has always been 2.
>
> One way to set it to 4 and change other things as well, is using
> what we have had in the "R Internals" (and previously "R Extensions") manual
> for many years;
> e.g. from the Swiss (CH) CRAN mirror:
>
> http://stat.ethz.ch/CRAN/doc/manuals/R-ints.html#R-coding-standards
> (about one page down):
>
> ;;; ESS
> (add-hook 'ess-mode-hook
> (lambda ()
> (ess-set-style 'C++ 'quiet)
> ;; Because
> ;; DEF GNU BSD K&R C++
> ;; ess-indent-level 2 2 8 5 4
> ;; ess-continued-statement-offset 2 2 8 5 4
> ;; ess-brace-offset 0 0 -8 -5 -4
> ;; ess-arg-function-offset 2 4 0 0 0
> ;; ess-expression-offset 4 2 8 5 4
> ;; ess-else-offset 0 0 0 0 0
> ;; ess-close-brace-offset 0 0 0 0
> 0
>
> [.... other recommendatinos omitted here ...]
>
> and as others have said repeatedly on this thread:
> Yes, you should and I think *must* set this via adding to the ess-mode-hook
> BTW: In the above Emacs code, most are comments showing you the diverse
> style settings,
> mentioning indeed that the default ("DEF") is at 2.
>
> Martin Maechler, ETH Zurich
>
OK. I finally got this to work, simple really, only took a few hours of
messing about. Changed C++ to DEF in Martin's code above:
;;; ESS
(add-hook 'ess-mode-hook
(lambda ()
(ess-set-style 'DEF 'quiet)
;; Because
;; DEF GNU BSD K&R C++
;; ess-indent-level 2 2 8 5 4
;; ess-continued-statement-offset 2 2 8 5 4
;; ess-brace-offset 0 0 -8 -5 -4
;; ess-arg-function-offset 2 4 0 0 0
;; ess-expression-offset 4 2 8 5 4
;; ess-else-offset 0 0 0 0 0
;; ess-close-brace-offset 0 0 0 0 0
(add-hook 'local-write-file-hooks
(lambda ()
(ess-nuke-trailing-whitespace)))))
(setq ess-nuke-trailing-whitespace-p 'ask)
;; or even
;; (setq ess-nuke-trailing-whitespace-p t)
;;; Perl
(add-hook 'perl-mode-hook
(lambda () (setq perl-indent-level 4)))
and lo and behold I got the default settings.
Thanks for all advice. Sorry to be obtuse, I just don't get lisp. Maybe
it all stems from my Computer Science lecturer telling me lisp is an
acronym for lots of irritating silly parentheses ...
I do love Emacs + ESS + AUCTeX + RefTex though. Brilliant when it is all
working, so thanks to all contributors.
David Scott
_________________________________________________________________
David Scott Department of Statistics
The University of Auckland, PB 92019
Auckland 1142, NEW ZEALAND
Phone: +64 9 923 5055, or +64 9 373 7599 ext 85055
Email: d.scott at auckland.ac.nz, Fax: +64 9 373 7018
Director of Consulting, Department of Statistics
More information about the ESS-help
mailing list