[ESS] Indentation level

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


>>>>> "SE" == Stephen Eglen <S.J.Eglen at damtp.cam.ac.uk>
>>>>>     on Fri, 14 May 2010 12:05:24 +0100 writes:

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


    SE> (This is mostly relevant for ess-core...)

    SE> To follow up on this thread, this question of setting ess-indent-level
    SE> was asked last year:

    SE> http://article.gmane.org/gmane.emacs.ess.general/3995


    SE> where I suggested the workaround of doing:

    SE> (defun myindent-ess-hook ()
    SE> (setq ess-indent-level 4))

    SE> (add-hook 'ess-mode-hook 'myindent-ess-hook) 

    SE> which has been reported in this thread.  I've now investigated further,
    SE> and ess-indent-level is set by the function ess-set-style, which is
    SE> called when a new R buffer is opened, via the call to ess-mode.  So
    SE> currently I think it makes no sense to have variables such as
    SE> ess-indent-level customizable.  This is my fault, as I think I
    SE> customized them many years ago!

Yes,...I'm pretty sure you are right, both about the history,
and about the conclusion.

I would like "us" to change this before releasing ESS 5.9 if
possible.
I have no time for this, this week though.

    SE>  Instead, it would make sense to allow 
    SE> users to customize the default style, which is exactly what Tony
    SE> suggested and I disagreed with many years ago.  Here is the relevant
    SE> output from vc-annotate on ess-custom.el:

    SE> 1421    rossini ;;; **FIXME**  The following NEEDS to be customized.
    SE> 3090   maechler ;; SJE: I disagree; this variable should not be
    SE> customized; individual vars, 
    SE> 3062    stephen ;; such as ess-indent-level are already customizable.
    SE> 1286        ess (defvar ess-default-style-list

    SE> This would then give us a chance to promote the R-coding standards that
    SE> Martin cites above.

Hmm, I do use it, but actually I'm not strongly promoting
that R users should adhere to the coding standard that R core (only!)
has adopted for the "base R" code.
But of course, I'm not against it either!

Martin

    SE> Stephen



More information about the ESS-help mailing list