My emacs setup for C++

Aug 16, 2012

I tried pretty hard to get existing solutions like ecb and semantic to work, but they seem to have fallen into a state of disrepair. I’d tried both a while back so I don’t remember exactly how they weren’t working, but both were throwing errors that had something to do with the changes in Emacs 24. I also tried to get the clang plugin working, but clang itself is pretty finicky and hard (for a beginner like me) to set up in windows, so I gave up on that pretty quickly and went back to my trusted Ctags solution that worked well in my Vim days. The solution is a combination of a bunch of things, including:

I’ve attached most of the required files at the end of this post, but here are a few notes and gotchas in no particular order

(defun risky-local-variable-p (sym &optional _ignored)
  (if (string-match "compile-command" sym) (nil)
  (condition-case nil
      (setq sym (indirect-variable sym))
    (error nil))
  (or (get sym 'risky-local-variable)
      (string-match "-hooks?$\\|-functions?$\\|-forms?$\\|-program$\\|\
      -map$\\|-map-alist$\\|-bindat-spec$" (symbol-name sym))))))

Look for “global-set-key” in cpp.el for keybindings I’ve defined. A binding I haven’t defined is C-* which takes you back to where you were before you jumped to a symbol’s definition with 'etags-select-find-tag (M-.). And if my bindings seem weird to you, that’s because I use a Dvorak layout.

Files referenced in this post