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