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 44KB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456
  1. * About
  2. # -*- mode: org; -*-
  3. #+TITLE: Wolfe's Literate Emacs Config
  4. #+AUTHOR: Josh Wolfe
  5. #+HTML_HEAD: <link rel="stylesheet" type="text/css" href="https://www.pirilampo.org/styles/readtheorg/css/htmlize.css"/>
  6. #+HTML_HEAD: <link rel="stylesheet" type="text/css" href="readtheorg.css"/>
  7. #+HTML_HEAD: <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
  8. #+HTML_HEAD: <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
  9. #+HTML_HEAD: <script type="text/javascript" src="https://www.pirilampo.org/styles/lib/js/jquery.stickytableheaders.min.js"></script>
  10. #+HTML_HEAD: <script type="text/javascript" src="https://www.pirilampo.org/styles/readtheorg/js/readtheorg.js"></script>
  11. #+LATEX_HEADER: \usepackage[margin=0.7in]{geometry}
  12. #+HTML: <a href="https://travis-ci.org/WolfeCub/dotfiles"><img style="width:90px" src="https://travis-ci.org/WolfeCub/dotfiles.svg?branch=master" alt="Build Status"/></a><br><br>
  13. This literate config is best read [[http://wolfecub.github.io/dotfiles/][here]] or in emacs.
  14. This page is generated and kept up to date using a combination of
  15. [[https://travis-ci.org/WolfeCub/dotfiles/][travis ci]] and [[https://github.com/fniessen/org-html-themes][ReadTheOrg]]. If you want to see the script that travis
  16. uses [[https://github.com/WolfeCub/dotfiles/blob/master/.travis/build_site.sh][here]] is the bash script it runs and [[https://github.com/WolfeCub/dotfiles/blob/master/.travis/generate-html.el][this]] is the =.el= file that
  17. it runs through emacs to generate the html page (this was mostly stolen
  18. from IvanMalison).
  19. Included in this section is also my export headers. These are responsible
  20. for including the ReadTheOrg theme as well as some metadata and options
  21. like title, author, table of contents etc. If you wish to see the headers
  22. I'm using, [[https://raw.githubusercontent.com/WolfeCub/dotfiles/master/emacs/.emacs.d/README.org][this]] is the raw org file.
  23. * Variables
  24. Variables come at the beginning so that they're consistently available.
  25. If you don't care about these [[Startup][click here to skip over them]].
  26. #+BEGIN_SRC emacs-lisp :tangle yes
  27. (defvar wolfe/literate-config-name "README.org"
  28. "The name of my literate config")
  29. #+END_SRC
  30. #+BEGIN_SRC emacs-lisp :tangle yes
  31. (defvar wolfe/init-file (concat user-emacs-directory wolfe/literate-config-name)
  32. "The path to my literate config file")
  33. #+END_SRC
  34. #+BEGIN_SRC emacs-lisp :tangle yes
  35. (defvar wolfe/linux? (eq system-type 'gnu/linux)
  36. "Are we on linux?")
  37. #+END_SRC
  38. #+BEGIN_SRC emacs-lisp :tangle yes
  39. (defvar wolfe/windows? (eq system-type 'windows-nt)
  40. "Are we on windows?")
  41. #+END_SRC
  42. #+BEGIN_SRC emacs-lisp :tangle yes
  43. (defvar wolfe/org-ellipsis
  44. (if (display-graphic-p)
  45. "⤵"
  46. "...")
  47. "The indicates if an `org-mode' tree can be expanded")
  48. #+END_SRC
  49. #+BEGIN_SRC emacs-lisp :tangle yes
  50. (defvar wolfe/project-path
  51. (cond
  52. (wolfe/linux? "~/Projects/")
  53. (wolfe/windows? "C:/dev/")
  54. (:else nil))
  55. "Path to my projects directory")
  56. #+END_SRC
  57. #+BEGIN_SRC emacs-lisp :tangle yes
  58. (defvar wolfe/org-dropbox-path
  59. (cond
  60. (wolfe/linux?
  61. "~/Dropbox/org/")
  62. (wolfe/windows?
  63. "C:\\Users\\Josh\\Dropbox\\org\\")
  64. (:else nil))
  65. "Path to my org files inside dropbox")
  66. #+END_SRC
  67. #+BEGIN_SRC emacs-lisp :tangle yes
  68. (defvar wolfe/using-light nil
  69. "Indicates whether we're using my light theme")
  70. #+END_SRC
  71. #+BEGIN_SRC emacs-lisp :tangle yes
  72. (defvar wolfe/lisp-dir-path "~/.emacs.d/lisp/"
  73. "Path to my custom lisp files")
  74. #+END_SRC
  75. * Startup
  76. My graphical settings change depending on whether I'm in terminal
  77. and if a command line flag (=-light=) was specified.
  78. ** Theme Setup
  79. This should be run regardless of whether I'm in terminal vs gui or dark vs light.
  80. #+BEGIN_SRC emacs-lisp :tangle yes
  81. (setq custom-theme-directory "~/.emacs.d/themes")
  82. (setq wolfe/using-light (member "-light" command-line-args))
  83. (setq command-line-args (delete "-light" command-line-args))
  84. #+END_SRC
  85. ** Dark
  86. Configuration for my dark theme =base16 default dark= which is loaded by default.
  87. *** Common
  88. #+BEGIN_SRC emacs-lisp :tangle yes
  89. (defun wolfe/dark-setup ()
  90. (use-package base16-theme
  91. :config
  92. (load-theme 'base16-default-dark t)
  93. (if (display-graphic-p)
  94. (wolfe/dark-gui-setup)
  95. (wolfe/dark-term-setup))))
  96. #+END_SRC
  97. *** Graphical
  98. #+BEGIN_SRC emacs-lisp :tangle yes
  99. (defun wolfe/dark-gui-setup ()
  100. (defvar my/base16-colors base16-default-dark-colors)
  101. (setq evil-emacs-state-cursor `(,(plist-get my/base16-colors :base0D) box)
  102. evil-insert-state-cursor `(,(plist-get my/base16-colors :base0D) bar)
  103. evil-motion-state-cursor `(,(plist-get my/base16-colors :base0E) box)
  104. evil-normal-state-cursor `(,(plist-get my/base16-colors :base07) box)
  105. evil-replace-state-cursor `(,(plist-get my/base16-colors :base08) bar)
  106. evil-visual-state-cursor `(,(plist-get my/base16-colors :base09) box))
  107. (set-face-attribute 'fringe nil :background nil)
  108. (custom-set-faces
  109. '(region ((t (:background "gray19"))))
  110. '(org-block ((t (:foreground "#d8d8d8"))))
  111. '(org-done ((t (:box (:line-width 1) :weight bold))))
  112. '(org-level-1 ((t (:inherit outline-1 :height 1.3))))
  113. '(org-todo ((t (:box (:line-width 1) :weight bold))))))
  114. #+END_SRC
  115. *** Terminal
  116. #+BEGIN_SRC emacs-lisp :tangle yes
  117. (defun wolfe/dark-term-setup ()
  118. (setq nlinum-format "%d ")
  119. (custom-set-faces
  120. '(line-number ((t (:background "color-18" :foreground "brightblack"))))
  121. '(ivy-current-match ((t (:background "color-18" :foreground "color-16"))))
  122. '(linum ((t (:background "color-18"))))
  123. '(region ((t :background "color-19")))
  124. '(mode-line ((t (:background "color-19" :foreground "brightblue" :box nil))))
  125. '(mode-line-inactive
  126. ((t (:background "color-18" :foreground "color-244"))))))
  127. #+END_SRC
  128. ** Light
  129. Configuration for my light theme =leuven=. This is only loaded when the =-light= flag is
  130. specified on the command line.
  131. *** Common
  132. #+BEGIN_SRC emacs-lisp :tangle yes
  133. (defun wolfe/light-setup ()
  134. (use-package leuven-theme
  135. :config
  136. (custom-set-faces
  137. '(ivy-subdir ((t (:background "gray88")))))
  138. (load-theme 'leuven t)))
  139. #+END_SRC
  140. ** Display check
  141. This checks which setup we're in and calls the appropriate function above.
  142. #+BEGIN_SRC emacs-lisp :tangle yes
  143. (if wolfe/using-light
  144. (wolfe/light-setup)
  145. (wolfe/dark-setup))
  146. #+END_SRC
  147. * General Settings
  148. Basic settings I can't really live without.
  149. ** Load Path
  150. Recursively add =~/.emacs.d/lisp/= to my load path.
  151. #+BEGIN_SRC emacs-lisp :tangle yes
  152. (add-to-list 'load-path wolfe/lisp-dir-path)
  153. (let ((default-directory wolfe/lisp-dir-path))
  154. (normal-top-level-add-subdirs-to-load-path))
  155. #+END_SRC
  156. ** Splash and Startup
  157. This makes sure I'm presented with a nice blank =*scratch*=
  158. buffer when emacs starts up.
  159. #+BEGIN_SRC emacs-lisp :tangle yes
  160. (setq inhibit-splash-screen t
  161. inhibit-startup-message t
  162. initial-scratch-message "") ; No scratch text
  163. (defun display-startup-echo-area-message ()
  164. (message "Welcome to the church of GNU/Emacs"))
  165. #+END_SRC
  166. ** Graphics
  167. *** Bars
  168. I don't really want to have to look at menu bars that I'm not going to use
  169. #+BEGIN_SRC emacs-lisp :tangle yes
  170. (tool-bar-mode -1) ; No toolbar
  171. (scroll-bar-mode -1) ; Hide scrollbars
  172. (menu-bar-mode -1) ; No menubar
  173. #+END_SRC
  174. *** Fonts
  175. Quick macro that tries to load the font. If it loads it return =t= so we
  176. know not to try and load anything else if it returns =nil= then we'll
  177. try a different font.
  178. #+BEGIN_SRC emacs-lisp :tangle yes
  179. (defmacro load-font-if-exists (family size)
  180. (if (member family (font-family-list)) ; Set default font
  181. (progn
  182. (let ((font-and-size (format "%s-%s" family size)))
  183. (add-to-list 'default-frame-alist `(font . ,font-and-size))
  184. (set-face-attribute 'default t :font font-and-size))
  185. t)
  186. nil))
  187. #+END_SRC
  188. I like =Inconsolata-dz= a bit more than =Inconsolata= so use it if installed
  189. otherwise fall back to regular =Inconsolata=.
  190. #+BEGIN_SRC emacs-lisp :tangle yes
  191. (unless (load-font-if-exists "Inconsolata-dz" 15)
  192. (load-font-if-exists "Inconsolata" 15))
  193. #+END_SRC
  194. Make sure that UTF-8 is used everywhere.
  195. #+BEGIN_SRC emacs-lisp :tangle yes
  196. (set-terminal-coding-system 'utf-8)
  197. (set-keyboard-coding-system 'utf-8)
  198. (set-language-environment 'utf-8)
  199. (set-selection-coding-system 'utf-8)
  200. (setq locale-coding-system 'utf-8)
  201. (prefer-coding-system 'utf-8)
  202. (set-input-method nil)
  203. #+END_SRC
  204. *** Column Marker
  205. #+BEGIN_SRC emacs-lisp :tangle yes
  206. (use-package column-marker
  207. :ensure nil
  208. :config
  209. (add-hook 'prog-mode-hook (lambda () (interactive) (column-marker-1 81)))
  210. (custom-set-faces
  211. '(column-marker-1 ((t (:background "dim gray"))))))
  212. #+END_SRC
  213. ** Personal Defaults
  214. Nothing to crazy here just the type of behaviour I personally
  215. expect as default.
  216. #+BEGIN_SRC emacs-lisp :tangle yes
  217. (show-paren-mode t) ; Highlights matching parens
  218. (fset 'yes-or-no-p 'y-or-n-p) ; y/n instead of yes/no
  219. (blink-cursor-mode -1) ; No need to flash the cursor
  220. (column-number-mode t) ; Show column in mode-line
  221. (delete-selection-mode 1) ; Replace selection on insert
  222. (setq-default truncate-lines t ; Don't wrap
  223. indent-tabs-mode nil)
  224. (setq vc-follow-symlinks t ; Always follow symlinks
  225. tags-revert-without-query t ; Don't ask to reload TAGS file
  226. echo-keystrokes 0.5
  227. custom-file "~/.emacs.d/custom.el" ; Set custom file & don't load it
  228. source-directory "~/Projects/emacs/")
  229. #+END_SRC
  230. ** Misc
  231. *** Vim Scrolloff
  232. This makes scrolling gradual rather than by half page. I find that the
  233. half page scroll really makes me lose where I am in the file so here
  234. I make sure to scroll one line at a time. In addition I want to keep
  235. what I'm working on centered so I start scrolling when the cursor is
  236. 10 lines away from the margin.
  237. This behaviour in general emulates the =scrolloff= option in vim.
  238. #+BEGIN_SRC emacs-lisp :tangle yes
  239. (setq scroll-margin 10
  240. scroll-step 1
  241. scroll-conservatively 10000
  242. scroll-preserve-screen-position 1)
  243. #+END_SRC
  244. *** Shell Tweaks
  245. #+BEGIN_SRC emacs-lisp :tangle yes
  246. (setq explicit-shell-file-name
  247. (if (file-readable-p "/usr/bin/zsh") "/usr/bin/zsh" "/bin/bash"))
  248. (when (eq system-type 'windows-nt)
  249. (setq explicit-shell-file-name "cmdproxy.exe"))
  250. #+END_SRC
  251. ** Mode Line
  252. If we're in GUI emacs we make sure to use =powerline= otherwise we use
  253. a custom mode line configuration.
  254. #+BEGIN_SRC emacs-lisp :tangle yes
  255. (if (display-graphic-p)
  256. (use-package powerline
  257. :init
  258. (defadvice powerline-major-mode (around delight-powerline-major-mode activate)
  259. (let ((inhibit-mode-name-delight nil))
  260. ad-do-it))
  261. :config
  262. (setq powerline-arrow-shape 'curve
  263. powerline-display-buffer-size nil
  264. powerline-display-mule-info nil)
  265. (powerline-default-theme)
  266. (remove-hook 'focus-out-hook 'powerline-unset-selected-window)
  267. (setq powerline-height 24))
  268. (setq-default mode-line-format
  269. (list
  270. " "
  271. ;; is this buffer read-only?
  272. '(:eval (when buffer-read-only
  273. (propertize "RO"
  274. 'face 'font-lock-type-face
  275. 'help-echo "Buffer is read-only")))
  276. ;; was this buffer modified since the last save?
  277. '(:eval (when (buffer-modified-p)
  278. (propertize "M"
  279. 'face 'font-lock-warning-face
  280. 'help-echo "Buffer has been modified")))
  281. " "
  282. ;; the buffer name; the file name as a tool tip
  283. '(:eval (propertize "%b " 'face 'font-lock-keyword-face
  284. 'help-echo (buffer-file-name)))
  285. ;; the current major mode for the buffer.
  286. "["
  287. '(:eval (propertize (format-mode-line mode-name) 'face '(:family "Arial")
  288. 'help-echo buffer-file-coding-system))
  289. '(:eval (propertize (format-mode-line minor-mode-alist)
  290. 'face '(:family "Arial")))
  291. "] "
  292. ;; line and column
  293. "(" ;; '%02' to set to 2 chars at least; prevents flickering
  294. (propertize "%02l" 'face 'font-lock-type-face) ","
  295. (propertize "%02c" 'face 'font-lock-type-face)
  296. ") "
  297. ;; relative position, size of file
  298. "["
  299. (propertize "%p" 'face 'font-lock-constant-face) ;; % above top
  300. "/"
  301. (propertize "%I" 'face 'font-lock-constant-face) ;; size
  302. "] "
  303. ;; add the time, with the date and the emacs uptime in the tooltip
  304. '(:eval (propertize (format-time-string "%H:%M")
  305. 'help-echo
  306. (concat (format-time-string "%c; ")
  307. (emacs-uptime "Uptime:%hh"))))
  308. )))
  309. #+END_SRC
  310. ** Line Numbers
  311. Vim-like relative line numbering. If we're on the latest versions of emacs
  312. (i.e. =26.0.50= or higher) then we should use the native line numbering
  313. otherwise we fall back to =nlinum-relative=.
  314. #+BEGIN_SRC emacs-lisp :tangle yes
  315. (if (fboundp 'display-line-numbers-mode)
  316. (progn
  317. (setq display-line-numbers 'relative)
  318. (add-hook 'prog-mode-hook 'display-line-numbers-mode))
  319. (progn
  320. (use-package nlinum-relative
  321. :config
  322. (nlinum-relative-setup-evil)
  323. (setq nlinum-relative-redisplay-delay 0.25)
  324. (setq nlinum-relative-current-symbol "")
  325. (add-hook 'prog-mode-hook 'nlinum-relative-mode))))
  326. #+END_SRC
  327. * Functions
  328. ** Face Under Point
  329. Returns the font lock face that's under the cursor.
  330. #+BEGIN_SRC emacs-lisp :tangle yes
  331. (defun what-face (pos)
  332. (interactive "d")
  333. (let ((face (or (get-char-property (point) 'read-face-name)
  334. (get-char-property (point) 'face))))
  335. (if face (message "Face: %s" face) (message "No face at %d" pos))))
  336. #+END_SRC
  337. ** Compile Project
  338. Compiles the project without a prompt.
  339. #+BEGIN_SRC emacs-lisp :tangle yes
  340. (defun wolfe/compile-no-prompt ()
  341. (interactive)
  342. (let ((compilation-read-command nil))
  343. (compile (eval compile-command))))
  344. #+END_SRC
  345. ** Compile Dotfiles
  346. Compiles all el files in the =~/.emacs.d= directory.
  347. #+BEGIN_SRC emacs-lisp :tangle yes
  348. (defun wolfe/compile-dot-emacs ()
  349. "Byte-compile dotfiles."
  350. (interactive)
  351. (byte-recompile-directory user-emacs-directory 0))
  352. #+END_SRC
  353. #+BEGIN_SRC emacs-lisp :tangle yes
  354. (defun wolfe/clear-all-elc ()
  355. (interactive)
  356. (shell-command "find ~/.emacs.d/ -name \"*.elc\" -type f -delete"))
  357. #+END_SRC
  358. #+BEGIN_SRC emacs-lisp :tangle yes
  359. (defun wolfe/remove-elc-on-save ()
  360. "If you're saving an emacs-lisp file, likely the .elc is no longer valid."
  361. (add-hook 'after-save-hook
  362. (lambda ()
  363. (if (file-exists-p (concat buffer-file-name "c"))
  364. (delete-file (concat buffer-file-name "c"))))
  365. nil t))
  366. (add-hook 'emacs-lisp-mode-hook 'wolfe/remove-elc-on-save)
  367. #+END_SRC
  368. ** Find Tags
  369. Looks up tag under point.
  370. #+BEGIN_SRC emacs-lisp :tangle yes
  371. (defun wolfe/find-tag ()
  372. "Jump to the tag at point without prompting"
  373. (interactive)
  374. (find-tag (find-tag-default)))
  375. #+END_SRC
  376. #+BEGIN_SRC emacs-lisp :tangle yes
  377. (defun wolfe/create-tags ()
  378. "Create the tags table"
  379. (interactive)
  380. (save-window-excursion (shell-command "etags -R -o ETAGS *")))
  381. #+END_SRC
  382. #+BEGIN_SRC emacs-lisp :tangle yes
  383. (defadvice xref-find-definitions (around refresh-etags activate)
  384. "Rerun etags and reload tags if tag not found and redo find-tag.
  385. If buffer is modified, ask about save before running etags."
  386. (condition-case err
  387. ad-do-it
  388. (error (and (buffer-modified-p) (not (ding))
  389. (save-buffer))
  390. (save-window-excursion (shell-command "etags -R *"))
  391. ad-do-it)))
  392. #+END_SRC
  393. ** Terminal Suspend
  394. Fixes =C-z= in terminal.
  395. #+BEGIN_SRC emacs-lisp :tangle yes
  396. (defun wolfe/controlz ()
  397. (interactive)
  398. (when (eq (display-graphic-p) nil)
  399. (suspend-frame)))
  400. #+END_SRC
  401. ** Dropbox
  402. Utility functions for finding Dropbox directories/files.
  403. #+BEGIN_SRC emacs-lisp :tangle yes
  404. (defun wolfe/org-open (name)
  405. "Opens the file in the dropbox path"
  406. (interactive)
  407. (evil-buffer-new nil (concat wolfe/org-dropbox-path name ".org")))
  408. #+END_SRC
  409. #+BEGIN_SRC emacs-lisp :tangle yes
  410. (defun wolfe/dropbox-start ()
  411. (interactive)
  412. (if (eq nil (file-exists-p "/virtual/wolfejos/dropbox/.dropbox-dist"))
  413. (call-process-shell-command "(python ~/.emacs.d/dropbox.py start -i&)")
  414. (call-process-shell-command "(python ~/.emacs.d/dropbox.py start&)")))
  415. #+END_SRC
  416. #+BEGIN_SRC emacs-lisp :tangle yes
  417. (defun wolfe/dropbox-stop ()
  418. (interactive)
  419. (call-process-shell-command "python ~/.emacs.d/dropbox.py stop&"))
  420. #+END_SRC
  421. ** Reload
  422. For reloading =init.el= file without restarting.
  423. #+BEGIN_SRC emacs-lisp :tangle yes
  424. (defun wolfe/load-init ()
  425. "Reloads init file"
  426. (interactive)
  427. (load-file "~/.emacs.d/init.el"))
  428. #+END_SRC
  429. ** Narrowing
  430. Better narrowing.
  431. #+BEGIN_SRC emacs-lisp :tangle yes
  432. (defun narrow-or-widen-dwim (p)
  433. "Widen if buffer is narrowed, narrow-dwim otherwise.
  434. Dwim means: region, org-src-block, org-subtree, or
  435. defun, whichever applies first. Narrowing to
  436. org-src-block actually calls `org-edit-src-code'.
  437. With prefix P, don't widen, just narrow even if buffer
  438. is already narrowed."
  439. (interactive "P")
  440. (declare (interactive-only))
  441. (cond ((and (buffer-narrowed-p) (not p)) (widen))
  442. ((region-active-p)
  443. (narrow-to-region (region-beginning)
  444. (region-end)))
  445. ((derived-mode-p 'org-mode)
  446. ;; `org-edit-src-code' is not a real narrowing
  447. ;; command. Remove this first conditional if
  448. ;; you don't want it.
  449. (cond ((ignore-errors (org-edit-src-code) t)
  450. (delete-other-windows))
  451. ((ignore-errors (org-narrow-to-block) t))
  452. (t (org-narrow-to-subtree))))
  453. ((derived-mode-p 'latex-mode)
  454. (LaTeX-narrow-to-environment))
  455. (t (narrow-to-defun))))
  456. (defun wolfe/man ()
  457. (if (executable-find "man")
  458. (man (word-at-point))
  459. (woman)))
  460. #+END_SRC
  461. ** Open C# Project File
  462. This function prompts for a file. It then opens that file and looks for a src/
  463. directory above it. The dir can be any number of levels higher. In that folder
  464. it looks for a C# .sln file and starts the an omnisharp server for that project.
  465. #+BEGIN_SRC emacs-lisp :tangle yes
  466. (defun wolfe/csharp-project ()
  467. (interactive)
  468. (setq path (read-file-name "File: " wolfe/project-path))
  469. (setq split-path (split-string path "/"))
  470. (if (member "src" split-path)
  471. (catch 'loop
  472. (dolist (item (reverse split-path))
  473. (if (string-equal item "src")
  474. (throw 'loop nil)
  475. (delete item split-path)))
  476. (message "src/ directory not found")))
  477. (if (or (equal '("c:") split-path) (equal '() split-path))
  478. (message "Could not find src directory for specified project")
  479. (progn
  480. (omnisharp-start-omnisharp-server (mapconcat 'identity split-path "/"))
  481. (find-file path))))
  482. #+END_SRC
  483. ** Hot Expand
  484. Is used in one of my [[Hydra][hydras]] =wolfe/hydra-org-expand=. For inserting org-templates.
  485. #+BEGIN_SRC emacs-lisp :tangle yes
  486. (defun hot-expand (str &optional additional-text)
  487. "Expand org template."
  488. (insert str)
  489. (org-try-structure-completion)
  490. (when additional-text
  491. (insert additional-text)
  492. (next-line)))
  493. #+END_SRC
  494. ** Ag Project If In Project
  495. If we're inside of a projectile project we'll use =projectile-ag= to
  496. search the project otherwise just normal ag frow our working directory
  497. does the job.
  498. #+BEGIN_SRC emacs-lisp :tangle yes
  499. (defun wolfe/ag-try-project ()
  500. (interactive)
  501. (if (projectile-project-p)
  502. (call-interactively 'projectile-ag)
  503. (call-interactively 'ag)))
  504. #+END_SRC
  505. ** Projectile Invalidate From List
  506. Select project from list of projectile projects to invalidate.
  507. #+BEGIN_SRC emacs-lisp :tangle yes
  508. (defun wolfe/projectile-invalidate-list ()
  509. (interactive)
  510. (projectile-invalidate-cache t))
  511. #+END_SRC
  512. ** User Pass Tupple
  513. Uses GPG to decrypt =file= and returns a list of the contents split on spaces.
  514. #+BEGIN_SRC emacs-lisp :tangle yes
  515. (defun wolfe/get-user-pass (file)
  516. (split-string
  517. (car (last (split-string
  518. (shell-command-to-string (concat "gpg --output - --decrypt "
  519. (expand-file-name file)))
  520. "[|\n]" t "[ \n]"))) " "))
  521. #+END_SRC
  522. * Org Mode
  523. ** General
  524. Setup some basic quality of life org settings.
  525. #+BEGIN_SRC emacs-lisp :tangle yes
  526. (setq org-pretty-entities t
  527. org-src-fontify-natively t
  528. org-src-tab-acts-natively t
  529. org-src-window-setup 'current-window
  530. org-fontify-whole-heading-line t
  531. org-fontify-done-headline t
  532. org-fontify-quote-and-verse-blocks t
  533. org-log-done 'time
  534. org-agenda-use-time-grid nil
  535. org-agenda-skip-deadline-if-done t
  536. org-agenda-skip-scheduled-if-done t
  537. org-ellipsis wolfe/org-ellipsis)
  538. (org-babel-do-load-languages
  539. 'org-babel-load-languages
  540. '((shell . t)
  541. ( dot . t)))
  542. (global-set-key "\C-cl" 'org-store-link)
  543. ;; ispell ignores SRC blocks
  544. (add-to-list 'ispell-skip-region-alist '("#\\+BEGIN_SRC" . "#\\+END_SRC"))
  545. (add-to-list 'ispell-skip-region-alist '("#\\+BEGIN_LATEX" . "#\\+END_LATEX"))
  546. ;; Refresh images after executing a src block
  547. (add-hook 'org-babel-after-execute-hook
  548. '(lambda ()
  549. (when org-inline-image-overlays
  550. (org-redisplay-inline-images))))
  551. ;; Open PDFs with zathura
  552. (add-hook 'org-mode-hook
  553. '(lambda ()
  554. (setq org-file-apps
  555. (append '(("\\.pdf\\'" . "zathura \"%s\"")) org-file-apps))))
  556. #+END_SRC
  557. ** Bullets
  558. Replaces the asterisks with nice UTF-8 bullets.
  559. #+BEGIN_SRC emacs-lisp :tangle yes
  560. (use-package org-bullets
  561. :config
  562. (add-hook 'org-mode-hook (lambda () (org-bullets-mode 1))))
  563. #+END_SRC
  564. ** Agenda
  565. Setup org agenda for managing my life.
  566. #+BEGIN_SRC emacs-lisp :tangle yes
  567. (use-package org-agenda
  568. :ensure nil
  569. :bind (("C-c a" . org-agenda)
  570. :map org-agenda-mode-map
  571. ("j" . org-agenda-next-item)
  572. ("k" . org-agenda-previous-item))
  573. :config
  574. ;; Formats the agenda into nice columns
  575. (setq org-agenda-prefix-format
  576. '((agenda . " %i %-12t% s %-12(car (last (org-get-outline-path)))")
  577. (timeline . " % s")
  578. (todo . " %i %-12:c")
  579. (tags . " %i %-12:c")
  580. (search . " %i %-12:c")))
  581. ;; Sets location of org files
  582. (setq org-agenda-files '((concat wolfe/org-dropbox-path "everything.org")))
  583. (setq browse-url-browser-function 'browse-url-chromium))
  584. #+END_SRC
  585. ** Export
  586. Setup html for syntax highlighting on export and add the apppropriate
  587. minted package for PDF export.
  588. #+BEGIN_SRC emacs-lisp :tangle yes
  589. (use-package htmlize)
  590. (require 'ox-latex)
  591. (add-to-list 'org-latex-packages-alist '("" "minted"))
  592. (setq org-latex-listings 'minted)
  593. (setq org-latex-pdf-process
  594. '("pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f"
  595. "pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f"
  596. "pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f"))
  597. #+END_SRC
  598. * Keymaps
  599. ** Hydra
  600. Customizable popup menus.
  601. #+BEGIN_SRC emacs-lisp :tangle yes
  602. (use-package hydra)
  603. #+END_SRC
  604. *** Major Modes
  605. **** C#
  606. #+BEGIN_SRC emacs-lisp :tangle yes
  607. (setq wolfe/hydra-csharp
  608. (defhydra hydra-csharp (:color blue)
  609. "Omnisharp"
  610. ("d" omnisharp-go-to-definition "Goto definition")
  611. ("D" omnisharp-go-to-definition-other-window "Pop-open definition")
  612. ("u" omnisharp-find-usages "Find usages")
  613. ("r" omnisharp-rename "Rename symbol")
  614. ("R" omnisharp-reload-solution "Reload solution")
  615. ("i" omnisharp-code-format-region "Indent region")
  616. ("I" omnisharp-code-format-entire-file "Indent entire file")
  617. ))
  618. #+END_SRC
  619. **** Org Mode
  620. #+BEGIN_SRC emacs-lisp :tangle yes
  621. (setq wolfe/hydra-org
  622. (defhydra hydra-org (:color blue)
  623. "Org Mode"
  624. ("t" (funcall wolfe/hydra-org-expand) "Expand template")))
  625. #+END_SRC
  626. **** Org Templates
  627. #+BEGIN_SRC emacs-lisp :tangle yes
  628. (setq wolfe/hydra-org-expand
  629. (defhydra hydra-org-template (:color blue :hint nil)
  630. "
  631. _c_enter _q_uote _L_aTeX:
  632. _l_atex _e_xample _i_ndex:
  633. _a_scii _v_erse _I_NCLUDE:
  634. _s_rc _t_angle _H_TML:
  635. _h_tml _d_ot src _A_SCII:
  636. "
  637. ("s" (hot-expand "<s"))
  638. ("e" (hot-expand "<e"))
  639. ("q" (hot-expand "<q"))
  640. ("v" (hot-expand "<v"))
  641. ("t" (hot-expand "<s" "emacs-lisp :tangle yes"))
  642. ("d" (hot-expand "<s" "dot :file TMP.png :cmdline -Kdot -Tpng"))
  643. ("c" (hot-expand "<c"))
  644. ("l" (hot-expand "<l"))
  645. ("h" (hot-expand "<h"))
  646. ("a" (hot-expand "<a"))
  647. ("L" (hot-expand "<L"))
  648. ("i" (hot-expand "<i"))
  649. ("I" (hot-expand "<I"))
  650. ("H" (hot-expand "<H"))
  651. ("A" (hot-expand "<A"))))
  652. #+END_SRC
  653. *** Minor Modes
  654. **** Projectile
  655. #+BEGIN_SRC emacs-lisp :tangle yes
  656. (setq wolfe/hydra-projectile
  657. (defhydra hydra-projectile (:color blue :columns 4)
  658. "Projectile"
  659. ("f" counsel-projectile-find-file "Find File")
  660. ("s" counsel-projectile-switch-project "Switch Project")
  661. ("k" projectile-kill-buffers "Kill Buffers")
  662. ("c" projectile-invalidate-cache "Clear Cache")
  663. ("d" counsel-projectile-find-dir "Find Directory")
  664. ("o" projectile-multi-occur "Multi Occur")
  665. ("P" projectile-clear-known-projects "Clear Projects")
  666. ("C" wolfe/projectile-invalidate-list "Clear A Cache")
  667. ))
  668. #+END_SRC
  669. **** Jira
  670. #+BEGIN_SRC emacs-lisp :tangle yes
  671. (setq wolfe/hydra-jira
  672. (defhydra hydra-jira (:color blue :columns 4)
  673. "Jira"
  674. ("p" org-jira-get-projects "Get Projects")
  675. ("b" org-jira-browse-issue "Browse Issue")
  676. ("g" org-jira-get-issues "Get Issues")
  677. ("u" org-jira-update-issue "Update Issue")
  678. ("p" org-jira-progress-issue "Update Issue Progress")
  679. ("a" org-jira-assign-issue "Assign Issue")
  680. ("r" org-jira-refresh-issue "Refresh Issue")
  681. ("R" org-jira-refresh-issues-in-buffer "Refresh Issues in Buffer")
  682. ("c" org-jira-create-issue "Create Issue")
  683. ("y" org-jira-copy-current-issue-key "Copy Current Issue Key")
  684. ("s" org-jira-create-subtask "Create Subtask")
  685. ("G" org-jira-get-subtasks "Get Subtasks")
  686. ("U" org-jira-update-comment "Update Comment")
  687. ("t" org-jira-todo-to-jira "Todo to Jira")
  688. ("O" (funcall wolfe/hydra-org-expand) "Org Hydra")))
  689. #+END_SRC
  690. *** Default
  691. #+BEGIN_SRC emacs-lisp :tangle yes
  692. (setq wolfe/hydra-default
  693. (defhydra hydra-default (:color blue)
  694. "Default"
  695. ("o" (funcall wolfe/hydra-org) "Org Mode")
  696. ("#" (funcall wolfe/hydra-csharp) "C# Mode")))
  697. #+END_SRC
  698. *** Selector
  699. #+BEGIN_SRC emacs-lisp :tangle yes
  700. (defun wolfe/hydra-selector ()
  701. (cond
  702. ((derived-mode-p 'csharp-mode) wolfe/hydra-csharp)
  703. ((bound-and-true-p org-jira-mode) wolfe/hydra-jira)
  704. ((derived-mode-p 'org-mode) wolfe/hydra-org)
  705. (:else wolfe/hydra-default)))
  706. #+END_SRC
  707. ** Evil & General
  708. *** General
  709. #+BEGIN_SRC emacs-lisp :tangle yes
  710. (use-package general)
  711. #+END_SRC
  712. *** Evil
  713. #+BEGIN_SRC emacs-lisp :tangle yes
  714. (use-package evil
  715. :demand
  716. :init
  717. (setq evil-want-C-u-scroll t) ; Unbind <C-u> for evil mode's use
  718. (setq evil-want-C-i-jump nil)
  719. :config
  720. (evil-mode t)
  721. (setq evil-split-window-below t
  722. evil-vsplit-window-right t
  723. evil-lookup-func #'wolfe/man)
  724. (setq-default evil-symbol-word-search t)
  725. (custom-set-variables '(evil-search-module (quote evil-search)))
  726. (evil-ex-define-cmd "re[load]" 'wolfe/load-init) ; Custom reload command
  727. (evil-ex-define-cmd "Q" 'save-buffers-kill-terminal) ; For typos
  728. (define-key evil-ex-map "e " 'counsel-find-file) ; Trigger file completion :e
  729. (global-unset-key (kbd "M-SPC")) ; Unbind secondary leader
  730. (general-create-definer wolfe/bind-leader
  731. :keymaps 'global
  732. :states '(normal insert visual emacs)
  733. :prefix "SPC"
  734. :non-normal-prefix "M-SPC")
  735. :general
  736. (:states 'motion
  737. "k" 'evil-previous-visual-line
  738. "j" 'evil-next-visual-line)
  739. (:states 'operator
  740. "k" 'evil-previous-line
  741. "j" 'evil-next-line)
  742. (:states 'visual
  743. "<" (lambda ()
  744. (interactive)
  745. (evil-shift-left (region-beginning) (region-end))
  746. (evil-normal-state)
  747. (evil-visual-restore))
  748. ">" (lambda ()
  749. (interactive)
  750. (evil-shift-right (region-beginning) (region-end))
  751. (evil-normal-state)
  752. (evil-visual-restore)))
  753. (:states 'normal
  754. "C-z" 'wolfe/controlz
  755. "C-l" 'evil-ex-nohighlight)
  756. (:states 'normal :prefix "g"
  757. "a" (lambda (beginning end)
  758. (interactive "r")
  759. (if (use-region-p)
  760. (align beginning end)
  761. (align-current)))
  762. "A" 'align-regexp)
  763. (wolfe/bind-leader
  764. "w" 'save-buffer
  765. "S" 'eval-buffer
  766. "s" 'eval-defun
  767. "b" 'mode-line-other-buffer
  768. "k" 'kill-buffer
  769. "m" 'ivy-switch-buffer
  770. "t" 'wolfe/find-tag
  771. "e" 'iedit-mode
  772. "c" 'wolfe/compile-no-prompt
  773. "n" 'narrow-or-widen-dwim
  774. "a" 'org-agenda
  775. "g" 'magit-status
  776. "f" 'wolfe/ag-try-project
  777. "''" 'org-edit-src-exit
  778. "#" 'wolfe/csharp-project
  779. "p" (lambda() (interactive) (funcall wolfe/hydra-projectile))
  780. ";" (lambda() (interactive) (save-excursion (end-of-line) (insert-char ?\;)))
  781. "id" (lambda() (interactive) (indent-region (point-min) (point-max)))
  782. "o" (lambda() (interactive) (wolfe/org-open "everything"))
  783. "SPC" (lambda() (interactive) (funcall (wolfe/hydra-selector)))
  784. "init" (lambda() (interactive) (evil-buffer-new nil wolfe/init-file))))
  785. #+END_SRC
  786. *** Evil Surround
  787. Tpope's surround
  788. #+BEGIN_SRC emacs-lisp :tangle yes
  789. (use-package evil-surround
  790. :config
  791. (global-evil-surround-mode 1))
  792. #+END_SRC
  793. *** Evil Magit
  794. #+BEGIN_SRC emacs-lisp :tangle yes
  795. (use-package evil-magit)
  796. #+END_SRC
  797. *** Evil Machit
  798. #+BEGIN_SRC emacs-lisp :tangle yes
  799. (use-package evil-matchit
  800. :config
  801. (global-evil-matchit-mode 1))
  802. #+END_SRC
  803. * Project Management
  804. ** Ag
  805. Emacs interface for ag
  806. #+BEGIN_SRC emacs-lisp :tangle yes
  807. (use-package ag)
  808. #+END_SRC
  809. ** Magit
  810. Magic git interface from within emacs
  811. #+BEGIN_SRC emacs-lisp :tangle yes
  812. (use-package magit
  813. :config
  814. (setq magit-bury-buffer-function
  815. (lambda (con)
  816. (kill-buffer)
  817. (delete-window)))
  818. (global-set-key "\C-x\g" 'magit-status))
  819. #+END_SRC
  820. ** Projectile
  821. Project management
  822. #+BEGIN_SRC emacs-lisp :tangle yes
  823. (use-package projectile
  824. :config
  825. (use-package counsel-projectile
  826. :config
  827. (counsel-projectile-on))
  828. (setq projectile-enable-caching t)
  829. (setq projectile-indexing-method 'alien)
  830. (setq projectile-globally-ignored-file-suffixes '(".dll" ".exe"))
  831. (projectile-global-mode))
  832. #+END_SRC
  833. * Languages
  834. ** Generic Web
  835. #+BEGIN_SRC emacs-lisp :tangle yes
  836. (use-package web-mode
  837. :config
  838. (add-to-list 'auto-mode-alist '("\\.html\\'" . web-mode))
  839. (add-to-list 'auto-mode-alist '("\\.php\\'" . web-mode))
  840. (add-to-list 'auto-mode-alist '("\\.js\\'" . web-mode))
  841. (setq web-mode-enable-auto-closing t)
  842. (setq web-mode-enable-auto-opening t)
  843. (setq web-mode-enable-auto-indentation t))
  844. (use-package json-mode)
  845. #+END_SRC
  846. #+BEGIN_SRC emacs-lisp :tangle yes
  847. (use-package company-restclient
  848. :after company
  849. :config
  850. (add-to-list 'company-backends 'company-restclient))
  851. #+END_SRC
  852. ** Javascript
  853. #+BEGIN_SRC emacs-lisp :tangle yes
  854. (use-package company-tern
  855. :after company
  856. :config
  857. (add-to-list 'company-backends 'company-tern)
  858. (add-hook 'web-mode-hook 'tern-mode))
  859. #+END_SRC
  860. ** Lisp Family
  861. #+BEGIN_SRC emacs-lisp :tangle yes
  862. (use-package parinfer
  863. :bind
  864. (("C-," . parinfer-toggle-mode))
  865. :init
  866. (setq
  867. parinfer-extensions '(defaults pretty-parens evil smart-tab smart-yank)
  868. parinfer-lighters '(" Φi" . " Φp"))
  869. (add-hook 'clojure-mode-hook #'parinfer-mode)
  870. (add-hook 'emacs-lisp-mode-hook #'parinfer-mode)
  871. (add-hook 'common-lisp-mode-hook #'parinfer-mode)
  872. (add-hook 'scheme-mode-hook #'parinfer-mode)
  873. (add-hook 'lisp-mode-hook #'parinfer-mode))
  874. #+END_SRC
  875. ** Racket
  876. #+BEGIN_SRC emacs-lisp :tangle yes
  877. (use-package racket-mode)
  878. #+END_SRC
  879. ** Latex
  880. #+BEGIN_SRC emacs-lisp :tangle yes
  881. (use-package latex-preview-pane
  882. :ensure f)
  883. #+END_SRC
  884. ** C/C++
  885. #+BEGIN_SRC emacs-lisp :tangle yes
  886. (setq gdb-many-windows t
  887. gdb-show-main t
  888. company-clang-insert-arguments nil)
  889. (use-package company-irony
  890. :after company
  891. :config
  892. (add-hook 'c++-mode-hook 'irony-mode)
  893. (add-hook 'c-mode-hook 'irony-mode)
  894. (eval-after-load 'company
  895. '(add-to-list 'company-backends 'company-irony)))
  896. #+END_SRC
  897. ** C#
  898. #+BEGIN_SRC emacs-lisp :tangle yes
  899. (use-package omnisharp
  900. :after company
  901. :config
  902. (setq omnisharp-server-executable-path "C:/emacs/omnisharp/Omnisharp.exe")
  903. (add-hook 'csharp-mode-hook 'omnisharp-mode)
  904. (add-to-list 'company-backends 'company-omnisharp))
  905. #+END_SRC
  906. ** Python
  907. #+BEGIN_SRC emacs-lisp :tangle yes
  908. (use-package company-jedi
  909. :after company
  910. :config
  911. (add-to-list 'company-backends 'company-jedi))
  912. #+END_SRC
  913. ** Shell Scripts
  914. #+BEGIN_SRC emacs-lisp :tangle yes
  915. (use-package company-shell
  916. :after company
  917. :config
  918. (add-to-list 'company-backends '(company-shell company-shell-env)))
  919. #+END_SRC
  920. * Utility
  921. ** Ranger
  922. #+BEGIN_SRC emacs-lisp :tangle yes
  923. (use-package ranger
  924. :config
  925. (setq ranger-cleanup-on-disable t)
  926. (ranger-override-dired-mode t))
  927. #+END_SRC
  928. ** Iedit
  929. Edit all instances of a string
  930. #+BEGIN_SRC emacs-lisp :tangle yes
  931. (use-package iedit
  932. :config
  933. (setq iedit-toggle-key-default nil))
  934. #+END_SRC
  935. ** Restclient
  936. Postman inside of emacs.
  937. #+BEGIN_SRC emacs-lisp :tangle yes
  938. (use-package restclient)
  939. #+END_SRC
  940. ** Rainbow Mode
  941. Shows hex colors inline.
  942. #+BEGIN_SRC emacs-lisp :tangle yes
  943. (use-package rainbow-mode)
  944. #+END_SRC
  945. ** Help Fns+
  946. #+BEGIN_SRC emacs-lisp :tangle yes
  947. (use-package help-fns+)
  948. #+END_SRC
  949. ** Org Jira
  950. #+BEGIN_SRC emacs-lisp :tangle yes
  951. (use-package org-jira
  952. :config
  953. (setq jiralib-url "https://indigoca.atlassian.net"))
  954. #+END_SRC
  955. ** Delight
  956. #+BEGIN_SRC emacs-lisp :tangle yes
  957. (use-package delight
  958. :config
  959. (delight '((emacs-lisp-mode "ξ" :major)
  960. (lisp-interaction-mode "λ" :major)
  961. (python-mode "π" :major)
  962. (org-mode "Ø" :major)
  963. (company-mode " C" company)
  964. (ivy-mode " ι" ivy)
  965. (projectile-mode " ρ" projectile)
  966. (eldoc-mode " ε" eldoc)
  967. (flycheck-mode " ƒ" flycheck)
  968. (undo-tree-mode "" undo-tree)
  969. (auto-revert-mode "" autorevert))))
  970. #+END_SRC
  971. * Completion
  972. ** Ivy & Counsel
  973. #+BEGIN_SRC emacs-lisp :tangle yes
  974. (use-package ivy
  975. :demand
  976. :bind (("M-x" . counsel-M-x)
  977. ("C-x C-f" . counsel-find-file)
  978. :map ivy-minibuffer-map
  979. ("TAB" . ivy-next-line)
  980. ("RET" . ivy-alt-done))
  981. :init
  982. (use-package smex)
  983. (use-package counsel)
  984. :config
  985. (setq ivy-re-builders-alist
  986. '((t . ivy--regex-ignore-order)))
  987. (setq ivy-wrap t)
  988. (ivy-mode 1)
  989. (eval-after-load "hydra" (use-package ivy-hydra)))
  990. #+END_SRC
  991. ** Swiper
  992. #+BEGIN_SRC emacs-lisp :tangle yes
  993. (use-package swiper
  994. :bind (("C-s" . swiper)))
  995. #+END_SRC
  996. ** Company
  997. Autocomplete engine
  998. #+BEGIN_SRC emacs-lisp :tangle yes
  999. (use-package company
  1000. :bind (:map company-active-map
  1001. ("C-n" . company-select-next)
  1002. ("C-p" . company-select-previous))
  1003. :init
  1004. (global-company-mode)
  1005. :config
  1006. (setq company-idle-delay 0) ; Delay to complete
  1007. (setq company-minimum-prefix-length 1)
  1008. (setq company-selection-wrap-around t) ; Loops around suggestions
  1009. (if (display-graphic-p)
  1010. (define-key company-active-map [tab] 'company-select-next)
  1011. (define-key company-active-map (kbd "C-i") 'company-select-next))
  1012. #+END_SRC
  1013. #+BEGIN_SRC emacs-lisp :tangle yes
  1014. (ignore-errors
  1015. (require 'color)
  1016. (let ((bg (face-attribute 'default :background)))
  1017. (custom-set-faces
  1018. `(company-tooltip ((t (:inherit default :background ,(color-lighten-name bg 2)))))
  1019. `(company-scrollbar-bg ((t (:background ,(color-lighten-name bg 10)))))
  1020. `(company-scrollbar-fg ((t (:background ,(color-lighten-name bg 5)))))
  1021. `(company-tooltip-selection ((t (:inherit font-lock-function-name-face))))
  1022. `(company-tooltip-common ((t (:inherit font-lock-constant-face))))))))
  1023. #+END_SRC
  1024. ** Flycheck Linting
  1025. On the fly syntax checking
  1026. #+BEGIN_SRC emacs-lisp :tangle yes
  1027. (use-package flycheck
  1028. :config
  1029. (global-flycheck-mode)
  1030. (with-eval-after-load 'flycheck
  1031. (setq-default flycheck-disabled-checkers '(emacs-lisp-checkdoc))))
  1032. #+END_SRC
  1033. * Misc
  1034. ** Email
  1035. #+BEGIN_SRC emacs-lisp :tangle yes
  1036. (when (require 'mu4e nil 'noerror)
  1037. (setq mu4e-msg2pdf "/usr/bin/msg2pdf")
  1038. (setq
  1039. ;; set mu4e as default mail client
  1040. mail-user-agent 'mu4e-user-agent
  1041. ;; root mail directory - can't be switched
  1042. ;; with context, can only be set once
  1043. mu4e-maildir "~/.mail"
  1044. mu4e-attachments-dir "~/Downloads/Attachments"
  1045. ;; update command
  1046. mu4e-get-mail-command "mbsync -q -a"
  1047. ;; update database every seven minutes
  1048. mu4e-update-interval (* 60 7)
  1049. ;; use smtpmail (bundled with emacs) for sending
  1050. message-send-mail-function 'smtpmail-send-it
  1051. ;; optionally log smtp output to a buffer
  1052. smtpmail-debug-info t
  1053. ;; close sent message buffers
  1054. message-kill-buffer-on-exit t
  1055. ;; customize list columns
  1056. mu4e-headers-fields '((:flags . 4)
  1057. (:from . 20)
  1058. (:human-date . 10)
  1059. (:subject))
  1060. ;; for mbsync
  1061. mu4e-change-filenames-when-moving t
  1062. ;; pick first context automatically on launch
  1063. mu4e-context-policy 'pick-first
  1064. ;; use current context for new mail
  1065. mu4e-compose-context-policy nil
  1066. mu4e-confirm-quit nil)
  1067. (global-set-key (kbd "<f12>") 'mu4e)
  1068. (global-set-key (kbd "<C-f12>") 'mu4e-update-mail-and-index)
  1069. (setq mu4e-contexts
  1070. `(,(make-mu4e-context
  1071. :name "gmail"
  1072. :match-func (lambda(msg)
  1073. (when msg
  1074. (mu4e-message-contact-field-matches msg :to "@gmail.com")))
  1075. :vars '(
  1076. ;; local directories, relative to mail root
  1077. (mu4e-sent-folder . "/gmail/[Gmail]/.Sent Mail")
  1078. (mu4e-drafts-folder . "/gmail/[Gmail]/.Drafts")
  1079. (mu4e-trash-folder . "/gmail/[Gmail]/.Trash")
  1080. (mu4e-refile-folder . "/gmail/[Gmail]/.All Mail")
  1081. ;; account details
  1082. (user-mail-address . "joshuafwolfe@gmail.com")
  1083. (user-full-name . "Josh Wolfe")
  1084. (mu4e-user-mail-address-list . ( "@gmail.com" ))
  1085. ;; gmail saves every outgoing message automatically
  1086. (mu4e-sent-messages-behavior . delete)
  1087. (mu4e-maildir-shortcuts . (("/gmail/INBOX" . ?j)
  1088. ("/gmail/[Gmail]/.All Mail" . ?a)
  1089. ("/gmail/[Gmail]/.Trash" . ?t)
  1090. ("/gmail/[Gmail]/.Drafts" . ?d)))
  1091. ;; outbound mail server
  1092. (smtpmail-smtp-server . "smtp.gmail.com")
  1093. ;; outbound mail port
  1094. (smtpmail-smtp-service . 465)
  1095. ;; use ssl
  1096. (smtpmail-stream-type . ssl)
  1097. ;; the All Mail folder has a copy of every other folder's contents,
  1098. ;; and duplicates search results, which is confusing
  1099. (mue4e-headers-skip-duplicates . t)))))
  1100. (use-package evil-mu4e))
  1101. #+END_SRC
  1102. ** IRC
  1103. #+BEGIN_SRC emacs-lisp :tangle yes
  1104. (use-package erc
  1105. :ensure nil
  1106. :config
  1107. (add-hook 'window-configuration-change-hook
  1108. '(lambda ()
  1109. (setq erc-fill-column (- (window-width) 2))))
  1110. (add-hook 'erc-mode-hook
  1111. '(lambda ()
  1112. (setq-local scroll-margin 1)))
  1113. (setq erc-rename-buffers t
  1114. erc-interpret-mirc-color t
  1115. erc-lurker-hide-list '("JOIN" "PART" "QUIT")
  1116. erc-autojoin-channels-alist '(("freenode.net" "#emacs")))
  1117. (defun wolfe/irc ()
  1118. (interactive)
  1119. (let* ((tupple (wolfe/get-user-pass "~/.authinfo.gpg"))
  1120. (user (car tupple))
  1121. (pass (cadr tupple)))
  1122. (erc
  1123. :server "irc.freenode.net"
  1124. :port 6667
  1125. :nick user
  1126. :password pass))))
  1127. #+END_SRC
  1128. ** Meme
  1129. Meme creator from within emacs... what more is there to say?
  1130. #+BEGIN_SRC emacs-lisp :tangle yes
  1131. (use-package meme
  1132. :ensure nil
  1133. :commands (meme meme-file))
  1134. #+END_SRC
  1135. * Backups
  1136. Stores all backups and temp files in =~/.bak.emacs/=
  1137. #+BEGIN_SRC emacs-lisp :tangle yes
  1138. (setq backup-by-copying t) ; Stop shinanigans with links
  1139. (setq backup-directory-alist '((".*" . "~/.bak.emacs/backup/")))
  1140. ;; Creates directory if it doesn't already exist
  1141. (if (eq nil (file-exists-p "~/.bak.emacs/"))
  1142. (make-directory "~/.bak.emacs/"))
  1143. ;; Creates auto directory if it doesn't already exist
  1144. (if (eq nil (file-exists-p "~/.bak.emacs/auto"))
  1145. (make-directory "~/.bak.emacs/auto"))
  1146. ;; backup in one place. flat, no tree structure
  1147. (setq auto-save-file-name-transforms '((".*" "~/.bak.emacs/auto/" t)))
  1148. #+END_SRC
  1149. * Testing
  1150. ** Org Project
  1151. #+BEGIN_SRC emacs-lisp :tangle yes
  1152. (cond ((file-exists-p "~/Projects/org-project/")
  1153. (load-file "~/Projects/org-project/org-project.el")
  1154. (setq org-project-use-ag t))
  1155. ((file-exists-p "C:/dev/SideProjects/org-project/")
  1156. (load-file "C:/dev/SideProjects/org-project/org-project.el")
  1157. (setq org-project-use-ag t)))
  1158. #+END_SRC
  1159. ** Extract Dates
  1160. #+BEGIN_SRC emacs-lisp :tangle yes
  1161. (defun wolfe/extract-dates (file-path)
  1162. "Parse through a file for a list of all the comments"
  1163. (let (already-open
  1164. buf
  1165. start
  1166. (comments '()))
  1167. (setq already-open (find-buffer-visiting file-path)
  1168. buf (find-file-noselect file-path))
  1169. (with-current-buffer buf
  1170. (goto-char (point-min))
  1171. (while (setq start (text-property-any
  1172. (point) (point-max)
  1173. 'face 'org-date))
  1174. (goto-char start)
  1175. (goto-char (next-single-char-property-change (point) 'face))
  1176. (let ((item (string-trim (buffer-substring-no-properties start (point)))))
  1177. (setq comments (cons item comments)))))
  1178. (unless already-open (kill-buffer buf))
  1179. (reverse comments)))
  1180. #+END_SRC