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