lang/cc: minor refactor

This commit is contained in:
Henrik Lissner 2017-09-20 14:25:35 +02:00
parent ad013e96dd
commit d600d36675
No known key found for this signature in database
GPG Key ID: 5F6C0EA160557395

View File

@ -1,8 +1,8 @@
;;; lang/cc/config.el --- c, c++, and obj-c -*- lexical-binding: t; -*- ;;; lang/cc/config.el --- c, c++, and obj-c -*- lexical-binding: t; -*-
(defvar +cc-include-paths (list "include/") (defvar +cc-include-paths (list "include/")
"A list of paths, relative to a project root, to search for headers in "A list of paths, relative to a project root, to search for headers in C/C++.
C/C++. Paths can be absolute. Paths can be absolute.
The purpose of this variable is to ensure syntax checkers and code-completion The purpose of this variable is to ensure syntax checkers and code-completion
knows where to look for headers.") knows where to look for headers.")
@ -13,8 +13,8 @@ knows where to look for headers.")
. ,(list "-std=c++11" ; use C++11 by default . ,(list "-std=c++11" ; use C++11 by default
(when IS-MAC (when IS-MAC
;; NOTE beware: you'll get abi-inconsistencies when passing ;; NOTE beware: you'll get abi-inconsistencies when passing
;; std-objects to libraries linked with libstdc++ (e.g. if you use ;; std-objects to libraries linked with libstdc++ (e.g. if you
;; boost which wasn't compiled with libc++) ;; use boost which wasn't compiled with libc++)
(list "-stdlib=libc++")))) (list "-stdlib=libc++"))))
(objc-mode . nil)) (objc-mode . nil))
"A list of default compiler options for the C family. These are ignored if a "A list of default compiler options for the C family. These are ignored if a
@ -45,7 +45,7 @@ compilation database is present in the project.")
(equal (file-name-extension buffer-file-name) "h") (equal (file-name-extension buffer-file-name) "h")
(re-search-forward "@\\<interface\\>" magic-mode-regexp-match-limit t))) (re-search-forward "@\\<interface\\>" magic-mode-regexp-match-limit t)))
(push (cons #'+cc-c++-header-file-p 'c++-mode) magic-mode-alist) (push (cons #'+cc-c++-header-file-p 'c++-mode) magic-mode-alist)
(push (cons #'+cc-objc-header-file-p 'objc-mode) magic-mode-alist) (push (cons #'+cc-objc-header-file-p 'objc-mode) magic-mode-alist)
:init :init
@ -62,14 +62,14 @@ compilation database is present in the project.")
;; C/C++ style settings ;; C/C++ style settings
(c-toggle-electric-state -1) (c-toggle-electric-state -1)
(c-toggle-auto-newline -1) (c-toggle-auto-newline -1)
(c-set-offset 'substatement-open '0) ; brackets should be at same indentation level as the statements they open (c-set-offset 'substatement-open '0) ; don't indent brackets
(c-set-offset 'inline-open '+) (c-set-offset 'inline-open '+)
(c-set-offset 'block-open '+) (c-set-offset 'block-open '+)
(c-set-offset 'brace-list-open '+) ; all "opens" should be indented by the c-indent-level (c-set-offset 'brace-list-open '+)
(c-set-offset 'case-label '+) ; indent case labels by c-indent-level, too (c-set-offset 'case-label '+)
(c-set-offset 'access-label '-) (c-set-offset 'access-label '-)
(c-set-offset 'arglist-intro '+) (c-set-offset 'arglist-intro '+)
(c-set-offset 'arglist-close '0) (c-set-offset 'arglist-close '0)
;; Indent privacy keywords at same level as class properties ;; Indent privacy keywords at same level as class properties
;; (c-set-offset 'inclass #'+cc-c-lineup-inclass) ;; (c-set-offset 'inclass #'+cc-c-lineup-inclass)