mirror of https://github.com/Chizi123/.emacs.d.git

Joel Grunbaum
2019-11-21 60454d2d6d47726926e6fc67b5b1a6555d6992aa
config.org
@@ -1,5 +1,7 @@
#+TITLE: My Emacs configuration
* Windows dependencies
#  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
* COMMENT Windows dependencies
Dependencies needed for Aspell, poppler PDF-tools, compilers and ghost-script provided by mingw64
#+BEGIN_SRC emacs-lisp
  (when (eq system-type 'windows-nt)
@@ -15,25 +17,40 @@
#+BEGIN_SRC emacs-lisp
  (setq emacs-theme 'zenburn)
  (defun disable-all-themes ()
    (dolist (i custom-enabled-themes)
      (disable-theme i)))
  (cond ((eq emacs-theme 'zenburn)
         (use-package zenburn-theme
           :ensure t
           :init
           (disable-all-themes)
           :config
           (load-theme 'zenburn t)))
        ((eq emacs-theme 'doom-one)
         (use-package doom-themes
           :ensure t
           :init
           (disable-all-themes)
           :config
           (setq doom-themes-enable-bolt t
                 doom-themes-enable-italic t)
           (load-theme 'doom-one t)
           (doom-themes-visual-bell-config)
           (doom-themes-org-config))))
           (doom-themes-org-config)))
        ((eq emacs-theme 'none)
         (disable-all-themes)))
#+END_SRC
** Default font
#+BEGIN_SRC emacs-lisp
  (set-frame-font "DejaVu Sans Mono" nil t)
#+BEGIN_SRC emacs-lisp
  ;;(set-frame-font "DejaVu Sans Mono" nil t)
  (set-frame-font "Dank Mono-11" nil t)
  (set-face-italic 'font-lock-comment-face t)
  (set-face-italic 'font-lock-keyword-face t)
#+END_SRC
** Remove menu bar, toolbar, but keep scroll bar
#+BEGIN_SRC emacs-lisp
  (menu-bar-mode 0)
@@ -68,6 +85,7 @@
  :bind
    ([remap other-window] . switch-window))
#+END_SRC
** Go to new window when opened
#+BEGIN_SRC emacs-lisp
  (defun split-and-follow-horizontally ()
@@ -84,14 +102,23 @@
    (other-window 1))
  (global-set-key (kbd "C-x 3") 'split-and-follow-vertically)
#+END_SRC
** PDF-tools
#+BEGIN_SRC emacs-lisp
(use-package pdf-tools
  :ensure t
  :config
  (pdf-tools-install))
  (use-package pdf-tools
   :ensure t
   :config
   (pdf-tools-install 1))
#+END_SRC
** Writegood-mode
Supposedly should provide insight to writing quality
#+BEGIN_SRC emacs-lisp
  (use-package writegood-mode
    :ensure t
    :hook (text-mode . writegood-mode))
#+END_SRC
* Helm and Projectile
** Helm core
#+BEGIN_SRC emacs-lisp
@@ -125,6 +152,7 @@
              'spacemacs//helm-hide-minibuffer-maybe)
    (helm-mode 1))
#+END_SRC
** Projectile
*** Enable it
 #+BEGIN_SRC emacs-lisp
@@ -138,27 +166,155 @@
     (when (eq system-type 'windows-nt)
       (setq projectile-indexing-method 'alien)))
 #+END_SRC
*** Let it compile things
 #+BEGIN_SRC emacs-lisp
   (global-set-key (kbd "<f5>") 'projectile-compile-project)
 #+END_SRC
*** Enable communication with helm
#+BEGIN_SRC emacs-lisp
(use-package helm-projectile
  :ensure t
  :config
  (helm-projectile-on))
  (use-package helm-projectile
    :ensure t
    :config
    (helm-projectile-on))
#+END_SRC
** ggtags
#+BEGIN_SRC emacs-lisp
    (use-package ggtags
      :ensure t
      :bind (("C-c g s" . ggtags-find-other-symbol)
           ("C-c g h" . ggtags-view-tag-history)
           ("C-c g r" . ggtags-find-reference)
           ("C-c g f" . ggtags-find-file)
           ("C-c g c" . ggtags-create-tags)
           ("C-c g u" . ggtags-update-tags))
      :config
      (add-hook 'c-mode-common-hook
              (lambda ()
                (when (derived-mode-p 'c-mode 'c++-mode 'java-mode)
                  (ggtags-mode 1))))
      )
    (setq
     helm-gtags-ignore-case t
     helm-gtags-auto-update t
     helm-gtags-use-input-at-cursor t
     helm-gtags-pulse-at-cursor t
     helm-gtags-prefix-key "\C-c g"
     helm-gtags-suggested-key-mapping t
     )
    (use-package helm-gtags
      :ensure t
      :config
      (add-hook 'dired-mode-hook 'helm-gtags-mode)
      (add-hook 'eshell-mode-hook 'helm-gtags-mode)
      (add-hook 'c-mode-hook 'helm-gtags-mode)
      (add-hook 'c++-mode-hook 'helm-gtags-mode)
      (add-hook 'asm-mode-hook 'helm-gtags-mode)
      (define-key helm-gtags-mode-map (kbd "C-c g a") 'helm-gtags-tags-in-this-function)
      (define-key helm-gtags-mode-map (kbd "C-j") 'helm-gtags-select)
      (define-key helm-gtags-mode-map (kbd "M-.") 'helm-gtags-dwim)
      (define-key helm-gtags-mode-map (kbd "M-,") 'helm-gtags-pop-stack)
      (define-key helm-gtags-mode-map (kbd "C-c <") 'helm-gtags-previous-history)
      (define-key helm-gtags-mode-map (kbd "C-c >") 'helm-gtags-next-history))
#+END_SRC
** Ctags
#+BEGIN_SRC emacs-lisp
  (defvar ctags-command "ctags -e -R --languages=vhdl")
  (defun ctags ()
    (call-process-shell-command ctags-command nil "*Ctags*"))
  (defun ctags-find-tags-file ()
    "Recursively searches each parent directory for a file named
                TAGS and returns the path to that file or nil if a tags file is
                not found or if the buffer is not visiting a file."
    (progn
      (defun find-tags-file-r (path)
        "Find the tags file from current to the parent directories."
        (let* ((parent-directory (file-name-directory (directory-file-name path)))
               (tags-file-name (concat (file-name-as-directory path) "TAGS")))
          (cond
           ((file-exists-p tags-file-name) (throw 'found tags-file-name))
           ((string= "/TAGS" tags-file-name) nil)
           (t (find-tags-file-r parent-directory)))))
      (if (buffer-file-name)
          (catch 'found
            (find-tags-file-r (file-name-directory buffer-file-name)))
        nil)))
  (defun ctags-set-tags-file ()
    "Uses `ctags-find-tags-file' to find a TAGS file. If found,
                set 'tags-file-name' with its path or set as nil."
    (setq-default tags-file-name (ctags-find-tags-file)))
  (defun ctags-create-tags-table ()
    (interactive)
    (let* ((current-directory default-directory)
           (top-directory (read-directory-name
                           "Top of source tree: " default-directory))
           (file-name (concat (file-name-as-directory top-directory) "TAGS")))
      (cd top-directory)
      (if (not (= 0 (ctags)))
          (message "Error creating %s!" file-name)
        (setq-default tags-file-name file-name)
        (message "Table %s created and configured." tags-file-name))
      (cd current-directory)))
  (defun ctags-update-tags-table ()
    (interactive)
    (let ((current-directory default-directory))
      (if (not tags-file-name)
          (message "Tags table not configured.")
        (cd (file-name-directory tags-file-name))
        (if (not (= 0 (ctags)))
            (message "Error updating %s!" tags-file-name)
          (message "Table %s updated." tags-file-name))
        (cd current-directory))))
  (defun ctags-create-or-update-tags-table ()
    "Create or update a tags table with `ctags-command'."
    (interactive)
    (if (not (ctags-set-tags-file))
        (ctags-create-tags-table)
      (ctags-update-tags-table)))
  (defun ctags-search ()
    "A wrapper for `tags-search' that provide a default input."
    (interactive)
    (let* ((symbol-at-point (symbol-at-point))
           (default (symbol-name symbol-at-point))
           (input (read-from-minibuffer
                   (if (symbol-at-point)
                       (concat "Tags search (default " default "): ")
                     "Tags search (regexp): "))))
      (if (and (symbol-at-point) (string= input ""))
          (tags-search default)
        (if (string= input "")
            (message "You must provide a regexp.")
          (tags-search input)))))
#+END_SRC
* Small tweaks
** Remove startup screen
#+BEGIN_SRC emacs-lisp
(setq inhibit-startup-message t)
#+END_SRC
** Disable bell
Bloody bell dings every time you hit a key too much
#+BEGIN_SRC emacs-lisp
(setq ring-bell-function 'ignore)
#+END_SRC
** Pretty symbols
Why not? They make it look nice
#+BEGIN_SRC emacs-lisp
@@ -169,6 +325,7 @@
      :config
      (global-pretty-mode)))
#+END_SRC
** find file other window
Lets it accept more than one file. Works recursively.
#+BEGIN_SRC emacs-lisp
@@ -177,6 +334,7 @@
      (loop for f in filename do (find-file-other-window f wildcards))
    ad-do-it))
#+END_SRC
** Which key
Helps to explain keybindings if you get lost
#+BEGIN_SRC emacs-lisp
@@ -186,21 +344,25 @@
    :config
    (which-key-mode))
#+END_SRC
** Go to this file
** Config shortcuts
*** Go to this file
#+BEGIN_SRC emacs-lisp
(defun config-visit ()
  (interactive)
  (find-file "~/.emacs.d/config.org"))
(global-set-key (kbd "C-c e d") 'config-visit)
#+END_SRC
** Go to init.el
*** Go to init.el
#+BEGIN_SRC emacs-lisp
  (defun init-visit ()
    (interactive)
    (find-file "~/.emacs.d/init.el"))
  (global-set-key (kbd "C-c e i") 'init-visit)
#+END_SRC
** Reload configuration
*** Reload configuration
#+BEGIN_SRC emacs-lisp
(defun config-reload ()
  "Reloads ~/.emacs.d/config.org at run time"
@@ -208,6 +370,7 @@
  (org-babel-load-file (expand-file-name "~/.emacs.d/config.org")))
(global-set-key (kbd "C-c e r") 'config-reload)
#+END_SRC
** Smartparens
Matches brackets automatically
#+BEGIN_SRC emacs-lisp
@@ -219,6 +382,7 @@
    (require 'smartparens-config)
    (smartparens-global-mode 1)))
#+END_SRC
** Rainbow
Its a little gimmicky but its still cool
#+BEGIN_SRC emacs-lisp
@@ -228,6 +392,7 @@
    :init
    (add-hook 'prog-mode-hook 'rainbow-mode))
#+END_SRC
** Rainbow delimiters
A bit more useful than above.
Colours the brackets so that they stand out more.
@@ -237,6 +402,7 @@
    :init
      (add-hook 'prog-mode-hook #'rainbow-delimiters-mode))
#+END_SRC
** clean-aindent-mode
Removes unnecessary white space
#+BEGIN_SRC emacs-lisp
@@ -248,6 +414,7 @@
#+BEGIN_SRC emacs-lisp
(add-hook 'prog-mode-hook (lambda () (interactive) (setq show-trailing-whitespace 1)))
#+END_SRC
** whitespace mode
Reveals whitespace characters
#+BEGIN_SRC emacs-lisp
@@ -267,12 +434,14 @@
                            (whitespace-mode 1)))
#+END_SRC
** eldoc
#+BEGIN_SRC emacs-lisp
  (add-hook 'emacs-lisp-mode-hook 'eldoc-mode)
  (add-hook 'lisp-interaction-mode-hook 'eldoc-mode)
  (add-hook 'ielm-mode-hook 'eldoc-mode)
#+END_SRC
** key-freq
collects interesting statistics
#+BEGIN_SRC emacs-lisp
@@ -282,6 +451,7 @@
  (keyfreq-mode 1)
  (keyfreq-autosave-mode 1))
#+END_SRC
** undo-tree
A more advanced undo mechanism
#+BEGIN_SRC emacs-lisp
@@ -291,6 +461,7 @@
  :config
  (global-undo-tree-mode))
#+END_SRC
** volatile highlights
Colour the material just copied
#+BEGIN_SRC emacs-lisp
@@ -300,20 +471,13 @@
  :config
  (volatile-highlights-mode t))
#+END_SRC
** Workgroups
Open the pages when you quit
#+BEGIN_SRC emacs-lisp
  ;; (use-package workgroups2
  ;;   :ensure t
  ;;   :diminish workgroups-mode
  ;;   :config
  ;;   (workgroups-mode 1))
#+END_SRC
** ibuffer
#+BEGIN_SRC emacs-lisp
(global-set-key (kbd "C-x C-b") 'ibuffer)
(setq ibuffer-use-other-window t)
#+END_SRC
** hippie expand
#+BEGIN_SRC emacs-lisp
(global-set-key (kbd "M-/") 'hippie-expand) ;; replace dabbrev-expand
@@ -331,10 +495,12 @@
   try-complete-lisp-symbol) ;; Try to complete word as an Emacs Lisp symbol.
 )
#+END_SRC
** Highlight line
#+BEGIN_SRC emacs-lisp
(global-hl-line-mode)
#+END_SRC
** Line numbers
#+BEGIN_SRC emacs-lisp
(add-hook 'prog-mode-hook 'linum-mode)
@@ -355,21 +521,26 @@
   kill-ring-max 5000
   kill-whole-line t)
#+END_SRC
** Coding style
#+BEGIN_SRC emacs-lisp
(setq c-default-style "linux")
  (setq c-default-style '((java-mode . "java")
                         (awk-mode . "awk")
                         (other . "k&r")))
#+END_SRC
** Coding system
#+BEGIN_SRC emacs-lisp
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
(set-language-environment "UTF-8")
(prefer-coding-system 'utf-8)
(setq-default indent-tabs-mode t)
(delete-selection-mode)
(global-set-key (kbd "RET") 'newline-and-indent)
  (set-terminal-coding-system 'utf-8)
  (set-keyboard-coding-system 'utf-8)
  (set-language-environment "UTF-8")
  (prefer-coding-system 'utf-8)
  (setq-default indent-tabs-mode t
            tab-width 4)
  (delete-selection-mode)
  (global-set-key (kbd "RET") 'newline-and-indent)
#+END_SRC
** Move to beginning of line ignoring whitespace
Move point back to indentation of beginning of line.
@@ -397,6 +568,7 @@
(global-set-key (kbd "C-a") 'prelude-move-beginning-of-line)
#+END_SRC
** Indent region or buffer
#+BEGIN_SRC emacs-lisp
(defun indent-region-or-buffer ()
@@ -415,6 +587,7 @@
(global-set-key (kbd "C-c i") 'indent-region-or-buffer)
#+END_SRC
** Tramp
#+BEGIN_SRC emacs-lisp
  (when (eq system-type 'windows-nt)
@@ -427,38 +600,45 @@
** Spaceline
A little easier to read than the default emacs mode line
#+BEGIN_SRC emacs-lisp
  (use-package spaceline
    :ensure t
    :config
    (require 'spaceline-config)
    (setq spaceline-buffer-encoding-abbrev-p t)
    (setq spaceline-line-column-p t)
    (setq spaceline-line-p t)
    (setq powerline-default-separator (quote arrow))
    (spaceline-spacemacs-theme))
    (use-package spaceline
      :ensure t
      :config
      (require 'spaceline-config)
      (setq spaceline-buffer-encoding-abbrev-p t)
      (setq spaceline-line-column-p t)
      (setq spaceline-line-p t)
      (setq powerline-default-separator (quote arrow))
      (spaceline-spacemacs-theme)
      (spaceline-helm-mode))
#+END_SRC
** No separator
#+BEGIN_SRC emacs-lisp
(setq powerline-default-seperator nil)
#+END_SRC
* Programming tweaks
** Yasnippet
#+BEGIN_SRC emacs-lisp
    (use-package yasnippet
      :ensure t
      :diminish yas-minor-mode
      :config
      (use-package yasnippet-snippets
   :ensure t)
      (yas-reload-all)
      (yas-global-mode 1))
  (use-package yasnippet
    :ensure t
    :diminish yas-minor-mode
    :config
    (use-package yasnippet-snippets
      :ensure t)
    (yas-reload-all)
    (yas-global-mode 1))
#+END_SRC
** flycheck
#+BEGIN_SRC emacs-lisp
(use-package flycheck
  :ensure t)
  (use-package flycheck
    :ensure t
    :diminish flycheck-mode
    :config
    (global-flycheck-mode))
#+END_SRC
*** flycheck-pos-tip
*** flycheck-pos-tipe
#+BEGIN_SRC emacs-lisp
(use-package flycheck-pos-tip
  :ensure t
@@ -466,8 +646,9 @@
  :config
  (flycheck-pos-tip-mode))
#+END_SRC
** Company
Company is auto-complete for emacs
Company is auto-complete for Emacs
#+BEGIN_SRC emacs-lisp
  (use-package company
    :ensure t
@@ -477,6 +658,7 @@
    (setq company-idle-delay 0)
    (setq company-minimum-prefix-length 3))
#+END_SRC
** Magit
#+BEGIN_SRC emacs-lisp
  (use-package magit
@@ -531,6 +713,7 @@
       magit-set-upstream-on-push 'askifnotset
       )))
#+END_SRC
** CEDET
*** semantic
#+BEGIN_SRC emacs-lisp
@@ -541,12 +724,14 @@
    (global-semantic-idle-summary-mode 1)
    (semantic-mode 1))
#+END_SRC
*** EDE
#+BEGIN_SRC emacs-lisp
(use-package ede
  :config
  (global-ede-mode t))
#+END_SRC
*** gdb-many-windows
#+BEGIN_SRC emacs-lisp
(setq
@@ -556,6 +741,7 @@
 ;; Non-nil means display source file containing the main routine at startup
 gdb-show-main t)
#+END_SRC
*** Semantic refactor
#+BEGIN_SRC emacs-lisp
(use-package srefactor
@@ -569,6 +755,7 @@
         :map c++-mode-map
         ("M-RET" . 'srefactor-refactor-at-point)))
#+END_SRC
** Language specific configs
*** C/C++
**** yasnippet
@@ -576,6 +763,7 @@
(add-hook 'c++-mode-hook 'yas-minor-mode)
(add-hook 'c-mode-hook 'yas-minor-mode)
#+END_SRC
**** flycheck clang
#+BEGIN_SRC emacs-lisp
(use-package flycheck-clang-analyzer
@@ -585,6 +773,7 @@
    (require 'flycheck-clang-analyzer)
     (flycheck-clang-analyzer-setup)))
#+END_SRC
**** company
#+BEGIN_SRC emacs-lisp
  (use-package company-c-headers
@@ -611,15 +800,18 @@
    (add-hook 'irony-mode-hook 'irony-cdb-autosetup-compile-options)
    (add-hook 'irony-mode-hook 'irony-cdb-autosetup-compile-options))
#+END_SRC
*** emacs-lisp
**** eldoc
#+BEGIN_SRC emacs-lisp
(add-hook 'emacs-lisp-mode-hook 'eldoc-mode)
#+END_SRC
**** yasnippet
#+BEGIN_SRC emacs-lisp
(add-hook 'emacs-lisp-mode-hook 'yas-minor-mode)
#+END_SRC
**** company
#+BEGIN_SRC emacs-lisp
(add-hook 'emacs-lisp-mode-hook 'company-mode)
@@ -636,7 +828,8 @@
    (require 'company)
    (slime-setup '(slime-fancy slime-company)))
#+END_SRC
*** x86
*** COMMENT x86
**** x86-lookup
#+BEGIN_SRC emacs-lisp
(use-package x86-lookup
@@ -645,17 +838,20 @@
  (setq x86-lookup-pdf "D:/Coding/x86-instructions.pdf")
  :bind ("C-h x" . x86-lookup))
#+END_SRC
*** Latex
**** AucTex
#+BEGIN_SRC emacs-lisp
(use-package tex
  :ensure auctex
  :config
  (setq TeX-auto-save t)
  (setq TeX-parse-self t)
  (setq doc-view-ghostscript-program "c:/msys64/mingw64/bin/gswin32c.exe")
  (setq preview-gs-command "c:/msys64/mingw64/bin/gs.exe"))
  (use-package tex
    :ensure auctex
    :config
    (setq TeX-auto-save t)
    (setq TeX-parse-self t)
    (setq TeX-view-program-selection '((output-pdf "PDF Tools"))
          TeX-source-correlate-start-server t)
    (add-hook 'TeX-after-compilation-finished-functions #'TeX-revert-document-buffer))
#+END_SRC
**** Company
#+BEGIN_SRC emacs-lisp
  (use-package company-math
@@ -681,51 +877,54 @@
    :after company
    (add-to-list 'company-backends 'company-bibtex))
#+END_SRC
**** Preview pane
#+BEGIN_SRC emacs-lisp
(use-package latex-preview-pane
  :ensure t
  :config
  (latex-preview-pane-enable))
#+END_SRC
**** TeXcount
     Word counts in latex
     #+BEGIN_SRC emacs-lisp
       (when (eq system-type 'windows-nt)
         (add-to-list 'exec-path "c:/Users/joelg/TeXcount_3_1_1")
         (setenv "PATH" (mapconcat #'identity exec-path path-separator)))
      (defun get-texcount-latest()
       (if (not(file-directory-p "~/.texcount"))
          (make-directory "~/.texcount"))
       (url-copy-file "https://app.uio.no/ifi/texcount/download.php?file=texcount_3_1_1.zip" "~/.texcount/texcount.zip" 1)
       (shell-command "unzip -o ~/.texcount/texcount.zip -d ~/.texcount")
       (add-to-list 'exec-path "~/.texcount/texcount.pl"))
       (defun texcount ()
         (interactive)
         (let*
             ( (this-file (buffer-file-name))
               (enc-str (symbol-name buffer-file-coding-system))
               (enc-opt
                (cond
                 ((string-match "utf-8" enc-str) "-utf8")
                 ((string-match "latin" enc-str) "-latin1")
                 ("-encoding=guess")
                 ) )
               (word-count
                (with-output-to-string
                  (with-current-buffer standard-output
                    (call-process "texcount" nil t nil "-0" enc-opt this-file)
                    ) ) ) )
           (message word-count)
           ) )
       (add-hook 'LaTeX-mode-hook (lambda () (define-key LaTeX-mode-map (kbd "C-c c") 'texcount)))
       (add-hook 'latex-mode-hook (lambda () (define-key latex-mode-map (kbd "C-c c") 'texcount)))
      (if (not(file-exists-p "~/.texcount/texcount.pl"))
         (get-texcount-latest))
      (defun texcount ()
       (interactive)
       (let*
          ( (this-file (buffer-file-name))
            (enc-str (symbol-name buffer-file-coding-system))
            (enc-opt
            (cond
             ((string-match "utf-8" enc-str) "-utf8")
             ((string-match "latin" enc-str) "-latin1")
             ("-encoding=guess")
             ) )
            (word-count
            (with-output-to-string
              (with-current-buffer standard-output
               (call-process "texcount" nil t nil "-0" enc-opt this-file)
               ) ) ) )
         (message word-count)
         ) )
      (add-hook 'LaTeX-mode-hook (lambda () (define-key LaTeX-mode-map (kbd "C-c c") 'texcount)))
      (add-hook 'latex-mode-hook (lambda () (define-key latex-mode-map (kbd "C-c c") 'texcount)))
     #+END_SRC
*** PlantUML
#+BEGIN_SRC emacs-lisp
(use-package plantuml-mode
  :ensure t
  :init
  (setq plantuml-jar-path "c:/ProgramData/chocolatey/lib/plantuml/tools/plantuml.jar"))
  (use-package plantuml-mode
    :ensure t
    :init
    (cond ((eq system-type 'windows-nt)
           (setq plantuml-jar-path "c:/ProgramData/chocolatey/lib/plantuml/tools/plantuml.jar"))
          ((eq system-type 'gnu/linux)
           (setq plantuml-jar-path "/usr/share/java/plantuml/plantuml.jar"))))
#+END_SRC
*** Racket
*** COMMENT Racket
**** Major mode
#+BEGIN_SRC emacs-lisp
  (when (eq system-type 'windows-nt)
@@ -738,19 +937,102 @@
      (autoload 'racket-mode "Racket" "Racket Editing Mode" t)
      (add-to-list
       'auto-mode-alist
       '("\\.rkt$" . matlab-mode))
       '("\\.rkt$" . racket-mode))
      (setq matlab-indent-function t))
#+END_SRC
*** Verilog
**** Get latest version
Pull the latest version from the web
#+BEGIN_SRC emacs-lisp
  (defun get-verilog-latest()
    (if (not(file-directory-p "~/.emacs.d/elpa/verilog-mode"))
        (make-directory "~/.emacs.d/elpa/verilog-mode"))
    (if (file-exists-p "~/.emacs.d/elpa/verilog-mode/verilog-mode.el")
        (delete-file "~/.emacs.d/elpa/verilog-mode/verilog-mode.el"))
    (url-copy-file "https://www.veripool.org/ftp/verilog-mode.el" "~/.emacs.d/elpa/verilog-mode/verilog-mode.el" 1))
#+END_SRC
**** Integrate into emacs
Add updated version and integrate it with Emacs.
#+BEGIN_SRC emacs-lisp
  (add-to-list 'load-path "~/.emacs.d/elpa/verilog-mode-20190324/verilog-mode.el")
  (require 'verilog-mode)
    (defun verilog-read-file-as-string (file)
      "Read FILE contents."
      (when (file-exists-p file)
        (with-temp-buffer
          (insert-file-contents file)
          (buffer-string))))
  (autoload 'verilog-mode "verilog-mode" "Verilog mode" t )
  (add-to-list 'auto-mode-alist '("\\.[ds]?vh?\\'" . verilog-mode))
    (defun verilog-write-string-to-file (file string)
      "Substitute FILE contents with STRING."
      (with-temp-buffer
        (insert string)
        (when (file-writable-p file)
          (write-region (point-min)
                        (point-max)
                        file))))
    (defun verilog-today-day ()
      (time-to-days (current-time)))
    (defun should-update-verilog-p ()
      "Return non-nil when an update is due."
      (and
       (or
        (not (file-exists-p "~/.emacs.d/.last-verilog-update-day"))
        (if (>= (/ (- (verilog-today-day) (verilog-read-last-update-day)) 7) 1)
            t
          nil))))
    (defun verilog-read-last-update-day ()
      "Read last update day."
      (string-to-number
       (verilog-read-file-as-string "~/.emacs.d/.last-verilog-update-day")))
    (defun verilog-write-current-day ()
      "Store current day."
      (verilog-write-string-to-file
       "~/.emacs.d/.last-verilog-update-day"
       (int-to-string (verilog-today-day))))
    (use-package verilog-mode
      :init
      (when (should-update-verilog-p)
          (get-verilog-latest)
          (verilog-write-current-day))
      (add-to-list 'load-path "~/.emacs.d/elpa/verilog-mode/verilog-mode.el")
      :config
      (autoload 'verilog-mode "verilog-mode" "Verilog mode" t )
      (add-to-list 'auto-mode-alist '("\\.[ds]?vh?\\'" . verilog-mode)))
#+END_SRC
*** MATLAB
Mode for editing MATLAB m-files.
Have to manually install matlab-mode
#+BEGIN_SRC emacs-lisp
  (autoload 'matlab-mode "matlab" "Matlab Editing Mode" t)
  (add-to-list
   'auto-mode-alist
   '("\\.m$" . matlab-mode))
  (setq matlab-indent-function t)
  (setq matlab-shell-command "matlab")
  (matlab-cedet-setup)
#+END_SRC
*** MIPS
#+BEGIN_SRC emacs-lisp
  (use-package mips-mode
    :ensure t
    :mode "\\.mips$")
#+END_SRC
*** IPython notebooks
Allow emacs to view and use IPython notebooks
#+BEGIN_SRC emacs-lisp
  (use-package ein
    :ensure t)
#+END_SRC
* Org mode
** Up to date org
#+BEGIN_SRC emacs-lisp
@@ -758,6 +1040,7 @@
      :ensure t
      :pin org)
#+END_SRC
** Small tweaks
#+BEGIN_SRC emacs-lisp
(setq org-src-fontify-natively t)
@@ -769,34 +1052,44 @@
(diminish 'org-indent-mode)
(diminish 'visual-line-mode)
#+END_SRC
** Line wrapping
#+BEGIN_SRC emacs-lisp
  (add-hook 'org-mode-hook
         '(lambda ()
       (visual-line-mode 1)))
            '(lambda ()
               (visual-line-mode 1)))
#+END_SRC
** org-bullets
#+BEGIN_SRC emacs-lisp
(use-package org-bullets
  :ensure t
  :config
  (use-package org-bullets
    :ensure t
    :config
    (add-hook 'org-mode-hook (lambda () (org-bullets-mode))))
#+END_SRC
** Org Babel
*** Languages
Add C to org babel supported languages
#+BEGIN_SRC emacs-lisp
  (org-babel-do-load-languages 'org-babel-load-languages '((emacs-lisp . t)
                                                           (C . t)
                                                           (python . t)
                                                           (latex . t)
                                                           (scheme . t)
                                                           (gnuplot . t)
                                                           (matlab . t)
                                                           (plantuml . t)
                                                           (fortran . t)
                                                           (java . t)))
    (org-babel-do-load-languages 'org-babel-load-languages '((emacs-lisp . t)
                                                             (C . t)
                                                             (python . t)
                                                             (latex . t)
                                                             (scheme . t)
                                                             (gnuplot . t)
                                                             (matlab . t)
                                                             (plantuml . t)
                                                             (fortran . t)
                                                             (java . t)
                                                             (plantuml . t)))
#+END_SRC
**** Plantuml path
#+BEGIN_SRC emacs-lisp
  (setq org-plantuml-jar-path plantuml-jar-path)
#+END_SRC
** Latex preview fragments match colour
Make the previews match theme colour of Emacs.
#+BEGIN_SRC emacs-lisp