[ESS] Indentation level

Martin Maechler maechler at stat.math.ethz.ch
Mon May 17 10:38:59 CEST 2010


>>>>> David Scott <d.scott at auckland.ac.nz>
>>>>>     on Wed, 12 May 2010 21:58:51 +1200 writes:

    > 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:
    >>>> 
    >>>> 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
    >>> 
    >> 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.

Yes, indeed ("disgusting").

I wonder why you seem to need to do that.
Couldn't it be that *you* set the ess style to C++  rather than
the default one.

Vincent, could it be that your emacs+ESS+Auctex+...  setup would
set that default ?

Martin

    > I am not sure if the problem is something Vince does in preparing his 
    > distribution.

    > 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

    > ______________________________________________
    > ESS-help at stat.math.ethz.ch mailing list
    > https://stat.ethz.ch/mailman/listinfo/ess-help



More information about the ESS-help mailing list