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