-
Notifications
You must be signed in to change notification settings - Fork 0
/
.emacs
185 lines (162 loc) · 5.91 KB
/
.emacs
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
;;/**
;; * AS - the open source Automotive Software on https://github.com/parai
;; *
;; * Copyright (C) 2015 AS <parai@foxmail.com>
;; *
;; * This source code is free software; you can redistribute it and/or modify it
;; * under the terms of the GNU General Public License version 2 as published by the
;; * Free Software Foundation; See <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>.
;; *
;; * This program is distributed in the hope that it will be useful, but
;; * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
;; * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
;; * for more details.
;; */
(setq frame-background-mode 'dark)
(set-background-color "black")
(set-foreground-color "gray")
(set-cursor-color "yellow")
(set-face-foreground 'highlight "white")
(set-face-background 'highlight "blue")
(set-face-foreground 'region "cyan")
(set-face-background 'region "blue")
(set-face-foreground 'secondary-selection "skyblue")
(set-face-background 'secondary-selection "darkblue")
(if (eq system-type 'windows-nt)
(set-default-font "Consolas-14")
(set-default-font "Monospace-12")
)
(setq make-backup-files nil)
(display-time)
(global-linum-mode t)
(column-number-mode t)
(show-paren-mode t)
(setq default-tab-width 4)
(setq c-indent-level 4)
(setq c-continued-statement-offset 4)
(setq c-brace-offset -4)
(setq c-argdecl-indent 4)
(setq c-label-offset -4)
(setq c-basic-offset 4)
;;(global-set-key "\C-m" 'reindent-then-newline-and-indent)
(setq indent-tabs-mode t)
(setq standard-indent 4)
;;Create MyCppStyle
(defconst MyCppStyle
'((c-tab-always-indent . t)
(c-comment-only-line-offset . 0)
(c-hanging-braces-alist . ((substatement-open after)
(brace-list-open)))
(c-cleanup-list . (comment-close-slash
compact-empty-funcall))
(c-offsets-alist . ((substatement-open . 0)
(innamespace . 0)
(case-label . +)
(access-label . -)
(inline-open . 0)
(block-open . 0)))
;; (c-echo-syntactic-information-p t)
(setq comment-start "/*"
comment-end "*/")
(setq indent-tabs-mode t))
"My Cpp Coding Style")
(c-add-style "MyCppStyle" MyCppStyle)
;;Define own hook
(defun MyCppHook ()
(interactive)
;; (company-mode)
(setq indent-tabs-mode t)
(setq global-hl-line-mode t)
(c-set-style "MyCppStyle"))
(add-hook 'c++-mode-hook 'MyCppHook)
(add-hook 'c-mode-hook 'MyCppHook)
(global-font-lock-mode 1)
(setq default-directory "~/")
;;(set-scroll-bar-mode nil)
(setq inhibit-startup-message t)
(setq indent-tabs-mode t)
;;solve mess encode issue of shell-mode
(ansi-color-for-comint-mode-on)
(fset 'yes-or-no-p 'y-or-n-p)
(global-set-key (kbd "M-g") 'goto-line)
(global-set-key [home] 'beginning-of-buffer)
(global-set-key [end] 'end-of-buffer)
(when (eq system-type 'windows-nt)
(setq find-program "gfind"))
(setq case-fold-search t)
;; display buffer name or absolute file path name in the frame title
(defun frame-title-string ()
"Return the file name of current buffer, using ~ if under home directory"
(let
((fname (or
(buffer-file-name (current-buffer))
(buffer-name)))
(max-len 100))
(when (string-match (getenv "HOME") fname)
(setq fname (replace-match "~" t t fname)))
(if (> (length fname) max-len)
(setq fname
(concat "..."
(substring fname (- (length fname) max-len)))))
fname))
(setq frame-title-format '("AS - Emacs@"(:eval (frame-title-string))))
(setq ediff-split-window-function 'split-window-horizontally)
(global-set-key [f3]
(lambda()
(interactive)
(split-window-vertically 7)
(eshell)
)
)
(add-hook 'c-mode-common-hook 'hs-minor-mode)
(defun make-some-files-read-only ()
;;"when file opened is of a certain mode, make it read only"
(when (memq major-mode '(c-mode c++-mode tcl-mode text-mode python-mode))
(toggle-read-only 1)))
(add-hook 'find-file-hooks 'make-some-files-read-only)
(add-hook 'python-mode-hook
(lambda ()
(setq indent-tabs-mode t)
(setq tab-width 4)
(setq python-indent 4)))
;example
;============
; (shell-command "mktags")
; :mktags is a shell script to make tags for etags and cscope
;============
;========================================================
; used to generate TAGS and cscope.out
;========================================================
(defun mktags (RootDir)
(interactive "DInput the RootDir:")
;;(if (eq system-type 'windows-nt)
(shell-command (format "cd %s && rm -f TAGS cscope.files cscope.out && find ./ -name *.[chCH] |xargs -i etags -a {}" RootDir))
(shell-command (format "cd %s && find ./ -name *.cpp |xargs -i etags -a {} && find ./ -name *.CPP |xargs -i etags -a {}" RootDir))
(shell-command (format "cd %s && find ./ -name *.[chCH] -print > cscope.files && find ./ -name *.cpp -print >> cscope.files" RootDir))
(shell-command (format "cd %s && find ./ -name *.CPP -print >> cscope.files && cscope -b -i cscope.files -f cscope.out" RootDir))
;;)
(setq tags-file-name (format "%s/TAGS" RootDir))
(message "generate TAGS and cscope.out for currend project")
)
(global-set-key (kbd "C-c e t") 'mktags)
;=======================================================
; used to delete TAGS and cscope.out
;=======================================================
(defun deltags()
(interactive)
(shell-command "rm -f TAGS cscope.files cscope.out")
(message "delete TAGS and cscope.out for currend project")
)
(global-set-key (kbd "C-c d e t") 'deltags)
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(tab-width 4))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)