Anthony Liguori <anth...@codemonkey.ws> writes: [...] > FWIW, this is what I use with emacs: > > (c-add-style "qemu" > '("stroustrup" > (indent-tabs-mode . nil) > (c-basic-offset . 4) > (tab-width . 8) > ) > nil) ; t = set this style, nil = don't
Here's my configuration (excuse liberal use of sledgehammer): (setq c-initialization-hook (lambda() (setcar (member '(other . "gnu") c-default-style) (cons 'other "stroustrup")))) (set-default 'c-recognize-knr-p nil) (setq c-electric-pound-behavior '(alignleft)) (defun linux-c-mode () "C mode with adjusted defaults for use with the Linux kernel." (interactive) (c-mode) (c-set-style "K&R") (setq tab-width 8) (setq indent-tabs-mode t) (setq c-basic-offset 8)) (setq auto-mode-alist (cons '("/linux.*\\.[ch]\\'" . linux-c-mode) auto-mode-alist)) ;; avoid tabs for some projects (defun my-choose-tabs () (let ((fname (buffer-file-name))) (and fname (string-match "/qemu" fname) (setq indent-tabs-mode nil)))) (add-hook 'after-change-major-mode-hook 'my-choose-tabs)