(defun set-if-void (symbol value) (or (boundp symbol) (set symbol value))) (require 'c-mode) (setq c-style-alist (nconc c-style-alist '(("AJB" ;An AJB special (c-auto-newline . t) (c-tab-always-indent . nil) (c-argdecl-indent . 0) (c-brace-imaginary-offset . 0) (c-brace-offset . 0) (c-continued-brace-offset . -4) (c-continued-statement-offset . 4) (c-indent-level . 4) (c-label-offset . -4))))) (defvar default-c-style "AJB") (setq c-mode-hook (function (lambda () ; (load-library "c-style") (set-c-style default-c-style) ; Pick up default-c-style (setq comment-column 40) ; Set comment column (abbrev-mode 0) ; Turn off abbrev mode (local-set-key "\M-{." 'ajb-c-braces)))) (defun ajb-c-braces () "Insert a pair of braces with the current indentation,\ and position the cursor between them." (interactive) (insert "{") (c-indent-line) (newline) ;; (newline) may have done auto-fill (c-indent-line) (setq insertpos (point)) (newline) (insert "}") (c-indent-line) (goto-char insertpos))