-
Notifications
You must be signed in to change notification settings - Fork 36
/
emacs-rc-cedet.el
169 lines (140 loc) · 5.73 KB
/
emacs-rc-cedet.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
;;; emacs-rc-cedet.el ---
;; Copyright (C) 2003 Alex Ott
;;
;; Author: alexott@gmail.com
;; Keywords:
;; Requirements:
;; Status: not intended to be distributed yet
(load-file "~/emacs/cedet/common/cedet.el")
(semantic-load-enable-excessive-code-helpers)
;;(semantic-load-enable-semantic-debugging-helpers)
(setq senator-minor-mode-name "SN")
(setq semantic-imenu-auto-rebuild-directory-indexes nil)
(global-srecode-minor-mode 1)
(global-semantic-mru-bookmark-mode 1)
(require 'semantic-decorate-include)
;; gcc setup
(require 'semantic-gcc)
;; smart complitions
(require 'semantic-ia)
(setq-mode-local c-mode semanticdb-find-default-throttle
'(project unloaded system recursive))
(setq-mode-local c++-mode semanticdb-find-default-throttle
'(project unloaded system recursive))
(setq-mode-local erlang-mode semanticdb-find-default-throttle
'(project unloaded system recursive))
(require 'eassist)
;; customisation of modes
(defun my-cedet-hook ()
(local-set-key [(control return)] 'semantic-ia-complete-symbol-menu)
(local-set-key "\C-c?" 'semantic-ia-complete-symbol)
;;
(local-set-key "\C-c>" 'semantic-complete-analyze-inline)
(local-set-key "\C-c=" 'semantic-decoration-include-visit)
(local-set-key "\C-cj" 'semantic-ia-fast-jump)
(local-set-key "\C-cq" 'semantic-ia-show-doc)
(local-set-key "\C-cs" 'semantic-ia-show-summary)
(local-set-key "\C-cp" 'semantic-analyze-proto-impl-toggle)
)
;;(add-hook 'semantic-init-hooks 'my-cedet-hook)
(add-hook 'c-mode-common-hook 'my-cedet-hook)
(add-hook 'lisp-mode-hook 'my-cedet-hook)
(add-hook 'emacs-lisp-mode-hook 'my-cedet-hook)
;; (add-hook 'erlang-mode-hook 'my-cedet-hook)
(defun my-c-mode-cedet-hook ()
;; (local-set-key "." 'semantic-complete-self-insert)
;; (local-set-key ">" 'semantic-complete-self-insert)
(local-set-key "\C-ct" 'eassist-switch-h-cpp)
(local-set-key "\C-xt" 'eassist-switch-h-cpp)
(local-set-key "\C-ce" 'eassist-list-methods)
(local-set-key "\C-c\C-r" 'semantic-symref)
)
(add-hook 'c-mode-common-hook 'my-c-mode-cedet-hook)
;; hooks, specific for semantic
(defun my-semantic-hook ()
;; (semantic-tag-folding-mode 1)
(imenu-add-to-menubar "TAGS")
)
(add-hook 'semantic-init-hooks 'my-semantic-hook)
(custom-set-variables
'(semantic-idle-scheduler-idle-time 3)
'(semantic-self-insert-show-completion-function (lambda nil (semantic-ia-complete-symbol-menu (point))))
'(global-semantic-tag-folding-mode t nil (semantic-util-modes)))
(global-semantic-folding-mode 1)
;; gnu global support
(require 'semanticdb-global)
(semanticdb-enable-gnu-global-databases 'c-mode)
(semanticdb-enable-gnu-global-databases 'c++-mode)
;; ctags
(require 'semanticdb-ectag)
(semantic-load-enable-primary-exuberent-ctags-support)
;;
(semantic-add-system-include "~/exp/include" 'c++-mode)
(semantic-add-system-include "~/exp/include" 'c-mode)
(add-to-list 'semantic-lex-c-preprocessor-symbol-file
"~/exp/include/boost-1_39/boost/config.hpp")
;;
(global-semantic-idle-tag-highlight-mode 1)
;;; ede customization
(require 'semantic-lex-spp)
(global-ede-mode t)
;; cpp-tests project definition
(setq cpp-tests-project
(ede-cpp-root-project "cpp-tests"
:file "~/projects/lang-exp/cpp/CMakeLists.txt"
:system-include-path '("/home/ott/exp/include"
"/home/ott/exp/include/boost-1_39")
:local-variables (list
(cons 'compile-command 'my-gen-cmake-debug-compile-string)
)
))
(setq squid-gsb-project
(ede-cpp-root-project "squid-gsb"
:file "~/projects/squid-gsb/README"
:system-include-path '("/home/ott/exp/include"
"/home/ott/exp/include/boost-1_39")
:local-variables (list
(cons 'compile-command 'my-gen-cmake-debug-compile-string)
)
))
;; my functions for EDE
(defun my-ede-get-local-var (fname var)
"fetch given variable var from :local-variables of project of file fname"
(let* ((current-dir (file-name-directory fname))
(prj (ede-current-project current-dir)))
(when prj
(let* ((ov (oref prj local-variables))
(lst (assoc var ov)))
(when lst
(cdr lst))))))
;; setup compile package
;; TODO: allow to specify function as compile-command
(require 'compile)
(setq compilation-disable-input nil)
(setq compilation-scroll-output t)
(setq mode-compile-always-save-buffer-p t)
(defun My-Compile ()
"Saves all unsaved buffers, and runs 'compile'."
(interactive)
(save-some-buffers t)
(let* ((r (my-ede-get-local-var
(or (buffer-file-name (current-buffer)) default-directory)
'compile-command))
(cmd (if (functionp r) (funcall r) r)))
;; (message "AA: %s" cmd)
(set (make-local-variable 'compile-command) (or cmd compile-command))
(compile compile-command)))
(global-set-key [f9] 'My-Compile)
;;
(defun my-gen-cmake-debug-compile-string ()
"Generates compile string for compiling CMake project in debug mode"
(let* ((current-dir (file-name-directory
(or (buffer-file-name (current-buffer)) default-directory)))
(prj (ede-current-project current-dir))
(root-dir (ede-project-root-directory prj))
(subdir "")
)
(when (string-match root-dir current-dir)
(setf subdir (substring current-dir (match-end 0))))
(concat "cd " root-dir "Debug/" subdir "; make -j3")))
;;; emacs-rc-cedet.el ends here