-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.el
288 lines (262 loc) · 14.5 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
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
(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.
'(backup-directory-alist (quote (("." . "/home/synthesis/.backup"))))
'(c-basic-offset 4)
'(indent-tabs-mode nil)
'(initial-buffer-choice t)
'(safe-local-variable-values (quote ((todo-categories "Calorie" "Todo" "CalorieKeeper"))))
'(speedbar-directory-unshown-regexp "^\\(CVS\\|RCS\\|SCCS\\|.deps\\)\\'")
'(speedbar-frame-parameters (quote ((minibuffer) (width . 20) (border-width . 0) (menu-bar-lines . 0) (toolbar-lines . 0) (unsplittable . t) (set-background-color "black"))))
'(speedbar-supported-extension-expressions (quote (".[ch]\\(\\+\\+\\|pp\\|c\\|h\\|xx\\)?" ".tex\\(i\\(nfo\\)?\\)?" ".el" ".emacs" ".l" ".lsp" ".p" ".java" ".f\\(90\\|77\\|or\\)?" ".ad*" ".p[lm]" ".tcl" ".m" ".scm" ".pm" ".py" ".g" ".s?html" "[Mm]akefile\\(\\.in\\|am\\)?" "configure.ac" ".ml*" ".tig" ".\\(ll\\|yy\\)")))
'(tab-width 4)
'(vc-make-backup-files t))
(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.
'(default ((t (:inherit nil :stipple nil :background "black" :foreground "white" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :height 98 :width normal :foundry "outline" :family "Consolas"))))
'(background "blue")
'(cursor ((t (:background "#8a8a8a"))))
'(font-lock-builtin-face ((((class color) (background dark)) (:foreground "Turquoise"))))
'(font-lock-comment-face ((t (:background "#202020" :foreground "#AAAAAA"))))
'(font-lock-constant-face ((((class color) (background dark)) (:bold t :foreground "DarkOrchid"))))
'(font-lock-doc-face ((t (:inherit font-lock-comment-face :foreground "#88FF88"))))
'(font-lock-doc-string-face ((t (:foreground "green2"))))
'(font-lock-function-name-face ((t (:foreground "SkyBlue"))))
'(font-lock-keyword-face ((t (:bold t :foreground "CornflowerBlue"))))
'(font-lock-preprocessor-face ((t (:italic nil :foreground "CornFlowerBlue"))))
'(font-lock-reference-face ((t (:foreground "DodgerBlue"))))
'(font-lock-string-face ((t (:foreground "LimeGreen"))))
'(font-lock-type-face ((t (:foreground "#9290ff"))))
'(font-lock-variable-name-face ((t (:foreground "PaleGreen"))))
'(font-lock-warning-face ((((class color) (background dark)) (:foreground "yellow" :background "red"))))
'(highlight ((t (:background "CornflowerBlue"))))
'(list-mode-item-selected ((t (:background "gold"))))
'(makefile-space-face ((t (:background "wheat"))) t)
'(mode-line ((t (:background "Navy" :foreground "yellow" :width condensed :family "sans"))))
'(paren-match ((t (:background "darkseagreen4"))))
'(region ((t (:background "DarkSlateBlue"))))
'(show-paren-match ((t (:foreground "black" :background "wheat"))))
'(show-paren-match-face ((t (:foreground "black" :background "wheat"))) t)
'(show-paren-mismatch ((((class color)) (:foreground "white" :background "red"))))
'(show-paren-mismatch-face ((((class color)) (:foreground "white" :background "red"))) t)
'(speedbar-button-face ((((class color) (background dark)) (:foreground "green4"))))
'(speedbar-directory-face ((((class color) (background dark)) (:foreground "khaki"))))
'(speedbar-file-face ((((class color) (background dark)) (:foreground "cyan"))))
'(speedbar-tag-face ((((class color) (background dark)) (:foreground "Springgreen"))))
'(vhdl-speedbar-architecture-selected-face ((((class color) (background dark)) (:underline t :foreground "Blue"))))
'(vhdl-speedbar-entity-face ((((class color) (background dark)) (:foreground "darkGreen"))))
'(vhdl-speedbar-entity-selected-face ((((class color) (background dark)) (:underline t :foreground "darkGreen"))))
'(vhdl-speedbar-package-face ((((class color) (background dark)) (:foreground "black"))))
'(vhdl-speedbar-package-selected-face ((((class color) (background dark)) (:underline t :foreground "black"))))
'(widget-field ((((class grayscale color) (background light)) (:background "DarkBlue")))))
; Generic Emacs configuration
(require 'cl)
(require 'eieio)
(global-font-lock-mode t)
(setq zone-timer nil)
(column-number-mode t)
(menu-bar-mode -1)
(tool-bar-mode -1)
(cond
((string= (system-name) "DANIEL-LAPTOP")
(setq initial-frame-alist '((top . 0) (left . 0) (width . 267) (height . 67))))
((string= (system-name) "DGALLAGHER-PC")
(setq initial-frame-alist '((top . 0) (left . 0) (width . 267) (height . 78))))
((string= (system-name) "tmlsdev-laptop")
(setq initial-frame-alist '((top . 0) (left . 0) (width . 267) (height . 80)))
(setq compile-command "make -k -j 32")
(set-face-attribute 'default nil :foundry "unknown" :family "Ubuntu Mono" :height 220)))
(toggle-uniquify-buffer-names)
; Package management
(setq package-archives '(("gnu" . "http://elpa.gnu.org/packages/")
("marmalade" . "http://marmalade-repo.org/packages/")
("melpa" . "http://melpa.milkbox.net/packages/")))
; Enable "confusing" features
(defun no-op ())
(setq ring-bell-function 'no-op)
(put 'upcase-region 'disabled nil)
(put 'narrow-to-region 'disabled nil)
(put 'set-goal-column 'disabled nil)
(defun update-copyright ()
(interactive)
(save-excursion
(beginning-of-buffer)
(let ((start-years (search-forward " Copyright (c) " nil t))
(current-year (cadddr (cddr (decode-time (current-time))))))
(if start-years
(let ((end-years (search-forward-regexp "\\([[:digit:]]\\{4\\}\\(-[[:digit:]]\\{4\\}\\)?, ?\\)+" nil t))
(previous-year (1- current-year)))
(if end-years
(let ((years (buffer-substring start-years end-years)))
(let ((current-year-idx (search (format "%d" current-year) years))
(range-ending-last-year-idx (search (format "-%d" previous-year) years))
(last-year-idx (search (format "%d" previous-year) years)))
(if (not current-year-idx)
(if range-ending-last-year-idx
(replace-string (format "%d" previous-year) (format "%d" current-year) nil start-years end-years)
(if last-year-idx
(replace-string (format "%d" previous-year) (format "%d-%d" previous-year current-year) nil start-years end-years)
(insert (format "%d, " current-year)))))))))))))
(add-hook 'before-save-hook #'update-copyright)
(add-hook 'before-save-hook #'(lambda () (unless (eq major-mode 'makefile-gmake-mode) (untabify 0 (point-max)))))
(add-hook 'before-save-hook #'delete-trailing-whitespace)
; Set up autoloads and keys
(add-to-list 'load-path (concat (getenv "HOME") "/.emacs.d"))
(autoload 'open-header-with-source-buffer "open-header-with-source")
(autoload 'open-header-with-source-file "open-header-with-source")
(autoload 'cweb-mode "cweb")
(autoload 'qml-mode "qml-mode")
(autoload 'go-mode "go-mode" "Major mode for editing Go source code" t)
(autoload 'zap-up-to-char "utilities" "Zap all characters before the next instance of ch" t)
(autoload 'forward-buffer "utilities")
(autoload 'backward-buffer "utilities")
(autoload 'pad-to-column "utilities" "Insert spaces up to the given column" t)
(autoload 'number-line-reset "utilities" "Reset the line number for `number-line'")
(autoload 'number-line "utilities" "Add a comment with sequential line numbers, starting at 0")
(autoload 'my-doxymacs-insert-function-comment "code-editing" "Add a function comment" t)
(autoload 'automate-add-pure-virtual "code-editing" "Add a pure virtual function" t)
(autoload 'automate-add-last-virtual "code-editing" "Insert the virtual function signature" t)
(autoload 'automate-add-last-function "code-editing" "Insert the virtual function definition" t)
(autoload 'automate-add-method "code-editing" "Insert a non-virtual method" t)
(autoload 'qfetch-to-addcolumn "code-editing" "Change QFETCH to QTest::addColumn" t)
(autoload 'class-for-current-buffer "code-editing" "Get the class name for the current buffer" t)
(autoload 'signature-to-definition "code-editing" "Change a signature to a method definition" t)
(autoload 'open-corresponding-file "code-editing" "Open the file corresponding file (header/source)" t)
(autoload 'insert-include-guard "code-editing" "Insert include guards for the header" t)
(autoload 'align-assignments "code-editing" "Align assignments in the current region" t)
(autoload 'standard-slot "code-editing" "Implement a standard value-checking slot from a declaration" t)
(autoload 'qproperty-read "code-editing" "Construct a getter declaration from a Q_PROPERTY declaration" t)
(autoload 'qproperty-write "code-editing" "Construct a setter declaration from a Q_PROPERTY declaration" t)
(autoload 'qproperty-notify "code-editing" "Construct a signal declaration from a Q_PROPERTY declaration" t)
(autoload 'qproperty-member "code-editing" "Construct a member declaration from a Q_PROPERTY declaration" t)
(autoload 'insert-test-header "code-editing" "Insert a skeleton test header" t)
(autoload 'to-display-set-definition "omc")
(autoload 'insert-enum-value "omc")
(autoload 'insert-omc-header-copyright "omc" "Insert the Optimedica copyright text for headers at the beginning of the buffer" t)
(autoload 'insert-omc-source-copyright "omc" "Insert the Optimedica copyright text for source files at the beginning of the buffer" t)
(autoload 'insert-topcon-copyright "copyright" "Insert the Topcon copyright text at the beginning of the buffer" t)
(autoload 'insert-lynx-copyright "copyright" "Insert the Lynx copyright text at the beginning of the buffer" t)
(autoload 'insert-amo-copyright "copyright" "Insert the Abbot copyright text at the beginning of the buffer" t)
(autoload 'fire-and-forget-todo "todo")
(autoload 'structure-wizard "structure" "Wizard tool to create structure files" t)
(autoload 'struct-fn "struct/all-structs" "Code generator for POD structures and helper functions" t)
(autoload 'enum-fn "struct/all-structs" "Code generator for enums and helper functions" t)
(autoload 'align-switch "code-editing" "Align a simple switch case with single-line cases" t)
(autoload 'cpp-recorded-proxy-from-signature "code-editing" "Convert a C++ signature to an implementation that records the call and forwards it to a real object")
(autoload 'cpp-recorded-and-forwarded-signal-from-signature "code-editing" "Convert a C++ signature to an implementation that records the call and re-emits a signal")
(load "banner")
(load "utilities")
(global-set-key "\M-z" 'zap-up-to-char)
(global-set-key "\M-Z" 'zap-to-char)
(global-set-key [(control ?')] 'eshell)
(global-set-key "\C-cb" 'open-header-with-source-buffer)
(global-set-key "\C-cf" 'open-header-with-source-file)
(global-set-key "\C-cp" 'auto-fill-mode)
(global-set-key "\C-x\C-m" 'execute-extended-command)
(global-set-key "\C-c\C-g" 'goto-line)
(global-set-key "\C-c(" 'show-subtree)
(global-set-key "\C-c)" 'hide-subtree)
(global-set-key "\C-c/" 'highlight-changes-mode)
(global-set-key "\C-c+" 'c++-mode)
(global-set-key "\C-cc" 'c-mode)
(global-set-key "\C-c\C-k" 'kill-region)
(global-set-key "\C-w" 'backward-kill-word)
(global-set-key [(control ?,)] 'backward-buffer)
(global-set-key [(control ?.)] 'forward-buffer)
(global-set-key (kbd "<f5>") 'compile)
(global-set-key "\C-cd" 'my-doxymacs-insert-function-comment)
(global-set-key "\C-xt" 'fire-and-forget-todo)
(global-set-key "\C-xT" 'todo-show)
; Python programming
(add-hook 'python-mode-hook
'(lambda ()
(local-set-key "\C-c\C-w" 'kill-region)))
; C or C++ programming
(setq c-offsets-alist
'((arglist-intro . +)
(arglist-close . -)
(defun-block-intro . +)
(substatement-open . 0)
(statement-block-intro . +)
(block-close . 0)
(defun-close . -)
(case-label . 0)
(brace-list-open . 0)
(access-label . -)))
(setq c-doc-comment-style
'((java-mode . javadoc) (pike-mode . autodoc)
(c-mode . javadoc) (c++-mode . javadoc)))
(defun c/c++-mode ()
(local-set-key (kbd "<f6>") 'gdb)
(local-set-key "\C-cv" 'automate-add-pure-virtual)
(local-set-key "\C-cs" 'automate-add-last-virtual)
(local-set-key "\C-c-" 'automate-add-last-function)
(local-set-key "\C-cm" 'automate-add-method)
(local-set-key "\C-cr" 'open-corresponding-file)
(setq show-trailing-whitespace t)
(toggle-truncate-lines t))
(add-hook 'c-mode-hook '(lambda () (c/c++-mode)))
(add-hook 'c-mode-hook 'c-turn-on-eldoc-mode)
(add-hook 'c++-mode-hook '(lambda () (c/c++-mode)))
(add-hook 'find-file-hook
'(lambda ()
(setq show-trailing-whitespace t)))
(defun switch-to-window (needle)
(interactive "sBuffer name: ")
(let ((start (buffer-name)))
(other-window 1)
(while (and (not (string= start (buffer-name)))
(not (string= needle (buffer-name))))
(other-window 1))))
(defadvice compile (after follow-compile first () activate)
"Automatically scroll the compilation window"
(let ((here (buffer-name)))
(switch-to-window "*compilation*")
(end-of-buffer)
(switch-to-window here)))
(defun parenthesize-impl (b e)
(kill-region b e)
(insert "( ")
(yank)
(insert " )"))
(defun parenthesize ()
(interactive)
(if (region-active-p)
(parenthesize-impl (region-beginning) (region-end))
(let ((bounds (bounds-of-thing-at-point 'word)))
(parenthesize-impl (car bounds) (cdr bounds)))))
; Auto-load modes
(setq auto-mode-alist (cons '("\\.w" . cweb-mode)
auto-mode-alist))
(setq auto-mode-alist (cons '("\\.qml" . qml-mode)
auto-mode-alist))
(setq auto-mode-alist (cons '("\\.go" . go-mode)
auto-mode-alist))
;; Fake UUID generator
(random t)
(defun insert-random-uuid ()
"Insert a random UUID.
Example of a UUID: 1df63142-a513-c850-31a3-535fc3520c3d
WARNING: this is a simple implementation. The chance of generating the same UUID is much higher than a robust algorithm.."
(interactive)
(insert
(format "{%04x%04x-%04x-4%03x-%01x%03x-%06x%06x}"
(random (expt 16 4))
(random (expt 16 4))
(random (expt 16 4))
(random (expt 16 3))
(+ 8 (random 4))
(random (expt 16 3))
(random (expt 16 6))
(random (expt 16 6)))))
; Lisp support
(setq inferior-lisp-program "/usr/bin/clisp")
; Support emacsclient as the system editor
(server-start)
; Custom setup for TMLS development
(setenv "TMLS_DEBUG" "1")