[ESS] How to control indentation in an R function?

Michael Hannon jm_hannon at yahoo.com
Thu Nov 26 03:35:35 CET 2009


Greetings.  I'd like to have statements in R functions be indented by four
spaces, as:

    fn <- function (x) {
        y <- x^2            #### this line is indented by four spaces
    }

What I get is indentation by two spaces, as:

    fn <- function (x) {
      y <- x^2            #### this line is indented by two spaces
    }



I've looked at:

    ess-cust.el

looking for ways to customize this, but I evidently have not yet found the
appropriate setting.

I've appended the entire contents of my .emacs file.  The variables that would
seem to be relevant are in the section:

    custom-set-variables

If you know what I'm doing wrong, please let me know.

Thanks.

-- Mike

Appendix: .emacs file
========



(set-default-font "-adobe-courier-bold-r-normal--14-140-75-75-m-90-iso8859-1")
(set-frame-height (selected-frame) 56)
(set-frame-width (selected-frame) 80)
(setq column-number-mode t)
(setq default-major-mode 'text-mode)
(add-hook 'text-mode-hook 'turn-on-auto-fill)
;;;; (define-key global-map "\C-x\C-u" 'undo)

(custom-set-variables
  ;; custom-set-variables was added by Custom.
  ;; If you edit it by hand, you could mess it up, so be careful.
  ;; Your init file should contain only one such instance.
  ;; If there is more than one, they won't work right.
 '(ess-continued-statement-offset 4)
 '(ess-continued-brace-offset 4)
 '(ess-indent-level 4)
 '(ess-ess-arg-function-offset 4)
 '(ess-function-template " <- function( ) {


}
")
)
(custom-set-faces
  ;; custom-set-faces was added by Custom.
  ;; If you edit it by hand, you could mess it up, so be careful.
  ;; Your init file should contain only one such instance.
  ;; If there is more than one, they won't work right.
 )



More information about the ESS-help mailing list