Here is my emacs for C coding setup:
- Packages:
- flymake – not using this right now as gcc won’t compile for the MCU I am targeting
- compile
- flyspell
- auto-complete –
- rainbow-delimiters-mode
- Formatting
- M-x align – Align comments, equal sign, etc.
- Other tools
- etags – M-. (jump to definition). See link for building TAGS table.
- which-function-mode – List the current function in the mode line.
- show-paren-mode – Highlight the matching paren or brace when cursor is next to a paren. The link also gives some other useful keyboard shortcuts.
- org capture – Grab marked text into an org file. Alternately, try fixeme-mode. Also eproject extras may do this nicely.
- semantic for Speedbar – Use a better C parser for the speedbar
My current config:
;; ;; C mode modifications ;; (require 'compile) (add-hook 'c-mode-hook (lambda () (add-to-list 'compilation-error-regexp-alist 'x51) (add-to-list 'compilation-error-regexp-alist-alist '(x51 "^... \\(\\w+\\) .*IN LINE \\([0-9]+\\) OF \\([^:]+\\):" 3 2 nil 1)) (flyspell-prog-mode) (rainbow-delimiters-mode) (setq compilation-auto-jump-to-first-error t) (which-function-mode) (show-paren-mode) (add-hook 'speedbar-load-hook (lambda () (require 'semantic/sb))) )) ;;Auto-Conmplete (require 'auto-complete) (add-to-list 'ac-dictionary-directories "~/.emacs.d/ac-dict") (require 'auto-complete-config) (ac-config-default)
Much of this is based on the useful notes in this SO post.