emacs - tidy up init.el file
[dotfiles.git] / emacs.d / init.el
1 ;;;(if (eq system-type 'darwin)
2 ;;;  (setenv "PATH"
3 ;;;)   (concat (getenv "path") ":/usr/local/bin:~/bin/")
4 ;;;  )
5
6
7 (setenv "PATH" (concat (getenv "PATH") ":/usr/local/bin"))
8 (setq exec-path (append exec-path '("/usr/local/bin")))
9
10 (setq debug-on-error t)
11
12
13 (add-to-list 'load-path "~/.emacs.d/config")
14
15 (require 'init-base)
16
17 (require 'my-packages)
18
19 (require 'init-color-theme)
20
21 (require 'init-ido)
22
23 (require 'init-magit)
24
25 (require 'init-evil)
26
27 (require 'init-project)
28
29 (require 'projectile-speedbar)
30
31
32 (require 'init-ggtags)
33
34
35 (setq scroll-margin 5)
36 (setq scroll-conservatively 10000)
37 (show-paren-mode t)
38
39
40 (require 'init-c-cpp)
41
42 (require 'recentf)
43 (recentf-mode 1)
44 (setq recentf-max-menu-items 100)
45
46
47 (require 'recentf-ext)
48
49 (require 'init-key-binding)
50
51 (winner-mode 1)
52
53 (global-set-key (kbd "C-c C-l") 'winner-redo)
54 (global-set-key (kbd "C-c C-h") 'winner-undo)
55
56
57
58
59
60
61 ;;; set font size of minibuffer
62 ;;;; http://stackoverflow.com/questions/7869429/altering-the-font-size-for-the-emacs-minibuffer-separately-from-default-emacs
63 (add-hook 'minibuffer-setup-hook 'my-minibuffer-setup)
64 (defun my-minibuffer-setup ()
65        (set (make-local-variable 'face-remapping-alist)
66           '((default :height 120))))
67
68
69
70 (add-hook 'minibuffer-setup-hook
71           (lambda ()
72             (make-local-variable 'face-remapping-alist)
73             (add-to-list 'face-remapping-alist '(default (:background "green")))))
74
75
76
77
78 ;;;;;(require 'escape)
79 ;(setq-default evil-escape-delay 0.2)   
80 ;(setq evil-escape-excluded-major-modes '(dired-mode))
81 ;(setq-default evil-escape-key-sequence "jj")
82 ;(evil-escape-mode 1)
83
84
85 ;; ---------------
86 ;; recent file
87 (require 'recentf)
88 (recentf-mode)
89 ;(setq recentf-max-menu-items 100)
90
91 ;; http://www.emacswiki.org/emacs/RecentFiles
92 (defun recentf-ido-find-file ()
93   "Find a recent file using Ido."
94   (interactive)
95   (let ((file (ido-completing-read "Choose recent file: " recentf-list nil t)))
96     (when file
97       (find-file file))))
98
99
100
101 ;; http://stackoverflow.com/questions/11484225/fix-an-auto-complete-mode-and-linum-mode-annoyance
102 (ac-linum-workaround)
103
104
105 ;; ---------------------------------
106 ;; linum-relative
107
108
109 (custom-set-variables
110  ;; custom-set-variables was added by Custom.
111  ;; If you edit it by hand, you could mess it up, so be careful.
112  ;; Your init file should contain only one such instance.
113  ;; If there is more than one, they won't work right.
114  '(fringe-mode (quote (4 . 0)) nil (fringe))
115  '(ggtags-split-window-function (quote split-window-vertically))
116  '(hes-mode-alist
117    (quote
118     ((c-mode . "\\(\\\\\\([0-7]\\{1,3\\}\\|x[[:xdigit:]]+\\|u[[:xdigit:]]\\{4\\}\\|U[[:xdigit:]]\\{8\\}\\|[\"'?\\abfnrtv]\\)\\)")
119      (cperl-mode . "\\(\\\\\\([0-7]\\{1,3\\}\\|x[[:xdigit:]]+\\|u[[:xdigit:]]\\{4\\}\\|U[[:xdigit:]]\\{8\\}\\|[\"'?\\abfnrtv]\\)\\)")
120      (c++-mode . "\\(\\\\\\([0-7]\\{1,3\\}\\|x[[:xdigit:]]+\\|u[[:xdigit:]]\\{4\\}\\|U[[:xdigit:]]\\{8\\}\\|[\"'?\\abfnrtv]\\)\\)")
121      (objc-mode . "\\(\\\\\\([0-7]\\{1,3\\}\\|x[[:xdigit:]]+\\|u[[:xdigit:]]\\{4\\}\\|U[[:xdigit:]]\\{8\\}\\|[\"'?\\abfnrtv]\\)\\)")
122      (java-mode . "\\(\\\\\\([0-7]\\{1,3\\}\\|u[[:xdigit:]]\\{4\\}\\|[\"'\\bfnrt]\\)\\)")
123      (js-mode . "\\(\\\\\\([0-7]\\{1,3\\}\\|x[[:xdigit:]]\\{2\\}\\|u[[:xdigit:]]\\{4\\}\\|.\\)\\)")
124      (js2-mode . "\\(\\\\\\([0-7]\\{1,3\\}\\|x[[:xdigit:]]\\{2\\}\\|u[[:xdigit:]]\\{4\\}\\|.\\)\\)")
125      (ruby-mode
126       ("\\(\\\\\\([0-7]\\{1,3\\}\\|x[[:xdigit:]]\\{1,2\\}\\|u\\(?:[[:xdigit:]]\\{4\\}\\|{[[:xdigit:]]\\{1,6\\}\\(?:[[:space:]]+[[:xdigit:]]\\{1,6\\}\\)*}\\)\\|.\\)\\)"
127        (0
128         (let*
129             ((state
130               (syntax-ppss))
131              (term
132               (nth 3 state)))
133           (when
134               (or
135                (and
136                 (eq term 39)
137                 (member
138                  (match-string 2)
139                  (quote
140                   ("\\" "'"))))
141                (if
142                    (fboundp
143                     (quote ruby-syntax-expansion-allowed-p))
144                    (ruby-syntax-expansion-allowed-p state)
145                  (memq term
146                        (quote
147                         (34 47 10 96 t)))))
148             (add-face-text-property
149              (match-beginning 1)
150              (match-end 1)
151              (quote hes-escape-backslash-face))
152             (add-face-text-property
153              (match-beginning 2)
154              (match-end 2)
155              (quote hes-escape-sequence-face))
156             nil))
157         prepend))))))
158  '(org-agenda-files (quote ("~/Private/org/diary.org" "~/temp/org-note.org")))
159  '(powerline-text-scale-factor 0.85))
160
161 ;; maybe better to fix the size of line number rather scaled 0.8
162 ;; https://github.com/howardabrams/dot-files/blob/master/emacs.org
163 (custom-set-faces
164  ;; custom-set-faces was added by Custom.
165  ;; If you edit it by hand, you could mess it up, so be careful.
166  ;; Your init file should contain only one such instance.
167  ;; If there is more than one, they won't work right.
168  '(highlight-current-line-face ((t (:background "gray22"))))
169  '(linum ((t (:background "#000000" :foreground "gray40" :height 0.8 :slant italic :weigth light))))
170  '(linum-relative-current-face ((t (:inherit linum :foreground "Yellow" :weight light :height 0.8))))
171  '(mode-line ((t (:foreground "#030303" :background "#bdbdbd" :box nil :family "Source Code Pro for Powerline" :height 100))))
172  '(mode-line-inactive ((t (:foreground "#f9f9f9" :background "#666666" :box nil :family "Source Code Pro for Powerline" :height 100)))))
173
174
175 ;; enable linum-relative in programming mode
176 ;https://github.com/howardabrams/dot-files/blob/master/emacs.org
177 (add-hook 'prog-mode-hook 'linum-mode)
178
179
180 ;; hight current line
181 (require 'highlight-current-line)
182 (highlight-current-line-on t)
183
184
185
186
187 (require 'workgroups2)
188
189
190 (setq wg-prefix-key (kbd "C-c z"))
191 (setq wg-session-file "~/.emacs.d/.emacs_workgroups")
192 (setq wg-mode-line-display-on t)          ; Default: (not (featurep 'powerline))
193 (setq wg-flag-modified t)                 ; Display modified flags as well
194 (setq wg-mode-line-decor-left-brace "["
195       wg-mode-line-decor-right-brace "]"  ; how to surround it
196       wg-mode-line-decor-divider ":")
197 ;(workgroups-mode 1)
198
199 (defalias 'perl-mode 'cperl-mode)
200 ;(setq cperl-invalid-face nil)
201  (setq cperl-invalid-face (quote off))
202 ;(add-hook 'prog-mode-hook '(lambda () 
203 ;        (highlight-regexp "%[[:alpha:]]\\|\\\\[[:alpha:]]")))
204
205 (require 'highlight-escape-sequences)
206 (hes-mode)
207 ;(setq cperl-font-lock t)
208 (put 'hes-escape-backslash-face 'face-alias 'font-lock-builtin-face)
209 (put 'hes-escape-sequence-face 'face-alias 'font-lock-builtin-face)
210
211
212 ;(add-to-list 'load-path "~/.emacs.d/Emacs-PDE-0.2.16/lisp/")
213 ;(load "pde-load")                       ;
214
215 (require 'init-linum)