commit | author | age
|
990949
|
1 |
#+TITLE: My Emacs configuration
|
C |
2 |
* Windows dependencies
|
|
3 |
Dependencies needed for Aspell, poppler PDF-tools, compilers and ghost-script provided by mingw64
|
|
4 |
#+BEGIN_SRC emacs-lisp
|
|
5 |
(when (eq system-type 'windows-nt)
|
|
6 |
(add-to-list 'exec-path "C:/msys64/usr/bin")
|
|
7 |
(add-to-list 'exec-path "C:/msys64/mingw64/bin")
|
|
8 |
(add-to-list 'exec-path "c:/Program Files/gnuplot")
|
|
9 |
(setenv "PATH" (mapconcat #'identity exec-path path-separator)))
|
|
10 |
#+END_SRC
|
|
11 |
|
|
12 |
* Aesthetic changes
|
|
13 |
** Zenburn theme
|
|
14 |
#+BEGIN_SRC emacs-lisp
|
|
15 |
(use-package zenburn-theme
|
|
16 |
:ensure t
|
|
17 |
:config
|
|
18 |
(load-theme 'zenburn t))
|
|
19 |
#+END_SRC
|
|
20 |
** Default font
|
|
21 |
#+BEGIN_SRC emacs-lisp
|
|
22 |
(set-frame-font "DejaVu Sans Mono" nil t)
|
|
23 |
#+END_SRC
|
|
24 |
** Remove menu bar, toolbar, but keep scroll bar
|
|
25 |
#+BEGIN_SRC emacs-lisp
|
|
26 |
(menu-bar-mode 0)
|
|
27 |
(tool-bar-mode 0)
|
|
28 |
(scroll-bar-mode 1)
|
|
29 |
#+END_SRC
|
|
30 |
|
|
31 |
* Writing requirements
|
|
32 |
** Spellchecking
|
|
33 |
#+BEGIN_SRC emacs-lisp
|
|
34 |
(require 'ispell)
|
|
35 |
(setq-default ispell-program-name "aspell")
|
|
36 |
(setq-default ispell-local-dictionary "en_AU")
|
|
37 |
(add-hook 'latex-mode-hook 'flyspell-mode)
|
|
38 |
(add-hook 'latex-mode-hook 'flyspell-buffer)
|
|
39 |
(add-hook 'org-mode-hook 'flyspell-mode)
|
|
40 |
(add-hook 'org-mode-hook 'flyspell-buffer)
|
|
41 |
#+END_SRC
|
|
42 |
|
|
43 |
** Switch-window
|
|
44 |
Helps to change windows easily when many are open at once
|
|
45 |
#+BEGIN_SRC emacs-lisp
|
|
46 |
(use-package switch-window
|
|
47 |
:ensure t
|
|
48 |
:config
|
|
49 |
(setq switch-window-input-style 'minibuffer)
|
|
50 |
(setq switch-window-increase 4)
|
|
51 |
(setq switch-window-threshold 2)
|
|
52 |
(setq switch-window-shortcut-style 'qwerty)
|
|
53 |
(setq switch-window-qwerty-shortcuts
|
|
54 |
'("a" "s" "d" "f" "j" "k" "l" "i" "o"))
|
|
55 |
:bind
|
|
56 |
([remap other-window] . switch-window))
|
|
57 |
#+END_SRC
|
|
58 |
** Go to new window when opened
|
|
59 |
#+BEGIN_SRC emacs-lisp
|
|
60 |
(defun split-and-follow-horizontally ()
|
|
61 |
(interactive)
|
|
62 |
(split-window-below)
|
|
63 |
(balance-windows)
|
|
64 |
(other-window 1))
|
|
65 |
(global-set-key (kbd "C-x 2") 'split-and-follow-horizontally)
|
|
66 |
|
|
67 |
(defun split-and-follow-vertically ()
|
|
68 |
(interactive)
|
|
69 |
(split-window-right)
|
|
70 |
(balance-windows)
|
|
71 |
(other-window 1))
|
|
72 |
(global-set-key (kbd "C-x 3") 'split-and-follow-vertically)
|
|
73 |
#+END_SRC
|
|
74 |
** PDF-tools
|
|
75 |
#+BEGIN_SRC emacs-lisp
|
|
76 |
(use-package pdf-tools
|
|
77 |
:ensure t
|
|
78 |
:config
|
|
79 |
(pdf-tools-install))
|
|
80 |
|
|
81 |
#+END_SRC
|
|
82 |
* Helm and Projectile
|
|
83 |
** Helm core
|
|
84 |
#+BEGIN_SRC emacs-lisp
|
|
85 |
(use-package helm-config
|
|
86 |
:ensure helm
|
|
87 |
:bind (("M-x" . helm-M-x)
|
|
88 |
("C-x C-f" . helm-find-files)
|
|
89 |
("M-y" . helm-show-kill-ring)
|
|
90 |
("C-x b" . helm-mini)
|
|
91 |
("C-c h o" . helm-occur))
|
|
92 |
:config
|
|
93 |
(setq helm-M-x-fuzzy-match t)
|
|
94 |
(setq helm-buffers-fuzzy-matching t
|
|
95 |
helm-recentf-fuzzy-match t)
|
|
96 |
(setq helm-split-window-in-side-p t ; open helm buffer inside current window, not occupy whole other window
|
|
97 |
helm-move-to-line-cycle-in-source t ; move to end or beginning of source when reaching top or bottom of source.
|
|
98 |
helm-ff-search-library-in-sexp t ; search for library in `require' and `declare-function' sexp.
|
|
99 |
helm-scroll-amount 8 ; scroll 8 lines other window using M-<next>/M-<prior>
|
|
100 |
helm-ff-file-name-history-use-recentf t
|
|
101 |
helm-echo-input-in-header-line t)
|
|
102 |
(defun spacemacs//helm-hide-minibuffer-maybe ()
|
|
103 |
"Hide minibuffer in Helm session if we use the header line as input field."
|
|
104 |
(when (with-helm-buffer helm-echo-input-in-header-line)
|
|
105 |
(let ((ov (make-overlay (point-min) (point-max) nil nil t)))
|
|
106 |
(overlay-put ov 'window (selected-window))
|
|
107 |
(overlay-put ov 'face
|
|
108 |
(let ((bg-color (face-background 'default nil)))
|
|
109 |
`(:background ,bg-color :foreground ,bg-color)))
|
|
110 |
(setq-local cursor-type nil))))
|
|
111 |
(add-hook 'helm-minibuffer-set-up-hook
|
|
112 |
'spacemacs//helm-hide-minibuffer-maybe)
|
|
113 |
(helm-mode 1))
|
|
114 |
#+END_SRC
|
|
115 |
** Projectile
|
|
116 |
*** Enable it
|
|
117 |
#+BEGIN_SRC emacs-lisp
|
|
118 |
(use-package projectile
|
|
119 |
:ensure t
|
|
120 |
:bind ("C-c p" . projectile-command-map)
|
|
121 |
:diminish projectile-mode
|
|
122 |
:config
|
|
123 |
(projectile-global-mode)
|
|
124 |
(setq projectile-completion-system 'helm)
|
|
125 |
(when (eq system-type 'windows-nt)
|
|
126 |
(setq projectile-indexing-method 'alien)))
|
|
127 |
#+END_SRC
|
|
128 |
*** Let it compile things
|
|
129 |
#+BEGIN_SRC emacs-lisp
|
|
130 |
(global-set-key (kbd "<f5>") 'projectile-compile-project)
|
|
131 |
#+END_SRC
|
|
132 |
*** Enable communication with helm
|
|
133 |
#+BEGIN_SRC emacs-lisp
|
|
134 |
(use-package helm-projectile
|
|
135 |
:ensure t
|
|
136 |
:config
|
|
137 |
(helm-projectile-on))
|
|
138 |
#+END_SRC
|
|
139 |
* Small tweaks
|
|
140 |
** Remove startup screen
|
|
141 |
#+BEGIN_SRC emacs-lisp
|
|
142 |
(setq inhibit-startup-message t)
|
|
143 |
#+END_SRC
|
|
144 |
** Disable bell
|
|
145 |
Bloody bell dings every time you hit a key too much
|
|
146 |
#+BEGIN_SRC emacs-lisp
|
|
147 |
(setq ring-bell-function 'ignore)
|
|
148 |
#+END_SRC
|
|
149 |
** Pretty symbols
|
|
150 |
Why not? They make it look nice
|
|
151 |
#+BEGIN_SRC emacs-lisp
|
|
152 |
(when window-system
|
|
153 |
(use-package pretty-mode
|
|
154 |
:ensure t
|
|
155 |
:diminish t
|
|
156 |
:config
|
|
157 |
(global-pretty-mode)))
|
|
158 |
#+END_SRC
|
|
159 |
** find file other window
|
|
160 |
Lets it accept more than one file. Works recursively.
|
|
161 |
#+BEGIN_SRC emacs-lisp
|
|
162 |
(defadvice find-file-other-window (around find-files activate)
|
|
163 |
(if (listp filename)
|
|
164 |
(loop for f in filename do (find-file-other-window f wildcards))
|
|
165 |
ad-do-it))
|
|
166 |
#+END_SRC
|
|
167 |
** Which key
|
|
168 |
Helps to explain keybindings if you get lost
|
|
169 |
#+BEGIN_SRC emacs-lisp
|
|
170 |
(use-package which-key
|
|
171 |
:ensure t
|
|
172 |
:diminish which-key-mode
|
|
173 |
:config
|
|
174 |
(which-key-mode))
|
|
175 |
#+END_SRC
|
|
176 |
** Go to this file
|
|
177 |
#+BEGIN_SRC emacs-lisp
|
|
178 |
(defun config-visit ()
|
|
179 |
(interactive)
|
|
180 |
(find-file "~/.emacs.d/config.org"))
|
|
181 |
(global-set-key (kbd "C-c e d") 'config-visit)
|
|
182 |
#+END_SRC
|
|
183 |
** Go to init.el
|
|
184 |
#+BEGIN_SRC emacs-lisp
|
|
185 |
(defun init-visit ()
|
|
186 |
(interactive)
|
|
187 |
(find-file "~/.emacs.d/init.el"))
|
|
188 |
(global-set-key (kbd "C-c e i") 'init-visit)
|
|
189 |
#+END_SRC
|
|
190 |
** Reload configuration
|
|
191 |
#+BEGIN_SRC emacs-lisp
|
|
192 |
(defun config-reload ()
|
|
193 |
"Reloads ~/.emacs.d/config.org at run time"
|
|
194 |
(interactive)
|
|
195 |
(org-babel-load-file (expand-file-name "~/.emacs.d/config.org")))
|
|
196 |
(global-set-key (kbd "C-c e r") 'config-reload)
|
|
197 |
#+END_SRC
|
|
198 |
** Smartparens
|
|
199 |
Matches brackets automatically
|
|
200 |
#+BEGIN_SRC emacs-lisp
|
|
201 |
(use-package smartparens
|
|
202 |
:ensure t
|
|
203 |
:diminish smartparens-mode
|
|
204 |
:config
|
|
205 |
(progn
|
|
206 |
(require 'smartparens-config)
|
|
207 |
(smartparens-global-mode 1)))
|
|
208 |
#+END_SRC
|
|
209 |
** Rainbow
|
|
210 |
Its a little gimmicky but its still cool
|
|
211 |
#+BEGIN_SRC emacs-lisp
|
|
212 |
(use-package rainbow-mode
|
|
213 |
:ensure t
|
|
214 |
:diminish rainbow-mode
|
|
215 |
:init
|
|
216 |
(add-hook 'prog-mode-hook 'rainbow-mode))
|
|
217 |
#+END_SRC
|
|
218 |
** Rainbow delimiters
|
|
219 |
A bit more useful than above.
|
|
220 |
Colours the brackets so that they stand out more.
|
|
221 |
#+BEGIN_SRC emacs-lisp
|
|
222 |
(use-package rainbow-delimiters
|
|
223 |
:ensure t
|
|
224 |
:init
|
|
225 |
(add-hook 'prog-mode-hook #'rainbow-delimiters-mode))
|
|
226 |
#+END_SRC
|
|
227 |
** clean-aindent-mode
|
|
228 |
Removes unnecessary white space
|
|
229 |
#+BEGIN_SRC emacs-lisp
|
|
230 |
(use-package clean-aindent-mode
|
|
231 |
:ensure t
|
|
232 |
:hook prog-mode)
|
|
233 |
#+END_SRC
|
|
234 |
Shows trailing white space
|
|
235 |
#+BEGIN_SRC emacs-lisp
|
|
236 |
(add-hook 'prog-mode-hook (lambda () (interactive) (setq show-trailing-whitespace 1)))
|
|
237 |
#+END_SRC
|
|
238 |
** whitespace mode
|
|
239 |
Reveals whitespace characters
|
|
240 |
#+BEGIN_SRC emacs-lisp
|
|
241 |
(global-set-key (kbd "C-c w") 'whitespace-mode)
|
|
242 |
(add-hook 'diff-mode-hook (lambda ()
|
|
243 |
(setq-local whitespace-style
|
|
244 |
'(face
|
|
245 |
tabs
|
|
246 |
tab-mark
|
|
247 |
spaces
|
|
248 |
space-mark
|
|
249 |
trailing
|
|
250 |
indentation::space
|
|
251 |
indentation::tab
|
|
252 |
newline
|
|
253 |
newline-mark))
|
|
254 |
(whitespace-mode 1)))
|
|
255 |
|
|
256 |
#+END_SRC
|
|
257 |
** eldoc
|
|
258 |
#+BEGIN_SRC emacs-lisp
|
|
259 |
(add-hook 'emacs-lisp-mode-hook 'eldoc-mode)
|
|
260 |
(add-hook 'lisp-interaction-mode-hook 'eldoc-mode)
|
|
261 |
(add-hook 'ielm-mode-hook 'eldoc-mode)
|
|
262 |
#+END_SRC
|
|
263 |
** key-freq
|
|
264 |
collects interesting statistics
|
|
265 |
#+BEGIN_SRC emacs-lisp
|
|
266 |
(use-package keyfreq
|
|
267 |
:ensure t
|
|
268 |
:config
|
|
269 |
(keyfreq-mode 1)
|
|
270 |
(keyfreq-autosave-mode 1))
|
|
271 |
#+END_SRC
|
|
272 |
** undo-tree
|
|
273 |
A more advanced undo mechanism
|
|
274 |
#+BEGIN_SRC emacs-lisp
|
|
275 |
(use-package undo-tree
|
|
276 |
:ensure t
|
|
277 |
:diminish undo-tree-mode
|
|
278 |
:config
|
|
279 |
(global-undo-tree-mode))
|
|
280 |
#+END_SRC
|
|
281 |
** volatile highlights
|
|
282 |
Colour the material just copied
|
|
283 |
#+BEGIN_SRC emacs-lisp
|
|
284 |
(use-package volatile-highlights
|
|
285 |
:ensure t
|
|
286 |
:diminish volatile-highlights-mode
|
|
287 |
:config
|
|
288 |
(volatile-highlights-mode t))
|
|
289 |
#+END_SRC
|
|
290 |
** Workgroups
|
|
291 |
Open the pages when you quit
|
|
292 |
#+BEGIN_SRC emacs-lisp
|
|
293 |
;; (use-package workgroups2
|
|
294 |
;; :ensure t
|
|
295 |
;; :diminish workgroups-mode
|
|
296 |
;; :config
|
|
297 |
;; (workgroups-mode 1))
|
|
298 |
#+END_SRC
|
|
299 |
** ibuffer
|
|
300 |
#+BEGIN_SRC emacs-lisp
|
|
301 |
(global-set-key (kbd "C-x C-b") 'ibuffer)
|
|
302 |
(setq ibuffer-use-other-window t)
|
|
303 |
#+END_SRC
|
|
304 |
** hippie expand
|
|
305 |
#+BEGIN_SRC emacs-lisp
|
|
306 |
(global-set-key (kbd "M-/") 'hippie-expand) ;; replace dabbrev-expand
|
|
307 |
(setq
|
|
308 |
hippie-expand-try-functions-list
|
|
309 |
'(try-expand-dabbrev ;; Try to expand word "dynamically", searching the current buffer.
|
|
310 |
try-expand-dabbrev-all-buffers ;; Try to expand word "dynamically", searching all other buffers.
|
|
311 |
try-expand-dabbrev-from-kill ;; Try to expand word "dynamically", searching the kill ring.
|
|
312 |
try-complete-file-name-partially ;; Try to complete text as a file name, as many characters as unique.
|
|
313 |
try-complete-file-name ;; Try to complete text as a file name.
|
|
314 |
try-expand-all-abbrevs ;; Try to expand word before point according to all abbrev tables.
|
|
315 |
try-expand-list ;; Try to complete the current line to an entire line in the buffer.
|
|
316 |
try-expand-line ;; Try to complete the current line to an entire line in the buffer.
|
|
317 |
try-complete-lisp-symbol-partially ;; Try to complete as an Emacs Lisp symbol, as many characters as unique.
|
|
318 |
try-complete-lisp-symbol) ;; Try to complete word as an Emacs Lisp symbol.
|
|
319 |
)
|
|
320 |
#+END_SRC
|
|
321 |
** Highlight line
|
|
322 |
#+BEGIN_SRC emacs-lisp
|
|
323 |
(global-hl-line-mode)
|
|
324 |
#+END_SRC
|
|
325 |
** Line numbers
|
|
326 |
#+BEGIN_SRC emacs-lisp
|
|
327 |
(add-hook 'prog-mode-hook 'linum-mode)
|
|
328 |
#+END_SRC
|
|
329 |
|
|
330 |
** Garbage collection
|
|
331 |
starts garbage collection every 100MB
|
|
332 |
#+BEGIN_SRC emacs-lisp
|
|
333 |
(setq gc-cons-threshold 100000000)
|
|
334 |
#+END_SRC
|
|
335 |
|
|
336 |
** Kill ring
|
|
337 |
Changes the kill ring size to 5000.
|
|
338 |
#+BEGIN_SRC emacs-lisp
|
|
339 |
(setq global-mark-ring-max 5000
|
|
340 |
mark-ring-max 5000
|
|
341 |
mode-require-final-newline t
|
|
342 |
kill-ring-max 5000
|
|
343 |
kill-whole-line t)
|
|
344 |
#+END_SRC
|
|
345 |
** Coding style
|
|
346 |
#+BEGIN_SRC emacs-lisp
|
|
347 |
(setq c-default-style "linux")
|
|
348 |
#+END_SRC
|
|
349 |
|
|
350 |
** Coding system
|
|
351 |
#+BEGIN_SRC emacs-lisp
|
|
352 |
(set-terminal-coding-system 'utf-8)
|
|
353 |
(set-keyboard-coding-system 'utf-8)
|
|
354 |
(set-language-environment "UTF-8")
|
|
355 |
(prefer-coding-system 'utf-8)
|
|
356 |
(setq-default indent-tabs-mode t)
|
|
357 |
(delete-selection-mode)
|
|
358 |
(global-set-key (kbd "RET") 'newline-and-indent)
|
|
359 |
#+END_SRC
|
|
360 |
** Move to beginning of line ignoring whitespace
|
|
361 |
Move point back to indentation of beginning of line.
|
|
362 |
|
|
363 |
Move point to the first non-whitespace character on this line.
|
|
364 |
If point is already there, move to the beginning of the line.
|
|
365 |
Effectively toggle between the first non-whitespace character and
|
|
366 |
the beginning of the line.
|
|
367 |
|
|
368 |
If ARG is not nil or 1, move forward ARG - 1 lines first. If
|
|
369 |
point reaches the beginning or end of the buffer, stop there.
|
|
370 |
#+BEGIN_SRC emacs-lisp
|
|
371 |
(defun prelude-move-beginning-of-line (arg)
|
|
372 |
(interactive "^p")
|
|
373 |
(setq arg (or arg 1))
|
|
374 |
|
|
375 |
;; Move lines first
|
|
376 |
(when (/= arg 1)
|
|
377 |
(let ((line-move-visual nil))
|
|
378 |
(forward-line (1- arg))))
|
|
379 |
|
|
380 |
(let ((orig-point (point)))
|
|
381 |
(back-to-indentation)
|
|
382 |
(when (= orig-point (point))
|
|
383 |
(move-beginning-of-line 1))))
|
|
384 |
|
|
385 |
(global-set-key (kbd "C-a") 'prelude-move-beginning-of-line)
|
|
386 |
#+END_SRC
|
|
387 |
** Indent region or buffer
|
|
388 |
#+BEGIN_SRC emacs-lisp
|
|
389 |
(defun indent-region-or-buffer ()
|
|
390 |
"Indent a region if selected, otherwise the whole buffer."
|
|
391 |
(interactive)
|
|
392 |
(unless (member major-mode prelude-indent-sensitive-modes)
|
|
393 |
(save-excursion
|
|
394 |
(if (region-active-p)
|
|
395 |
(progn
|
|
396 |
(indent-region (region-beginning) (region-end))
|
|
397 |
(message "Indented selected region."))
|
|
398 |
(progn
|
|
399 |
(indent-buffer)
|
|
400 |
(message "Indented buffer.")))
|
|
401 |
(whitespace-cleanup))))
|
|
402 |
|
|
403 |
(global-set-key (kbd "C-c i") 'indent-region-or-buffer)
|
|
404 |
#+END_SRC
|
|
405 |
** Tramp
|
|
406 |
#+BEGIN_SRC emacs-lisp
|
|
407 |
(when (eq system-type 'windows-nt)
|
|
408 |
(setq tramp-default-method "pscp"))
|
|
409 |
(setq password-cache-expiry nil)
|
|
410 |
#+END_SRC
|
|
411 |
|
|
412 |
* Mode line tweaks
|
|
413 |
Diminish is used but is included in init.el such that it can be used throughout this document
|
|
414 |
** Spaceline
|
|
415 |
A little easier to read than the default emacs mode line
|
|
416 |
#+BEGIN_SRC emacs-lisp
|
|
417 |
(use-package spaceline
|
|
418 |
:ensure t
|
|
419 |
:config
|
|
420 |
(require 'spaceline-config)
|
|
421 |
(setq spaceline-buffer-encoding-abbrev-p t)
|
|
422 |
(setq spaceline-line-column-p t)
|
|
423 |
(setq spaceline-line-p t)
|
|
424 |
(setq powerline-default-separator (quote arrow))
|
|
425 |
(spaceline-spacemacs-theme))
|
|
426 |
#+END_SRC
|
|
427 |
** No separator
|
|
428 |
#+BEGIN_SRC emacs-lisp
|
|
429 |
(setq powerline-default-seperator nil)
|
|
430 |
#+END_SRC
|
|
431 |
* Programming tweaks
|
|
432 |
** Yasnippet
|
|
433 |
#+BEGIN_SRC emacs-lisp
|
|
434 |
(use-package yasnippet
|
|
435 |
:ensure t
|
|
436 |
:diminish yas-minor-mode
|
|
437 |
:config
|
|
438 |
(use-package yasnippet-snippets
|
|
439 |
:ensure t)
|
|
440 |
(yas-reload-all)
|
|
441 |
(yas-global-mode 1))
|
|
442 |
#+END_SRC
|
|
443 |
** flycheck
|
|
444 |
#+BEGIN_SRC emacs-lisp
|
|
445 |
(use-package flycheck
|
|
446 |
:ensure t)
|
|
447 |
#+END_SRC
|
|
448 |
*** flycheck-pos-tip
|
|
449 |
#+BEGIN_SRC emacs-lisp
|
|
450 |
(use-package flycheck-pos-tip
|
|
451 |
:ensure t
|
|
452 |
:after flycheck
|
|
453 |
:config
|
|
454 |
(flycheck-pos-tip-mode))
|
|
455 |
#+END_SRC
|
|
456 |
** Company
|
|
457 |
Company is auto-complete for emacs
|
|
458 |
#+BEGIN_SRC emacs-lisp
|
|
459 |
(use-package company
|
|
460 |
:ensure t
|
|
461 |
:diminish company-mode
|
|
462 |
:config
|
|
463 |
(global-company-mode)
|
|
464 |
(setq company-idle-delay 0)
|
|
465 |
(setq company-minimum-prefix-length 3))
|
|
466 |
#+END_SRC
|
|
467 |
** Magit
|
|
468 |
#+BEGIN_SRC emacs-lisp
|
|
469 |
(use-package magit
|
|
470 |
:ensure t
|
|
471 |
:commands magit-get-top-dir
|
|
472 |
:bind ("C-x g" . magit-status)
|
|
473 |
:init
|
|
474 |
(progn
|
|
475 |
;; make magit status go full-screen but remember previous window
|
|
476 |
;; settings
|
|
477 |
;; from: http://whattheemacsd.com/setup-magit.el-01.html
|
|
478 |
(defadvice magit-status (around magit-fullscreen activate)
|
|
479 |
(window-configuration-to-register :magit-fullscreen)
|
|
480 |
ad-do-it
|
|
481 |
(delete-other-windows))
|
|
482 |
|
|
483 |
;; Close popup when committing - this stops the commit window
|
|
484 |
;; hanging around
|
|
485 |
;; From: http://git.io/rPBE0Q
|
|
486 |
(defadvice git-commit-commit (after delete-window activate)
|
|
487 |
(delete-window))
|
|
488 |
|
|
489 |
(defadvice git-commit-abort (after delete-window activate)
|
|
490 |
(delete-window))
|
|
491 |
|
|
492 |
:config
|
|
493 |
(progn
|
|
494 |
;; restore previously hidden windows
|
|
495 |
(defadvice magit-quit-window (around magit-restore-screen activate)
|
|
496 |
(let ((current-mode major-mode))
|
|
497 |
ad-do-it
|
|
498 |
;; we only want to jump to register when the last seen buffer
|
|
499 |
;; was a magit-status buffer.
|
|
500 |
(when (eq 'magit-status-mode current-mode)
|
|
501 |
(jump-to-register :magit-fullscreen)))))
|
|
502 |
|
|
503 |
;; magit settings
|
|
504 |
(setq
|
|
505 |
;; don't put "origin-" in front of new branch names by default
|
|
506 |
magit-default-tracking-name-function 'magit-default-tracking-name-branch-only
|
|
507 |
;; open magit status in same window as current buffer
|
|
508 |
magit-status-buffer-switch-function 'switch-to-buffer
|
|
509 |
;; highlight word/letter changes in hunk diffs
|
|
510 |
magit-diff-refine-hunk t
|
|
511 |
;; ask me if I want to include a revision when rewriting
|
|
512 |
magit-rewrite-inclusive 'ask
|
|
513 |
;; ask me to save buffers
|
|
514 |
magit-save-some-buffers t
|
|
515 |
;; pop the process buffer if we're taking a while to complete
|
|
516 |
magit-process-popup-time 10
|
|
517 |
;; ask me if I want a tracking upstream
|
|
518 |
magit-set-upstream-on-push 'askifnotset
|
|
519 |
)))
|
|
520 |
#+END_SRC
|
|
521 |
** CEDET
|
|
522 |
*** semantic
|
|
523 |
#+BEGIN_SRC emacs-lisp
|
|
524 |
(use-package semantic
|
|
525 |
:config
|
|
526 |
(global-semanticdb-minor-mode 1)
|
|
527 |
(global-semantic-idle-scheduler-mode 1)
|
|
528 |
(global-semantic-idle-summary-mode 1)
|
|
529 |
(semantic-mode 1))
|
|
530 |
#+END_SRC
|
|
531 |
*** EDE
|
|
532 |
#+BEGIN_SRC emacs-lisp
|
|
533 |
(use-package ede
|
|
534 |
:config
|
|
535 |
(global-ede-mode t))
|
|
536 |
#+END_SRC
|
|
537 |
*** gdb-many-windows
|
|
538 |
#+BEGIN_SRC emacs-lisp
|
|
539 |
(setq
|
|
540 |
;; use gdb-many-windows by default
|
|
541 |
gdb-many-windows t
|
|
542 |
|
|
543 |
;; Non-nil means display source file containing the main routine at startup
|
|
544 |
gdb-show-main t)
|
|
545 |
#+END_SRC
|
|
546 |
*** Semantic refactor
|
|
547 |
#+BEGIN_SRC emacs-lisp
|
|
548 |
(use-package srefactor
|
|
549 |
:ensure t
|
|
550 |
:bind (("M-RET o" . 'srefactor-lisp-one-line)
|
|
551 |
("M-RET m" . 'srefactor-lisp-format-sexp)
|
|
552 |
("M-RET d" . 'srefactor-lisp-format-defun)
|
|
553 |
("M-RET b" . 'srefactor-lisp-format-buffer)
|
|
554 |
:map c-mode-base-map
|
|
555 |
("M-RET" . 'srefactor-refactor-at-point)
|
|
556 |
:map c++-mode-map
|
|
557 |
("M-RET" . 'srefactor-refactor-at-point)))
|
|
558 |
#+END_SRC
|
|
559 |
** Language specific configs
|
|
560 |
*** C/C++
|
|
561 |
**** yasnippet
|
|
562 |
#+BEGIN_SRC emacs-lisp
|
|
563 |
(add-hook 'c++-mode-hook 'yas-minor-mode)
|
|
564 |
(add-hook 'c-mode-hook 'yas-minor-mode)
|
|
565 |
#+END_SRC
|
|
566 |
**** flycheck clang
|
|
567 |
#+BEGIN_SRC emacs-lisp
|
|
568 |
(use-package flycheck-clang-analyzer
|
|
569 |
:ensure t
|
|
570 |
:config
|
|
571 |
(with-eval-after-load 'flycheck
|
|
572 |
(require 'flycheck-clang-analyzer)
|
|
573 |
(flycheck-clang-analyzer-setup)))
|
|
574 |
#+END_SRC
|
|
575 |
**** company
|
|
576 |
#+BEGIN_SRC emacs-lisp
|
|
577 |
(use-package company-c-headers
|
|
578 |
:ensure t
|
|
579 |
:after company
|
|
580 |
:config
|
|
581 |
(add-hook 'c++-mode-hook 'company-mode)
|
|
582 |
(add-hook 'c-mode-hook 'company-mode))
|
|
583 |
|
|
584 |
(use-package company-irony
|
|
585 |
:ensure t
|
|
586 |
:config
|
|
587 |
(add-to-list 'company-backends '(company-c-headers
|
|
588 |
company-dabbrev-code
|
|
589 |
company-irony)))
|
|
590 |
|
|
591 |
(use-package irony
|
|
592 |
:ensure t
|
|
593 |
:init
|
|
594 |
(setq w32-pipe-read-delay 0)
|
|
595 |
(setq irony-server-w32-pipe-buffer-size (* 64 1024))
|
|
596 |
(add-hook 'c++-mode-hook 'irony-mode)
|
|
597 |
(add-hook 'c-mode-hook 'irony-mode)
|
|
598 |
(add-hook 'irony-mode-hook 'irony-cdb-autosetup-compile-options)
|
|
599 |
(add-hook 'irony-mode-hook 'irony-cdb-autosetup-compile-options))
|
|
600 |
#+END_SRC
|
|
601 |
*** emacs-lisp
|
|
602 |
**** eldoc
|
|
603 |
#+BEGIN_SRC emacs-lisp
|
|
604 |
(add-hook 'emacs-lisp-mode-hook 'eldoc-mode)
|
|
605 |
#+END_SRC
|
|
606 |
**** yasnippet
|
|
607 |
#+BEGIN_SRC emacs-lisp
|
|
608 |
(add-hook 'emacs-lisp-mode-hook 'yas-minor-mode)
|
|
609 |
#+END_SRC
|
|
610 |
**** company
|
|
611 |
#+BEGIN_SRC emacs-lisp
|
|
612 |
(add-hook 'emacs-lisp-mode-hook 'company-mode)
|
|
613 |
|
|
614 |
(use-package slime
|
|
615 |
:ensure t
|
|
616 |
:config
|
|
617 |
(setq inferior-lisp-program "/usr/bin/sbcl")
|
|
618 |
(setq slime-contribs '(slime-fancy)))
|
|
619 |
|
|
620 |
(use-package slime-company
|
|
621 |
:ensure t
|
|
622 |
:init
|
|
623 |
(require 'company)
|
|
624 |
(slime-setup '(slime-fancy slime-company)))
|
|
625 |
#+END_SRC
|
|
626 |
*** x86
|
|
627 |
**** x86-lookup
|
|
628 |
#+BEGIN_SRC emacs-lisp
|
|
629 |
(use-package x86-lookup
|
|
630 |
:ensure t
|
|
631 |
:init
|
|
632 |
(setq x86-lookup-pdf "D:/Coding/x86-instructions.pdf")
|
|
633 |
:bind ("C-h x" . x86-lookup))
|
|
634 |
#+END_SRC
|
|
635 |
*** Latex
|
|
636 |
**** AucTex
|
|
637 |
#+BEGIN_SRC emacs-lisp
|
|
638 |
(use-package tex
|
|
639 |
:ensure auctex
|
|
640 |
:config
|
|
641 |
(setq TeX-auto-save t)
|
|
642 |
(setq TeX-parse-self t)
|
|
643 |
(setq doc-view-ghostscript-program "c:/msys64/mingw64/bin/gswin32c.exe")
|
|
644 |
(setq preview-gs-command "c:/msys64/mingw64/bin/gs.exe"))
|
|
645 |
#+END_SRC
|
|
646 |
**** Company
|
|
647 |
#+BEGIN_SRC emacs-lisp
|
|
648 |
(use-package company-math
|
|
649 |
:ensure t
|
|
650 |
:after company
|
|
651 |
:config
|
|
652 |
(add-to-list 'company-backends 'company-math-symbols-unicode))
|
|
653 |
|
|
654 |
(use-package company-reftex
|
|
655 |
:ensure t
|
|
656 |
:after company
|
|
657 |
:config
|
|
658 |
(add-to-list 'company-backends 'company-reftex))
|
|
659 |
|
|
660 |
(use-package company-auctex
|
|
661 |
:ensure t
|
|
662 |
:after company
|
|
663 |
:config
|
|
664 |
(company-auctex-init))
|
|
665 |
|
|
666 |
(use-package company-bibtex
|
|
667 |
:ensure t
|
|
668 |
:after company
|
|
669 |
(add-to-list 'company-backends 'company-bibtex))
|
|
670 |
#+END_SRC
|
|
671 |
**** Preview pane
|
|
672 |
#+BEGIN_SRC emacs-lisp
|
|
673 |
(use-package latex-preview-pane
|
|
674 |
:ensure t
|
|
675 |
:config
|
|
676 |
(latex-preview-pane-enable))
|
|
677 |
#+END_SRC
|
|
678 |
**** TeXcount
|
|
679 |
Word counts in latex
|
|
680 |
#+BEGIN_SRC emacs-lisp
|
|
681 |
(when (eq system-type 'windows-nt)
|
|
682 |
(add-to-list 'exec-path "c:/Users/joelg/TeXcount_3_1_1")
|
|
683 |
(setenv "PATH" (mapconcat #'identity exec-path path-separator)))
|
|
684 |
|
|
685 |
(defun texcount ()
|
|
686 |
(interactive)
|
|
687 |
(let*
|
|
688 |
( (this-file (buffer-file-name))
|
|
689 |
(enc-str (symbol-name buffer-file-coding-system))
|
|
690 |
(enc-opt
|
|
691 |
(cond
|
|
692 |
((string-match "utf-8" enc-str) "-utf8")
|
|
693 |
((string-match "latin" enc-str) "-latin1")
|
|
694 |
("-encoding=guess")
|
|
695 |
) )
|
|
696 |
(word-count
|
|
697 |
(with-output-to-string
|
|
698 |
(with-current-buffer standard-output
|
|
699 |
(call-process "texcount" nil t nil "-0" enc-opt this-file)
|
|
700 |
) ) ) )
|
|
701 |
(message word-count)
|
|
702 |
) )
|
|
703 |
(add-hook 'LaTeX-mode-hook (lambda () (define-key LaTeX-mode-map (kbd "C-c c") 'texcount)))
|
|
704 |
(add-hook 'latex-mode-hook (lambda () (define-key latex-mode-map (kbd "C-c c") 'texcount)))
|
|
705 |
#+END_SRC
|
|
706 |
|
|
707 |
*** PlantUML
|
|
708 |
#+BEGIN_SRC emacs-lisp
|
|
709 |
(use-package plantuml-mode
|
|
710 |
:ensure t
|
|
711 |
:init
|
|
712 |
(setq plantuml-jar-path "c:/ProgramData/chocolatey/lib/plantuml/tools/plantuml.jar"))
|
|
713 |
#+END_SRC
|
|
714 |
|
|
715 |
*** Racket
|
|
716 |
**** Major mode
|
|
717 |
#+BEGIN_SRC emacs-lisp
|
|
718 |
(when (eq system-type 'windows-nt)
|
|
719 |
(add-to-list 'exec-path "c:/Program Files/Racket")
|
|
720 |
(setenv "PATH" (mapconcat #'identity exec-path path-separator)))
|
|
721 |
|
|
722 |
(use-package racket-mode
|
|
723 |
:ensure t
|
|
724 |
:config
|
|
725 |
(autoload 'racket-mode "Racket" "Racket Editing Mode" t)
|
|
726 |
(add-to-list
|
|
727 |
'auto-mode-alist
|
|
728 |
'("\\.rkt$" . matlab-mode))
|
|
729 |
(setq matlab-indent-function t))
|
|
730 |
#+END_SRC
|
|
731 |
|
|
732 |
*** Verilog
|
|
733 |
Add updated version and integrate it with Emacs.
|
|
734 |
#+BEGIN_SRC emacs-lisp
|
|
735 |
(add-to-list 'load-path "~/.emacs.d/elpa/verilog-mode-20190324/verilog-mode.el")
|
|
736 |
(require 'verilog-mode)
|
|
737 |
|
|
738 |
(autoload 'verilog-mode "verilog-mode" "Verilog mode" t )
|
|
739 |
(add-to-list 'auto-mode-alist '("\\.[ds]?vh?\\'" . verilog-mode))
|
|
740 |
#+END_SRC
|
|
741 |
* Org mode
|
|
742 |
** Up to date org
|
|
743 |
#+BEGIN_SRC emacs-lisp
|
|
744 |
(use-package org
|
|
745 |
:ensure t
|
|
746 |
:pin org)
|
|
747 |
#+END_SRC
|
|
748 |
** Small tweaks
|
|
749 |
#+BEGIN_SRC emacs-lisp
|
|
750 |
(setq org-src-fontify-natively t)
|
|
751 |
(setq org-src-tab-acts-natively t)
|
|
752 |
(setq org-confirm-babel-evaluate nil)
|
|
753 |
(setq org-export-with-smart-quotes t)
|
|
754 |
(setq org-src-window-setup 'current-window)
|
|
755 |
(add-hook 'org-mode-hook 'org-indent-mode)
|
|
756 |
(diminish 'org-indent-mode)
|
|
757 |
(diminish 'visual-line-mode)
|
|
758 |
#+END_SRC
|
|
759 |
** Line wrapping
|
|
760 |
#+BEGIN_SRC emacs-lisp
|
|
761 |
(add-hook 'org-mode-hook
|
|
762 |
'(lambda ()
|
|
763 |
(visual-line-mode 1)))
|
|
764 |
#+END_SRC
|
|
765 |
** org-bullets
|
|
766 |
#+BEGIN_SRC emacs-lisp
|
|
767 |
(use-package org-bullets
|
|
768 |
:ensure t
|
|
769 |
:config
|
|
770 |
(add-hook 'org-mode-hook (lambda () (org-bullets-mode))))
|
|
771 |
#+END_SRC
|
|
772 |
** Org Babel
|
|
773 |
*** Languages
|
|
774 |
Add C to org babel supported languages
|
|
775 |
#+BEGIN_SRC emacs-lisp
|
|
776 |
(org-babel-do-load-languages 'org-babel-load-languages '((emacs-lisp . t)
|
|
777 |
(C . t)
|
|
778 |
(python . t)
|
|
779 |
(latex . t)
|
|
780 |
(scheme . t)
|
|
781 |
(gnuplot . t)
|
|
782 |
(matlab . t)
|
|
783 |
(plantuml . t)
|
|
784 |
(fortran . t)
|
|
785 |
(java . t)))
|
|
786 |
#+END_SRC
|
|
787 |
** Latex preview fragments match colour
|
|
788 |
Make the previews match theme colour of Emacs.
|
|
789 |
#+BEGIN_SRC emacs-lisp
|
|
790 |
(let ((dvipng--plist (alist-get 'dvipng org-preview-latex-process-alist)))
|
|
791 |
(plist-put dvipng--plist :use-xcolor t)
|
|
792 |
(plist-put dvipng--plist :image-converter '("dvipng -D %D -T tight -o %O %f")))
|
|
793 |
#+END_SRC
|
|
794 |
|