My personal dotfiles
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.org 24KB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742
  1. * Garbage Collection
  2. Temporarily set garbage collect threshold high to improve start time
  3. #+BEGIN_SRC emacs-lisp :tangle yes
  4. (setq gc-cons-threshold most-positive-fixnum)
  5. (add-hook 'after-init-hook (lambda () (setq gc-cons-threshold 800000)))
  6. #+END_SRC
  7. * Package Control
  8. Setup package control
  9. #+BEGIN_SRC emacs-lisp :tangle yes
  10. (setq package--init-file-ensured t) ; So (package-initialize) doesn't show up
  11. (require 'package)
  12. (setq package-archives '(("gnu" . "http://elpa.gnu.org/packages/")
  13. ("marmalade" . "http://marmalade-repo.org/packages/")
  14. ("melpa" . "http://melpa.org/packages/")))
  15. (setq package-enable-at-startup nil)
  16. (package-initialize)
  17. #+END_SRC
  18. Have use-package auto download
  19. #+BEGIN_SRC emacs-lisp :tangle yes
  20. (unless (package-installed-p 'use-package)
  21. (package-refresh-contents)
  22. (package-install 'use-package))
  23. (require 'use-package)
  24. (setq use-package-always-ensure t)
  25. #+END_SRC
  26. * Startup
  27. Runs a different function on startup depending on display mode.
  28. #+BEGIN_SRC emacs-lisp :tangle yes
  29. (setq custom-theme-directory "~/.emacs.d/themes")
  30. #+END_SRC
  31. #+BEGIN_SRC emacs-lisp :tangle yes
  32. (defun wolfe/term-setup ()
  33. (load-theme 'ujelly t)
  34. (setq nlinum-format "%d ")
  35. (global-hl-line-mode 1)
  36. (add-to-list 'default-frame-alist '(background-color . "color-16"))
  37. (custom-set-faces
  38. '(linum ((t (:background "color-16" :foreground "#ffffff"))))
  39. '(iedit-occurrence ((t (:background "color-93"))))
  40. '(column-marker-1 ((t (:background "color-88"))))
  41. '(hl-line ((t (:weight bold))))))
  42. #+END_SRC
  43. #+BEGIN_SRC emacs-lisp :tangle yes
  44. (defun wolfe/gui-setup ()
  45. ;; (use-package solarized-theme
  46. ;; :config
  47. ;; (load-theme 'solarized-dark t))
  48. ;; (set-frame-size (selected-frame) 90 40)
  49. (use-package sublime-themes
  50. :config
  51. (load-theme 'spolsky t))
  52. (load-file "~/.emacs.d/lisp/init-powerline.el")
  53. (setq powerline-height 24)
  54. (custom-set-faces
  55. '(org-done ((t (:foreground "PaleGreen" :box (:line-width 1 :color "PaleGreen") :weight bold))))
  56. '(org-level-1 ((t (:inherit outline-1 :height 1.3))))
  57. '(org-todo ((t (:foreground "Pink" :box (:line-width 1 :color "Pink") :weight bold))))
  58. '(powerline-evil-normal-face ((t (:inherit powerline-evil-base-face :background "forest green")))))
  59. ;; For old jazz theme
  60. ;;(custom-set-faces
  61. ;; '(helm-ff-directory ((t (:background nil :foreground "DarkRed"))))
  62. ;; '(helm-ff-file ((t :foreground "#ffffff")))
  63. ;; '(column-marker-1 ((t (:background "#ff0000"))))
  64. ;; '(iedit-occurrence ((t (:background "#00bfff"))))
  65. ;; '(isearch ((t (:foreground "#ff0000"))))
  66. ;; '(lazy-highlight ((t (:foreground "#ff0000" :background nil))))
  67. ;; '(linum ((t (:foreground "#ffffff")))))
  68. )
  69. ;; Not a function but it needs to be after the 2 setup functions
  70. (if (display-graphic-p)
  71. (wolfe/gui-setup)
  72. (wolfe/term-setup))
  73. #+END_SRC
  74. * General Settings
  75. #+BEGIN_SRC emacs-lisp :tangle yes
  76. ;;(pdf-tools-install)
  77. (setq inhibit-splash-screen t
  78. inhibit-startup-message t
  79. inhibit-startup-echo-area-message "wolfe")
  80. (tool-bar-mode -1) ; No toolbar
  81. (scroll-bar-mode -1) ; Hide scrollbars
  82. (menu-bar-mode -1) ; No menubar
  83. (show-paren-mode t) ; Highlights matching parens
  84. (setq initial-scratch-message "") ; No scratch text
  85. (fset 'yes-or-no-p 'y-or-n-p) ; y/n instead of yes/no
  86. (setq-default indent-tabs-mode nil)
  87. (column-number-mode t)
  88. (delete-selection-mode 1) ; Replace selection on insert
  89. (setq vc-follow-symlinks t) ; Always follow symlinks
  90. (when (member "Inconsolata" (font-family-list)) ; Set default font
  91. (add-to-list 'default-frame-alist '(font . "Inconsolata-15" ))
  92. (set-face-attribute 'default t :font "Inconsolata-15"))
  93. (setq custom-file "~/.emacs.d/custom.el") ; Set custom file
  94. (load custom-file 'noerror) ; Load custom file
  95. (setq tags-revert-without-query t) ; Don't ask to reload TAGS file
  96. (setq scroll-margin 10
  97. scroll-step 1
  98. scroll-conservatively 10000
  99. scroll-preserve-screen-position 1)
  100. (load-file "~/.emacs.d/lisp/column-marker.el")
  101. (add-hook 'prog-mode-hook (lambda () (interactive) (column-marker-1 81)))
  102. (setq explicit-shell-file-name
  103. (if (file-readable-p "/usr/bin/zsh") "/usr/bin/zsh" "/bin/bash"))
  104. #+END_SRC
  105. * Functions
  106. ** Face Under Point
  107. Returns the font lock face that's under the cursor.
  108. #+BEGIN_SRC emacs-lisp :tangle yes
  109. (defun what-face (pos)
  110. (interactive "d")
  111. (let ((face (or (get-char-property (point) 'read-face-name)
  112. (get-char-property (point) 'face))))
  113. (if face (message "Face: %s" face) (message "No face at %d" pos))))
  114. #+END_SRC
  115. ** Compile Project
  116. Compiles the project without a prompt.
  117. #+BEGIN_SRC emacs-lisp :tangle yes
  118. (defun wolfe/compile-no-prompt ()
  119. (interactive)
  120. (let ((compilation-read-command nil))
  121. (compile (eval compile-command))))
  122. #+END_SRC
  123. ** Compile Dotfiles
  124. Compiles all el files in the =~/.emacs.d= directory.
  125. #+BEGIN_SRC emacs-lisp :tangle yes
  126. (defun wolfe/compile-dot-emacs ()
  127. "Byte-compile dotfiles."
  128. (interactive)
  129. (byte-recompile-directory user-emacs-directory 0))
  130. #+END_SRC
  131. #+BEGIN_SRC emacs-lisp :tangle yes
  132. (defun wolfe/clear-all-elc ()
  133. (interactive)
  134. (shell-command "find ~/.emacs.d/ -name \"*.elc\" -type f -delete"))
  135. #+END_SRC
  136. #+BEGIN_SRC emacs-lisp :tangle yes
  137. (defun wolfe/remove-elc-on-save ()
  138. "If you're saving an emacs-lisp file, likely the .elc is no longer valid."
  139. (add-hook 'after-save-hook
  140. (lambda ()
  141. (if (file-exists-p (concat buffer-file-name "c"))
  142. (delete-file (concat buffer-file-name "c"))))
  143. nil t))
  144. (add-hook 'emacs-lisp-mode-hook 'wolfe/remove-elc-on-save)
  145. #+END_SRC
  146. ** Find Tags
  147. Looks up tag under point.
  148. #+BEGIN_SRC emacs-lisp :tangle yes
  149. (defun wolfe/find-tag ()
  150. "Jump to the tag at point without prompting"
  151. (interactive)
  152. (find-tag (find-tag-default)))
  153. #+END_SRC
  154. #+BEGIN_SRC emacs-lisp :tangle yes
  155. (defadvice xref-find-definitions (around refresh-etags activate)
  156. "Rerun etags and reload tags if tag not found and redo find-tag.
  157. If buffer is modified, ask about save before running etags."
  158. (condition-case err
  159. ad-do-it
  160. (error (and (buffer-modified-p) (not (ding))
  161. (save-buffer))
  162. (save-window-excursion (shell-command "etags -R *"))
  163. ad-do-it)))
  164. #+END_SRC
  165. ** Terminal Suspend
  166. Fixes =C-z= in terminal.
  167. #+BEGIN_SRC emacs-lisp :tangle yes
  168. (defun wolfe/controlz ()
  169. (interactive)
  170. (when (eq (display-graphic-p) nil)
  171. (suspend-frame)))
  172. #+END_SRC
  173. ** Dropbox
  174. Utility functions for finding Dropbox directories/files.
  175. #+BEGIN_SRC emacs-lisp :tangle yes
  176. (defun wolfe/org-open (name)
  177. "Opens the file in the dropbox path"
  178. (interactive)
  179. (when (eq system-type 'gnu/linux)
  180. (evil-buffer-new nil (concat "~/Dropbox/org/" name ".org")))
  181. (when (eq system-type 'windows-nt)
  182. (evil-buffer-new nil (concat "C:\\Users\\Josh\\Dropbox\\org\\"
  183. name ".org"))))
  184. #+END_SRC
  185. #+BEGIN_SRC emacs-lisp :tangle yes
  186. (defun wolfe/org-dropbox-path ()
  187. "Returns the dropbox path"
  188. (interactive)
  189. (cond
  190. ((eq system-type 'gnu/linux)
  191. "~/Dropbox/org/")
  192. ((eq system-type 'windows-nt)
  193. "C:\\Users\\Josh\\Dropbox\\org\\")
  194. (else "")))
  195. #+END_SRC
  196. #+BEGIN_SRC emacs-lisp :tangle yes
  197. (defun wolfe/dropbox-start ()
  198. (interactive)
  199. (if (eq nil (file-exists-p "/virtual/wolfejos/dropbox/.dropbox-dist"))
  200. (call-process-shell-command "(python ~/.emacs.d/dropbox.py start -i&)")
  201. (call-process-shell-command "(python ~/.emacs.d/dropbox.py start&)")))
  202. #+END_SRC
  203. #+BEGIN_SRC emacs-lisp :tangle yes
  204. (defun wolfe/dropbox-stop ()
  205. (interactive)
  206. (call-process-shell-command "python ~/.emacs.d/dropbox.py stop&"))
  207. #+END_SRC
  208. ** Reload
  209. For reloading =init.el= file without restarting.
  210. #+BEGIN_SRC emacs-lisp :tangle yes
  211. (defun wolfe/load-init ()
  212. "Reloads init file"
  213. (interactive)
  214. (load-file "~/.emacs.d/init.el"))
  215. #+END_SRC
  216. ** Narrowing
  217. Better narrowing.
  218. #+BEGIN_SRC emacs-lisp :tangle yes
  219. (defun narrow-or-widen-dwim (p)
  220. "Widen if buffer is narrowed, narrow-dwim otherwise.
  221. Dwim means: region, org-src-block, org-subtree, or
  222. defun, whichever applies first. Narrowing to
  223. org-src-block actually calls `org-edit-src-code'.
  224. With prefix P, don't widen, just narrow even if buffer
  225. is already narrowed."
  226. (interactive "P")
  227. (declare (interactive-only))
  228. (cond ((and (buffer-narrowed-p) (not p)) (widen))
  229. ((region-active-p)
  230. (narrow-to-region (region-beginning)
  231. (region-end)))
  232. ((derived-mode-p 'org-mode)
  233. ;; `org-edit-src-code' is not a real narrowing
  234. ;; command. Remove this first conditional if
  235. ;; you don't want it.
  236. (cond ((ignore-errors (org-edit-src-code) t)
  237. (delete-other-windows))
  238. ((ignore-errors (org-narrow-to-block) t))
  239. (t (org-narrow-to-subtree))))
  240. ((derived-mode-p 'latex-mode)
  241. (LaTeX-narrow-to-environment))
  242. (t (narrow-to-defun))))
  243. (defun wolfe/man ()
  244. (if (executable-find "man")
  245. (man (word-at-point))
  246. (woman)))
  247. #+END_SRC
  248. ** Ivy Completion
  249. #+BEGIN_SRC emacs-lisp :tangle yes
  250. (defun wolfe/ivy--regex-fuzzy (str)
  251. "Build a regex sequence from STR.
  252. Insert .* between each char."
  253. (if (string-match "\\`\\(\\^?\\)\\(.*?\\)\\(\\$?\\)\\'" str)
  254. (prog1
  255. (concat (match-string 1 str)
  256. (mapconcat
  257. (lambda (x)
  258. (format "\\(%c\\)" x))
  259. (delq 32 (string-to-list (match-string 2 str)))
  260. ".*?")
  261. (match-string 3 str))
  262. (setq ivy--subexps (length (match-string 2 str))))))
  263. #+END_SRC
  264. * Evil & General
  265. #+BEGIN_SRC emacs-lisp :tangle yes
  266. (use-package general)
  267. (use-package evil
  268. :demand
  269. :init
  270. (setq evil-want-C-u-scroll t) ; Unbind <C-u> for evil mode's use
  271. (setq evil-want-C-i-jump nil)
  272. :config
  273. (evil-mode t)
  274. (setq evil-split-window-below t)
  275. (setq evil-vsplit-window-right t)
  276. (setq-default evil-symbol-word-search t)
  277. (setq evil-lookup-func #'wolfe/man)
  278. (evil-ex-define-cmd "re[load]" 'wolfe/load-init) ; Custom reload command
  279. (define-key evil-ex-map "e " 'counsel-find-file) ; Trigger file completion :e
  280. (global-unset-key (kbd "M-SPC")) ; Unbind secondary leader
  281. (general-create-definer wolfe/bind-leader
  282. :keymaps 'global
  283. :states '(normal insert visual emacs)
  284. :prefix "SPC"
  285. :non-normal-prefix "M-SPC")
  286. :general
  287. (:states 'motion
  288. "k" 'evil-previous-visual-line
  289. "j" 'evil-next-visual-line)
  290. (:states 'operator
  291. "k" 'evil-previous-line
  292. "j" 'evil-next-line)
  293. (:states 'normal
  294. "C-z" 'wolfe/controlz)
  295. (wolfe/bind-leader
  296. "w" 'save-buffer
  297. "S" 'eval-buffer
  298. "s" 'eval-defun
  299. "b" 'mode-line-other-buffer
  300. "k" 'kill-buffer
  301. "m" 'ivy-switch-buffer
  302. "t" 'wolfe/find-tag
  303. "e" 'iedit-mode
  304. "c" 'wolfe/compile-no-prompt
  305. "n" 'narrow-or-widen-dwim
  306. "p" 'counsel-git
  307. "a" 'org-agenda
  308. "g" 'magit-status
  309. "''" 'org-edit-src-exit
  310. ";" (lambda() (interactive) (save-excursion (end-of-line) (insert-char ?\;)))
  311. "id" (lambda() (interactive) (indent-region (point-min) (point-max)))
  312. "o" (lambda() (interactive) (wolfe/org-open "everything"))
  313. "init" (lambda() (interactive) (evil-buffer-new nil "~/.emacs.d/README.org"))))
  314. ;; Tpope's surround
  315. (use-package evil-surround
  316. :config
  317. (global-evil-surround-mode 1))
  318. (use-package evil-magit)
  319. #+END_SRC
  320. * Org Mode
  321. #+BEGIN_SRC emacs-lisp :tangle yes
  322. (require 'ox-latex)
  323. (add-to-list 'org-latex-packages-alist '("" "minted"))
  324. (setq org-latex-listings 'minted)
  325. (setq org-latex-pdf-process
  326. '("pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f"
  327. "pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f"
  328. "pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f"))
  329. (require 'org-agenda)
  330. (use-package ox-reveal
  331. :ensure nil
  332. :config
  333. (use-package htmlize
  334. :ensure nil))
  335. (use-package calfw
  336. :config
  337. (require 'calfw-org)
  338. (custom-set-faces
  339. '(cfw:face-title ((t (:foreground "#f0dfaf" :weight bold :height 2.0 :inherit variable-pitch))))
  340. '(cfw:face-header ((t (:foreground "#d0bf8f" :weight bold))))
  341. '(cfw:face-sunday ((t :foreground "#cc9393" :background "grey10" :weight bold)))
  342. '(cfw:face-saturday ((t :foreground "#8cd0d3" :background "grey10" :weight bold)))
  343. '(cfw:face-holiday ((t :background "grey10" :foreground "#8c5353" :weight bold)))
  344. '(cfw:face-grid ((t :foreground "DarkGrey")))
  345. '(cfw:face-default-content ((t :foreground "#bfebbf")))
  346. '(cfw:face-periods ((t :foreground "cyan")))
  347. '(cfw:face-day-title ((t :background "grey10")))
  348. '(cfw:face-default-day ((t :weight bold :inherit cfw:face-day-title)))
  349. '(cfw:face-annotation ((t :foreground "RosyBrown" :inherit cfw:face-day-title)))
  350. '(cfw:face-disable ((t :foreground "DarkGray" :inherit cfw:face-day-title)))
  351. '(cfw:face-today-title ((t :background "#7f9f7f" :weight bold)))
  352. '(cfw:face-today ((t :background: "grey10" :weight bold)))
  353. '(cfw:face-select ((t :background "#2f2f2f")))
  354. '(cfw:face-toolbar ((t :foreground "Steelblue4" :background "Steelblue4")))
  355. '(cfw:face-toolbar-button-off ((t :foreground "Gray10" :weight bold)))
  356. '(cfw:face-toolbar-button-on ((t :foreground "Gray50" :weight bold)))))
  357. ;; Formats the agenda into nice columns
  358. (setq org-agenda-prefix-format
  359. '((agenda . " %i %-12t% s %-12(car (last (org-get-outline-path)))")
  360. (timeline . " % s")
  361. (todo . " %i %-12:c")
  362. (tags . " %i %-12:c")
  363. (search . " %i %-12:c")))
  364. ;; Sets location of org files
  365. (setq org-agenda-files '("~/Dropbox/org/everything.org"))
  366. (setq browse-url-browser-function 'browse-url-chromium)
  367. (add-hook 'org-mode-hook
  368. '(lambda ()
  369. (setq org-file-apps
  370. (append '(("\\.pdf\\'" . "zathura \"%s\"")) org-file-apps ))))
  371. (global-set-key "\C-cl" 'org-store-link)
  372. (global-set-key "\C-ca" 'org-agenda)
  373. (global-set-key (kbd "C-M-y") 'yank)
  374. (define-key org-agenda-mode-map "j" 'org-agenda-next-item)
  375. (define-key org-agenda-mode-map "k" 'org-agenda-previous-item)
  376. ;; ispell ignores SRC blocks
  377. (add-to-list 'ispell-skip-region-alist '("#\\+BEGIN_SRC" . "#\\+END_SRC"))
  378. (add-to-list 'ispell-skip-region-alist '("#\\+BEGIN_LATEX" . "#\\+END_LATEX"))
  379. (setq org-pretty-entities t
  380. org-src-fontify-natively t
  381. org-src-tab-acts-natively t
  382. org-src-window-setup 'current-window
  383. org-fontify-whole-heading-line t
  384. org-fontify-done-headline t
  385. org-fontify-quote-and-verse-blocks t
  386. org-log-done 'time
  387. org-agenda-use-time-grid nil
  388. org-agenda-skip-deadline-if-done t
  389. org-agenda-skip-scheduled-if-done t
  390. org-ellipsis "⤵")
  391. ;; Better looking org headers
  392. (use-package org-bullets
  393. :config
  394. (add-hook 'org-mode-hook (lambda () (org-bullets-mode 1))))
  395. #+END_SRC
  396. * Packages
  397. ** Delight
  398. #+BEGIN_SRC emacs-lisp :tangle yes
  399. (use-package delight
  400. :config
  401. (delight '((emacs-lisp-mode "ξ" :major)
  402. (lisp-interaction-mode "λ" :major)
  403. (python-mode "π" :major)
  404. (c-mode "𝐂 " :major)
  405. (org-mode "Ø" :major)
  406. (company-mode " α" company)
  407. (ivy-mode " ι" ivy)
  408. (eldoc-mode " ε" eldoc)
  409. (undo-tree-mode "" undo-tree)
  410. (auto-revert-mode "" autorevert))))
  411. #+END_SRC
  412. ** Ivy, Counsel and Swiper
  413. #+BEGIN_SRC emacs-lisp :tangle yes
  414. (use-package ivy
  415. :demand
  416. :bind (("M-x" . counsel-M-x)
  417. ("C-x C-f" . counsel-find-file)
  418. :map ivy-minibuffer-map
  419. ("TAB" . ivy-next-line)
  420. ("RET" . ivy-alt-done))
  421. :init
  422. (use-package smex)
  423. (use-package counsel)
  424. :config
  425. (setq ivy-re-builders-alist
  426. '((t . wolfe/ivy--regex-fuzzy)))
  427. (setq ivy-wrap t)
  428. (ivy-mode 1)
  429. (setq ivy-use-virtual-buffers t))
  430. #+END_SRC
  431. #+BEGIN_SRC emacs-lisp :tangle yes
  432. (use-package swiper
  433. :bind (("C-s" . swiper)))
  434. #+END_SRC
  435. ** Nlinum
  436. #+BEGIN_SRC emacs-lisp :tangle yes
  437. (use-package nlinum-relative
  438. :config
  439. (nlinum-relative-setup-evil)
  440. (setq nlinum-relative-redisplay-delay 0.25)
  441. (setq nlinum-relative-current-symbol "")
  442. (add-hook 'prog-mode-hook 'nlinum-relative-mode))
  443. #+END_SRC
  444. ** Magit
  445. #+BEGIN_SRC emacs-lisp :tangle yes
  446. (use-package magit
  447. :config
  448. (global-set-key "\C-x\g" 'magit-status))
  449. #+END_SRC
  450. ** Iedit
  451. #+BEGIN_SRC emacs-lisp :tangle yes
  452. (use-package iedit
  453. :config
  454. (setq iedit-toggle-key-default nil))
  455. #+END_SRC
  456. ** Flycheck
  457. #+BEGIN_SRC emacs-lisp :tangle yes
  458. (use-package flycheck
  459. :config
  460. (global-flycheck-mode)
  461. (add-hook 'haskell-mode-hook (lambda() (flycheck-select-checker 'haskell-ghc)))
  462. (with-eval-after-load 'flycheck
  463. (setq-default flycheck-disabled-checkers '(emacs-lisp-checkdoc))))
  464. #+END_SRC
  465. ** Spotify
  466. #+BEGIN_SRC emacs-lisp :tangle yes
  467. (when (executable-find "spotify")
  468. (when (file-exists-p "~/Documents/spotify-secret-id.el")
  469. (load-file "~/Documents/spotify-secret-id.el"))
  470. (add-to-list 'load-path "~/.emacs.d/spotify.el")
  471. (require 'spotify)
  472. (setq spotify-mode-line-refresh-interval 1)
  473. (setq spotify-mode-line-format "%t - %a"))
  474. #+END_SRC
  475. * Email
  476. #+BEGIN_SRC emacs-lisp :tangle yes
  477. (when (require 'mu4e nil 'noerror)
  478. (setq mu4e-msg2pdf "/usr/bin/msg2pdf")
  479. (setq
  480. ;; set mu4e as default mail client
  481. mail-user-agent 'mu4e-user-agent
  482. ;; root mail directory - can't be switched
  483. ;; with context, can only be set once
  484. mu4e-maildir "~/.mail"
  485. mu4e-attachments-dir "~/Downloads/Attachments"
  486. ;; update command
  487. mu4e-get-mail-command "mbsync -q -a"
  488. ;; update database every seven minutes
  489. mu4e-update-interval (* 60 7)
  490. ;; use smtpmail (bundled with emacs) for sending
  491. message-send-mail-function 'smtpmail-send-it
  492. ;; optionally log smtp output to a buffer
  493. smtpmail-debug-info t
  494. ;; close sent message buffers
  495. message-kill-buffer-on-exit t
  496. ;; customize list columns
  497. mu4e-headers-fields '((:flags . 4)
  498. (:from . 20)
  499. (:human-date . 10)
  500. (:subject))
  501. ;; for mbsync
  502. mu4e-change-filenames-when-moving t
  503. ;; pick first context automatically on launch
  504. mu4e-context-policy 'pick-first
  505. ;; use current context for new mail
  506. mu4e-compose-context-policy nil
  507. mu4e-confirm-quit nil)
  508. (global-set-key (kbd "<f12>") 'mu4e)
  509. (global-set-key (kbd "<C-f12>") 'mu4e-update-mail-and-index)
  510. (setq mu4e-contexts
  511. `(,(make-mu4e-context
  512. :name "gmail"
  513. :match-func (lambda(msg)
  514. (when msg
  515. (mu4e-message-contact-field-matches msg :to "@gmail.com")))
  516. :vars '(
  517. ;; local directories, relative to mail root
  518. (mu4e-sent-folder . "/gmail/[Gmail]/.Sent Mail")
  519. (mu4e-drafts-folder . "/gmail/[Gmail]/.Drafts")
  520. (mu4e-trash-folder . "/gmail/[Gmail]/.Trash")
  521. (mu4e-refile-folder . "/gmail/[Gmail]/.All Mail")
  522. ;; account details
  523. (user-mail-address . "joshuafwolfe@gmail.com")
  524. (user-full-name . "Josh Wolfe")
  525. (mu4e-user-mail-address-list . ( "@gmail.com" ))
  526. ;; gmail saves every outgoing message automatically
  527. (mu4e-sent-messages-behavior . delete)
  528. (mu4e-maildir-shortcuts . (("/gmail/INBOX" . ?j)
  529. ("/gmail/[Gmail]/.All Mail" . ?a)
  530. ("/gmail/[Gmail]/.Trash" . ?t)
  531. ("/gmail/[Gmail]/.Drafts" . ?d)))
  532. ;; outbound mail server
  533. (smtpmail-smtp-server . "smtp.gmail.com")
  534. ;; outbound mail port
  535. (smtpmail-smtp-service . 465)
  536. ;; use ssl
  537. (smtpmail-stream-type . ssl)
  538. ;; the All Mail folder has a copy of every other folder's contents,
  539. ;; and duplicates search results, which is confusing
  540. (mue4e-headers-skip-duplicates . t)))))
  541. (use-package evil-mu4e))
  542. #+END_SRC
  543. * Language Specific
  544. ** Web
  545. #+BEGIN_SRC emacs-lisp :tangle yes
  546. (use-package web-mode
  547. :config
  548. (add-to-list 'auto-mode-alist '("\\.html\\'" . web-mode))
  549. (add-to-list 'auto-mode-alist '("\\.php\\'" . web-mode)))
  550. #+END_SRC
  551. ** Haskell
  552. #+BEGIN_SRC emacs-lisp :tangle yes
  553. (use-package haskell-mode)
  554. (use-package company-ghc
  555. :config
  556. (add-to-list 'company-backends 'company-ghc))
  557. #+END_SRC
  558. ** Latex
  559. #+BEGIN_SRC emacs-lisp :tangle yes
  560. (use-package latex-preview-pane
  561. :ensure f)
  562. #+END_SRC
  563. ** Matlab
  564. #+BEGIN_SRC emacs-lisp :tangle yes
  565. (use-package matlab-mode
  566. :config
  567. (load-library "matlab-load")
  568. (autoload 'matlab-mode "matlab" "Matlab Editing Mode" t)
  569. (add-to-list
  570. 'auto-mode-alist
  571. '("\\.m$" . octave-mode))
  572. (setq matlab-indent-function t)
  573. (setq matlab-shell-command "matlab")
  574. ;; emacs-lisp setup for matlab-mode:
  575. (setq matlab-shell-command-switches (list "-nodesktop")))
  576. #+END_SRC
  577. * Company
  578. #+BEGIN_SRC emacs-lisp :tangle yes
  579. (use-package company
  580. :init
  581. (global-company-mode)
  582. :config
  583. (setq company-idle-delay 0) ; Delay to complete
  584. (setq company-minimum-prefix-length 1)
  585. (setq company-selection-wrap-around t) ; Loops around suggestions
  586. (if (display-graphic-p)
  587. (define-key company-active-map [tab] 'company-select-next)
  588. (define-key company-active-map (kbd "C-i") 'company-select-next))
  589. ;; C / C++
  590. (setq company-clang-insert-arguments nil)
  591. (add-hook 'c++-mode-hook 'irony-mode)
  592. (add-hook 'c-mode-hook 'irony-mode)
  593. (use-package company-irony
  594. :config
  595. (eval-after-load 'company
  596. '(add-to-list 'company-backends 'company-irony)))
  597. (ignore-errors
  598. (require 'color)
  599. (let ((bg (face-attribute 'default :background)))
  600. (custom-set-faces
  601. `(company-tooltip ((t (:inherit default :background ,(color-lighten-name bg 2)))))
  602. `(company-scrollbar-bg ((t (:background ,(color-lighten-name bg 10)))))
  603. `(company-scrollbar-fg ((t (:background ,(color-lighten-name bg 5)))))
  604. `(company-tooltip-selection ((t (:inherit font-lock-function-name-face))))
  605. `(company-tooltip-common ((t (:inherit font-lock-constant-face))))))))
  606. #+END_SRC
  607. * Misc
  608. #+BEGIN_SRC emacs-lisp :tangle yes
  609. (setq gdb-many-windows t ;; use gdb-many-windows by default
  610. gdb-show-main t
  611. ;; Non-nil means display source file containing the main routine at startup
  612. )
  613. #+END_SRC
  614. * Backups
  615. #+BEGIN_SRC emacs-lisp :tangle yes
  616. (setq backup-by-copying t) ; Stop shinanigans with links
  617. (setq backup-directory-alist '((".*" . "~/.bak.emacs/backup/")))
  618. ;; Creates directory if it doesn't already exist
  619. (if (eq nil (file-exists-p "~/.bak.emacs/"))
  620. (make-directory "~/.bak.emacs/"))
  621. ;; Creates auto directory if it doesn't already exist
  622. (if (eq nil (file-exists-p "~/.bak.emacs/auto"))
  623. (make-directory "~/.bak.emacs/auto"))
  624. ;; backup in one place. flat, no tree structure
  625. (setq auto-save-file-name-transforms '((".*" "~/.bak.emacs/auto/" t)))
  626. #+END_SRC