X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=project.el;h=74eafadbaf21f408464dcdf62a593cdead44e94c;hb=81f84badf27b66dbadec9890646ca1193e998505;hp=85fac8b8d6b7bc183e15f98fc49f3e74bdd79255;hpb=412024ed31a4ab4eaea7a4165a434f8efebee325;p=senf.git diff --git a/project.el b/project.el index 85fac8b..74eafad 100644 --- a/project.el +++ b/project.el @@ -1,13 +1,20 @@ ;; Configuration file for cc-ide.el (Emacs C++ IDE extension, see http://g0dil.de) +(defun check-namespace-indent (arg) + (save-excursion + (back-to-indentation) + (if (and (looking-at "namespace") + (looking-at ".*{") + (not (looking-at ".*}"))) + [0] '+))) + (defconst senf-c-style '((c-basic-offset . 4) (c-backslash-column . 98) (c-cleanup-list . (empty-defun-braces defun-close-semi list-close-comma - scope-operator - compact-empty-funcall)) + scope-operator)) (c-hanging-braces-alist . ((namespace-open after) (namespace-close before after) (brace-list-open) @@ -17,9 +24,9 @@ (extern-lang-open after) (inexpr-class-open after) (inexpr-class-close before))) - (c-offsets-alist . ((namespace-open . 0) - (namespace-close . -) - (innamespace . +) + (c-offsets-alist . ((namespace-open . [0]) + (namespace-close . [0]) + (innamespace . check-namespace-indent) (statement-block-intro . +) (substatement-open . 0) (label . 0) @@ -82,3 +89,17 @@ is ignored (Those are the file local variables and local words)." (set (make-local-variable 'ispell-personal-dictionary) (expand-file-name "senf.dict" ccide-project-root)) (flyspell-cc-mode) + +(defun senf-new-file-hook () + (when (string-match "\\.test\\.cc$" (buffer-file-name)) + (save-excursion + (goto-char (point-min)) + (search-forward "auto_unit_test.hpp") + (beginning-of-line) + (delete-region (point) (progn (end-of-line) (point))) + (insert "#include \"" + (string-replace "[^/]+/" "../" (substring (file-name-directory (buffer-file-name)) + (length ccide-project-root)) t) + "Utils/auto_unit_test.hh\"")))) + +(add-hook 'ccide-new-file-hooks 'senf-new-file-hook nil t)