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

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