Packets: Packet Registry unregister() support
[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 (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")))
44
45 (set (make-local-variable 'ccide-default-copyright)
46      (concat "//\n"
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"
51              "//\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"
56              "//\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"))
61
62 (set (make-local-variable 'ccide-project-name) "SENF")
63
64 (let ((local-conf (ccide-project-search-upwards "project-local.el")))
65   (if local-conf
66       (load-file local-conf)))
67
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)
74          (not (save-excursion
75                 (beginning-of-line)
76                 (looking-at "\\(//\\)?#")))
77          (not (let ((l (max (point-min) (- (point-max) 4096))))
78                 (and (< l (point))
79                      (save-excursion (search-backward "\f" l t))))))))
80
81 (defun flyspell-cc-mode ()
82   "Torn on `flyspell-mode` for comments and strings in C/C++ mode."
83   (interactive)
84   (setq flyspell-generic-check-word-p 'flyspell-cc-progmode-verify)
85   (flyspell-mode 1))
86
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 "tools/senf.dict" ccide-project-root))
91 (flyspell-cc-mode)
92
93 (defun senf-new-file-hook ()
94   (when (string-match "\\.test\\.cc$" (buffer-file-name))
95     (save-excursion
96       (goto-char (point-min))
97       (search-forward "auto_unit_test.hpp")
98       (beginning-of-line)
99       (delete-region (point) (progn (end-of-line) (point)))
100       (insert "#include <senf/Utils/auto_unit_test.hh>"))))
101
102 (add-hook 'ccide-new-file-hooks 'senf-new-file-hook nil t)
103
104 (setq indent-tabs-mode nil) ;; needed since whitespace-mode caches this value ...
105 (whitespace-mode 1)
106
107 \f
108 ;; Local Variables:
109 ;; indent-tabs-mode: nil
110 ;; End: