My personal dotfiles
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

README.org 58KB

3 år sedan
3 år sedan
3 år sedan
3 år sedan
3 år sedan
3 år sedan
3 år sedan
3 år sedan
3 år sedan
3 år sedan
3 år sedan
2 år sedan
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958
  1. * About
  2. #+TITLE: Wolfe's Literate Emacs Config
  3. #+AUTHOR: Josh Wolfe
  4. #+HTML_HEAD: <link rel="stylesheet" type="text/css" href="https://www.pirilampo.org/styles/readtheorg/css/htmlize.css"/>
  5. #+HTML_HEAD: <link rel="stylesheet" type="text/css" href="readtheorg.css"/>
  6. #+HTML_HEAD: <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
  7. #+HTML_HEAD: <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
  8. #+HTML_HEAD: <script type="text/javascript" src="https://www.pirilampo.org/styles/lib/js/jquery.stickytableheaders.min.js"></script>
  9. #+HTML_HEAD: <script type="text/javascript" src="https://www.pirilampo.org/styles/readtheorg/js/readtheorg.js"></script>
  10. #+LATEX_HEADER: \usepackage[margin=0.7in]{geometry}
  11. #+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>
  12. This literate config is best read [[http://wolfecub.github.io/dotfiles/][here]] or in emacs.
  13. This page is generated and kept up to date using a combination of
  14. [[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
  15. 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
  16. it runs through emacs to generate the html page (this was mostly stolen
  17. from IvanMalison).
  18. Included in this section is also my export headers. These are responsible
  19. for including the ReadTheOrg theme as well as some metadata and options
  20. like title, author, table of contents etc. If you wish to see the headers
  21. I'm using, [[https://raw.githubusercontent.com/WolfeCub/dotfiles/master/emacs/.emacs.d/README.org][this]] is the raw org file.
  22. Right off the bat we want these libraries but they don't really belong
  23. anywhere else. So here they are.
  24. #+BEGIN_SRC emacs-lisp :tangle yes
  25. (use-package dash)
  26. (use-package s)
  27. #+END_SRC
  28. * Variables
  29. Variables come at the beginning so that they're consistently available.
  30. If you don't care about these *[[Startup][click here to skip over them]]*.
  31. ** Config Name
  32. #+BEGIN_SRC emacs-lisp :tangle yes
  33. (defvar wolfe/literate-config-name "README.org"
  34. "The name of my literate config")
  35. #+END_SRC
  36. ** Init File
  37. #+BEGIN_SRC emacs-lisp :tangle yes
  38. (defvar wolfe/init-file (concat user-emacs-directory wolfe/literate-config-name)
  39. "The path to my literate config file")
  40. #+END_SRC
  41. ** Linux Check
  42. #+BEGIN_SRC emacs-lisp :tangle yes
  43. (defvar wolfe/linux? (eq system-type 'gnu/linux)
  44. "Are we on linux?")
  45. #+END_SRC
  46. ** Windows Check
  47. #+BEGIN_SRC emacs-lisp :tangle yes
  48. (defvar wolfe/windows? (eq system-type 'windows-nt)
  49. "Are we on windows?")
  50. #+END_SRC
  51. ** Org Ellipsis
  52. #+BEGIN_SRC emacs-lisp :tangle yes
  53. (defvar wolfe/org-ellipsis "⤵"
  54. "The indicates if an `org-mode' tree can be expanded")
  55. #+END_SRC
  56. ** Project Path
  57. #+BEGIN_SRC emacs-lisp :tangle yes
  58. (defvar wolfe/project-path
  59. (cond
  60. (wolfe/linux? "~/Projects/")
  61. (wolfe/windows? "C:/dev/")
  62. (:else nil))
  63. "Path to my projects directory")
  64. #+END_SRC
  65. ** Dropbox Path
  66. #+BEGIN_SRC emacs-lisp :tangle yes
  67. (defvar wolfe/org-dropbox-path
  68. (cond
  69. (wolfe/linux?
  70. "~/Dropbox/org/")
  71. (wolfe/windows?
  72. (concat "C:\\Users\\" (getenv "USERNAME") "\\Dropbox\\org\\"))
  73. (:else nil))
  74. "Path to my org files inside dropbox")
  75. #+END_SRC
  76. ** Theme Checks
  77. #+BEGIN_SRC emacs-lisp :tangle yes
  78. (defvar wolfe/using-dark t
  79. "Indicates whether we're using my dark theme")
  80. #+END_SRC
  81. #+BEGIN_SRC emacs-lisp :tangle yes
  82. (defvar wolfe/using-light nil
  83. "Indicates whether we're using my light theme")
  84. #+END_SRC
  85. ** Lisp Path Location
  86. #+BEGIN_SRC emacs-lisp :tangle yes
  87. (defvar wolfe/lisp-dir-path "~/.emacs.d/lisp/"
  88. "Path to my custom lisp files")
  89. #+END_SRC
  90. ** Highlight Escapes Modes
  91. #+BEGIN_SRC emacs-lisp :tangle yes
  92. (defvar wolfe/highlight-escapes-mode-list '(python-mode
  93. c-mode
  94. c++-mode
  95. web-mode)
  96. "List of modes to highlight escape characters in")
  97. #+END_SRC
  98. ** IRC Info Path
  99. #+BEGIN_SRC emacs-lisp :tangle yes
  100. (defvar wolfe/irc-info-path "~/.ircinfo.gpg"
  101. "Location of the GPG encrypted file that has my irc login info")
  102. #+END_SRC
  103. * Startup
  104. My graphical settings change depending on whether I'm in terminal
  105. and if a command line flag (=-light=) was specified.
  106. ** WM
  107. Start load emacs window manager config if it exists.
  108. #+BEGIN_SRC emacs-lisp :tangle yes
  109. (when (file-exists-p "~/.exwm.org")
  110. (org-babel-load-file "~/.exwm.org"))
  111. #+END_SRC
  112. ** Theme Setup
  113. This should be run regardless of whether I'm in terminal vs gui or dark vs light.
  114. #+BEGIN_SRC emacs-lisp :tangle yes
  115. (setq custom-theme-directory "~/.emacs.d/themes")
  116. (defun check-and-remove-command-line-arg (argument)
  117. "Checks `command-line-args' for argument and removes it if found returning t or nil"
  118. (if (member argument command-line-args)
  119. (progn
  120. (setq command-line-args (delete argument command-line-args))
  121. t)
  122. nil))
  123. (let ((result (check-and-remove-command-line-arg "-light")))
  124. (setq wolfe/using-light result)
  125. (setq wolfe/using-dark (not result)))
  126. #+END_SRC
  127. ** Dark
  128. Configuration for my dark theme =base16 default dark= which is loaded by default.
  129. #+BEGIN_SRC emacs-lisp :tangle yes
  130. (defun wolfe/dark-setup ()
  131. (setq evil-emacs-state-cursor `(,"#81a2be" box)
  132. evil-insert-state-cursor `(,"#81a2be" bar)
  133. evil-motion-state-cursor `(,"#85678f" box)
  134. evil-normal-state-cursor `(,"#f8f8f8" box)
  135. evil-replace-state-cursor `(,"#a54242" (hbar . 10))
  136. evil-visual-state-cursor `(,"#ff6000" box))
  137. (load-theme 'my t)
  138. (set-face-attribute 'fringe nil :background nil)
  139. (eval-after-load 'ivy (lambda () (setq ivy-switch-buffer-faces-alist '((dired-mode . ivy-subdir)))))
  140. (custom-set-faces
  141. '(org-done ((t (:box (:line-width 1) :weight bold))))
  142. '(org-level-1 ((t (:inherit outline-1 :height 1.3))))
  143. '(org-todo ((t (:box (:line-width 1) :weight bold))))))
  144. #+END_SRC
  145. ** Light
  146. Configuration for my light theme =leuven=. This is only loaded when the =-light= flag is
  147. specified on the command line.
  148. #+BEGIN_SRC emacs-lisp :tangle yes
  149. (defun wolfe/light-setup ()
  150. (use-package leuven-theme
  151. :config
  152. (custom-set-faces
  153. '(ivy-subdir ((t (:background "gray88")))))
  154. (load-theme 'leuven t)))
  155. #+END_SRC
  156. ** Display check
  157. This checks which setup we're in and calls the appropriate function above.
  158. #+BEGIN_SRC emacs-lisp :tangle yes
  159. (defun hook-if-daemonp (func)
  160. (if (daemonp)
  161. (add-hook 'after-make-frame-functions
  162. (lambda (frame)
  163. (with-selected-frame frame
  164. (funcall func))))
  165. (funcall func)))
  166. #+END_SRC
  167. #+BEGIN_SRC emacs-lisp :tangle yes
  168. (if wolfe/using-light
  169. (wolfe/light-setup)
  170. (wolfe/dark-setup))
  171. #+END_SRC
  172. * General Settings
  173. Basic settings I can't really live without.
  174. ** Load Path
  175. Recursively add =~/.emacs.d/lisp/= to my load path.
  176. #+BEGIN_SRC emacs-lisp :tangle yes
  177. (add-to-list 'load-path wolfe/lisp-dir-path)
  178. (let ((default-directory wolfe/lisp-dir-path))
  179. (normal-top-level-add-subdirs-to-load-path))
  180. #+END_SRC
  181. ** Splash and Startup
  182. This makes sure I'm presented with a nice blank =*scratch*=
  183. buffer when emacs starts up.
  184. #+BEGIN_SRC emacs-lisp :tangle yes
  185. (setq inhibit-splash-screen t
  186. inhibit-startup-message t
  187. initial-scratch-message "") ; No scratch text
  188. (defun display-startup-echo-area-message ()
  189. (message "Welcome to the church of GNU/Emacs"))
  190. #+END_SRC
  191. ** Graphics
  192. *** Bars
  193. I don't really want to have to look at menu bars that I'm not going to use
  194. #+BEGIN_SRC emacs-lisp :tangle yes
  195. (hook-if-daemonp
  196. (lambda ()
  197. (tool-bar-mode -1) ; No toolbar
  198. (scroll-bar-mode -1) ; Hide scrollbars
  199. (menu-bar-mode -1))) ; No menubar
  200. #+END_SRC
  201. *** Fonts
  202. I used =Inconsolata-dz= for quite a long time but have recently been
  203. using =Fira Mono=.
  204. #+BEGIN_SRC emacs-lisp :tangle yes
  205. (let* ((font "Fira Mono")
  206. (size 15)
  207. (font-size (format "%s-%s" font size)))
  208. (setq default-frame-alist `((font . ,font-size)))
  209. (set-face-attribute 'default t :font font-size))
  210. #+END_SRC
  211. Force =Fira Code= for all =UTF-8= symbols.
  212. #+BEGIN_SRC emacs-lisp :tangle yes
  213. (hook-if-daemonp
  214. (lambda ()
  215. (when (display-graphic-p)
  216. (let ((utf8-font "Fira Code"))
  217. (set-fontset-font "fontset-startup" '(#x000000 . #x3FFFFF) utf8-font)
  218. (set-fontset-font "fontset-default" '(#x000000 . #x3FFFFF) utf8-font)
  219. (set-fontset-font "fontset-standard" '(#x000000 . #x3FFFFF) utf8-font)))))
  220. #+END_SRC
  221. Make sure that UTF-8 is used everywhere.
  222. #+BEGIN_SRC emacs-lisp :tangle yes
  223. (set-terminal-coding-system 'utf-8)
  224. (set-keyboard-coding-system 'utf-8)
  225. (set-language-environment 'utf-8)
  226. (set-selection-coding-system 'utf-8)
  227. (setq locale-coding-system 'utf-8)
  228. (prefer-coding-system 'utf-8)
  229. (set-input-method nil)
  230. #+END_SRC
  231. *** Pretty Symbols
  232. In emacs =24.4= we got =prettify-symbols-mode= which replaces things like =lambda=
  233. with =λ=. This can help make the code easier to read. The =inhibit-compacting-font-caches=
  234. stops garbage collect from trying to handle font caches which makes things a lot faster
  235. and saves us ram.
  236. #+BEGIN_SRC emacs-lisp :tangle yes
  237. (setq prettify-symbols-unprettify-at-point 'right-edge)
  238. (setq inhibit-compacting-font-caches t)
  239. #+END_SRC
  240. **** Global
  241. These symbols are the basics that I would like enabled for all =prog-mode= modes.
  242. This function can be called by the mode specific hook to push the defaults.
  243. #+BEGIN_SRC emacs-lisp :tangle yes
  244. (defun wolfe/pretty-symbol-push-default ()
  245. (push '("!=" . ?≠) prettify-symbols-alist)
  246. (push '("<=" . ?≤) prettify-symbols-alist)
  247. (push '(">=" . ?≥) prettify-symbols-alist)
  248. (push '("=>" . ?⇒) prettify-symbols-alist))
  249. #+END_SRC
  250. Now apply the default to some modes I don't want anything special in.
  251. #+BEGIN_SRC emacs-lisp :tangle yes
  252. (mapc
  253. (lambda (hook)
  254. (add-hook 'hook (lambda () (wolfe/pretty-symbol-push-default))))
  255. '(c-mode))
  256. #+END_SRC
  257. **** Python
  258. #+BEGIN_SRC emacs-lisp :tangle yes
  259. (add-hook 'python-mode-hook
  260. (lambda ()
  261. (wolfe/pretty-symbol-push-default)
  262. (push '("def" . ?ƒ) prettify-symbols-alist)
  263. (push '("sum" . ?Σ) prettify-symbols-alist)
  264. (push '("**2" . ?²) prettify-symbols-alist)
  265. (push '("**3" . ?³) prettify-symbols-alist)
  266. (push '("None" . ?∅) prettify-symbols-alist)
  267. (push '("in" . ?∈) prettify-symbols-alist)
  268. (push '("not in" . ?∉) prettify-symbols-alist)
  269. (push '("return" . ?➡) prettify-symbols-alist)
  270. (prettify-symbols-mode t)))
  271. #+END_SRC
  272. **** Lisp
  273. #+BEGIN_SRC emacs-lisp :tangle yes
  274. (add-hook 'emacs-lisp-mode-hook
  275. (lambda ()
  276. (wolfe/pretty-symbol-push-default)
  277. (push '("defun" . ?ƒ) prettify-symbols-alist)
  278. (push '("defmacro" . ?μ) prettify-symbols-alist)
  279. (push '("defvar" . ?ν) prettify-symbols-alist)
  280. (prettify-symbols-mode t)))
  281. #+END_SRC
  282. **** Go
  283. #+BEGIN_SRC emacs-lisp :tangle yes
  284. (add-hook 'go-mode-hook
  285. (lambda ()
  286. (wolfe/pretty-symbol-push-default)
  287. (push '("func" . ?ƒ) prettify-symbols-alist)
  288. (push '(":=" . ?←) prettify-symbols-alist)
  289. (prettify-symbols-mode t)))
  290. #+END_SRC
  291. *** Column Marker
  292. #+BEGIN_SRC emacs-lisp :tangle yes
  293. (use-package column-marker
  294. :ensure nil
  295. :config
  296. (add-hook 'prog-mode-hook (lambda () (interactive) (column-marker-1 81)))
  297. (custom-set-faces
  298. '(column-marker-1 ((t (:background "dim gray"))))))
  299. #+END_SRC
  300. *** Highlight Escape Characters
  301. This defines 4 new faces and the appropriate =regexps= that highlight
  302. them and maps them to all the modes in [[Highlight Escapes Modes][=wolfe/highlight-escapes-mode-list=]].
  303. #+BEGIN_SRC emacs-lisp :tangle yes
  304. (defface wolfe/backslash-escape-backslash-face
  305. '((t :inherit font-lock-regexp-grouping-backslash))
  306. "Face for the back-slash component of a back-slash escape."
  307. :group 'font-lock-faces)
  308. (defface wolfe/backslash-escape-char-face
  309. '((t :inherit font-lock-regexp-grouping-construct))
  310. "Face for the charcter component of a back-slash escape."
  311. :group 'font-lock-faces)
  312. (defface wolfe/format-code-format-face
  313. '((t :inherit font-lock-regexp-grouping-backslash))
  314. "Face for the % component of a printf format code."
  315. :group 'font-lock-faces)
  316. (defface wolfe/format-code-directive-face
  317. '((t :inherit font-lock-regexp-grouping-construct))
  318. "Face for the directive component of a printf format code."
  319. :group 'font-lock-faces)
  320. (mapc
  321. (lambda (mode)
  322. (font-lock-add-keywords
  323. mode
  324. '(("\\(\\\\\\)." 1 'wolfe/backslash-escape-backslash-face prepend)
  325. ("\\\\\\(.\\)" 1 'wolfe/backslash-escape-char-face prepend)
  326. ("\\(%\\)." 1 'wolfe/format-code-format-face prepend)
  327. ("%\\(.\\)" 1 'wolfe/format-code-directive-face prepend))))
  328. wolfe/highlight-escapes-mode-list)
  329. #+END_SRC
  330. *** Highlight Todo, Fixme & Bug
  331. #+BEGIN_SRC emacs-lisp :tangle yes
  332. (add-hook 'prog-mode-hook
  333. (lambda ()
  334. (font-lock-add-keywords nil
  335. '(("\\<\\(FIXME\\|TODO\\|BUG\\|XXX\\):" 1 font-lock-warning-face t)))))
  336. #+END_SRC
  337. ** Personal Defaults
  338. Nothing to crazy here just the type of behaviour I personally
  339. expect as default.
  340. #+BEGIN_SRC emacs-lisp :tangle yes
  341. (show-paren-mode t) ; Highlights matching parens
  342. (fset 'yes-or-no-p 'y-or-n-p) ; y/n instead of yes/no
  343. (blink-cursor-mode -1) ; No need to flash the cursor
  344. (column-number-mode t) ; Show column in mode-line
  345. (delete-selection-mode 1) ; Replace selection on insert
  346. (setq-default truncate-lines t ; Don't wrap
  347. indent-tabs-mode nil)
  348. (setq vc-follow-symlinks t ; Always follow symlinks
  349. tags-revert-without-query t ; Don't ask to reload TAGS file
  350. echo-keystrokes 0.5
  351. custom-file "~/.emacs.d/custom.el" ; Set custom file and don't load it
  352. source-directory "~/Projects/emacs/")
  353. #+END_SRC
  354. ** Misc
  355. *** Vim Scrolloff
  356. This makes scrolling gradual rather than by half page. I find that the
  357. half page scroll really makes me lose where I am in the file so here
  358. I make sure to scroll one line at a time. In addition I want to keep
  359. what I'm working on centered so I start scrolling when the cursor is
  360. 10 lines away from the margin.
  361. This behaviour in general emulates the =scrolloff= option in vim.
  362. #+BEGIN_SRC emacs-lisp :tangle yes
  363. (setq scroll-margin 10
  364. scroll-step 1
  365. scroll-conservatively 10000
  366. scroll-preserve-screen-position 1)
  367. #+END_SRC
  368. *** Shell Tweaks
  369. #+BEGIN_SRC emacs-lisp :tangle yes
  370. (setq explicit-shell-file-name
  371. (if (file-readable-p "/usr/bin/zsh") "/usr/bin/zsh" "/bin/bash"))
  372. (when (eq system-type 'windows-nt)
  373. (setq explicit-shell-file-name "cmdproxy.exe"))
  374. #+END_SRC
  375. *** Spell Check
  376. #+BEGIN_SRC emacs-lisp :tangle yes
  377. (when wolfe/windows?
  378. (setq ispell-program-name "c:/emacs/hunspell/bin/hunspell.exe"))
  379. #+END_SRC
  380. *** Help & Compilation
  381. Keep the output scrolling as it compiles.
  382. #+BEGIN_SRC emacs-lisp :tangle yes
  383. (require 'compile)
  384. (setq compilation-scroll-output t)
  385. #+END_SRC
  386. =q= should really quit the buffer not just stick it at the bottom.
  387. #+BEGIN_SRC emacs-lisp :tangle yes
  388. (dolist (m (list help-mode-map compilation-mode-map))
  389. (bind-key (kbd "q") (lambda () (interactive) (quit-window t)) m))
  390. #+END_SRC
  391. ** Mode Line
  392. If we're in GUI emacs we make sure to use =powerline= otherwise we use
  393. a custom mode line configuration.
  394. #+BEGIN_SRC emacs-lisp :tangle yes
  395. (if (or (display-graphic-p) (daemonp))
  396. (use-package doom-modeline
  397. :init
  398. (use-package anzu)
  399. (use-package evil-anzu)
  400. (setq evil-normal-state-tag ""
  401. evil-emacs-state-tag ""
  402. evil-insert-state-tag ""
  403. evil-motion-state-tag ""
  404. evil-visual-state-tag ""
  405. evil-operator-state-tag "")
  406. :config
  407. (setq doom-modeline-bar-width 3)
  408. (custom-set-faces
  409. `(doom-modeline-bar ((t (:inherit default :background ,(face-foreground 'match))))))
  410. :defer t
  411. :hook (after-init . doom-modeline-init))
  412. (setq-default
  413. mode-line-format
  414. (list
  415. " "
  416. ;; is this buffer read-only?
  417. '(:eval (when buffer-read-only
  418. (propertize "RO"
  419. 'face 'font-lock-type-face
  420. 'help-echo "Buffer is read-only")))
  421. ;; was this buffer modified since the last save?
  422. '(:eval (when (buffer-modified-p)
  423. (propertize "M"
  424. 'face 'font-lock-warning-face
  425. 'help-echo "Buffer has been modified")))
  426. " "
  427. ;; the buffer name; the file name as a tool tip
  428. '(:eval (propertize "%b " 'face 'font-lock-keyword-face
  429. 'help-echo (buffer-file-name)))
  430. ;; the current major mode for the buffer.
  431. "["
  432. '(:eval (propertize (format-mode-line mode-name) 'face '(:family "Arial")
  433. 'help-echo buffer-file-coding-system))
  434. '(:eval (propertize (format-mode-line minor-mode-alist)
  435. 'face '(:family "Arial")))
  436. "] "
  437. ;; line and column
  438. "(" ;; '%02' to set to 2 chars at least; prevents flickering
  439. (propertize "%02l" 'face 'font-lock-type-face) ","
  440. (propertize "%02c" 'face 'font-lock-type-face)
  441. ") "
  442. ;; relative position, size of file
  443. "["
  444. (propertize "%p" 'face 'font-lock-constant-face) ;; % above top
  445. "/"
  446. (propertize "%I" 'face 'font-lock-constant-face) ;; size
  447. "] "
  448. ;; add the time, with the date and the emacs uptime in the tooltip
  449. '(:eval (propertize (format-time-string "%H:%M")
  450. 'help-echo
  451. (concat (format-time-string "%c; ")
  452. (emacs-uptime "Uptime:%hh")))))))
  453. #+END_SRC
  454. ** Line Numbers
  455. Vim-like relative line numbering. If we're on the latest versions of emacs
  456. (i.e. =26.0.50= or higher) then we should use the native line numbering
  457. otherwise we fall back to =nlinum-relative=.
  458. #+BEGIN_SRC emacs-lisp :tangle yes
  459. (if (version< "26.0.50" emacs-version)
  460. (progn
  461. (add-hook 'prog-mode-hook (lambda ()
  462. (display-line-numbers-mode t)
  463. (setq display-line-numbers 'relative))))
  464. (progn
  465. (use-package nlinum-relative
  466. :config
  467. (nlinum-relative-setup-evil)
  468. (setq nlinum-relative-redisplay-delay 0.25)
  469. (setq nlinum-relative-current-symbol "")
  470. (add-hook 'prog-mode-hook 'nlinum-relative-mode))))
  471. #+END_SRC
  472. * Functions
  473. ** Face Under Point
  474. Returns the font lock face that's under the cursor.
  475. #+BEGIN_SRC emacs-lisp :tangle yes
  476. (defun what-face (pos)
  477. (interactive "d")
  478. (let ((face (or (get-char-property (point) 'read-face-name)
  479. (get-char-property (point) 'face))))
  480. (if face (message "Face: %s" face) (message "No face at %d" pos))))
  481. #+END_SRC
  482. ** Compile Project
  483. Compiles the project without a prompt.
  484. #+BEGIN_SRC emacs-lisp :tangle yes
  485. (defun wolfe/compile-no-prompt ()
  486. (interactive)
  487. (let ((compilation-read-command nil))
  488. (compile (eval compile-command))))
  489. #+END_SRC
  490. ** Compile Dotfiles
  491. Compiles all el files in the =~/.emacs.d= directory.
  492. #+BEGIN_SRC emacs-lisp :tangle yes
  493. (defun wolfe/compile-dot-emacs ()
  494. "Byte-compile dotfiles."
  495. (interactive)
  496. (byte-recompile-directory user-emacs-directory 0))
  497. #+END_SRC
  498. #+BEGIN_SRC emacs-lisp :tangle yes
  499. (defun wolfe/clear-all-elc ()
  500. (interactive)
  501. (shell-command "find ~/.emacs.d/ -name \"*.elc\" -type f -delete"))
  502. #+END_SRC
  503. #+BEGIN_SRC emacs-lisp :tangle yes
  504. (defun wolfe/remove-elc-on-save ()
  505. "If you're saving an emacs-lisp file, likely the .elc is no longer valid."
  506. (add-hook 'after-save-hook
  507. (lambda ()
  508. (if (file-exists-p (concat buffer-file-name "c"))
  509. (delete-file (concat buffer-file-name "c"))))
  510. nil t))
  511. (add-hook 'emacs-lisp-mode-hook 'wolfe/remove-elc-on-save)
  512. #+END_SRC
  513. ** Find Tags
  514. Looks up tag under point.
  515. #+BEGIN_SRC emacs-lisp :tangle yes
  516. (defun wolfe/find-tag ()
  517. "Jump to the tag at point without prompting"
  518. (interactive)
  519. (find-tag (find-tag-default)))
  520. #+END_SRC
  521. #+BEGIN_SRC emacs-lisp :tangle yes
  522. (defun wolfe/create-tags ()
  523. "Create the tags table"
  524. (interactive)
  525. (save-window-excursion (shell-command "etags -R -o ETAGS *")))
  526. #+END_SRC
  527. #+BEGIN_SRC emacs-lisp :tangle yes
  528. (defadvice xref-find-definitions (around refresh-etags activate)
  529. "Rerun etags and reload tags if tag not found and redo find-tag.
  530. If buffer is modified, ask about save before running etags."
  531. (condition-case err
  532. ad-do-it
  533. (error (and (buffer-modified-p) (not (ding))
  534. (save-buffer))
  535. (save-window-excursion (shell-command "etags -R *"))
  536. ad-do-it)))
  537. #+END_SRC
  538. ** Terminal Suspend
  539. Fixes =C-z= in terminal.
  540. #+BEGIN_SRC emacs-lisp :tangle yes
  541. (defun wolfe/controlz ()
  542. (interactive)
  543. (when (eq (display-graphic-p) nil)
  544. (suspend-frame)))
  545. #+END_SRC
  546. ** Dropbox
  547. Utility functions for finding Dropbox directories/files.
  548. #+BEGIN_SRC emacs-lisp :tangle yes
  549. (defun wolfe/org-open (name)
  550. "Opens the file in the dropbox path"
  551. (interactive)
  552. (evil-buffer-new nil (concat wolfe/org-dropbox-path name ".org")))
  553. #+END_SRC
  554. #+BEGIN_SRC emacs-lisp :tangle yes
  555. (defun wolfe/dropbox-start ()
  556. (interactive)
  557. (if (eq nil (file-exists-p "/virtual/wolfejos/dropbox/.dropbox-dist"))
  558. (call-process-shell-command "(python ~/.emacs.d/dropbox.py start -i&)")
  559. (call-process-shell-command "(python ~/.emacs.d/dropbox.py start&)")))
  560. #+END_SRC
  561. #+BEGIN_SRC emacs-lisp :tangle yes
  562. (defun wolfe/dropbox-stop ()
  563. (interactive)
  564. (call-process-shell-command "python ~/.emacs.d/dropbox.py stop&"))
  565. #+END_SRC
  566. ** Reload
  567. For reloading =init.el= file without restarting.
  568. #+BEGIN_SRC emacs-lisp :tangle yes
  569. (defun wolfe/load-init ()
  570. "Reloads init file"
  571. (interactive)
  572. (load-file "~/.emacs.d/init.el"))
  573. #+END_SRC
  574. ** Narrowing
  575. Better narrowing.
  576. #+BEGIN_SRC emacs-lisp :tangle yes
  577. (defun narrow-or-widen-dwim (p)
  578. "Widen if buffer is narrowed, narrow-dwim otherwise.
  579. Dwim means: region, org-src-block, org-subtree, or
  580. defun, whichever applies first. Narrowing to
  581. org-src-block actually calls `org-edit-src-code'.
  582. With prefix P, don't widen, just narrow even if buffer
  583. is already narrowed."
  584. (interactive "P")
  585. (declare (interactive-only))
  586. (cond ((and (buffer-narrowed-p) (not p)) (widen))
  587. ((region-active-p)
  588. (narrow-to-region (region-beginning)
  589. (region-end)))
  590. ((derived-mode-p 'org-mode)
  591. ;; `org-edit-src-code' is not a real narrowing
  592. ;; command. Remove this first conditional if
  593. ;; you don't want it.
  594. (cond ((ignore-errors (org-edit-src-code) t)
  595. (delete-other-windows))
  596. ((ignore-errors (org-narrow-to-block) t))
  597. (t (org-narrow-to-subtree))))
  598. ((derived-mode-p 'latex-mode)
  599. (LaTeX-narrow-to-environment))
  600. (t (narrow-to-defun))))
  601. #+END_SRC
  602. ** Man Replacement
  603. Use the real =man= if I'm on a system that has the binary otherwise
  604. we should just use the emacs =woman=.
  605. #+BEGIN_SRC emacs-lisp :tangle yes
  606. (defun wolfe/man ()
  607. (if (executable-find "man")
  608. (man (word-at-point))
  609. (woman)))
  610. #+END_SRC
  611. ** Hot Expand
  612. Is used in one of my [[Hydra][hydras]] =wolfe/hydra-org-expand=. For inserting org-templates.
  613. #+BEGIN_SRC emacs-lisp :tangle yes
  614. (defun hot-expand (str &optional additional-text)
  615. "Expand org template."
  616. (insert str)
  617. (org-try-structure-completion)
  618. (when additional-text
  619. (insert additional-text)
  620. (forward-line)))
  621. #+END_SRC
  622. ** Projectile If-Else
  623. This allows us to easily call a projectile version of a
  624. function if we're inside of a project otherwise we can just
  625. call the normal version. For example =projectile-ag= vs =ag=.
  626. #+BEGIN_SRC emacs-lisp :tangle yes
  627. (defun wolfe/if-else-projectile (if-function else-function)
  628. "Calls the if-function if inside a project otherwise
  629. it calls the else-function"
  630. (interactive)
  631. (if (projectile-project-p)
  632. (call-interactively if-function)
  633. (call-interactively else-function)))
  634. #+END_SRC
  635. ** Projectile Invalidate From List
  636. Select project from list of projectile projects to invalidate.
  637. #+BEGIN_SRC emacs-lisp :tangle yes
  638. (defun wolfe/projectile-invalidate-list ()
  639. (interactive)
  640. (projectile-invalidate-cache t))
  641. #+END_SRC
  642. ** User Pass Tupple
  643. Uses GPG to decrypt =file= and returns a list of the contents split on spaces.
  644. #+BEGIN_SRC emacs-lisp :tangle yes
  645. (defun wolfe/get-user-pass (file)
  646. (split-string
  647. (car (last (split-string
  648. (shell-command-to-string (concat "gpg --output - --decrypt "
  649. (expand-file-name file)))
  650. "[|\n]" t "[ \n]"))) " "))
  651. #+END_SRC
  652. ** Ag Kill Buffers and Close Window
  653. Kill all the open ag buffers and delete the window I'm in. This is bound
  654. in my [[Ag][=ag config=]] in =ag-mode-map= so it will close the current =ag= window
  655. and all the buffers.
  656. #+BEGIN_SRC emacs-lisp :tangle yes
  657. (defun wolfe/ag-kill-buffers-and-window ()
  658. (interactive)
  659. (ag-kill-buffers)
  660. (delete-window))
  661. #+END_SRC
  662. ** Org Tree Slides Set Transient Map
  663. This function once called will keep a transient map active until =wolfe--enable-transient-map=
  664. is set to nil at which point it will unbind the variable. This is used with [[Org Tree Slide][=org-tree-slide-mode=]]
  665. to add custom bindings regardless of the mode.
  666. #+BEGIN_SRC emacs-lisp :tangle yes
  667. (defun wolfe/org-tree-set-transient-map ()
  668. (interactive)
  669. (if wolfe--enable-transient-map
  670. (let ((map (make-sparse-keymap)))
  671. (define-key map (kbd "<right>") 'org-tree-slide-move-next-tree)
  672. (define-key map (kbd "<left>") 'org-tree-slide-move-previous-tree)
  673. (define-key map (kbd "<up>") 'org-tree-slide-content)
  674. (define-key map (kbd "<down>") 'org-tree-slide-display-header-toggle)
  675. (set-transient-map map nil 'wolfe/org-tree-set-transient-map))
  676. (makeunbound wolfe--enable-transient-map)))
  677. #+END_SRC
  678. ** Eval and Replace
  679. This was stolen from [[https://github.com/bbatsov/prelude][prelude]] emacs. Over there it's called =prelude-eval-and-replace=.
  680. #+BEGIN_SRC emacs-lisp :tangle yes
  681. (defun wolfe/eval-and-replace (beginning end)
  682. "Replace the preceding sexp or region with its value."
  683. (interactive "r")
  684. (if (region-active-p)
  685. (delete-region beginning end)
  686. (backward-kill-sexp))
  687. (condition-case nil
  688. (prin1 (eval (read (current-kill 0)))
  689. (current-buffer))
  690. (error (message "Invalid expression")
  691. (insert (current-kill 0)))))
  692. #+END_SRC
  693. ** Call Function and Update Ex History
  694. #+BEGIN_SRC emacs-lisp :tangle yes
  695. (defun wolfe/call-and-update-ex (fun)
  696. "Calls the function and updates `evil-ex-history' with the result"
  697. (interactive)
  698. (setq evil-ex-history (cons (format "e %s" (funcall fun)) evil-ex-history)))
  699. #+END_SRC
  700. * Org Mode
  701. ** General
  702. Setup some basic quality of life org settings.
  703. #+BEGIN_SRC emacs-lisp :tangle yes
  704. (setq org-pretty-entities t
  705. org-src-fontify-natively t
  706. org-src-tab-acts-natively t
  707. org-src-window-setup 'current-window
  708. org-fontify-whole-heading-line t
  709. org-fontify-done-headline t
  710. org-fontify-quote-and-verse-blocks t
  711. org-highlight-latex-and-related '(latex)
  712. org-log-done 'time
  713. org-enforce-todo-dependencies t
  714. org-agenda-use-time-grid nil
  715. org-agenda-skip-deadline-if-done t
  716. org-agenda-skip-scheduled-if-done t
  717. org-ellipsis wolfe/org-ellipsis)
  718. (defun wolfe/org-tags-compute-width ()
  719. (- (floor (* 0.8 (frame-width)))))
  720. (add-hook 'org-mode-hook
  721. (lambda ()
  722. (setq org-tags-column (wolfe/org-tags-compute-width))
  723. (org-align-all-tags)))
  724. (add-hook 'org-agenda-mode-hook
  725. (lambda ()
  726. (setq org-agenda-tags-column (wolfe/org-tags-compute-width))
  727. (org-agenda-align-tags)))
  728. (defun wolfe/save-org-archive-buffers (orig-fun &rest args)
  729. (save-some-buffers 'no-confirm
  730. (lambda ()
  731. (string-match "_archive\\'" buffer-file-name))))
  732. (advice-add 'org-archive-subtree :after 'wolfe/save-org-archive-buffers)
  733. (org-babel-do-load-languages
  734. 'org-babel-load-languages
  735. '((shell . t)
  736. ( dot . t)))
  737. (global-set-key "\C-cl" 'org-store-link)
  738. ;; ispell ignores SRC blocks
  739. (add-to-list 'ispell-skip-region-alist '("#\\+BEGIN_SRC" . "#\\+END_SRC"))
  740. (add-to-list 'ispell-skip-region-alist '("#\\+BEGIN_LATEX" . "#\\+END_LATEX"))
  741. ;; Refresh images after executing a src block
  742. (add-hook 'org-babel-after-execute-hook
  743. (lambda ()
  744. (when org-inline-image-overlays
  745. (org-redisplay-inline-images))))
  746. (defun wolfe/confirm-babel-evaluate (lang body)
  747. (not (string= lang "dot")))
  748. (setq org-confirm-babel-evaluate 'wolfe/confirm-babel-evaluate)
  749. ;; Open PDFs with zathura
  750. (add-hook 'org-mode-hook
  751. (lambda ()
  752. (setq org-file-apps
  753. (append '(("\\.pdf\\'" . "zathura \"%s\"")) org-file-apps))))
  754. #+END_SRC
  755. ** Bullets
  756. Replaces the asterisks with nice UTF-8 bullets.
  757. #+BEGIN_SRC emacs-lisp :tangle yes
  758. (use-package org-bullets
  759. :config
  760. (add-hook 'org-mode-hook (lambda () (org-bullets-mode 1))))
  761. #+END_SRC
  762. ** Agenda
  763. Setup org agenda for managing my life.
  764. #+BEGIN_SRC emacs-lisp :tangle yes
  765. (use-package org-agenda
  766. :ensure nil
  767. :bind (("C-c a" . org-agenda)
  768. :map org-agenda-mode-map
  769. ("j" . org-agenda-next-item)
  770. ("k" . org-agenda-previous-item))
  771. :config
  772. ;; Formats the agenda into nice columns
  773. (setq org-agenda-prefix-format
  774. '((agenda . " %i %-12t% s %-12(car (last (org-get-outline-path)))")
  775. (timeline . " % s")
  776. (todo . " %i %-12:c")
  777. (tags . " %i %-12:c")
  778. (search . " %i %-12:c")))
  779. ;; Sets location of org files
  780. (setq org-agenda-files `(,(concat wolfe/org-dropbox-path "everything.org")))
  781. (setq browse-url-browser-function 'browse-url-chromium))
  782. #+END_SRC
  783. ** Capture
  784. #+BEGIN_SRC emacs-lisp :tangle yes
  785. (global-set-key "\C-cc" 'org-capture)
  786. (setq org-default-notes-file (concat wolfe/org-dropbox-path "everything.org"))
  787. (setq org-capture-templates
  788. '(("t" "Task" entry (file+headline "" "Tasks")
  789. "* TODO %?\n DEADLINE: %t\n")))
  790. #+END_SRC
  791. ** Export
  792. Setup html for syntax highlighting on export and add the apppropriate
  793. minted package for PDF export.
  794. #+BEGIN_SRC emacs-lisp :tangle yes
  795. (use-package htmlize)
  796. (require 'ox-latex)
  797. (add-to-list 'org-latex-packages-alist '("" "minted"))
  798. (setq org-export-allow-bind-keywords t
  799. org-latex-listings 'minted)
  800. (setq org-latex-pdf-process
  801. '("pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f"
  802. "pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f"
  803. "pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f"))
  804. #+END_SRC
  805. *** Hugo
  806. #+BEGIN_SRC emacs-lisp :tangle yes
  807. (use-package ox-hugo
  808. :after ox)
  809. #+END_SRC
  810. ** Org Tree Slide
  811. Presentation mode that runs from within an org document. I add a custom hook for [[Org Tree Slides Set Transient Map][a function]] that
  812. repeatedly creates a transient map replacing the controls regardless of my evil mode.
  813. #+BEGIN_SRC emacs-lisp :tangle yes
  814. (use-package org-tree-slide
  815. :config
  816. (add-hook 'org-tree-slide-mode-hook
  817. (lambda ()
  818. (if org-tree-slide-mode
  819. ;; When mode is enabled
  820. (progn (setq wolfe--enable-transient-map t)
  821. (wolfe/org-tree-set-transient-map))
  822. ;; When mode is disabled
  823. (setq wolfe--enable-transient-map nil)))))
  824. #+END_SRC
  825. * Keymaps
  826. ** Hydra
  827. Customizable popup menus.
  828. #+BEGIN_SRC emacs-lisp :tangle yes
  829. (use-package hydra)
  830. (use-package major-mode-hydra
  831. :ensure nil)
  832. #+END_SRC
  833. *** Major Modes
  834. **** C#
  835. #+BEGIN_SRC emacs-lisp :tangle yes
  836. (major-mode-hydra-bind csharp-mode "Find"
  837. ("d" omnisharp-go-to-definition "Goto definition")
  838. ("D" omnisharp-go-to-definition-other-window "Pop-open definition")
  839. ("u" omnisharp-find-usages "Find usages")
  840. ("p" omnisharp-find-implementations "Find implementations"))
  841. (major-mode-hydra-bind csharp-mode "Fix/Refactor"
  842. ("r" omnisharp-rename "Rename symbol")
  843. ("f" omnisharp-run-code-action-refactoring "Code action")
  844. ("i" omnisharp-code-format-region "Indent region")
  845. ("I" omnisharp-code-format-entire-file "Indent entire file"))
  846. (major-mode-hydra-bind csharp-mode "Solution"
  847. ("e" omnisharp-solution-errors "Solution errors")
  848. ("a" omnisharp-add-to-solution-current-file "Add current file to sln")
  849. ("s" omnisharp-reload-solution "Reload solution"))
  850. #+END_SRC
  851. **** Python
  852. #+BEGIN_SRC emacs-lisp :tangle yes
  853. (major-mode-hydra-bind python-mode "Python"
  854. ("i" elpy-importmagic-fixup "Importmagic fixup")
  855. ("d" elpy-goto-definition "Goto definition")
  856. ("r" elpy-multiedit-python-symbol-at-point "Rename symbol")
  857. ("f" elpy-format-code "Format code")
  858. )
  859. #+END_SRC
  860. **** Org Mode
  861. #+BEGIN_SRC emacs-lisp :tangle yes
  862. (major-mode-hydra-bind org-mode "Org Mode"
  863. ("t" (funcall wolfe/hydra-org-expand) "Expand template"))
  864. #+END_SRC
  865. **** Org Templates
  866. #+BEGIN_SRC emacs-lisp :tangle yes
  867. (setq wolfe/hydra-org-expand
  868. (defhydra hydra-org-template (:color blue :hint nil)
  869. "
  870. _c_enter _q_uote _L_aTeX:
  871. _l_atex _e_xample _i_ndex:
  872. _a_scii _v_erse _I_NCLUDE:
  873. _s_rc _t_angle _H_TML:
  874. _h_tml _d_ot src _A_SCII:
  875. "
  876. ("s" (hot-expand "<s"))
  877. ("e" (hot-expand "<e"))
  878. ("q" (hot-expand "<q"))
  879. ("v" (hot-expand "<v"))
  880. ("t" (hot-expand "<s" "emacs-lisp :tangle yes"))
  881. ("d" (hot-expand "<s" "dot :file TMP.png :cmdline -Kdot -Tpng"))
  882. ("c" (hot-expand "<c"))
  883. ("l" (hot-expand "<l"))
  884. ("h" (hot-expand "<h"))
  885. ("a" (hot-expand "<a"))
  886. ("L" (hot-expand "<L"))
  887. ("i" (hot-expand "<i"))
  888. ("I" (hot-expand "<I"))
  889. ("H" (hot-expand "<H"))
  890. ("A" (hot-expand "<A"))))
  891. #+END_SRC
  892. *** Minor Modes
  893. **** Projectile
  894. #+BEGIN_SRC emacs-lisp :tangle yes
  895. (setq wolfe/hydra-projectile
  896. (pretty-hydra-define hydra-projectile (:exit t :hint nil)
  897. ("Files" (("f" counsel-projectile-find-file "Find File")
  898. ("d" counsel-projectile-find-dir "Find Directory")
  899. ("o" projectile-multi-occur "Multi Occur")
  900. ("s" counsel-projectile-switch-project "Switch Project")
  901. ("k" projectile-kill-buffers "Kill Buffers"))
  902. "Cache" (("c" projectile-invalidate-cache "Clear Cache")
  903. ("C" wolfe/projectile-invalidate-list "Clear A Cache")
  904. ("P" projectile-clear-known-projects "Clear Projects")))))
  905. #+END_SRC
  906. **** Jira
  907. #+BEGIN_SRC emacs-lisp :tangle yes
  908. (defun wolfe/hydra-jira ()
  909. (interactive)
  910. (funcall
  911. (pretty-hydra-define hydra-jira (:exit t :hint nil)
  912. ("Get" (("p" org-jira-get-projects "Get Projects")
  913. ("g" org-jira-get-issues "Get Issues")
  914. ("G" org-jira-get-subtasks "Get Subtasks")
  915. ("r" org-jira-refresh-issue "Refresh Issue")
  916. ("R" org-jira-refresh-issues-in-buffer "Refresh Issues in Buffer"))
  917. "Manage" (("b" org-jira-browse-issue "Browse Issue")
  918. ("c" org-jira-create-issue "Create Issue")
  919. ("s" org-jira-create-subtask "Create Subtask")
  920. ("P" org-jira-progress-issue "Update Issue Progress")
  921. ("a" org-jira-assign-issue "Assign Issue"))
  922. "Push" (("u" org-jira-update-issue "Update Issue")
  923. ("y" org-jira-copy-current-issue-key "Copy Current Issue Key")
  924. ("U" org-jira-update-comment "Update Comment")
  925. ("t" org-jira-todo-to-jira "Todo to Jira"))))))
  926. #+END_SRC
  927. ** Evil & General
  928. *** General
  929. #+BEGIN_SRC emacs-lisp :tangle yes
  930. (use-package general)
  931. #+END_SRC
  932. *** Evil
  933. #+BEGIN_SRC emacs-lisp :tangle yes
  934. (use-package evil
  935. :demand
  936. :bind
  937. (:map evil-motion-state-map
  938. ("C-u" . evil-scroll-up))
  939. :init
  940. (setq evil-want-C-u-scroll t) ; Unbind <C-u> for evil mode's use
  941. (setq evil-want-C-i-jump nil)
  942. :config
  943. (evil-mode t)
  944. (setq evil-split-window-below t
  945. evil-vsplit-window-right t
  946. evil-lookup-func #'wolfe/man)
  947. (setq-default evil-symbol-word-search t)
  948. (custom-set-variables '(evil-search-module (quote evil-search)))
  949. (evil-ex-define-cmd "re[load]" 'wolfe/load-init) ; Custom reload command
  950. (evil-ex-define-cmd "Q" 'save-buffers-kill-terminal) ; For typos
  951. (define-key evil-ex-map "e " (lambda () (interactive) (wolfe/call-and-update-ex 'counsel-find-file))) ; Trigger file completion :e
  952. (global-unset-key (kbd "M-SPC")) ; Unbind secondary leader
  953. (general-create-definer wolfe/bind-leader
  954. :keymaps 'global
  955. :states '(normal insert visual emacs)
  956. :prefix "SPC"
  957. :non-normal-prefix "M-SPC")
  958. (general-define-key
  959. :states 'motion
  960. "k" 'evil-previous-visual-line
  961. "j" 'evil-next-visual-line)
  962. (general-define-key
  963. :states 'operator
  964. "k" 'evil-previous-line
  965. "j" 'evil-next-line)
  966. (general-define-key
  967. :states 'visual
  968. "<" (lambda ()
  969. (interactive)
  970. (evil-shift-left (region-beginning) (region-end))
  971. (evil-normal-state)
  972. (evil-visual-restore))
  973. ">" (lambda ()
  974. (interactive)
  975. (evil-shift-right (region-beginning) (region-end))
  976. (evil-normal-state)
  977. (evil-visual-restore)))
  978. (general-define-key
  979. :states 'normal
  980. "C-z" 'wolfe/controlz
  981. "C-l" 'evil-ex-nohighlight)
  982. (wolfe/bind-leader
  983. "w" 'save-buffer
  984. "S" 'wolfe/eval-and-replace
  985. "s" 'eval-defun
  986. "b" 'mode-line-other-buffer
  987. "k" 'kill-buffer
  988. "m" 'ivy-switch-buffer
  989. "e" 'iedit-mode
  990. "c" 'wolfe/compile-no-prompt
  991. "n" 'narrow-or-widen-dwim
  992. "a" 'org-agenda
  993. "g" 'magit-status
  994. "''" 'org-edit-src-exit
  995. "#" 'wolfe/csharp-project
  996. "t" (lambda() (interactive) (wolfe/if-else-projectile 'treemacs-projectile 'treemacs))
  997. "f" (lambda() (interactive) (wolfe/if-else-projectile 'counsel-projectile-ag 'counsel-ag))
  998. "p" (lambda() (interactive) (funcall wolfe/hydra-projectile))
  999. ";" (lambda() (interactive) (save-excursion (end-of-line) (insert-char ?\;)))
  1000. "id" (lambda() (interactive) (indent-region (point-min) (point-max)))
  1001. "o" (lambda() (interactive) (wolfe/org-open "everything"))
  1002. "init" (lambda() (interactive) (evil-buffer-new nil wolfe/init-file))
  1003. "SPC" 'major-mode-hydra))
  1004. #+END_SRC
  1005. *** Evil Surround
  1006. Tpope's surround
  1007. #+BEGIN_SRC emacs-lisp :tangle yes
  1008. (use-package evil-surround
  1009. :config
  1010. (global-evil-surround-mode 1))
  1011. #+END_SRC
  1012. *** Evil Machit
  1013. #+BEGIN_SRC emacs-lisp :tangle yes
  1014. (use-package evil-matchit
  1015. :config
  1016. (global-evil-matchit-mode 1))
  1017. #+END_SRC
  1018. *** Evil Visual Star
  1019. This allows me to easily start a =*= or =#= search from a visual selection.
  1020. #+BEGIN_SRC emacs-lisp :tangle yes
  1021. (use-package evil-visualstar
  1022. :config
  1023. (global-evil-visualstar-mode))
  1024. #+END_SRC
  1025. *** Evil Numbers
  1026. #+BEGIN_SRC emacs-lisp :tangle yes
  1027. (use-package evil-numbers
  1028. :bind
  1029. (:map evil-normal-state-map
  1030. ("C-a" . 'evil-numbers/inc-at-pt)
  1031. ("C--" . 'evil-numbers/dec-at-pt)))
  1032. #+END_SRC
  1033. *** Evil Lion
  1034. #+BEGIN_SRC emacs-lisp :tangle yes
  1035. (use-package evil-lion
  1036. :config
  1037. (evil-lion-mode))
  1038. #+END_SRC
  1039. *** Evil Exchange
  1040. #+BEGIN_SRC emacs-lisp :tangle yes
  1041. (use-package evil-exchange
  1042. :config
  1043. (evil-exchange-install))
  1044. #+END_SRC
  1045. * Project Management
  1046. ** Ag
  1047. Emacs interface for ag
  1048. #+BEGIN_SRC emacs-lisp :tangle yes
  1049. (use-package ag
  1050. :bind (:map ag-mode-map
  1051. ("Q" . wolfe/ag-kill-buffers-and-window)))
  1052. #+END_SRC
  1053. ** Magit
  1054. Magic git interface from within emacs
  1055. #+BEGIN_SRC emacs-lisp :tangle yes
  1056. (use-package magit
  1057. :defer 10
  1058. :config
  1059. (use-package evil-magit)
  1060. (setq magit-bury-buffer-function
  1061. (lambda (con)
  1062. (kill-buffer)
  1063. (delete-window))))
  1064. #+END_SRC
  1065. ** Projectile
  1066. Project management
  1067. #+BEGIN_SRC emacs-lisp :tangle yes
  1068. (use-package projectile
  1069. :config
  1070. (use-package counsel-projectile
  1071. :config
  1072. (counsel-projectile-mode))
  1073. (setq projectile-enable-caching t)
  1074. (setq projectile-indexing-method 'alien)
  1075. (setq projectile-globally-ignored-file-suffixes
  1076. '("#" "~" ".swp" ".o" ".so" ".exe" ".dll" ".elc" ".pyc" ".jar" "*.class"))
  1077. (setq projectile-globally-ignored-directories
  1078. '(".git" "node_modules" "__pycache__" ".vs"))
  1079. (setq projectile-globally-ignored-files '("TAGS" "tags" ".DS_Store"))
  1080. (projectile-mode))
  1081. #+END_SRC
  1082. ** Treemacs
  1083. #+BEGIN_SRC emacs-lisp :tangle yes
  1084. (use-package treemacs
  1085. :config
  1086. (setq treemacs-follow-after-init t
  1087. treemacs-width 35
  1088. treemacs-indentation 2))
  1089. #+END_SRC
  1090. #+BEGIN_SRC emacs-lisp :tangle yes
  1091. (use-package treemacs-evil)
  1092. #+END_SRC
  1093. #+BEGIN_SRC emacs-lisp :tangle yes
  1094. (use-package treemacs-projectile)
  1095. #+END_SRC
  1096. ** Dumb Jump
  1097. Automatically =grep= or =ag= through a project for a definition. This
  1098. is useful when semantic jump to definition or =TAGS= files aren't present
  1099. or don't exist for the language.
  1100. #+BEGIN_SRC emacs-lisp :tangle yes
  1101. (use-package dumb-jump
  1102. :bind
  1103. (:map evil-normal-state-map
  1104. ("g D" . dumb-jump-go))
  1105. :config
  1106. (setq dumb-jump-selector 'ivy))
  1107. #+END_SRC
  1108. ** Persp Mode
  1109. #+BEGIN_SRC emacs-lisp :tangle yes
  1110. (use-package persp-mode
  1111. :hook (after-init . (lambda () (persp-mode 1)))
  1112. :config
  1113. (defvar wolfe/persp-default-workspace "main")
  1114. (defvar wolfe/persp-shared-buffers '("*scratch*" "*Messages*"))
  1115. (setq wg-morph-on nil ;; switch off animation
  1116. persp-autokill-buffer-on-remove 'kill-weak
  1117. persp-auto-save-opt 0
  1118. persp-auto-resume-time -1
  1119. persp-nil-hidden t
  1120. persp-add-buffer-on-find-file t
  1121. persp-add-buffer-on-after-change-major-mode nil
  1122. persp-hook-up-emacs-buffer-completion t)
  1123. ;; Make ivy play nice
  1124. (with-eval-after-load "ivy"
  1125. (add-hook 'ivy-ignore-buffers
  1126. #'(lambda (b)
  1127. (when persp-mode
  1128. (let ((persp (get-current-persp)))
  1129. (if persp
  1130. (not (persp-contain-buffer-p b persp))
  1131. nil)))))
  1132. (setq ivy-sort-functions-alist
  1133. (append ivy-sort-functions-alist
  1134. '((persp-kill-buffer . nil)
  1135. (persp-remove-buffer . nil)
  1136. (persp-add-buffer . nil)
  1137. (persp-switch . nil)
  1138. (persp-window-switch . nil)
  1139. (persp-frame-switch . nil)))))
  1140. (defun wolfe/persp-switch-project-action ()
  1141. (let ((frame (selected-frame))
  1142. (name (projectile-project-name)))
  1143. (with-selected-frame frame
  1144. (persp-add-new name)
  1145. (persp-frame-switch name)
  1146. (persp-add-buffer wolfe/persp-shared-buffers (get-current-persp) nil)
  1147. (run-with-timer 0 nil (lambda () (persp-add-buffer (current-buffer)))))))
  1148. (add-hook 'projectile-after-switch-project-hook 'wolfe/persp-switch-project-action)
  1149. (defun wolfe/persp-concat-name (count)
  1150. (if (eq count 0)
  1151. wolfe/persp-default-workspace
  1152. (format "%s-%s" wolfe/persp-default-workspace count)))
  1153. (defun wolfe/persp-next-main-name (&optional count)
  1154. (let ((count (or count 0)))
  1155. (if (persp-with-name-exists-p (wolfe/persp-concat-name count))
  1156. (wolfe/persp-next-main-name (+ count 1))
  1157. (wolfe/persp-concat-name count))))
  1158. (add-hook
  1159. 'after-make-frame-functions
  1160. (lambda (frame)
  1161. (let ((name (wolfe/persp-next-main-name)))
  1162. (with-selected-frame frame
  1163. (message "Making persp %s" name)
  1164. (persp-add-new name)
  1165. (persp-add-buffer wolfe/persp-shared-buffers (get-current-persp) nil)
  1166. (persp-frame-switch name frame))))))
  1167. #+END_SRC
  1168. * Languages
  1169. ** Generic Web
  1170. #+BEGIN_SRC emacs-lisp :tangle yes
  1171. (use-package web-mode
  1172. :mode ("\\.html\\'" "\\.php\\'" "\\.js\\'")
  1173. :config
  1174. (setq web-mode-enable-auto-closing t)
  1175. (setq web-mode-enable-auto-opening t)
  1176. (setq web-mode-enable-auto-indentation t))
  1177. (use-package json-mode)
  1178. #+END_SRC
  1179. #+BEGIN_SRC emacs-lisp :tangle yes
  1180. (use-package company-restclient
  1181. :after company
  1182. :config
  1183. (add-to-list 'company-backends 'company-restclient))
  1184. #+END_SRC
  1185. ** Javascript
  1186. #+BEGIN_SRC emacs-lisp :tangle yes
  1187. (use-package company-tern
  1188. :after company
  1189. :config
  1190. (add-to-list 'company-backends 'company-tern)
  1191. (add-hook 'web-mode-hook 'tern-mode))
  1192. #+END_SRC
  1193. #+BEGIN_SRC emacs-lisp :tangle yes
  1194. (use-package indium)
  1195. #+END_SRC
  1196. Basic editing mode for React.js files.
  1197. #+BEGIN_SRC emacs-lisp :tangle yes
  1198. (use-package rjsx-mode)
  1199. #+END_SRC
  1200. ** Lisp Family
  1201. #+BEGIN_SRC emacs-lisp :tangle yes
  1202. (use-package parinfer
  1203. :defer t
  1204. :bind
  1205. (("C-," . parinfer-toggle-mode))
  1206. :init
  1207. (setq
  1208. parinfer-extensions '(defaults pretty-parens evil smart-tab smart-yank)
  1209. parinfer-lighters '(" Φi" . " Φp"))
  1210. (add-hook 'racket-mode #'parinfer-mode)
  1211. (add-hook 'clojure-mode-hook #'parinfer-mode)
  1212. (add-hook 'emacs-lisp-mode-hook #'parinfer-mode)
  1213. (add-hook 'common-lisp-mode-hook #'parinfer-mode)
  1214. (add-hook 'scheme-mode-hook #'parinfer-mode)
  1215. (add-hook 'lisp-mode-hook #'parinfer-mode))
  1216. #+END_SRC
  1217. ** Racket
  1218. #+BEGIN_SRC emacs-lisp :tangle yes
  1219. (use-package racket-mode
  1220. :defer t)
  1221. #+END_SRC
  1222. ** Haskell
  1223. #+BEGIN_SRC emacs-lisp :tangle yes
  1224. (use-package haskell-mode)
  1225. #+END_SRC
  1226. #+BEGIN_SRC emacs-lisp :tangle yes
  1227. (use-package flycheck-haskell
  1228. :after flycheck
  1229. :config
  1230. (add-hook 'haskell-mode-hook #'flycheck-haskell-setup))
  1231. #+END_SRC
  1232. ** Latex
  1233. #+BEGIN_SRC emacs-lisp :tangle yes
  1234. (use-package latex-preview-pane
  1235. :defer t
  1236. :ensure f)
  1237. #+END_SRC
  1238. ** C/C++
  1239. #+BEGIN_SRC emacs-lisp :tangle yes
  1240. (setq gdb-many-windows t
  1241. gdb-show-main t
  1242. company-clang-insert-arguments nil)
  1243. (use-package company-irony
  1244. :after company
  1245. :config
  1246. (add-hook 'c++-mode-hook 'irony-mode)
  1247. (add-hook 'c-mode-hook 'irony-mode)
  1248. (eval-after-load 'company
  1249. '(add-to-list 'company-backends 'company-irony)))
  1250. #+END_SRC
  1251. ** C#
  1252. #+BEGIN_SRC emacs-lisp :tangle yes
  1253. (use-package omnisharp
  1254. :after company
  1255. :config
  1256. (when wolfe/windows?
  1257. (setq omnisharp-server-executable-path "C:/emacs/omnisharp/Omnisharp.exe"))
  1258. (add-hook 'csharp-mode-hook
  1259. (lambda ()
  1260. (evil-define-key 'normal omnisharp-mode-map (kbd "g d") 'omnisharp-go-to-definition)
  1261. (unless (file-exists-p "Makefile")
  1262. (set (make-local-variable 'compile-command) (concat "msbuild " (cdr (assoc :project-root omnisharp--server-info)))))))
  1263. (add-hook 'csharp-mode-hook 'omnisharp-mode)
  1264. (add-to-list 'company-backends 'company-omnisharp))
  1265. #+END_SRC
  1266. ** Python
  1267. I explicitly load the python package so that I can defer it
  1268. and =elpy= together since elpy is a bit slow to load at startup.
  1269. #+BEGIN_SRC emacs-lisp :tangle yes
  1270. (use-package python
  1271. :defer 10
  1272. :hook python-mode-hook)
  1273. (use-package elpy
  1274. :after (company python)
  1275. :init (elpy-enable)
  1276. :config
  1277. (setq elpy-rpc-backend "jedi")
  1278. (when (executable-find "ipython")
  1279. (setq python-shell-interpreter "ipython"
  1280. python-shell-interpreter-args "-i --simple-prompt"))
  1281. (delete 'elpy-module-highlight-indentation elpy-modules)
  1282. (delete 'elpy-module-flymake elpy-modules))
  1283. #+END_SRC
  1284. ** Shell Scripts
  1285. #+BEGIN_SRC emacs-lisp :tangle yes
  1286. (use-package company-shell
  1287. :after company
  1288. :config
  1289. (add-to-list 'company-backends '(company-shell company-shell-env)))
  1290. #+END_SRC
  1291. ** Go
  1292. #+BEGIN_SRC emacs-lisp :tangle yes
  1293. (use-package go-mode
  1294. :config
  1295. (add-hook 'go-mode-hook (lambda () (setq tab-width 4))))
  1296. #+END_SRC
  1297. #+BEGIN_SRC emacs-lisp :tangle yes
  1298. (use-package company-go
  1299. :after company
  1300. :config
  1301. (when wolfe/linux?
  1302. (add-to-list 'exec-path "~/Projects/go/bin"))
  1303. (add-to-list 'company-backends 'company-go))
  1304. #+END_SRC
  1305. ** Nim
  1306. #+BEGIN_SRC emacs-lisp :tangle yes
  1307. (use-package nim-mode
  1308. :defer t)
  1309. #+END_SRC
  1310. ** Java
  1311. #+BEGIN_SRC emacs-lisp :tangle yes
  1312. (use-package company-emacs-eclim
  1313. :after company
  1314. :config
  1315. (company-emacs-eclim-setup)
  1316. (setq eclimd-autostart t)
  1317. (defun my-java-mode-hook ()
  1318. (eclim-mode t))
  1319. (add-hook 'java-mode-hook 'my-java-mode-hook))
  1320. #+END_SRC
  1321. * Utility
  1322. ** Ranger
  1323. #+BEGIN_SRC emacs-lisp :tangle yes
  1324. (use-package ranger
  1325. :config
  1326. (setq ranger-cleanup-on-disable t)
  1327. (ranger-override-dired-mode t))
  1328. #+END_SRC
  1329. ** Iedit
  1330. Edit all instances of a string
  1331. #+BEGIN_SRC emacs-lisp :tangle yes
  1332. (use-package iedit
  1333. :config
  1334. (set-face-attribute 'iedit-occurrence nil :foreground (face-attribute 'match :foreground))
  1335. (setq iedit-toggle-key-default nil))
  1336. #+END_SRC
  1337. ** Quick Run
  1338. #+BEGIN_SRC emacs-lisp :tangle yes
  1339. (use-package quickrun
  1340. :defer t)
  1341. #+END_SRC
  1342. ** Restclient
  1343. Postman inside of emacs.
  1344. #+BEGIN_SRC emacs-lisp :tangle yes
  1345. (use-package restclient
  1346. :defer t)
  1347. #+END_SRC
  1348. ** Rainbow Mode
  1349. Shows hex colors inline.
  1350. #+BEGIN_SRC emacs-lisp :tangle yes
  1351. (use-package rainbow-mode
  1352. :defer t)
  1353. #+END_SRC
  1354. ** Helpful
  1355. #+BEGIN_SRC emacs-lisp :tangle yes
  1356. (use-package helpful
  1357. :defer t
  1358. :bind
  1359. (("C-h f" . helpful-callable)
  1360. ("C-h v" . helpful-variable)
  1361. ("C-h k" . helpful-key)
  1362. ("C-h F" . helpful-function)
  1363. ("C-h C" . helpful-command))
  1364. :config
  1365. (evil-define-key 'normal helpful-mode-map (kbd "q") 'kill-buffer-and-window)
  1366. (set-face-attribute 'helpful-heading nil :height 1.1))
  1367. #+END_SRC
  1368. ** Shackle
  1369. #+BEGIN_SRC emacs-lisp :tangle yes
  1370. (use-package shackle
  1371. :config
  1372. (setq shackle-default-alignment 'below
  1373. shackle-default-size 0.4
  1374. shackle-rules
  1375. '(("*HTTP Response*" :popup t :align right)))
  1376. (shackle-mode))
  1377. #+END_SRC
  1378. ** Zoom
  1379. #+BEGIN_SRC emacs-lisp :tangle yes
  1380. (use-package zoom
  1381. :config
  1382. (setq zoom-size '(0.618 . 0.618))
  1383. (zoom-mode t))
  1384. #+END_SRC
  1385. * Completion
  1386. ** Ivy & Counsel
  1387. #+BEGIN_SRC emacs-lisp :tangle yes
  1388. (use-package ivy
  1389. :demand
  1390. :bind (("M-x" . counsel-M-x)
  1391. ("C-x C-f" . counsel-find-file)
  1392. :map ivy-minibuffer-map
  1393. ("TAB" . ivy-next-line)
  1394. ("RET" . ivy-alt-done)
  1395. :map ivy-switch-buffer-map
  1396. ("C-d" . ivy-switch-buffer-kill))
  1397. :init
  1398. (use-package smex)
  1399. (use-package counsel)
  1400. :config
  1401. (setq ivy-re-builders-alist
  1402. '((t . ivy--regex-ignore-order)))
  1403. (setq ivy-wrap t)
  1404. (ivy-mode 1)
  1405. (use-package doom-todo-ivy
  1406. :ensure nil
  1407. :config
  1408. (evil-define-command doom/ivy-tasks-ex (&optional bang)
  1409. "An ex wrapper around `doom/ivy-tasks'."
  1410. (interactive "<!>")
  1411. (doom/ivy-tasks bang))
  1412. (evil-ex-define-cmd "todo" 'doom/ivy-tasks-ex))
  1413. (eval-after-load "hydra" (use-package ivy-hydra)))
  1414. #+END_SRC
  1415. ** Swiper
  1416. #+BEGIN_SRC emacs-lisp :tangle yes
  1417. (use-package swiper
  1418. :bind (("C-s" . swiper)))
  1419. #+END_SRC
  1420. ** Company
  1421. Autocomplete engine
  1422. #+BEGIN_SRC emacs-lisp :tangle yes
  1423. (use-package company
  1424. :bind (:map company-active-map
  1425. ("C-n" . company-select-next)
  1426. ("C-p" . company-select-previous))
  1427. :init
  1428. (global-company-mode)
  1429. :config
  1430. (setq company-idle-delay 0) ; Delay to complete
  1431. (setq company-minimum-prefix-length 1)
  1432. (setq company-selection-wrap-around t) ; Loops around suggestions
  1433. (if (display-graphic-p)
  1434. (define-key company-active-map [tab] 'company-select-next)
  1435. (define-key company-active-map (kbd "C-i") 'company-select-next))
  1436. #+END_SRC
  1437. #+BEGIN_SRC emacs-lisp :tangle yes
  1438. (require 'color)
  1439. (let ((bg (face-attribute 'default :background))
  1440. (ac (face-attribute 'match :foreground)))
  1441. (custom-set-faces
  1442. `(company-tooltip ((t (:inherit default :background ,(color-lighten-name bg 2)))))
  1443. `(company-scrollbar-bg ((t (:background ,(color-lighten-name bg 10)))))
  1444. `(company-scrollbar-fg ((t (:background ,(color-lighten-name bg 5)))))
  1445. `(company-tooltip-selection ((t (:inherit font-lock-function-name-face))))
  1446. `(company-tooltip-common ((t (:inherit font-lock-constant-face))))
  1447. `(company-preview-common ((t (:foreground ,ac :background ,(color-lighten-name bg 10))))))))
  1448. #+END_SRC
  1449. ** Flycheck Linting
  1450. On the fly syntax checking
  1451. #+BEGIN_SRC emacs-lisp :tangle yes
  1452. (use-package flycheck
  1453. :config
  1454. (global-flycheck-mode)
  1455. (setq-default flycheck-disabled-checkers '(emacs-lisp-checkdoc)))
  1456. #+END_SRC
  1457. ** Yasnippet
  1458. #+BEGIN_SRC emacs-lisp :tangle yes
  1459. (use-package yasnippet
  1460. :config
  1461. (yas-global-mode 1))
  1462. #+END_SRC
  1463. * Misc
  1464. ** Email
  1465. #+BEGIN_SRC emacs-lisp :tangle yes
  1466. (require 'epa-file)
  1467. (custom-set-variables '(epg-gpg-program "c:/Program Files (x86)/GNU/GnuPG/pub/gpg2"))
  1468. (epa-file-enable)
  1469. (require 'gnus)
  1470. (setq user-mail-address "joshuafwolfe@gmail.com"
  1471. user-full-name "Josh Wolfe")
  1472. (setq gnus-select-method
  1473. '(nnimap "gmail"
  1474. (nnimap-address "imap.gmail.com")
  1475. (nnimap-server-port 993)
  1476. (nnimap-stream ssl)))
  1477. (setq smtpmail-smtp-server "smtp.gmail.com"
  1478. smtpmail-smtp-service 587
  1479. gnus-ignored-newsgroups "^to\\.\\|^[0-9. ]+\\( \\|$\\)\\|^[\"]\"[#'()]")
  1480. (setq gnus-thread-sort-functions
  1481. '(gnus-thread-sort-by-most-recent-date
  1482. (not gnus-thread-sort-by-number)))
  1483. (defun my-gnus-group-list-subscribed-groups ()
  1484. "List all subscribed groups with or without un-read messages"
  1485. (interactive)
  1486. (gnus-group-list-all-groups 5))
  1487. (define-key gnus-group-mode-map
  1488. ;; list all the subscribed groups even they contain zero un-read messages
  1489. (kbd "o") 'my-gnus-group-list-subscribed-groups)
  1490. #+END_SRC
  1491. ** IRC
  1492. My =erc= settings are pretty basic. I have the fill column recalculate
  1493. on window resize and I put the scroll margin back to default so that my
  1494. [[Vim Scrolloff][scrolloff]] settings don't mess with it.
  1495. #+BEGIN_SRC emacs-lisp :tangle yes
  1496. (use-package erc
  1497. :ensure nil
  1498. :defer t
  1499. :config
  1500. (add-hook 'window-configuration-change-hook
  1501. (lambda ()
  1502. (setq erc-fill-column (- (window-width) 2))))
  1503. (add-hook 'erc-mode-hook
  1504. (lambda ()
  1505. (setq-local scroll-margin 1)))
  1506. (setq erc-rename-buffers t
  1507. erc-interpret-mirc-color t
  1508. erc-lurker-hide-list '("JOIN" "PART" "QUIT")
  1509. erc-autojoin-channels-alist '(("freenode.net" "#emacs"))))
  1510. #+END_SRC
  1511. Simple function that pulls my credentials from a GPG encrypted file
  1512. and connects to =freenode= providing a nick and password to verify my user.
  1513. #+BEGIN_SRC emacs-lisp :tangle yes
  1514. (defun wolfe/irc ()
  1515. (interactive)
  1516. (let* ((tupple (wolfe/get-user-pass wolfe/irc-info-path))
  1517. (user (car tupple))
  1518. (pass (cadr tupple)))
  1519. (erc
  1520. :server "irc.freenode.net"
  1521. :port 6667
  1522. :nick user
  1523. :password pass)))
  1524. #+END_SRC
  1525. ** Meme
  1526. Meme creator from within emacs... what more is there to say?
  1527. #+BEGIN_SRC emacs-lisp :tangle yes
  1528. (use-package meme
  1529. :ensure nil
  1530. :commands (meme meme-file))
  1531. #+END_SRC
  1532. * Backups
  1533. Stores all backups and temp files in =~/.bak.emacs/=
  1534. #+BEGIN_SRC emacs-lisp :tangle yes
  1535. (setq backup-by-copying t) ; Stop shinanigans with links
  1536. (setq backup-directory-alist '((".*" . "~/.bak.emacs/backup/")))
  1537. ;; Creates directory if it doesn't already exist
  1538. (make-directory "~/.bak.emacs/" t)
  1539. ;; Creates auto directory if it doesn't already exist
  1540. (make-directory "~/.bak.emacs/auto" t)
  1541. ;; backup in one place. flat, no tree structure
  1542. (setq auto-save-file-name-transforms '((".*" "~/.bak.emacs/auto/" t)))
  1543. #+END_SRC
  1544. * Testing
  1545. ** Org Project
  1546. #+BEGIN_SRC emacs-lisp :tangle yes
  1547. (let ((todo-file-path "~/Projects/todo-projectile/todo-projectile.el"))
  1548. (when wolfe/windows?
  1549. (setq todo-file-path "c:/dev/SideProjects/todo-projectile/todo-projectile.el"))
  1550. (when (file-exists-p todo-file-path)
  1551. (load-file todo-file-path)
  1552. (setq todo-projectile-use-ag t)))
  1553. #+END_SRC
  1554. ** Extract Dates
  1555. #+BEGIN_SRC emacs-lisp :tangle yes
  1556. (defun wolfe/extract-dates (file-path)
  1557. "Parse through a file for a list of all the comments"
  1558. (let (already-open
  1559. buf
  1560. start
  1561. (comments '()))
  1562. (setq already-open (find-buffer-visiting file-path)
  1563. buf (find-file-noselect file-path))
  1564. (with-current-buffer buf
  1565. (goto-char (point-min))
  1566. (while (setq start (text-property-any
  1567. (point) (point-max)
  1568. 'face 'org-date))
  1569. (goto-char start)
  1570. (goto-char (next-single-char-property-change (point) 'face))
  1571. (let ((item (string-trim (buffer-substring-no-properties start (point)))))
  1572. (setq comments (cons item comments)))))
  1573. (unless already-open (kill-buffer buf))
  1574. (reverse comments)))
  1575. #+END_SRC