This repository has been archived by the owner on Nov 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
init-min.el
217 lines (191 loc) · 7.12 KB
/
init-min.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
;; init-min.el --- Miniaml Initialization file for Emacs
;; Author: Mike Wall
;; URL: https://github.com/mjwall/emacs.d
;;; Commentary:
;; Emacs Startup File --- minimal initialization for Emacs
;; not using package.el here, see init.el for that
;;; Code:
;; turn off stuff early to avoid flicker
(when (fboundp 'menu-bar-mode) (menu-bar-mode -1))
(when (fboundp 'tool-bar-mode) (tool-bar-mode -1))
(when (fboundp 'scroll-bar-mode) (scroll-bar-mode -1))
;; some defaults
(setq-default
user-full-name "Michael Wall"
user-mail-address "[email protected]"
indent-tabs-mode nil
tab-width 2
inhibit-startup-message t
)
;; revert files when they change, like when switching git branches
(global-auto-revert-mode 1)
;; use y or n
(defalias 'yes-or-no-p 'y-or-n-p)
;; use cua
(cua-mode 1)
;; but enable selection without the C-z/C-x/C-c/C-v bindings.
(cua-selection-mode t)
;; insert matching delimiters
(electric-pair-mode 1)
;; highlight matching parentheses when the point is on them.
(show-paren-mode t)
;; show (L:C) in modeline
(column-number-mode 1)
;; stop showing completion buffer from minibuffer, use ? if you really want it
;; didn't really work for ido
;;(setq completion-auto-help nil)
;; encoding UTF-8
(prefer-coding-system 'utf-8)
(set-default-coding-systems 'utf-8)
(set-language-environment 'utf-8)
(set-selection-coding-system 'utf-8)
(set-language-environment "UTF-8")
;; backups
(defconst private-dir (expand-file-name "private" user-emacs-directory))
(defconst temp-dir (format "%s/cache" private-dir)
"Hostname-based elisp temp directories")
(setq
delete-old-versions t
history-length 1000
backup-inhibited nil
make-backup-files t
auto-save-default t
auto-save-list-file-name (concat temp-dir "/autosave")
make-backup-files t
create-lockfiles nil
backup-directory-alist `((".*" . ,(concat temp-dir "/backup/")))
auto-save-file-name-transforms `((".*" ,(concat temp-dir "/auto-save-list/") t)))
(unless (file-exists-p (concat temp-dir "/auto-save-list"))
(make-directory (concat temp-dir "/auto-save-list") :parents))
;; put customizations in a seperate file
(setq custom-file (expand-file-name "custom.el" user-emacs-directory))
(load custom-file)
;; Change some default keybinding
;; from https://sites.google.com/site/steveyegge2/effective-emacs
;; easier on the fingers and I don't do mail
(global-unset-key (kbd "C-x m"))
(global-set-key (kbd "C-x m") 'execute-extended-command)
(global-set-key (kbd "C-x C-m") 'execute-extended-command)
;; go to ibuffer instead of showing the list
(global-set-key (kbd "C-x C-b") 'ibuffer)
;; kill the current buffer, don't ask
(global-set-key (kbd "C-x C-k") 'kill-this-buffer)
;; add keys for indenting
(global-set-key (kbd "C->") 'indent-rigidly-right-to-tab-stop)
(global-set-key (kbd "C-<") 'indent-rigidly-left-to-tab-stop)
;; comments - since M-; call comment-dwim with doesn't comment a line
;; but this is not working in the terminal https://emacs.stackexchange.com/a/1056
;;(global-set-key (kbd "C-;") 'comment-or-uncomment-region)
;; theme - wombat is a good default dark one, adwaita is a good default light one
(load-theme 'adwaita t)
;; don't activate package
;; if you don't do this, the packages in elpa are loaded
(package-initialize 'no-activate)
;; add ~/.emacs.d/site-lisp
;; not using packages so anything that needs to be loaded must come from here
;; keeping is separate from site-lisp for now
(add-to-list 'load-path (expand-file-name "site-lisp" user-emacs-directory))
;; integrate text terminal with X clipboard
;; in site-lisp from https://github.com/emacsmirror/xclip/blob/master/xclip.el i
(require 'xclip)
(xclip-mode 1)
;; vc
(setq version-control t
vc-make-backup-files t
vc-follow-symlinks t
)
(require 'log-edit)
(require 'vc-git)
(add-to-list 'auto-mode-alist '("COMMIT_EDITMSG\\'" . vc-git-log-edit-mode))
;; eshell
(setq
eshell-directory-name (expand-file-name "eshell" temp-dir))
;; ido
(setq
;; Display ido results vertically, rather than horizontally
ido-decorations '("\n-> " " " "\n " "\n ..."
"[" "]" " [No match]" " [Matched]"
" [Not readable]" " [Too big]" " [Confirm]")
ido-enable-flex-matching t
ido-enable-prefix nil
ido-everywhere t
ido-max-prospects 20
ido-save-directory-list-file (concat temp-dir "/ido.last")
)
(defun my/ido-keys ()
(define-key ido-completion-map (kbd "C-n") 'ido-next-match)
(define-key ido-completion-map (kbd "<down>") 'ido-next-match)
(define-key ido-completion-map (kbd "C-p") 'ido-prev-match)
(define-key ido-completion-map (kbd "<up>") 'ido-prev-match))
(add-hook 'ido-setup-hook 'my/ido-keys)
(ido-mode 1)
(defvar ido-other-ignore-directories
'("\\`auto/" "\\`auto-save-list/" "\\`backups/" "\\`semanticdb/"
"\\`target/" "\\`\\.git/" "\\`\\.svn/" ))
(add-to-list 'ido-ignore-directories 'ido-other-ignore-directories)
(defvar ido-other-ignore-files
'("\\`auto/" "\\.prv/" "_region_" "\\.class/"))
(add-to-list 'ido-ignore-files 'ido-other-ignore-files)
;; recentf
(setq
recentf-max-saved-items 50
recentf-save-file (expand-file-name "recentf" temp-dir)
)
(global-set-key (kbd "C-x f") 'recentf-open-files)
(recentf-mode 1)
;; expansion
(setq hippie-expand-try-functions-list
'(try-expand-dabbrev
try-expand-dabbrev-all-buffers
try-expand-dabbrev-from-kill
try-complete-file-name-partially
try-complete-file-name
try-expand-all-abbrevs
try-expand-list
try-expand-line
try-complete-lisp-symbol-partially
try-complete-lisp-symbol))
;; reassign from dabbrev-expand
(global-set-key (kbd "M-/") 'hippie-expand)
;; color in compilation mode
(ignore-errors
(require 'ansi-color)
(defun colorize-compilation-buffer ()
(when (eq major-mode 'compilation-mode)
(ansi-color-apply-on-region compilation-filter-start (point-max))))
(add-hook 'compilation-filter-hook 'colorize-compilation-buffer))
;; and follow along during compile
(setq compilation-scroll-output 'first-error)
;; org mode
(setq org-startup-truncated nil) ;; wrap lines
;; speedbar
(setq
speedbar-use-images nil
speedbar-show-unknown-files t
speedbar-update-flag nil
)
;; sr-speedbar - because speedbar doesn't work in terminal
;; NOT built-in, see site-lisp
(require 'sr-speedbar)
(setq
sr-speedbar-right-side nil
sr-speedbar-auto-refresh nil
)
;; find file - because project-find-file is ugly
;; NOT built-in, see site-lisp
(require 'find-file-in-git-repo)
(require 'project)
(defun my-compile (dir)
"Run compile in project-current directory."
(interactive
(let ((default-directory (cdr (project-current))))
(call-interactively 'compile))))
(global-set-key (kbd "<f4>") 'my-compile)
(global-set-key (kbd "<f5>") 'vc-dir)
(global-set-key (kbd "<f6>") 'vc-git-grep)
;; (global-set-key (kbd "<f7>") 'project-find-file)
(global-set-key (kbd "<f7>") 'find-file-in-git-repo)
(global-set-key (kbd "<f8>") 'sr-speedbar-toggle)
(global-set-key (kbd "<f9>") 'eshell)
(provide 'init-min)
;;; init-min.el ends here