Emacs indentation behavior for R
Asked Answered
H

0

7

I recently upgraded to the new Emacs ESS version 15.03-1 and it has changed how my R code is being indented. For example,

setMethod('show','AClass',function(object) {
            ## do something....

indents after I hit Tab to have '##' 2 spaces after 'setMethod('. The behavior I would like is to offset 2 spaces from the start of the line like this:

setMethod('show','AClass',function(object) {
  ## do something....

The part of my .emacs file that deals with this is below

(require 'ess-site)

(add-hook 'ess-mode-hook
      (lambda()
        (ess-set-style 'C++ 'quiet)
        (setq ess-indent-level 2)
        (setq comment-column 2)
        (setq ess-continued-statement-offset 2)
        (setq ess-brace-offset 0)
        (setq ess-arg-function-offset nil)  ;; had been 2
        (setq ess-expression-offset 4)
        (setq ess-else-offset 0)
        (setq ess-close-brace-offset 0)
        (add-hook 'local-write-file-hooks
              (lambda ()
            (ess-nuke-trailing-whitespace)))
        ))
Howrah answered 6/5, 2015 at 13:3 Comment(1)
Not sure whether this is still a problem for you. I just installed the latest version from elpa (15.09-devel [elpa: 20150729.118]) and indentation works fine when set at 2. Note that as of 15.09 ess-indent-level is obsolete and just an alias for ess-indent-offsetAndersen

© 2022 - 2024 — McMap. All rights reserved.