(defun match-alist (str list) (while (and (not (string-match (car (car list)) str)) (setq list (cdr list)))) (cdr (car list))) (c-add-style "linux" '("k&r" (c-basic-offset . 8) (indent-tabs-mode . t))) (c-add-style "notabs" '("k&r" (c-basic-offset . 4) (indent-tabs-mode . nil))) (setq c-file-style-alist '(("/linux.*/" . "linux") ("/u-boot/" . "linux") ("/x-load/" . "linux") ("/x264/" . "notabs") ("/ffmpeg.*/" . "notabs") ("" . "notabs"))) (defun fixup-c-style () (c-set-style (match-alist (or (buffer-file-name) "") c-file-style-alist)))