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

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