[ESS] indentation not working if parentheses are already closed

Vitalie Spinu spinuvit at gmail.com
Tue Apr 16 22:41:15 CEST 2013


 >> Jannis <bt_jannis at yahoo.de>
 >> on Tue, 16 Apr 2013 17:02:57 +0200 wrote:

[...]

 > foo <- function() {<cursor>}

 > hiting return would yield:

 > foo <- function() {
 >      <cursor>}

What would you like to happen on RET
  

  foo <- function() {
      something_here <cursor>}

? 

As Ista said, } is correctly indented unless you want } to always be
shifted with respect to "foo". I guess you are using skeleton (or
something similar), otherwise the problem would not have occurred. 

You have two options, first modify your skeleton to insert "\n}" instead
of "}". Second modify the indentation ess style. Have a look at
ess-close-brace-offset. You should set it either in ess-post-run-hook or
as part of your kustom style, like:

(add-to-list 'ess-style-alist
             '(my-C++
               (ess-indent-level . 4)
               (ess-continued-statement-offset . 4)
               (ess-brace-offset . -4)
               (ess-expression-offset . 4)
               (ess-else-offset . 0)
               (ess-close-brace-offset . 4)
               (ess-brace-imaginary-offset . 0)
               (ess-continued-brace-offset . 0)
               (ess-arg-function-offset . 2)
	       (ess-arg-function-offset-new-line . '(2))
             ))
(setq ess-default-style 'my-C++)


    Vitalie



More information about the ESS-help mailing list