Emacs 24.1 released
Posted Jun 15, 2012 12:42 UTC (Fri) by nix
In reply to: Emacs 24.1 released
Parent article: Emacs 24.1 released
My entire autocompletion configuration (using auto-complete.el to provide completion with intellisense-style pull-down menus that vanish at convenient times: tweaked locally, may be full of horrible typos):
;; Turn on project management.
(setq ede-locate-setup-options '(ede-locate-global ede-locate-locate ede-locate-base))
;; Kick off the semantic bovinator, function menu, C-warning mode, and flashing
(setq semantic-default-submodes (append semantic-default-submodes
(setq semantic-decoration-styles '(("semantic-decoration-on-includes" . t)
;; auto-complete should use Semantic.
(defun nix-setup-auto-complete-semantic ()
"Arrange to do semantic autocompletion."
(add-to-list 'ac-sources 'ac-source-semantic))
(add-hook 'c-mode-common-hook 'nix-setup-auto-complete-semantic t)
;; Some key bindings
(define-key semantic-mode-map (kbd "C-c , .") 'semantic-ia-fast-jump)
(define-key semantic-mode-map (kbd "C-c , P") 'semantic-analyze-proto-impl-toggle)
(define-key semantic-mode-map (kbd "C-c , h") 'semantic-decoration-include-visit)
(I use GNU GLOBAL as a better tagging system and to help CEDET identify headers and associated things in projects rapidly: if I haven't run gtags, it'll use the locate database instead, and if even that isn't enough it'll fall back to find(1). There are other possibilities too.)
That's enough global setup for C and C++ code to work, and almost all of it is unnecessary -- the system will sort of work with nothing but (semantic-mode 1). But you want some local per-project setup too, so it knows where your headers are and what #defines to apply when parsing them and stuff like that. Projects using Autoconf and Automake, and a few major projects such as the Linux kernel, are automatically detected, but for others you might need something like this for each project:
(ede-cpp-root-project "Blah Project" :file "/home/nix/src/blah/Makerules"
:include-path '("/include" "/local/include")
:system-include-path '("/home/nix/src/otherproject/include" "/usr/include")
:spp-table '(("_GNU_SOURCE" . "") ("_FILE_OFFSET_BITS" . "64") ("WOMBLE" . "foo")))
Here, the :file is the name of some file whose presence indicates that this project exists, :include-path is the include path for project-local headers to search for (initial / indicates "relative to project root directory"), :system-include-path is the include path for stuff coming from other projects and systemwide (often just "/usr/include"), and :spp-table is a bunch of #defines you want set. (There are lots of other ways of adding projects, and defining your own is not very hard: see /usr/share/emacs/*/lisp/cedet/ede/proj-*.el.gz.)
to post comments)