[ESS] Indentation level
d.scott at auckland.ac.nz
Wed May 12 11:58:51 CEST 2010
David Scott wrote:
> David Scott wrote:
>> 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:
>>> (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
>>> [.... 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 ()
>> (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
> Oh dear, wrong again. This is only gave me the indentation I wanted
> because the command gave an error.
> David Scott
Not sure if everyone else is using linux but this is on Windows using
Vince Goulet's emacs-23.1-modified, freshly downloaded and installed.
Currently that uses ESS 5.8. I even had available a Windows 7 machine
with a just installed operating system, no existing .emacs. End result
was I could get none of the suggestions from the list to work. The only
way I got what I wanted was to hack ess-custom.el changing the values in
the C++ entry in ess-default-style-list from 4 to 2 throughout. That is
a pretty disgusting hack I know.
I am not sure if the problem is something Vince does in preparing his
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