-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcpp.el
43 lines (36 loc) · 1.36 KB
/
cpp.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
;;自动插入匹配的括号
;;C/C++ mode
;; (defun my-c-mode-auto-pair ()
;; (interactive)
;; (make-local-variable 'skeleton-pair-alist)
;; (setq skeleton-pair-alist '(
;; (?{ \n > _ \n ?} >)))
;; (setq skeleton-pair t)
;; (local-set-key (kbd "(") 'skeleton-pair-insert-maybe)
;; (local-set-key (kbd "[") 'skeleton-pair-insert-maybe)
;; (local-set-key (kbd "\"") 'skeleton-pair-insert-maybe)
;; (local-set-key (kbd "{") 'skeleton-pair-insert-maybe)
;; (backward-char))
;;(add-hook 'c-mode-hook 'my-c-mode-auto-pair)
;;(add-hook 'c++-mode-hook 'my-c-mode-auto-pair)
(add-hook 'c-mode-hook
'(lambda ()
(c-set-style "K&R")
(c-toggle-auto-state)
(c-toggle-auto-hungry-state)
(c-set-offset 'case-label '+) ;switch/case: make each case line indent from switch
(setq tab-width 4)
(setq c-basic-offset 4)))
(add-hook 'c++-mode-hook
'(lambda ()
(c-set-style "stroustrup")
(c-toggle-auto-state)
(setq tab-width 4)
(c-set-offset 'case-label '+) ;switch/case: make each case line indent from switch
(c-toggle-auto-hungry-state)))
;; indent switch
;;; set this in all c-based programming modes
(add-hook 'c-mode-common-hook
(lambda ()
(c-set-offset 'case-label '+)))
(provide 'init-cpp)