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