commit | author | age
|
990949
|
1 |
#+TITLE: My Emacs configuration
|
20e001
|
2 |
# LocalWords: poppler mingw emacs eq nt gnuplot setenv mapconcat el cond minibuffer pdf color Smartparens smartparens yas aindent whitespace eldoc ielm ibuffer hippie pscp pos Spaceline spaceline powerline spacemacs seperator dir Yasnippet yasnippet flycheck magit fullscreen CEDET askifnotset semanticdb EDE ede gdb srefactor analyzer eval cdb autosetup ghostscript math unicode reftex bibtex TeXcount texcount str latin rkt PlantUML plantuml autoload alist matlab verilog ds vh src fontify natively fortran dvipng plist xcolor EXWM Zenburn setq zenburn defun dolist init config DejaVu ispell aspell flyspell kbd recentf sexp ov bg listp defadvice progn prog keyfreq autosave dabbrev hl gc linum linux utf RET ARG arg configs backends contribs AucTex tex auctex LaTeX url
|
8a38cc
|
3 |
|
bf794a
|
4 |
* COMMENT Windows dependencies
|
990949
|
5 |
Dependencies needed for Aspell, poppler PDF-tools, compilers and ghost-script provided by mingw64
|
C |
6 |
#+BEGIN_SRC emacs-lisp
|
|
7 |
(when (eq system-type 'windows-nt)
|
|
8 |
(add-to-list 'exec-path "C:/msys64/usr/bin")
|
|
9 |
(add-to-list 'exec-path "C:/msys64/mingw64/bin")
|
|
10 |
(add-to-list 'exec-path "c:/Program Files/gnuplot")
|
|
11 |
(setenv "PATH" (mapconcat #'identity exec-path path-separator)))
|
|
12 |
#+END_SRC
|
|
13 |
|
|
14 |
* Aesthetic changes
|
0fcc09
|
15 |
** Emacs theme
|
C |
16 |
Zenburn theme is the default
|
990949
|
17 |
#+BEGIN_SRC emacs-lisp
|
0fcc09
|
18 |
(setq emacs-theme 'zenburn)
|
C |
19 |
|
412080
|
20 |
(defun disable-all-themes ()
|
C |
21 |
(dolist (i custom-enabled-themes)
|
|
22 |
(disable-theme i)))
|
|
23 |
|
0fcc09
|
24 |
(cond ((eq emacs-theme 'zenburn)
|
C |
25 |
(use-package zenburn-theme
|
|
26 |
:ensure t
|
412080
|
27 |
:init
|
C |
28 |
(disable-all-themes)
|
0fcc09
|
29 |
:config
|
C |
30 |
(load-theme 'zenburn t)))
|
|
31 |
((eq emacs-theme 'doom-one)
|
|
32 |
(use-package doom-themes
|
|
33 |
:ensure t
|
412080
|
34 |
:init
|
C |
35 |
(disable-all-themes)
|
0fcc09
|
36 |
:config
|
C |
37 |
(setq doom-themes-enable-bolt t
|
|
38 |
doom-themes-enable-italic t)
|
|
39 |
(load-theme 'doom-one t)
|
|
40 |
(doom-themes-visual-bell-config)
|
412080
|
41 |
(doom-themes-org-config)))
|
C |
42 |
((eq emacs-theme 'none)
|
|
43 |
(disable-all-themes)))
|
990949
|
44 |
#+END_SRC
|
8a38cc
|
45 |
|
990949
|
46 |
** Default font
|
20e001
|
47 |
#+BEGIN_SRC emacs-lisp
|
C |
48 |
;;(set-frame-font "DejaVu Sans Mono" nil t)
|
|
49 |
(set-frame-font "Dank Mono-11" nil t)
|
|
50 |
(set-face-italic 'font-lock-comment-face t)
|
|
51 |
(set-face-italic 'font-lock-keyword-face t)
|
990949
|
52 |
#+END_SRC
|
8a38cc
|
53 |
|
990949
|
54 |
** Remove menu bar, toolbar, but keep scroll bar
|
C |
55 |
#+BEGIN_SRC emacs-lisp
|
|
56 |
(menu-bar-mode 0)
|
|
57 |
(tool-bar-mode 0)
|
|
58 |
(scroll-bar-mode 1)
|
|
59 |
#+END_SRC
|
|
60 |
|
|
61 |
* Writing requirements
|
|
62 |
** Spellchecking
|
|
63 |
#+BEGIN_SRC emacs-lisp
|
|
64 |
(require 'ispell)
|
|
65 |
(setq-default ispell-program-name "aspell")
|
|
66 |
(setq-default ispell-local-dictionary "en_AU")
|
|
67 |
(add-hook 'latex-mode-hook 'flyspell-mode)
|
|
68 |
(add-hook 'latex-mode-hook 'flyspell-buffer)
|
|
69 |
(add-hook 'org-mode-hook 'flyspell-mode)
|
|
70 |
(add-hook 'org-mode-hook 'flyspell-buffer)
|
|
71 |
#+END_SRC
|
|
72 |
|
|
73 |
** Switch-window
|
|
74 |
Helps to change windows easily when many are open at once
|
|
75 |
#+BEGIN_SRC emacs-lisp
|
|
76 |
(use-package switch-window
|
|
77 |
:ensure t
|
|
78 |
:config
|
|
79 |
(setq switch-window-input-style 'minibuffer)
|
|
80 |
(setq switch-window-increase 4)
|
|
81 |
(setq switch-window-threshold 2)
|
|
82 |
(setq switch-window-shortcut-style 'qwerty)
|
|
83 |
(setq switch-window-qwerty-shortcuts
|
|
84 |
'("a" "s" "d" "f" "j" "k" "l" "i" "o"))
|
|
85 |
:bind
|
|
86 |
([remap other-window] . switch-window))
|
|
87 |
#+END_SRC
|
8a38cc
|
88 |
|
990949
|
89 |
** Go to new window when opened
|
C |
90 |
#+BEGIN_SRC emacs-lisp
|
|
91 |
(defun split-and-follow-horizontally ()
|
|
92 |
(interactive)
|
|
93 |
(split-window-below)
|
|
94 |
(balance-windows)
|
|
95 |
(other-window 1))
|
|
96 |
(global-set-key (kbd "C-x 2") 'split-and-follow-horizontally)
|
|
97 |
|
|
98 |
(defun split-and-follow-vertically ()
|
|
99 |
(interactive)
|
|
100 |
(split-window-right)
|
|
101 |
(balance-windows)
|
|
102 |
(other-window 1))
|
|
103 |
(global-set-key (kbd "C-x 3") 'split-and-follow-vertically)
|
|
104 |
#+END_SRC
|
8a38cc
|
105 |
|
990949
|
106 |
** PDF-tools
|
C |
107 |
#+BEGIN_SRC emacs-lisp
|
bf794a
|
108 |
(use-package pdf-tools
|
JG |
109 |
:ensure t
|
|
110 |
:config
|
|
111 |
(pdf-tools-install 1))
|
990949
|
112 |
#+END_SRC
|
8a38cc
|
113 |
|
49aa9f
|
114 |
** Writegood-mode
|
JG |
115 |
Supposedly should provide insight to writing quality
|
|
116 |
#+BEGIN_SRC emacs-lisp
|
|
117 |
(use-package writegood-mode
|
|
118 |
:ensure t
|
|
119 |
:hook (text-mode . writegood-mode))
|
|
120 |
#+END_SRC
|
|
121 |
|
990949
|
122 |
* Helm and Projectile
|
C |
123 |
** Helm core
|
|
124 |
#+BEGIN_SRC emacs-lisp
|
|
125 |
(use-package helm-config
|
|
126 |
:ensure helm
|
|
127 |
:bind (("M-x" . helm-M-x)
|
|
128 |
("C-x C-f" . helm-find-files)
|
|
129 |
("M-y" . helm-show-kill-ring)
|
|
130 |
("C-x b" . helm-mini)
|
|
131 |
("C-c h o" . helm-occur))
|
|
132 |
:config
|
|
133 |
(setq helm-M-x-fuzzy-match t)
|
|
134 |
(setq helm-buffers-fuzzy-matching t
|
|
135 |
helm-recentf-fuzzy-match t)
|
|
136 |
(setq helm-split-window-in-side-p t ; open helm buffer inside current window, not occupy whole other window
|
|
137 |
helm-move-to-line-cycle-in-source t ; move to end or beginning of source when reaching top or bottom of source.
|
|
138 |
helm-ff-search-library-in-sexp t ; search for library in `require' and `declare-function' sexp.
|
|
139 |
helm-scroll-amount 8 ; scroll 8 lines other window using M-<next>/M-<prior>
|
|
140 |
helm-ff-file-name-history-use-recentf t
|
|
141 |
helm-echo-input-in-header-line t)
|
|
142 |
(defun spacemacs//helm-hide-minibuffer-maybe ()
|
|
143 |
"Hide minibuffer in Helm session if we use the header line as input field."
|
|
144 |
(when (with-helm-buffer helm-echo-input-in-header-line)
|
|
145 |
(let ((ov (make-overlay (point-min) (point-max) nil nil t)))
|
|
146 |
(overlay-put ov 'window (selected-window))
|
|
147 |
(overlay-put ov 'face
|
|
148 |
(let ((bg-color (face-background 'default nil)))
|
|
149 |
`(:background ,bg-color :foreground ,bg-color)))
|
|
150 |
(setq-local cursor-type nil))))
|
|
151 |
(add-hook 'helm-minibuffer-set-up-hook
|
|
152 |
'spacemacs//helm-hide-minibuffer-maybe)
|
|
153 |
(helm-mode 1))
|
|
154 |
#+END_SRC
|
8a38cc
|
155 |
|
990949
|
156 |
** Projectile
|
C |
157 |
*** Enable it
|
|
158 |
#+BEGIN_SRC emacs-lisp
|
|
159 |
(use-package projectile
|
|
160 |
:ensure t
|
|
161 |
:bind ("C-c p" . projectile-command-map)
|
|
162 |
:diminish projectile-mode
|
|
163 |
:config
|
|
164 |
(projectile-global-mode)
|
|
165 |
(setq projectile-completion-system 'helm)
|
|
166 |
(when (eq system-type 'windows-nt)
|
|
167 |
(setq projectile-indexing-method 'alien)))
|
|
168 |
#+END_SRC
|
8a38cc
|
169 |
|
990949
|
170 |
*** Let it compile things
|
C |
171 |
#+BEGIN_SRC emacs-lisp
|
|
172 |
(global-set-key (kbd "<f5>") 'projectile-compile-project)
|
|
173 |
#+END_SRC
|
8a38cc
|
174 |
|
990949
|
175 |
*** Enable communication with helm
|
C |
176 |
#+BEGIN_SRC emacs-lisp
|
baf326
|
177 |
(use-package helm-projectile
|
C |
178 |
:ensure t
|
|
179 |
:config
|
|
180 |
(helm-projectile-on))
|
990949
|
181 |
#+END_SRC
|
8a38cc
|
182 |
|
bf794a
|
183 |
** ggtags
|
JG |
184 |
#+BEGIN_SRC emacs-lisp
|
|
185 |
(use-package ggtags
|
|
186 |
:ensure t
|
|
187 |
:bind (("C-c g s" . ggtags-find-other-symbol)
|
|
188 |
("C-c g h" . ggtags-view-tag-history)
|
|
189 |
("C-c g r" . ggtags-find-reference)
|
|
190 |
("C-c g f" . ggtags-find-file)
|
|
191 |
("C-c g c" . ggtags-create-tags)
|
|
192 |
("C-c g u" . ggtags-update-tags))
|
|
193 |
:config
|
|
194 |
(add-hook 'c-mode-common-hook
|
|
195 |
(lambda ()
|
|
196 |
(when (derived-mode-p 'c-mode 'c++-mode 'java-mode)
|
|
197 |
(ggtags-mode 1))))
|
|
198 |
)
|
|
199 |
|
|
200 |
(setq
|
|
201 |
helm-gtags-ignore-case t
|
|
202 |
helm-gtags-auto-update t
|
|
203 |
helm-gtags-use-input-at-cursor t
|
|
204 |
helm-gtags-pulse-at-cursor t
|
|
205 |
helm-gtags-prefix-key "\C-c g"
|
|
206 |
helm-gtags-suggested-key-mapping t
|
|
207 |
)
|
|
208 |
|
|
209 |
(use-package helm-gtags
|
|
210 |
:ensure t
|
|
211 |
:config
|
|
212 |
(add-hook 'dired-mode-hook 'helm-gtags-mode)
|
|
213 |
(add-hook 'eshell-mode-hook 'helm-gtags-mode)
|
|
214 |
(add-hook 'c-mode-hook 'helm-gtags-mode)
|
|
215 |
(add-hook 'c++-mode-hook 'helm-gtags-mode)
|
|
216 |
(add-hook 'asm-mode-hook 'helm-gtags-mode)
|
|
217 |
|
|
218 |
(define-key helm-gtags-mode-map (kbd "C-c g a") 'helm-gtags-tags-in-this-function)
|
|
219 |
(define-key helm-gtags-mode-map (kbd "C-j") 'helm-gtags-select)
|
|
220 |
(define-key helm-gtags-mode-map (kbd "M-.") 'helm-gtags-dwim)
|
|
221 |
(define-key helm-gtags-mode-map (kbd "M-,") 'helm-gtags-pop-stack)
|
|
222 |
(define-key helm-gtags-mode-map (kbd "C-c <") 'helm-gtags-previous-history)
|
|
223 |
(define-key helm-gtags-mode-map (kbd "C-c >") 'helm-gtags-next-history))
|
|
224 |
#+END_SRC
|
|
225 |
|
|
226 |
** Ctags
|
|
227 |
#+BEGIN_SRC emacs-lisp
|
|
228 |
(defvar ctags-command "ctags -e -R --languages=vhdl")
|
|
229 |
|
|
230 |
(defun ctags ()
|
|
231 |
(call-process-shell-command ctags-command nil "*Ctags*"))
|
|
232 |
|
|
233 |
|
|
234 |
(defun ctags-find-tags-file ()
|
|
235 |
"Recursively searches each parent directory for a file named
|
|
236 |
TAGS and returns the path to that file or nil if a tags file is
|
|
237 |
not found or if the buffer is not visiting a file."
|
|
238 |
(progn
|
|
239 |
(defun find-tags-file-r (path)
|
|
240 |
"Find the tags file from current to the parent directories."
|
|
241 |
(let* ((parent-directory (file-name-directory (directory-file-name path)))
|
|
242 |
(tags-file-name (concat (file-name-as-directory path) "TAGS")))
|
|
243 |
(cond
|
|
244 |
((file-exists-p tags-file-name) (throw 'found tags-file-name))
|
|
245 |
((string= "/TAGS" tags-file-name) nil)
|
|
246 |
(t (find-tags-file-r parent-directory)))))
|
|
247 |
|
|
248 |
(if (buffer-file-name)
|
|
249 |
(catch 'found
|
|
250 |
(find-tags-file-r (file-name-directory buffer-file-name)))
|
|
251 |
nil)))
|
|
252 |
|
|
253 |
(defun ctags-set-tags-file ()
|
|
254 |
"Uses `ctags-find-tags-file' to find a TAGS file. If found,
|
|
255 |
set 'tags-file-name' with its path or set as nil."
|
|
256 |
(setq-default tags-file-name (ctags-find-tags-file)))
|
|
257 |
|
|
258 |
(defun ctags-create-tags-table ()
|
|
259 |
(interactive)
|
|
260 |
(let* ((current-directory default-directory)
|
|
261 |
(top-directory (read-directory-name
|
|
262 |
"Top of source tree: " default-directory))
|
|
263 |
(file-name (concat (file-name-as-directory top-directory) "TAGS")))
|
|
264 |
(cd top-directory)
|
|
265 |
(if (not (= 0 (ctags)))
|
|
266 |
(message "Error creating %s!" file-name)
|
|
267 |
(setq-default tags-file-name file-name)
|
|
268 |
(message "Table %s created and configured." tags-file-name))
|
|
269 |
(cd current-directory)))
|
|
270 |
|
|
271 |
(defun ctags-update-tags-table ()
|
|
272 |
(interactive)
|
|
273 |
(let ((current-directory default-directory))
|
|
274 |
(if (not tags-file-name)
|
|
275 |
(message "Tags table not configured.")
|
|
276 |
(cd (file-name-directory tags-file-name))
|
|
277 |
(if (not (= 0 (ctags)))
|
|
278 |
(message "Error updating %s!" tags-file-name)
|
|
279 |
(message "Table %s updated." tags-file-name))
|
|
280 |
(cd current-directory))))
|
|
281 |
|
|
282 |
(defun ctags-create-or-update-tags-table ()
|
|
283 |
"Create or update a tags table with `ctags-command'."
|
|
284 |
(interactive)
|
|
285 |
(if (not (ctags-set-tags-file))
|
|
286 |
(ctags-create-tags-table)
|
|
287 |
(ctags-update-tags-table)))
|
|
288 |
|
|
289 |
|
|
290 |
(defun ctags-search ()
|
|
291 |
"A wrapper for `tags-search' that provide a default input."
|
|
292 |
(interactive)
|
|
293 |
(let* ((symbol-at-point (symbol-at-point))
|
|
294 |
(default (symbol-name symbol-at-point))
|
|
295 |
(input (read-from-minibuffer
|
|
296 |
(if (symbol-at-point)
|
|
297 |
(concat "Tags search (default " default "): ")
|
|
298 |
"Tags search (regexp): "))))
|
|
299 |
(if (and (symbol-at-point) (string= input ""))
|
|
300 |
(tags-search default)
|
|
301 |
(if (string= input "")
|
|
302 |
(message "You must provide a regexp.")
|
|
303 |
(tags-search input)))))
|
|
304 |
#+END_SRC
|
|
305 |
|
990949
|
306 |
* Small tweaks
|
C |
307 |
** Remove startup screen
|
|
308 |
#+BEGIN_SRC emacs-lisp
|
|
309 |
(setq inhibit-startup-message t)
|
|
310 |
#+END_SRC
|
8a38cc
|
311 |
|
990949
|
312 |
** Disable bell
|
C |
313 |
Bloody bell dings every time you hit a key too much
|
|
314 |
#+BEGIN_SRC emacs-lisp
|
|
315 |
(setq ring-bell-function 'ignore)
|
|
316 |
#+END_SRC
|
8a38cc
|
317 |
|
990949
|
318 |
** Pretty symbols
|
C |
319 |
Why not? They make it look nice
|
|
320 |
#+BEGIN_SRC emacs-lisp
|
|
321 |
(when window-system
|
|
322 |
(use-package pretty-mode
|
|
323 |
:ensure t
|
|
324 |
:diminish t
|
|
325 |
:config
|
|
326 |
(global-pretty-mode)))
|
|
327 |
#+END_SRC
|
8a38cc
|
328 |
|
990949
|
329 |
** find file other window
|
C |
330 |
Lets it accept more than one file. Works recursively.
|
|
331 |
#+BEGIN_SRC emacs-lisp
|
|
332 |
(defadvice find-file-other-window (around find-files activate)
|
|
333 |
(if (listp filename)
|
|
334 |
(loop for f in filename do (find-file-other-window f wildcards))
|
|
335 |
ad-do-it))
|
|
336 |
#+END_SRC
|
8a38cc
|
337 |
|
990949
|
338 |
** Which key
|
C |
339 |
Helps to explain keybindings if you get lost
|
|
340 |
#+BEGIN_SRC emacs-lisp
|
|
341 |
(use-package which-key
|
|
342 |
:ensure t
|
|
343 |
:diminish which-key-mode
|
|
344 |
:config
|
|
345 |
(which-key-mode))
|
|
346 |
#+END_SRC
|
8a38cc
|
347 |
|
bf794a
|
348 |
** Config shortcuts
|
JG |
349 |
*** Go to this file
|
990949
|
350 |
#+BEGIN_SRC emacs-lisp
|
C |
351 |
(defun config-visit ()
|
|
352 |
(interactive)
|
|
353 |
(find-file "~/.emacs.d/config.org"))
|
|
354 |
(global-set-key (kbd "C-c e d") 'config-visit)
|
|
355 |
#+END_SRC
|
8a38cc
|
356 |
|
bf794a
|
357 |
*** Go to init.el
|
990949
|
358 |
#+BEGIN_SRC emacs-lisp
|
C |
359 |
(defun init-visit ()
|
|
360 |
(interactive)
|
|
361 |
(find-file "~/.emacs.d/init.el"))
|
|
362 |
(global-set-key (kbd "C-c e i") 'init-visit)
|
|
363 |
#+END_SRC
|
8a38cc
|
364 |
|
bf794a
|
365 |
*** Reload configuration
|
990949
|
366 |
#+BEGIN_SRC emacs-lisp
|
C |
367 |
(defun config-reload ()
|
|
368 |
"Reloads ~/.emacs.d/config.org at run time"
|
|
369 |
(interactive)
|
|
370 |
(org-babel-load-file (expand-file-name "~/.emacs.d/config.org")))
|
|
371 |
(global-set-key (kbd "C-c e r") 'config-reload)
|
|
372 |
#+END_SRC
|
8a38cc
|
373 |
|
990949
|
374 |
** Smartparens
|
C |
375 |
Matches brackets automatically
|
|
376 |
#+BEGIN_SRC emacs-lisp
|
|
377 |
(use-package smartparens
|
|
378 |
:ensure t
|
|
379 |
:diminish smartparens-mode
|
|
380 |
:config
|
|
381 |
(progn
|
|
382 |
(require 'smartparens-config)
|
|
383 |
(smartparens-global-mode 1)))
|
|
384 |
#+END_SRC
|
8a38cc
|
385 |
|
990949
|
386 |
** Rainbow
|
C |
387 |
Its a little gimmicky but its still cool
|
|
388 |
#+BEGIN_SRC emacs-lisp
|
|
389 |
(use-package rainbow-mode
|
|
390 |
:ensure t
|
|
391 |
:diminish rainbow-mode
|
|
392 |
:init
|
|
393 |
(add-hook 'prog-mode-hook 'rainbow-mode))
|
|
394 |
#+END_SRC
|
8a38cc
|
395 |
|
990949
|
396 |
** Rainbow delimiters
|
C |
397 |
A bit more useful than above.
|
|
398 |
Colours the brackets so that they stand out more.
|
|
399 |
#+BEGIN_SRC emacs-lisp
|
|
400 |
(use-package rainbow-delimiters
|
|
401 |
:ensure t
|
|
402 |
:init
|
|
403 |
(add-hook 'prog-mode-hook #'rainbow-delimiters-mode))
|
|
404 |
#+END_SRC
|
8a38cc
|
405 |
|
990949
|
406 |
** clean-aindent-mode
|
C |
407 |
Removes unnecessary white space
|
|
408 |
#+BEGIN_SRC emacs-lisp
|
|
409 |
(use-package clean-aindent-mode
|
|
410 |
:ensure t
|
|
411 |
:hook prog-mode)
|
|
412 |
#+END_SRC
|
|
413 |
Shows trailing white space
|
|
414 |
#+BEGIN_SRC emacs-lisp
|
|
415 |
(add-hook 'prog-mode-hook (lambda () (interactive) (setq show-trailing-whitespace 1)))
|
|
416 |
#+END_SRC
|
8a38cc
|
417 |
|
990949
|
418 |
** whitespace mode
|
C |
419 |
Reveals whitespace characters
|
|
420 |
#+BEGIN_SRC emacs-lisp
|
|
421 |
(global-set-key (kbd "C-c w") 'whitespace-mode)
|
|
422 |
(add-hook 'diff-mode-hook (lambda ()
|
|
423 |
(setq-local whitespace-style
|
|
424 |
'(face
|
|
425 |
tabs
|
|
426 |
tab-mark
|
|
427 |
spaces
|
|
428 |
space-mark
|
|
429 |
trailing
|
|
430 |
indentation::space
|
|
431 |
indentation::tab
|
|
432 |
newline
|
|
433 |
newline-mark))
|
|
434 |
(whitespace-mode 1)))
|
|
435 |
|
|
436 |
#+END_SRC
|
8a38cc
|
437 |
|
990949
|
438 |
** eldoc
|
C |
439 |
#+BEGIN_SRC emacs-lisp
|
|
440 |
(add-hook 'emacs-lisp-mode-hook 'eldoc-mode)
|
|
441 |
(add-hook 'lisp-interaction-mode-hook 'eldoc-mode)
|
|
442 |
(add-hook 'ielm-mode-hook 'eldoc-mode)
|
|
443 |
#+END_SRC
|
8a38cc
|
444 |
|
990949
|
445 |
** key-freq
|
C |
446 |
collects interesting statistics
|
|
447 |
#+BEGIN_SRC emacs-lisp
|
|
448 |
(use-package keyfreq
|
|
449 |
:ensure t
|
|
450 |
:config
|
|
451 |
(keyfreq-mode 1)
|
|
452 |
(keyfreq-autosave-mode 1))
|
|
453 |
#+END_SRC
|
8a38cc
|
454 |
|
990949
|
455 |
** undo-tree
|
C |
456 |
A more advanced undo mechanism
|
|
457 |
#+BEGIN_SRC emacs-lisp
|
|
458 |
(use-package undo-tree
|
|
459 |
:ensure t
|
|
460 |
:diminish undo-tree-mode
|
|
461 |
:config
|
|
462 |
(global-undo-tree-mode))
|
|
463 |
#+END_SRC
|
8a38cc
|
464 |
|
990949
|
465 |
** volatile highlights
|
C |
466 |
Colour the material just copied
|
|
467 |
#+BEGIN_SRC emacs-lisp
|
|
468 |
(use-package volatile-highlights
|
|
469 |
:ensure t
|
|
470 |
:diminish volatile-highlights-mode
|
|
471 |
:config
|
|
472 |
(volatile-highlights-mode t))
|
|
473 |
#+END_SRC
|
8a38cc
|
474 |
|
990949
|
475 |
** ibuffer
|
C |
476 |
#+BEGIN_SRC emacs-lisp
|
|
477 |
(global-set-key (kbd "C-x C-b") 'ibuffer)
|
|
478 |
(setq ibuffer-use-other-window t)
|
|
479 |
#+END_SRC
|
8a38cc
|
480 |
|
990949
|
481 |
** hippie expand
|
C |
482 |
#+BEGIN_SRC emacs-lisp
|
|
483 |
(global-set-key (kbd "M-/") 'hippie-expand) ;; replace dabbrev-expand
|
|
484 |
(setq
|
|
485 |
hippie-expand-try-functions-list
|
|
486 |
'(try-expand-dabbrev ;; Try to expand word "dynamically", searching the current buffer.
|
|
487 |
try-expand-dabbrev-all-buffers ;; Try to expand word "dynamically", searching all other buffers.
|
|
488 |
try-expand-dabbrev-from-kill ;; Try to expand word "dynamically", searching the kill ring.
|
|
489 |
try-complete-file-name-partially ;; Try to complete text as a file name, as many characters as unique.
|
|
490 |
try-complete-file-name ;; Try to complete text as a file name.
|
|
491 |
try-expand-all-abbrevs ;; Try to expand word before point according to all abbrev tables.
|
|
492 |
try-expand-list ;; Try to complete the current line to an entire line in the buffer.
|
|
493 |
try-expand-line ;; Try to complete the current line to an entire line in the buffer.
|
|
494 |
try-complete-lisp-symbol-partially ;; Try to complete as an Emacs Lisp symbol, as many characters as unique.
|
|
495 |
try-complete-lisp-symbol) ;; Try to complete word as an Emacs Lisp symbol.
|
|
496 |
)
|
|
497 |
#+END_SRC
|
8a38cc
|
498 |
|
990949
|
499 |
** Highlight line
|
C |
500 |
#+BEGIN_SRC emacs-lisp
|
|
501 |
(global-hl-line-mode)
|
|
502 |
#+END_SRC
|
8a38cc
|
503 |
|
990949
|
504 |
** Line numbers
|
C |
505 |
#+BEGIN_SRC emacs-lisp
|
|
506 |
(add-hook 'prog-mode-hook 'linum-mode)
|
|
507 |
#+END_SRC
|
|
508 |
|
|
509 |
** Garbage collection
|
|
510 |
starts garbage collection every 100MB
|
|
511 |
#+BEGIN_SRC emacs-lisp
|
|
512 |
(setq gc-cons-threshold 100000000)
|
|
513 |
#+END_SRC
|
|
514 |
|
|
515 |
** Kill ring
|
|
516 |
Changes the kill ring size to 5000.
|
|
517 |
#+BEGIN_SRC emacs-lisp
|
|
518 |
(setq global-mark-ring-max 5000
|
|
519 |
mark-ring-max 5000
|
|
520 |
mode-require-final-newline t
|
|
521 |
kill-ring-max 5000
|
|
522 |
kill-whole-line t)
|
|
523 |
#+END_SRC
|
8a38cc
|
524 |
|
990949
|
525 |
** Coding style
|
C |
526 |
#+BEGIN_SRC emacs-lisp
|
bf794a
|
527 |
(setq c-default-style '((java-mode . "java")
|
JG |
528 |
(awk-mode . "awk")
|
|
529 |
(other . "k&r")))
|
990949
|
530 |
#+END_SRC
|
C |
531 |
|
|
532 |
** Coding system
|
|
533 |
#+BEGIN_SRC emacs-lisp
|
bf794a
|
534 |
(set-terminal-coding-system 'utf-8)
|
JG |
535 |
(set-keyboard-coding-system 'utf-8)
|
|
536 |
(set-language-environment "UTF-8")
|
|
537 |
(prefer-coding-system 'utf-8)
|
|
538 |
(setq-default indent-tabs-mode t
|
|
539 |
tab-width 4)
|
|
540 |
(delete-selection-mode)
|
|
541 |
(global-set-key (kbd "RET") 'newline-and-indent)
|
990949
|
542 |
#+END_SRC
|
8a38cc
|
543 |
|
990949
|
544 |
** Move to beginning of line ignoring whitespace
|
C |
545 |
Move point back to indentation of beginning of line.
|
|
546 |
|
|
547 |
Move point to the first non-whitespace character on this line.
|
|
548 |
If point is already there, move to the beginning of the line.
|
|
549 |
Effectively toggle between the first non-whitespace character and
|
|
550 |
the beginning of the line.
|
|
551 |
|
|
552 |
If ARG is not nil or 1, move forward ARG - 1 lines first. If
|
|
553 |
point reaches the beginning or end of the buffer, stop there.
|
|
554 |
#+BEGIN_SRC emacs-lisp
|
|
555 |
(defun prelude-move-beginning-of-line (arg)
|
|
556 |
(interactive "^p")
|
|
557 |
(setq arg (or arg 1))
|
|
558 |
|
|
559 |
;; Move lines first
|
|
560 |
(when (/= arg 1)
|
|
561 |
(let ((line-move-visual nil))
|
|
562 |
(forward-line (1- arg))))
|
|
563 |
|
|
564 |
(let ((orig-point (point)))
|
|
565 |
(back-to-indentation)
|
|
566 |
(when (= orig-point (point))
|
|
567 |
(move-beginning-of-line 1))))
|
|
568 |
|
|
569 |
(global-set-key (kbd "C-a") 'prelude-move-beginning-of-line)
|
|
570 |
#+END_SRC
|
8a38cc
|
571 |
|
990949
|
572 |
** Indent region or buffer
|
C |
573 |
#+BEGIN_SRC emacs-lisp
|
|
574 |
(defun indent-region-or-buffer ()
|
|
575 |
"Indent a region if selected, otherwise the whole buffer."
|
|
576 |
(interactive)
|
|
577 |
(unless (member major-mode prelude-indent-sensitive-modes)
|
|
578 |
(save-excursion
|
|
579 |
(if (region-active-p)
|
|
580 |
(progn
|
|
581 |
(indent-region (region-beginning) (region-end))
|
|
582 |
(message "Indented selected region."))
|
|
583 |
(progn
|
|
584 |
(indent-buffer)
|
|
585 |
(message "Indented buffer.")))
|
|
586 |
(whitespace-cleanup))))
|
|
587 |
|
|
588 |
(global-set-key (kbd "C-c i") 'indent-region-or-buffer)
|
|
589 |
#+END_SRC
|
8a38cc
|
590 |
|
990949
|
591 |
** Tramp
|
C |
592 |
#+BEGIN_SRC emacs-lisp
|
|
593 |
(when (eq system-type 'windows-nt)
|
|
594 |
(setq tramp-default-method "pscp"))
|
|
595 |
(setq password-cache-expiry nil)
|
|
596 |
#+END_SRC
|
|
597 |
|
|
598 |
* Mode line tweaks
|
|
599 |
Diminish is used but is included in init.el such that it can be used throughout this document
|
|
600 |
** Spaceline
|
|
601 |
A little easier to read than the default emacs mode line
|
|
602 |
#+BEGIN_SRC emacs-lisp
|
412080
|
603 |
(use-package spaceline
|
C |
604 |
:ensure t
|
|
605 |
:config
|
|
606 |
(require 'spaceline-config)
|
|
607 |
(setq spaceline-buffer-encoding-abbrev-p t)
|
|
608 |
(setq spaceline-line-column-p t)
|
|
609 |
(setq spaceline-line-p t)
|
|
610 |
(setq powerline-default-separator (quote arrow))
|
|
611 |
(spaceline-spacemacs-theme)
|
|
612 |
(spaceline-helm-mode))
|
990949
|
613 |
#+END_SRC
|
8a38cc
|
614 |
|
990949
|
615 |
** No separator
|
C |
616 |
#+BEGIN_SRC emacs-lisp
|
|
617 |
(setq powerline-default-seperator nil)
|
|
618 |
#+END_SRC
|
8a38cc
|
619 |
|
990949
|
620 |
* Programming tweaks
|
C |
621 |
** Yasnippet
|
|
622 |
#+BEGIN_SRC emacs-lisp
|
bf794a
|
623 |
(use-package yasnippet
|
JG |
624 |
:ensure t
|
|
625 |
:diminish yas-minor-mode
|
|
626 |
:config
|
|
627 |
(use-package yasnippet-snippets
|
|
628 |
:ensure t)
|
|
629 |
(yas-reload-all)
|
|
630 |
(yas-global-mode 1))
|
990949
|
631 |
#+END_SRC
|
8a38cc
|
632 |
|
990949
|
633 |
** flycheck
|
C |
634 |
#+BEGIN_SRC emacs-lisp
|
8a38cc
|
635 |
(use-package flycheck
|
C |
636 |
:ensure t
|
|
637 |
:diminish flycheck-mode
|
|
638 |
:config
|
|
639 |
(global-flycheck-mode))
|
990949
|
640 |
#+END_SRC
|
bf794a
|
641 |
*** flycheck-pos-tipe
|
990949
|
642 |
#+BEGIN_SRC emacs-lisp
|
C |
643 |
(use-package flycheck-pos-tip
|
|
644 |
:ensure t
|
|
645 |
:after flycheck
|
|
646 |
:config
|
|
647 |
(flycheck-pos-tip-mode))
|
|
648 |
#+END_SRC
|
8a38cc
|
649 |
|
990949
|
650 |
** Company
|
8a38cc
|
651 |
Company is auto-complete for Emacs
|
990949
|
652 |
#+BEGIN_SRC emacs-lisp
|
C |
653 |
(use-package company
|
|
654 |
:ensure t
|
|
655 |
:diminish company-mode
|
|
656 |
:config
|
|
657 |
(global-company-mode)
|
|
658 |
(setq company-idle-delay 0)
|
|
659 |
(setq company-minimum-prefix-length 3))
|
|
660 |
#+END_SRC
|
8a38cc
|
661 |
|
990949
|
662 |
** Magit
|
C |
663 |
#+BEGIN_SRC emacs-lisp
|
|
664 |
(use-package magit
|
|
665 |
:ensure t
|
|
666 |
:commands magit-get-top-dir
|
|
667 |
:bind ("C-x g" . magit-status)
|
|
668 |
:init
|
|
669 |
(progn
|
|
670 |
;; make magit status go full-screen but remember previous window
|
|
671 |
;; settings
|
|
672 |
;; from: http://whattheemacsd.com/setup-magit.el-01.html
|
|
673 |
(defadvice magit-status (around magit-fullscreen activate)
|
|
674 |
(window-configuration-to-register :magit-fullscreen)
|
|
675 |
ad-do-it
|
|
676 |
(delete-other-windows))
|
|
677 |
|
|
678 |
;; Close popup when committing - this stops the commit window
|
|
679 |
;; hanging around
|
|
680 |
;; From: http://git.io/rPBE0Q
|
|
681 |
(defadvice git-commit-commit (after delete-window activate)
|
|
682 |
(delete-window))
|
|
683 |
|
|
684 |
(defadvice git-commit-abort (after delete-window activate)
|
|
685 |
(delete-window))
|
|
686 |
|
|
687 |
:config
|
|
688 |
(progn
|
|
689 |
;; restore previously hidden windows
|
|
690 |
(defadvice magit-quit-window (around magit-restore-screen activate)
|
|
691 |
(let ((current-mode major-mode))
|
|
692 |
ad-do-it
|
|
693 |
;; we only want to jump to register when the last seen buffer
|
|
694 |
;; was a magit-status buffer.
|
|
695 |
(when (eq 'magit-status-mode current-mode)
|
|
696 |
(jump-to-register :magit-fullscreen)))))
|
|
697 |
|
|
698 |
;; magit settings
|
|
699 |
(setq
|
|
700 |
;; don't put "origin-" in front of new branch names by default
|
|
701 |
magit-default-tracking-name-function 'magit-default-tracking-name-branch-only
|
|
702 |
;; open magit status in same window as current buffer
|
|
703 |
magit-status-buffer-switch-function 'switch-to-buffer
|
|
704 |
;; highlight word/letter changes in hunk diffs
|
|
705 |
magit-diff-refine-hunk t
|
|
706 |
;; ask me if I want to include a revision when rewriting
|
|
707 |
magit-rewrite-inclusive 'ask
|
|
708 |
;; ask me to save buffers
|
|
709 |
magit-save-some-buffers t
|
|
710 |
;; pop the process buffer if we're taking a while to complete
|
|
711 |
magit-process-popup-time 10
|
|
712 |
;; ask me if I want a tracking upstream
|
|
713 |
magit-set-upstream-on-push 'askifnotset
|
|
714 |
)))
|
|
715 |
#+END_SRC
|
8a38cc
|
716 |
|
990949
|
717 |
** CEDET
|
C |
718 |
*** semantic
|
|
719 |
#+BEGIN_SRC emacs-lisp
|
|
720 |
(use-package semantic
|
|
721 |
:config
|
|
722 |
(global-semanticdb-minor-mode 1)
|
|
723 |
(global-semantic-idle-scheduler-mode 1)
|
|
724 |
(global-semantic-idle-summary-mode 1)
|
|
725 |
(semantic-mode 1))
|
|
726 |
#+END_SRC
|
8a38cc
|
727 |
|
990949
|
728 |
*** EDE
|
C |
729 |
#+BEGIN_SRC emacs-lisp
|
|
730 |
(use-package ede
|
|
731 |
:config
|
|
732 |
(global-ede-mode t))
|
|
733 |
#+END_SRC
|
8a38cc
|
734 |
|
990949
|
735 |
*** gdb-many-windows
|
C |
736 |
#+BEGIN_SRC emacs-lisp
|
|
737 |
(setq
|
|
738 |
;; use gdb-many-windows by default
|
|
739 |
gdb-many-windows t
|
|
740 |
|
|
741 |
;; Non-nil means display source file containing the main routine at startup
|
|
742 |
gdb-show-main t)
|
|
743 |
#+END_SRC
|
8a38cc
|
744 |
|
990949
|
745 |
*** Semantic refactor
|
C |
746 |
#+BEGIN_SRC emacs-lisp
|
|
747 |
(use-package srefactor
|
|
748 |
:ensure t
|
|
749 |
:bind (("M-RET o" . 'srefactor-lisp-one-line)
|
|
750 |
("M-RET m" . 'srefactor-lisp-format-sexp)
|
|
751 |
("M-RET d" . 'srefactor-lisp-format-defun)
|
|
752 |
("M-RET b" . 'srefactor-lisp-format-buffer)
|
|
753 |
:map c-mode-base-map
|
|
754 |
("M-RET" . 'srefactor-refactor-at-point)
|
|
755 |
:map c++-mode-map
|
|
756 |
("M-RET" . 'srefactor-refactor-at-point)))
|
|
757 |
#+END_SRC
|
8a38cc
|
758 |
|
990949
|
759 |
** Language specific configs
|
C |
760 |
*** C/C++
|
|
761 |
**** yasnippet
|
|
762 |
#+BEGIN_SRC emacs-lisp
|
|
763 |
(add-hook 'c++-mode-hook 'yas-minor-mode)
|
|
764 |
(add-hook 'c-mode-hook 'yas-minor-mode)
|
|
765 |
#+END_SRC
|
8a38cc
|
766 |
|
990949
|
767 |
**** flycheck clang
|
C |
768 |
#+BEGIN_SRC emacs-lisp
|
|
769 |
(use-package flycheck-clang-analyzer
|
|
770 |
:ensure t
|
|
771 |
:config
|
|
772 |
(with-eval-after-load 'flycheck
|
|
773 |
(require 'flycheck-clang-analyzer)
|
|
774 |
(flycheck-clang-analyzer-setup)))
|
|
775 |
#+END_SRC
|
8a38cc
|
776 |
|
990949
|
777 |
**** company
|
C |
778 |
#+BEGIN_SRC emacs-lisp
|
|
779 |
(use-package company-c-headers
|
|
780 |
:ensure t
|
|
781 |
:after company
|
|
782 |
:config
|
|
783 |
(add-hook 'c++-mode-hook 'company-mode)
|
|
784 |
(add-hook 'c-mode-hook 'company-mode))
|
|
785 |
|
|
786 |
(use-package company-irony
|
|
787 |
:ensure t
|
|
788 |
:config
|
|
789 |
(add-to-list 'company-backends '(company-c-headers
|
|
790 |
company-dabbrev-code
|
|
791 |
company-irony)))
|
|
792 |
|
|
793 |
(use-package irony
|
|
794 |
:ensure t
|
|
795 |
:init
|
|
796 |
(setq w32-pipe-read-delay 0)
|
|
797 |
(setq irony-server-w32-pipe-buffer-size (* 64 1024))
|
|
798 |
(add-hook 'c++-mode-hook 'irony-mode)
|
|
799 |
(add-hook 'c-mode-hook 'irony-mode)
|
|
800 |
(add-hook 'irony-mode-hook 'irony-cdb-autosetup-compile-options)
|
|
801 |
(add-hook 'irony-mode-hook 'irony-cdb-autosetup-compile-options))
|
|
802 |
#+END_SRC
|
8a38cc
|
803 |
|
990949
|
804 |
*** emacs-lisp
|
C |
805 |
**** eldoc
|
|
806 |
#+BEGIN_SRC emacs-lisp
|
|
807 |
(add-hook 'emacs-lisp-mode-hook 'eldoc-mode)
|
|
808 |
#+END_SRC
|
8a38cc
|
809 |
|
990949
|
810 |
**** yasnippet
|
C |
811 |
#+BEGIN_SRC emacs-lisp
|
|
812 |
(add-hook 'emacs-lisp-mode-hook 'yas-minor-mode)
|
|
813 |
#+END_SRC
|
8a38cc
|
814 |
|
990949
|
815 |
**** company
|
C |
816 |
#+BEGIN_SRC emacs-lisp
|
|
817 |
(add-hook 'emacs-lisp-mode-hook 'company-mode)
|
|
818 |
|
|
819 |
(use-package slime
|
|
820 |
:ensure t
|
|
821 |
:config
|
|
822 |
(setq inferior-lisp-program "/usr/bin/sbcl")
|
|
823 |
(setq slime-contribs '(slime-fancy)))
|
|
824 |
|
|
825 |
(use-package slime-company
|
|
826 |
:ensure t
|
|
827 |
:init
|
|
828 |
(require 'company)
|
|
829 |
(slime-setup '(slime-fancy slime-company)))
|
|
830 |
#+END_SRC
|
8a38cc
|
831 |
|
bf794a
|
832 |
*** COMMENT x86
|
990949
|
833 |
**** x86-lookup
|
C |
834 |
#+BEGIN_SRC emacs-lisp
|
|
835 |
(use-package x86-lookup
|
|
836 |
:ensure t
|
|
837 |
:init
|
|
838 |
(setq x86-lookup-pdf "D:/Coding/x86-instructions.pdf")
|
|
839 |
:bind ("C-h x" . x86-lookup))
|
|
840 |
#+END_SRC
|
8a38cc
|
841 |
|
990949
|
842 |
*** Latex
|
C |
843 |
**** AucTex
|
|
844 |
#+BEGIN_SRC emacs-lisp
|
20e001
|
845 |
(use-package tex
|
C |
846 |
:ensure auctex
|
|
847 |
:config
|
|
848 |
(setq TeX-auto-save t)
|
|
849 |
(setq TeX-parse-self t)
|
|
850 |
(setq TeX-view-program-selection '((output-pdf "PDF Tools"))
|
|
851 |
TeX-source-correlate-start-server t)
|
|
852 |
(add-hook 'TeX-after-compilation-finished-functions #'TeX-revert-document-buffer))
|
990949
|
853 |
#+END_SRC
|
8a38cc
|
854 |
|
990949
|
855 |
**** Company
|
C |
856 |
#+BEGIN_SRC emacs-lisp
|
|
857 |
(use-package company-math
|
|
858 |
:ensure t
|
|
859 |
:after company
|
|
860 |
:config
|
|
861 |
(add-to-list 'company-backends 'company-math-symbols-unicode))
|
|
862 |
|
|
863 |
(use-package company-reftex
|
|
864 |
:ensure t
|
|
865 |
:after company
|
|
866 |
:config
|
|
867 |
(add-to-list 'company-backends 'company-reftex))
|
|
868 |
|
|
869 |
(use-package company-auctex
|
|
870 |
:ensure t
|
|
871 |
:after company
|
|
872 |
:config
|
|
873 |
(company-auctex-init))
|
|
874 |
|
|
875 |
(use-package company-bibtex
|
|
876 |
:ensure t
|
|
877 |
:after company
|
|
878 |
(add-to-list 'company-backends 'company-bibtex))
|
|
879 |
#+END_SRC
|
8a38cc
|
880 |
|
bf794a
|
881 |
**** TeXcount
|
990949
|
882 |
Word counts in latex
|
C |
883 |
#+BEGIN_SRC emacs-lisp
|
bf794a
|
884 |
(defun get-texcount-latest()
|
JG |
885 |
(if (not(file-directory-p "~/.texcount"))
|
|
886 |
(make-directory "~/.texcount"))
|
|
887 |
(url-copy-file "https://app.uio.no/ifi/texcount/download.php?file=texcount_3_1_1.zip" "~/.texcount/texcount.zip" 1)
|
|
888 |
(shell-command "unzip -o ~/.texcount/texcount.zip -d ~/.texcount")
|
|
889 |
(add-to-list 'exec-path "~/.texcount/texcount.pl"))
|
20e001
|
890 |
|
bf794a
|
891 |
(if (not(file-exists-p "~/.texcount/texcount.pl"))
|
JG |
892 |
(get-texcount-latest))
|
990949
|
893 |
|
bf794a
|
894 |
(defun texcount ()
|
JG |
895 |
(interactive)
|
|
896 |
(let*
|
|
897 |
( (this-file (buffer-file-name))
|
|
898 |
(enc-str (symbol-name buffer-file-coding-system))
|
|
899 |
(enc-opt
|
|
900 |
(cond
|
|
901 |
((string-match "utf-8" enc-str) "-utf8")
|
|
902 |
((string-match "latin" enc-str) "-latin1")
|
|
903 |
("-encoding=guess")
|
|
904 |
) )
|
|
905 |
(word-count
|
|
906 |
(with-output-to-string
|
|
907 |
(with-current-buffer standard-output
|
|
908 |
(call-process "texcount" nil t nil "-0" enc-opt this-file)
|
|
909 |
) ) ) )
|
|
910 |
(message word-count)
|
|
911 |
) )
|
|
912 |
(add-hook 'LaTeX-mode-hook (lambda () (define-key LaTeX-mode-map (kbd "C-c c") 'texcount)))
|
|
913 |
(add-hook 'latex-mode-hook (lambda () (define-key latex-mode-map (kbd "C-c c") 'texcount)))
|
990949
|
914 |
#+END_SRC
|
C |
915 |
|
|
916 |
*** PlantUML
|
|
917 |
#+BEGIN_SRC emacs-lisp
|
bf794a
|
918 |
(use-package plantuml-mode
|
JG |
919 |
:ensure t
|
|
920 |
:init
|
|
921 |
(cond ((eq system-type 'windows-nt)
|
|
922 |
(setq plantuml-jar-path "c:/ProgramData/chocolatey/lib/plantuml/tools/plantuml.jar"))
|
|
923 |
((eq system-type 'gnu/linux)
|
|
924 |
(setq plantuml-jar-path "/usr/share/java/plantuml/plantuml.jar"))))
|
990949
|
925 |
#+END_SRC
|
C |
926 |
|
bf794a
|
927 |
*** COMMENT Racket
|
990949
|
928 |
**** Major mode
|
C |
929 |
#+BEGIN_SRC emacs-lisp
|
|
930 |
(when (eq system-type 'windows-nt)
|
|
931 |
(add-to-list 'exec-path "c:/Program Files/Racket")
|
|
932 |
(setenv "PATH" (mapconcat #'identity exec-path path-separator)))
|
|
933 |
|
|
934 |
(use-package racket-mode
|
|
935 |
:ensure t
|
|
936 |
:config
|
|
937 |
(autoload 'racket-mode "Racket" "Racket Editing Mode" t)
|
|
938 |
(add-to-list
|
|
939 |
'auto-mode-alist
|
8a38cc
|
940 |
'("\\.rkt$" . racket-mode))
|
990949
|
941 |
(setq matlab-indent-function t))
|
C |
942 |
#+END_SRC
|
|
943 |
|
|
944 |
*** Verilog
|
baf326
|
945 |
**** Get latest version
|
C |
946 |
Pull the latest version from the web
|
|
947 |
#+BEGIN_SRC emacs-lisp
|
|
948 |
(defun get-verilog-latest()
|
0864ff
|
949 |
(if (not(file-directory-p "~/.emacs.d/elpa/verilog-mode"))
|
C |
950 |
(make-directory "~/.emacs.d/elpa/verilog-mode"))
|
|
951 |
(if (file-exists-p "~/.emacs.d/elpa/verilog-mode/verilog-mode.el")
|
|
952 |
(delete-file "~/.emacs.d/elpa/verilog-mode/verilog-mode.el"))
|
dc8eb0
|
953 |
(url-copy-file "https://www.veripool.org/ftp/verilog-mode.el" "~/.emacs.d/elpa/verilog-mode/verilog-mode.el" 1))
|
baf326
|
954 |
#+END_SRC
|
C |
955 |
|
|
956 |
**** Integrate into emacs
|
990949
|
957 |
Add updated version and integrate it with Emacs.
|
C |
958 |
#+BEGIN_SRC emacs-lisp
|
0864ff
|
959 |
(defun verilog-read-file-as-string (file)
|
C |
960 |
"Read FILE contents."
|
|
961 |
(when (file-exists-p file)
|
|
962 |
(with-temp-buffer
|
|
963 |
(insert-file-contents file)
|
|
964 |
(buffer-string))))
|
|
965 |
|
|
966 |
(defun verilog-write-string-to-file (file string)
|
|
967 |
"Substitute FILE contents with STRING."
|
|
968 |
(with-temp-buffer
|
|
969 |
(insert string)
|
|
970 |
(when (file-writable-p file)
|
|
971 |
(write-region (point-min)
|
|
972 |
(point-max)
|
|
973 |
file))))
|
|
974 |
|
|
975 |
(defun verilog-today-day ()
|
|
976 |
(time-to-days (current-time)))
|
|
977 |
|
|
978 |
(defun should-update-verilog-p ()
|
|
979 |
"Return non-nil when an update is due."
|
|
980 |
(and
|
|
981 |
(or
|
|
982 |
(not (file-exists-p "~/.emacs.d/.last-verilog-update-day"))
|
|
983 |
(if (>= (/ (- (verilog-today-day) (verilog-read-last-update-day)) 7) 1)
|
|
984 |
t
|
|
985 |
nil))))
|
|
986 |
|
|
987 |
(defun verilog-read-last-update-day ()
|
|
988 |
"Read last update day."
|
|
989 |
(string-to-number
|
|
990 |
(verilog-read-file-as-string "~/.emacs.d/.last-verilog-update-day")))
|
|
991 |
|
|
992 |
(defun verilog-write-current-day ()
|
|
993 |
"Store current day."
|
|
994 |
(verilog-write-string-to-file
|
|
995 |
"~/.emacs.d/.last-verilog-update-day"
|
|
996 |
(int-to-string (verilog-today-day))))
|
|
997 |
|
|
998 |
(use-package verilog-mode
|
|
999 |
:init
|
|
1000 |
(when (should-update-verilog-p)
|
|
1001 |
(get-verilog-latest)
|
|
1002 |
(verilog-write-current-day))
|
|
1003 |
(add-to-list 'load-path "~/.emacs.d/elpa/verilog-mode/verilog-mode.el")
|
|
1004 |
:config
|
|
1005 |
(autoload 'verilog-mode "verilog-mode" "Verilog mode" t )
|
|
1006 |
(add-to-list 'auto-mode-alist '("\\.[ds]?vh?\\'" . verilog-mode)))
|
990949
|
1007 |
#+END_SRC
|
8a38cc
|
1008 |
|
49aa9f
|
1009 |
*** MATLAB
|
JG |
1010 |
Mode for editing MATLAB m-files.
|
|
1011 |
Have to manually install matlab-mode
|
|
1012 |
#+BEGIN_SRC emacs-lisp
|
|
1013 |
(autoload 'matlab-mode "matlab" "Matlab Editing Mode" t)
|
|
1014 |
(add-to-list
|
|
1015 |
'auto-mode-alist
|
|
1016 |
'("\\.m$" . matlab-mode))
|
|
1017 |
(setq matlab-indent-function t)
|
|
1018 |
(setq matlab-shell-command "matlab")
|
|
1019 |
(matlab-cedet-setup)
|
|
1020 |
#+END_SRC
|
|
1021 |
|
|
1022 |
*** MIPS
|
|
1023 |
#+BEGIN_SRC emacs-lisp
|
|
1024 |
(use-package mips-mode
|
|
1025 |
:ensure t
|
|
1026 |
:mode "\\.mips$")
|
|
1027 |
#+END_SRC
|
|
1028 |
|
60454d
|
1029 |
*** IPython notebooks
|
JG |
1030 |
Allow emacs to view and use IPython notebooks
|
|
1031 |
#+BEGIN_SRC emacs-lisp
|
|
1032 |
(use-package ein
|
|
1033 |
:ensure t)
|
|
1034 |
#+END_SRC
|
|
1035 |
|
990949
|
1036 |
* Org mode
|
C |
1037 |
** Up to date org
|
|
1038 |
#+BEGIN_SRC emacs-lisp
|
|
1039 |
(use-package org
|
|
1040 |
:ensure t
|
|
1041 |
:pin org)
|
|
1042 |
#+END_SRC
|
8a38cc
|
1043 |
|
990949
|
1044 |
** Small tweaks
|
C |
1045 |
#+BEGIN_SRC emacs-lisp
|
|
1046 |
(setq org-src-fontify-natively t)
|
|
1047 |
(setq org-src-tab-acts-natively t)
|
|
1048 |
(setq org-confirm-babel-evaluate nil)
|
|
1049 |
(setq org-export-with-smart-quotes t)
|
|
1050 |
(setq org-src-window-setup 'current-window)
|
|
1051 |
(add-hook 'org-mode-hook 'org-indent-mode)
|
|
1052 |
(diminish 'org-indent-mode)
|
|
1053 |
(diminish 'visual-line-mode)
|
|
1054 |
#+END_SRC
|
8a38cc
|
1055 |
|
990949
|
1056 |
** Line wrapping
|
C |
1057 |
#+BEGIN_SRC emacs-lisp
|
|
1058 |
(add-hook 'org-mode-hook
|
bf794a
|
1059 |
'(lambda ()
|
JG |
1060 |
(visual-line-mode 1)))
|
990949
|
1061 |
#+END_SRC
|
8a38cc
|
1062 |
|
990949
|
1063 |
** org-bullets
|
C |
1064 |
#+BEGIN_SRC emacs-lisp
|
bf794a
|
1065 |
(use-package org-bullets
|
JG |
1066 |
:ensure t
|
|
1067 |
:config
|
990949
|
1068 |
(add-hook 'org-mode-hook (lambda () (org-bullets-mode))))
|
C |
1069 |
#+END_SRC
|
8a38cc
|
1070 |
|
990949
|
1071 |
** Org Babel
|
C |
1072 |
*** Languages
|
|
1073 |
Add C to org babel supported languages
|
|
1074 |
#+BEGIN_SRC emacs-lisp
|
baf326
|
1075 |
(org-babel-do-load-languages 'org-babel-load-languages '((emacs-lisp . t)
|
C |
1076 |
(C . t)
|
|
1077 |
(python . t)
|
|
1078 |
(latex . t)
|
|
1079 |
(scheme . t)
|
|
1080 |
(gnuplot . t)
|
|
1081 |
(matlab . t)
|
|
1082 |
(plantuml . t)
|
|
1083 |
(fortran . t)
|
|
1084 |
(java . t)
|
|
1085 |
(plantuml . t)))
|
|
1086 |
#+END_SRC
|
|
1087 |
|
|
1088 |
**** Plantuml path
|
|
1089 |
#+BEGIN_SRC emacs-lisp
|
|
1090 |
(setq org-plantuml-jar-path plantuml-jar-path)
|
990949
|
1091 |
#+END_SRC
|
8a38cc
|
1092 |
|
990949
|
1093 |
** Latex preview fragments match colour
|
C |
1094 |
Make the previews match theme colour of Emacs.
|
|
1095 |
#+BEGIN_SRC emacs-lisp
|
|
1096 |
(let ((dvipng--plist (alist-get 'dvipng org-preview-latex-process-alist)))
|
|
1097 |
(plist-put dvipng--plist :use-xcolor t)
|
|
1098 |
(plist-put dvipng--plist :image-converter '("dvipng -D %D -T tight -o %O %f")))
|
|
1099 |
#+END_SRC
|
bf794a
|
1100 |
|