Emacs 24.1 released
Posted Jun 15, 2012 12:42 UTC (Fri) by
nix (subscriber, #2304)
In reply to:
Emacs 24.1 released by daglwn
Parent article:
Emacs 24.1 released
Yes, here.
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):
(require 'cedet)
(require 'semantic)
(require 'srecode)
(require 'auto-complete-config)
;; Turn on project management.
(setq ede-locate-setup-options '(ede-locate-global ede-locate-locate ede-locate-base))
(global-ede-mode 1)
(global-srecode-minor-mode 1)
;; Kick off the semantic bovinator, function menu, C-warning mode, and flashing
;; brackets.
(setq semantic-default-submodes (append semantic-default-submodes
'(global-semantic-idle-local-symbol-highlight-mode
global-semantic-idle-summary-mode
global-semantic-decoration-mode
global-semantic-highlight-func-mode
global-semantic-stickyfunc-mode
global-semantic-show-unmatched-syntax-mode
global-semantic-mru-bookmark-mode)))
(setq semantic-decoration-styles '(("semantic-decoration-on-includes" . t)
("semantic-decoration-on-protected-members")
("semantic-decoration-on-private-members")))
(semantic-mode 1)
(semanticdb-enable-gnu-global-databases 'c-mode)
(semanticdb-enable-gnu-global-databases 'c++-mode)
;; auto-complete should use Semantic.
(ac-config-default)
(ac-set-trigger-key "TAB")
(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.)
(
Log in to post comments)