-
Notifications
You must be signed in to change notification settings - Fork 1
/
init.el
254 lines (190 loc) · 7.81 KB
/
init.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
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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
;;;; init.el -- load me first! Assumes thirdparty libs are available in ./lib
(defvar emacs-start-time (float-time))
(require 'cl)
(defun maybe-load (file)
"If we can find file on the load-path, load it and return t, otherwise nil"
(interactive "sFile: ")
(load file t t nil))
(setq dotfiles-dir (file-name-directory
(or (buffer-file-name) load-file-name)))
(message "Loading from %s" dotfiles-dir)
(add-to-list 'load-path dotfiles-dir)
(require 'basic)
(when (>= emacs-major-version 24)
(require 'package)
(add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/") t)
(add-to-list 'package-archives '("org" . "http://orgmode.org/elpa/") t)
(package-initialize))
(unless (package-installed-p 'use-package)
(package-refresh-contents)
(package-install 'use-package))
(require 'use-package)
(add-to-list 'load-path (concat dotfiles-dir "lib"))
(require 'mk-utils)
(require 'org-init)
(require 'java)
(require 'lang)
(require 'clojure)
(require 'www)
(require 'projects)
(require 'mk-tags)
;;; Various libs and autoloads -----------------------------------------
(autoload 'find-file-recursively "find-recursive" "" t)
(autoload 'light-symbol-mode "light-symbol" "" t)
(use-package htmlize :commands htmlize-buffer :ensure t)
(use-package typing :commands typing-of-emacs :ensure t)
(autoload 'css-mode "css-mode" "Mode for editing CSS files" t)
(add-to-list 'auto-mode-alist '("\\.css$" . css-mode))
(autoload 'ack "ack" "Ack is better than grep" t)
(autoload 'mcp-hl-mode "mcp-hl" "" t)
(use-package list-register :ensure t :commands list-register)
(autoload 'rainbow-paren-mode "rainbow-parens" "" t)
(use-package log4j-mode :ensure t :commands log4j-mode)
(use-package markdown-mode
:ensure t
:commands markdown-mode
:config (add-hook 'markdown-mode-hook (lambda () (visual-line-mode 1))))
(when (< emacs-major-version 23)
(autoload 'linum-mode "linum" "" t))
;;; Recent files -------------------------------------------------------
(require 'recentf)
(recentf-mode 1)
(require 'recentf-ext)
(setq recentf-max-menu-items 25)
;;; Emacs server -------------------------------------------------------
;; no servers *started* from here, leave that to the host- files
(require 'server)
(defun is-server-running (name)
"Check is an emacs-server process is already running"
(interactive)
(let ((socket-path (concat server-socket-dir "/" name)))
;; server-running-p defined only in emacs23
(if (functionp 'server-running-p)
(server-running-p socket-path)
;; fall back, not as reliable
(file-exists-p socket-path))))
(defun start-named-server (name)
"Start a server named 'name' - ensure only 1 server of that name is running"
(interactive "sServer Name: ")
(setq server-name name)
(setq mk-server-socket-file (concat server-socket-dir "/" name))
(unless (is-server-running name)
(server-start)))
;;; NXML Setup ---------------------------------------------------------
(autoload 'nxml-mode "nxml-mode" "" t)
(add-to-list 'auto-mode-alist '("\\.\\(xml\\|xsl\\|rng\\|xhtml\\|pom\\)\\'" . nxml-mode))
;;; etags-select -------------------------------------------------------
(autoload 'etags-select-find-tag "etags-select" "for etags-select method" t)
(setq etags-select-no-select-for-one-match t)
(global-set-key "\M-." 'etags-select-find-tag)
(global-set-key [f7] 'etags-select-find-tag)
;;; Tramp (remote editing) ---------------------------------------------
(setq tramp-default-method "scp")
(setq tramp-default-user user-login-name)
(setq tramp-auto-save-directory "~/.tramp-autosave")
;;; Git VC backend setup -----------------------------------------------
(if nil
(progn
(require 'vc-git)
(when (featurep 'vc-git) (add-to-list 'vc-handled-backends 'git))
(require 'git)
(autoload 'git-blame-mode "git-blame" "Minor mode for incremental blame for Git." t))
(setq vc-handled-backends nil))
;;; Browse Kill Ring ---------------------------------------------------
(use-package browse-kill-ring
:ensure t
:commands browse-kill-ring
:config
(defadvice yank-pop (around kill-ring-browse-maybe (arg))
"If last action was not a yank, run `browse-kill-ring' instead."
(if (not (eq last-command 'yank))
(browse-kill-ring)
ad-do-it))
(ad-activate 'yank-pop))
;;; color-theme -------------------------------------------------------
(defun is-daemonized ()
(and (functionp 'daemonp)
(daemonp)))
(when (or window-system (is-daemonized))
(use-package base16-theme
:ensure t)
(load-theme 'base16-default-dark t))
;;;; Utils --------------------------------------------------------------
;; using mk-utils
(mk-arrow-keys-on)
(defalias 'imenu 'mk-ido-goto-symbol "imenu using ido")
(global-set-key (kbd "C-c TAB") 'imenu)
(define-key ctl-x-4-map "t" 'mk-toggle-window-split)
(define-key ctl-x-4-map "s" 'mk-swap-windows)
(global-set-key (kbd "C-x C-r") 'find-file-root)
(global-set-key (kbd "C-c C-f") 'mk-recentf-ido-find-file)
(autoload 'etags-update-mode "etags-update" "sweet!" t)
(eval-after-load "etags-update.el"
'(progn
(defun mk-etags-update-append-file-p (file)
(cond
((and mk-proj-name
mk-proj-tags-file
(string= mk-proj-basedir (substring file 0 (length mk-proj-basedir)))) ; eg, file *in* project
;; TODO (match mk-proj-src-patterns)
;; TODO (not-match mk-proj-ignore-patterns))
'add)
(t 'prompt)))
(setq etu/append-file-prompt 'mk-etags-update-append-file-p)))
;;; ido ----------------------------------------------------------------
(defvar mk-dont-ignore-buffer-names '("*grep*" "*Messages*" "*scratch*"))
(defun mk-ido-ignore-most-star-buffers (name)
(and
(string-match-p "^*" name)
(not (member name mk-dont-ignore-buffer-names))))
(setq ido-ignore-buffers (list "\\` " #'mk-ido-ignore-most-star-buffers))
;;;; Uniqify ------------------------------------------------------------
(require 'uniquify)
(setq uniquify-buffer-name-style 'post-forward ;; unique buffer names using
uniquify-separator ":") ;; part of file's path
;;; Host and System specific config -------------------------------------
(let ((hostname (downcase system-name))
(systype (downcase (symbol-name system-type))))
(cond ((string= "windows-nt" systype)
(maybe-load (concat "system-windows")))
((string= "gnu/linux" systype)
(maybe-load (concat "system-linux")))
((string= "berkeley-unix" systype)
(maybe-load (concat "system-bsd"))))
(maybe-load (concat "host-" hostname))
(when (and (>= (length hostname) (length "kelma12"))
(string= "kelma12" (substring hostname 0 (length "kelma12"))))
(maybe-load "work")))
(maybe-load "~/.emacs-local.el")
;;;; expand-region -----------------------------------------------------
(use-package expand-region
:ensure t
:bind (("C-c e" . er/expand-region)))
(use-package ace-window
:ensure t
:bind (("M-o" . ace-window))
:config (setq aw-keys '(?a ?s ?d ?f ?h ?j ?k ?l)))
(use-package ace-jump-mode
:ensure t
:bind (("M-SPC" . ace-jump-mode)))
(use-package magit
:ensure t
:commands magit-status magit-blame-mode
:bind (("C-c C-g" . mk-magit-for-project)
("C-M-g" . ido-switch-magit-buffer))
:config
(setq magit-save-repository-buffers nil
magit-last-seen-setup-instructions "1.4.0")
(add-to-list 'ido-ignore-buffers "*magit")) ;; TODO not working
(use-package git-timemachine
:ensure t)
(require 'smart-mode-line-obvious-theme)
(use-package smart-mode-line
:ensure t
:config (setq sml/theme 'obvious))
;;;; smex (keep at bottom of .emacs) ------------------------------------
(require 'smex)
(setq smex-save-file "~/.smex.save"
ido-enable-flex-matching t) ;; see also ido-enable-regexp
(smex-initialize)
(message "Emacs took %s seconds to start" (- (float-time) emacs-start-time))