1 ;; Configuration file for cc-ide.el (Emacs C++ IDE extension, see http://g0dil.de)
3 (defun check-namespace-indent (arg)
6 (if (and (looking-at "namespace")
8 (not (looking-at ".*}")))
11 (defconst senf-c-style
12 '((c-basic-offset . 4)
13 (c-backslash-column . 98)
14 (c-cleanup-list . (empty-defun-braces
18 (c-hanging-braces-alist . ((namespace-open after)
19 (namespace-close before after)
22 (substatement-open after)
23 (block-close . c-snug-do-while)
24 (extern-lang-open after)
25 (inexpr-class-open after)
26 (inexpr-class-close before)))
27 (c-offsets-alist . ((namespace-open . [0])
28 (namespace-close . [0])
29 (innamespace . check-namespace-indent)
30 (statement-block-intro . +)
31 (substatement-open . 0)
33 (statement-cont . +))) ))
35 (c-add-style "senf" senf-c-style)
37 (set (make-local-variable 'ccide-file-vars)
38 '(( fill-column . 100 )
39 ( comment-column . 40 )
40 ( c-file-style . "senf" )
41 ( indent-tabs-mode . nil )
42 ( ispell-local-dictionary . "american" )
43 ( compile-command . "scons -u test") ))
45 (set (make-local-variable 'ccide-default-copyright)
47 "// This program is free software; you can redistribute it and/or modify\n"
48 "// it under the terms of the GNU General Public License as published by\n"
49 "// the Free Software Foundation; either version 2 of the License, or\n"
50 "// (at your option) any later version.\n"
52 "// This program is distributed in the hope that it will be useful,\n"
53 "// but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
54 "// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
55 "// GNU General Public License for more details.\n"
57 "// You should have received a copy of the GNU General Public License\n"
58 "// along with this program; if not, write to the\n"
59 "// Free Software Foundation, Inc.,\n"
60 "// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.\n"))
62 (set (make-local-variable 'ccide-project-name) "SENF")
64 (let ((local-conf (ccide-project-search-upwards "project-local.el")))
66 (load-file local-conf)))
68 (defun flyspell-cc-progmode-verify ()
69 "Replacement for standard flyspell-generic-progmode-verify which
70 checks for C/C++ preproc directives. Additionally, anything after ^L
71 is ignored (Those are the file local variables and local words)."
72 (let ((f (get-text-property (point) 'face)))
73 (and (memq f flyspell-prog-text-faces)
76 (looking-at "\\(//\\)?#")))
77 (not (let ((l (max (point-min) (- (point-max) 4096))))
79 (save-excursion (search-backward "
\f" l t))))))))
81 (defun flyspell-cc-mode ()
82 "Torn on `flyspell-mode` for comments and strings in C/C++ mode."
84 (setq flyspell-generic-check-word-p 'flyspell-cc-progmode-verify)
87 ;; Better set this here than in the file variables since the setting
88 ;; is only valid if project.el is loaded ...
89 (set (make-local-variable 'ispell-personal-dictionary)
90 (expand-file-name "senf.dict" ccide-project-root))
93 (defun senf-new-file-hook ()
94 (when (string-match "\\.test\\.cc$" (buffer-file-name))
96 (goto-char (point-min))
97 (search-forward "auto_unit_test.hpp")
99 (delete-region (point) (progn (end-of-line) (point)))
100 (insert "#include \""
101 (string-replace "[^/]+/" "../" (substring (file-name-directory (buffer-file-name))
102 (length ccide-project-root)) t)
103 "Utils/auto_unit_test.hh\""))))
105 (add-hook 'ccide-new-file-hooks 'senf-new-file-hook nil t)