indent levels

Liaw, Andy andy_liaw at merck.com
Mon Oct 4 01:23:52 CEST 2004


Dear ESS-help,

Apologies for such an off-topic question:  The `Writing R Extensions' manual
has a snippet of elisp code that defines the indentation style for R code.
Can anyone tell me how to get C code to be indented similarly in (X)Emacs?
In particular, how do I get XEmacs to use four spaces for indentation,
intead of the default of two spaces?  I tried:

(add-hook 'C-mode-hook
          (lambda () 
	    (C-set-style 'C++)
            ;; Because
            ;;                                 DEF GNU BSD K&R C++
            ;; C-indent-level                  2   2   8   5   4
            ;; C-continued-statement-offset    2   2   8   5   4
            ;; C-brace-offset                  0   0  -8  -5  -4
            ;; C-arg-function-offset           2   4   0   0   0
            ;; C-expression-offset             4   2   8   5   4
            ;; C-else-offset                   0   0   0   0   0
            ;; C-close-brace-offset            0   0   0   0   0
            (add-hook 'local-write-file-hooks
                      (lambda ()
                        (nuke-trailing-whitespace)))))

but when I load a .c file, XEmacs complained about unknown style "C++".

I'd very much appreciate any pointer.

Best,
Andy

Andy Liaw, PhD
Biometrics Research      PO Box 2000, RY33-300     
Merck Research Labs           Rahway, NJ 07065
andy_liaw <at> merck.com          732-594-0820




More information about the ESS-help mailing list