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

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998
  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. This checks which setup we're in and calls the appropriate function above.
  128. #+BEGIN_SRC emacs-lisp :tangle yes
  129. (defun hook-if-daemonp (func)
  130. (if (daemonp)
  131. (add-hook 'after-make-frame-functions
  132. (lambda (frame)
  133. (with-selected-frame frame
  134. (funcall func))))
  135. (funcall func)))
  136. #+END_SRC
  137. ** Dark
  138. Configuration for my dark theme =base16 default dark= which is loaded by default.
  139. #+BEGIN_SRC emacs-lisp :tangle yes
  140. (defun wolfe/dark-setup ()
  141. (use-package base16-theme
  142. :config
  143. (load-theme 'base16-default-dark t)
  144. (defvar my/base16-colors base16-default-dark-colors)
  145. (setq evil-emacs-state-cursor `(,(plist-get my/base16-colors :base0D) box)
  146. evil-insert-state-cursor `(,(plist-get my/base16-colors :base0D) bar)
  147. evil-motion-state-cursor `(,(plist-get my/base16-colors :base0E) box)
  148. evil-normal-state-cursor `(,(plist-get my/base16-colors :base07) box)
  149. evil-replace-state-cursor `(,(plist-get my/base16-colors :base08) bar)
  150. evil-visual-state-cursor `(,(plist-get my/base16-colors :base09) box)))
  151. (eval-after-load 'ivy (lambda () (setq ivy-switch-buffer-faces-alist '((dired-mode . ivy-subdir)))))
  152. (hook-if-daemonp (lambda () (set-face-attribute 'fringe nil :background nil)))
  153. (custom-set-faces
  154. '(org-block-begin-line ((t (:inherit (org-meta-line) :height 0.7))))
  155. '(org-block-end-line ((t (:inherit (org-meta-line) :height 0.7))))
  156. '(region ((t (:background "gray19"))))
  157. '(org-block ((t (:foreground "#d8d8d8"))))
  158. '(org-done ((t (:box (:line-width 1) :weight bold))))
  159. '(org-level-1 ((t (:inherit outline-1 :height 1.3))))
  160. '(org-todo ((t (:box (:line-width 1) :weight bold))))))
  161. #+END_SRC
  162. ** Light
  163. Configuration for my light theme =leuven=. This is only loaded when the =-light= flag is
  164. specified on the command line.
  165. #+BEGIN_SRC emacs-lisp :tangle yes
  166. (defun wolfe/light-setup ()
  167. (use-package leuven-theme
  168. :config
  169. (custom-set-faces
  170. '(ivy-subdir ((t (:background "gray88")))))
  171. (load-theme 'leuven t)))
  172. #+END_SRC
  173. ** Display check
  174. #+BEGIN_SRC emacs-lisp :tangle yes
  175. (if wolfe/using-light
  176. (wolfe/light-setup)
  177. (wolfe/dark-setup))
  178. #+END_SRC
  179. * General Settings
  180. Basic settings I can't really live without.
  181. ** Load Path
  182. Recursively add =~/.emacs.d/lisp/= to my load path.
  183. #+BEGIN_SRC emacs-lisp :tangle yes
  184. (add-to-list 'load-path wolfe/lisp-dir-path)
  185. (let ((default-directory wolfe/lisp-dir-path))
  186. (normal-top-level-add-subdirs-to-load-path))
  187. #+END_SRC
  188. ** Splash and Startup
  189. This makes sure I'm presented with a nice blank =*scratch*=
  190. buffer when emacs starts up.
  191. #+BEGIN_SRC emacs-lisp :tangle yes
  192. (setq inhibit-splash-screen t
  193. inhibit-startup-message t
  194. initial-scratch-message "") ; No scratch text
  195. (defun display-startup-echo-area-message ()
  196. (message "Welcome to the church of GNU/Emacs"))
  197. #+END_SRC
  198. ** Graphics
  199. *** Bars
  200. I don't really want to have to look at menu bars that I'm not going to use
  201. #+BEGIN_SRC emacs-lisp :tangle yes
  202. (hook-if-daemonp
  203. (lambda ()
  204. (tool-bar-mode -1) ; No toolbar
  205. (scroll-bar-mode -1) ; Hide scrollbars
  206. (menu-bar-mode -1))) ; No menubar
  207. #+END_SRC
  208. *** Fonts
  209. I used =Inconsolata-dz= for quite a long time but have recently been
  210. using =Fira Mono=.
  211. #+BEGIN_SRC emacs-lisp :tangle yes
  212. (let* ((font "Fira Mono")
  213. (size 15)
  214. (font-size (format "%s-%s" font size)))
  215. (setq default-frame-alist `((font . ,font-size)))
  216. (set-face-attribute 'default t :font font-size))
  217. #+END_SRC
  218. Force =Fira Code= for all =UTF-8= symbols.
  219. #+BEGIN_SRC emacs-lisp :tangle yes
  220. (hook-if-daemonp
  221. (lambda ()
  222. (when (display-graphic-p)
  223. (let ((utf8-font "Fira Code"))
  224. (set-fontset-font "fontset-startup" '(#x000000 . #x3FFFFF) utf8-font)
  225. (set-fontset-font "fontset-default" '(#x000000 . #x3FFFFF) utf8-font)
  226. (set-fontset-font "fontset-standard" '(#x000000 . #x3FFFFF) utf8-font)))))
  227. #+END_SRC
  228. Make sure that UTF-8 is used everywhere.
  229. #+BEGIN_SRC emacs-lisp :tangle yes
  230. (set-terminal-coding-system 'utf-8)
  231. (set-keyboard-coding-system 'utf-8)
  232. (set-language-environment 'utf-8)
  233. (set-selection-coding-system 'utf-8)
  234. (setq locale-coding-system 'utf-8)
  235. (prefer-coding-system 'utf-8)
  236. (set-input-method nil)
  237. #+END_SRC
  238. *** Pretty Symbols
  239. In emacs =24.4= we got =prettify-symbols-mode= which replaces things like =lambda=
  240. with =λ=. This can help make the code easier to read. The =inhibit-compacting-font-caches=
  241. stops garbage collect from trying to handle font caches which makes things a lot faster
  242. and saves us ram.
  243. #+BEGIN_SRC emacs-lisp :tangle yes
  244. (setq prettify-symbols-unprettify-at-point 'right-edge)
  245. (setq inhibit-compacting-font-caches t)
  246. #+END_SRC
  247. **** Global
  248. These symbols are the basics that I would like enabled for all =prog-mode= modes.
  249. This function can be called by the mode specific hook to push the defaults.
  250. #+BEGIN_SRC emacs-lisp :tangle yes
  251. (defun wolfe/pretty-symbol-push-default ()
  252. (push '("!=" . ?≠) prettify-symbols-alist)
  253. (push '("<=" . ?≤) prettify-symbols-alist)
  254. (push '(">=" . ?≥) prettify-symbols-alist)
  255. (push '("=>" . ?⇒) prettify-symbols-alist))
  256. #+END_SRC
  257. Now apply the default to some modes I don't want anything special in.
  258. #+BEGIN_SRC emacs-lisp :tangle yes
  259. (mapc
  260. (lambda (hook)
  261. (add-hook 'hook (lambda () (wolfe/pretty-symbol-push-default))))
  262. '(c-mode))
  263. #+END_SRC
  264. **** Python
  265. #+BEGIN_SRC emacs-lisp :tangle yes
  266. (add-hook 'python-mode-hook
  267. (lambda ()
  268. (wolfe/pretty-symbol-push-default)
  269. (push '("def" . ?ƒ) prettify-symbols-alist)
  270. (push '("sum" . ?Σ) prettify-symbols-alist)
  271. (push '("**2" . ?²) prettify-symbols-alist)
  272. (push '("**3" . ?³) prettify-symbols-alist)
  273. (push '("None" . ?∅) prettify-symbols-alist)
  274. (push '("in" . ?∈) prettify-symbols-alist)
  275. (push '("not in" . ?∉) prettify-symbols-alist)
  276. (push '("return" . ?➡) prettify-symbols-alist)
  277. (prettify-symbols-mode t)))
  278. #+END_SRC
  279. **** Lisp
  280. #+BEGIN_SRC emacs-lisp :tangle yes
  281. (add-hook 'emacs-lisp-mode-hook
  282. (lambda ()
  283. (wolfe/pretty-symbol-push-default)
  284. (push '("defun" . ?ƒ) prettify-symbols-alist)
  285. (push '("defmacro" . ?μ) prettify-symbols-alist)
  286. (push '("defvar" . ?ν) prettify-symbols-alist)
  287. (prettify-symbols-mode t)))
  288. #+END_SRC
  289. **** Go
  290. #+BEGIN_SRC emacs-lisp :tangle yes
  291. (add-hook 'go-mode-hook
  292. (lambda ()
  293. (wolfe/pretty-symbol-push-default)
  294. (push '("func" . ?ƒ) prettify-symbols-alist)
  295. (push '(":=" . ?←) prettify-symbols-alist)
  296. (prettify-symbols-mode t)))
  297. #+END_SRC
  298. *** Column Marker
  299. #+BEGIN_SRC emacs-lisp :tangle yes
  300. (use-package column-marker
  301. :ensure nil
  302. :config
  303. (add-hook 'prog-mode-hook (lambda () (interactive) (column-marker-1 81)))
  304. (custom-set-faces
  305. '(column-marker-1 ((t (:background "dim gray"))))))
  306. #+END_SRC
  307. *** Highlight Escape Characters
  308. This defines 4 new faces and the appropriate =regexps= that highlight
  309. them and maps them to all the modes in [[Highlight Escapes Modes][=wolfe/highlight-escapes-mode-list=]].
  310. #+BEGIN_SRC emacs-lisp :tangle yes
  311. (defface wolfe/backslash-escape-backslash-face
  312. '((t :inherit font-lock-regexp-grouping-backslash))
  313. "Face for the back-slash component of a back-slash escape."
  314. :group 'font-lock-faces)
  315. (defface wolfe/backslash-escape-char-face
  316. '((t :inherit font-lock-regexp-grouping-construct))
  317. "Face for the charcter component of a back-slash escape."
  318. :group 'font-lock-faces)
  319. (defface wolfe/format-code-format-face
  320. '((t :inherit font-lock-regexp-grouping-backslash))
  321. "Face for the % component of a printf format code."
  322. :group 'font-lock-faces)
  323. (defface wolfe/format-code-directive-face
  324. '((t :inherit font-lock-regexp-grouping-construct))
  325. "Face for the directive component of a printf format code."
  326. :group 'font-lock-faces)
  327. (mapc
  328. (lambda (mode)
  329. (font-lock-add-keywords
  330. mode
  331. '(("\\(\\\\\\)." 1 'wolfe/backslash-escape-backslash-face prepend)
  332. ("\\\\\\(.\\)" 1 'wolfe/backslash-escape-char-face prepend)
  333. ("\\(%\\)." 1 'wolfe/format-code-format-face prepend)
  334. ("%\\(.\\)" 1 'wolfe/format-code-directive-face prepend))))
  335. wolfe/highlight-escapes-mode-list)
  336. #+END_SRC
  337. *** Highlight Todo, Fixme & Bug
  338. #+BEGIN_SRC emacs-lisp :tangle yes
  339. (add-hook 'prog-mode-hook
  340. (lambda ()
  341. (font-lock-add-keywords nil
  342. '(("\\<\\(FIXME\\|TODO\\|BUG\\|XXX\\)" 1 font-lock-warning-face t)))))
  343. #+END_SRC
  344. ** Personal Defaults
  345. Nothing to crazy here just the type of behaviour I personally
  346. expect as default.
  347. #+BEGIN_SRC emacs-lisp :tangle yes
  348. (show-paren-mode t) ; Highlights matching parens
  349. (fset 'yes-or-no-p 'y-or-n-p) ; y/n instead of yes/no
  350. (blink-cursor-mode -1) ; No need to flash the cursor
  351. (column-number-mode t) ; Show column in mode-line
  352. (delete-selection-mode 1) ; Replace selection on insert
  353. (setq-default truncate-lines t ; Don't wrap
  354. indent-tabs-mode nil)
  355. (setq vc-follow-symlinks t ; Always follow symlinks
  356. tags-revert-without-query t ; Don't ask to reload TAGS file
  357. echo-keystrokes 0.5
  358. custom-file "~/.emacs.d/custom.el" ; Set custom file and don't load it
  359. source-directory "~/Projects/emacs/")
  360. #+END_SRC
  361. ** Misc
  362. *** Vim Scrolloff
  363. This makes scrolling gradual rather than by half page. I find that the
  364. half page scroll really makes me lose where I am in the file so here
  365. I make sure to scroll one line at a time. In addition I want to keep
  366. what I'm working on centered so I start scrolling when the cursor is
  367. 10 lines away from the margin.
  368. This behaviour in general emulates the =scrolloff= option in vim.
  369. #+BEGIN_SRC emacs-lisp :tangle yes
  370. (setq scroll-margin 10
  371. scroll-step 1
  372. scroll-conservatively 10000
  373. scroll-preserve-screen-position 1)
  374. #+END_SRC
  375. *** Shell Tweaks
  376. #+BEGIN_SRC emacs-lisp :tangle yes
  377. (setq explicit-shell-file-name
  378. (if (file-readable-p "/usr/bin/zsh") "/usr/bin/zsh" "/bin/bash"))
  379. (when (eq system-type 'windows-nt)
  380. (setq explicit-shell-file-name "cmdproxy.exe"))
  381. #+END_SRC
  382. *** Spell Check
  383. #+BEGIN_SRC emacs-lisp :tangle yes
  384. (when wolfe/windows?
  385. (setq ispell-program-name "c:/emacs/hunspell/bin/hunspell.exe"))
  386. #+END_SRC
  387. *** Help & Compilation
  388. Keep the output scrolling as it compiles.
  389. #+BEGIN_SRC emacs-lisp :tangle yes
  390. (require 'compile)
  391. (setq compilation-scroll-output t)
  392. #+END_SRC
  393. =q= should really quit the buffer not just stick it at the bottom.
  394. #+BEGIN_SRC emacs-lisp :tangle yes
  395. (dolist (m (list help-mode-map compilation-mode-map))
  396. (bind-key (kbd "q") (lambda () (interactive) (quit-window t)) m))
  397. #+END_SRC
  398. ** Mode Line
  399. If we're in GUI emacs we make sure to use =powerline= otherwise we use
  400. a custom mode line configuration.
  401. #+BEGIN_SRC emacs-lisp :tangle yes
  402. (if (or (display-graphic-p) (daemonp))
  403. (use-package powerline
  404. :config
  405. (setq powerline-arrow-shape 'curve
  406. powerline-display-buffer-size nil
  407. powerline-display-mule-info nil)
  408. (powerline-default-theme)
  409. (remove-hook 'focus-out-hook 'powerline-unset-selected-window)
  410. (setq powerline-height 24)
  411. (defpowerline powerline-minor-modes ""))
  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-enforce-todo-dependencies t
  713. org-agenda-use-time-grid nil
  714. org-agenda-skip-deadline-if-done t
  715. org-agenda-skip-scheduled-if-done t
  716. org-ellipsis wolfe/org-ellipsis
  717. org-entities-user '(("bot" "\\bot" nil "" "" "" "⊥")
  718. ("square" "$\\square$" nil "" "" "" "□")))
  719. (defun wolfe/org-tags-compute-width ()
  720. (- (floor (* 0.6 (frame-width)))))
  721. (add-hook 'org-mode-hook
  722. (lambda ()
  723. (setq org-tags-column (wolfe/org-tags-compute-width))
  724. (org-align-all-tags)))
  725. (add-hook 'org-agenda-mode-hook
  726. (lambda ()
  727. (setq org-agenda-tags-column (wolfe/org-tags-compute-width))
  728. (org-agenda-align-tags)))
  729. (defun wolfe/save-org-archive-buffers (orig-fun &rest args)
  730. (save-some-buffers 'no-confirm
  731. (lambda ()
  732. (string-match "_archive\\'" buffer-file-name))))
  733. (advice-add 'org-archive-subtree :after 'wolfe/save-org-archive-buffers)
  734. (org-babel-do-load-languages
  735. 'org-babel-load-languages
  736. '((shell . t)
  737. ( dot . t)))
  738. (global-set-key "\C-cl" 'org-store-link)
  739. ;; ispell ignores SRC blocks
  740. (add-to-list 'ispell-skip-region-alist '("#\\+BEGIN_SRC" . "#\\+END_SRC"))
  741. (add-to-list 'ispell-skip-region-alist '("#\\+BEGIN_LATEX" . "#\\+END_LATEX"))
  742. ;; Refresh images after executing a src block
  743. (add-hook 'org-babel-after-execute-hook
  744. (lambda ()
  745. (when org-inline-image-overlays
  746. (org-redisplay-inline-images))))
  747. (defun wolfe/confirm-babel-evaluate (lang body)
  748. (not (string= lang "dot")))
  749. (setq org-confirm-babel-evaluate 'wolfe/confirm-babel-evaluate)
  750. ;; Open PDFs with zathura
  751. (add-hook 'org-mode-hook
  752. (lambda ()
  753. (setq org-file-apps
  754. (append '(("\\.pdf\\'" . "zathura \"%s\"")) org-file-apps))))
  755. #+END_SRC
  756. ** Bullets
  757. Replaces the asterisks with nice UTF-8 bullets.
  758. #+BEGIN_SRC emacs-lisp :tangle yes
  759. (use-package org-bullets
  760. :config
  761. (add-hook 'org-mode-hook (lambda () (org-bullets-mode 1))))
  762. #+END_SRC
  763. ** Agenda
  764. Setup org agenda for managing my life.
  765. #+BEGIN_SRC emacs-lisp :tangle yes
  766. (use-package org-agenda
  767. :ensure nil
  768. :bind (("C-c a" . org-agenda)
  769. :map org-agenda-mode-map
  770. ("j" . org-agenda-next-item)
  771. ("k" . org-agenda-previous-item))
  772. :config
  773. ;; Formats the agenda into nice columns
  774. (setq org-agenda-prefix-format
  775. '((agenda . " %i %-12t% s %-12(car (last (org-get-outline-path)))")
  776. (timeline . " % s")
  777. (todo . " %i %-12:c")
  778. (tags . " %i %-12:c")
  779. (search . " %i %-12:c")))
  780. ;; Sets location of org files
  781. (setq org-agenda-files `(,(concat wolfe/org-dropbox-path "everything.org")))
  782. (setq browse-url-browser-function 'browse-url-chromium))
  783. #+END_SRC
  784. ** Capture
  785. #+BEGIN_SRC emacs-lisp :tangle yes
  786. (global-set-key "\C-cc" 'org-capture)
  787. (setq org-default-notes-file (concat wolfe/org-dropbox-path "everything.org"))
  788. (setq org-capture-templates
  789. '(("t" "Task" entry (file+headline "" "Need Refiling")
  790. "* TODO %?\n DEADLINE: %t\n")))
  791. #+END_SRC
  792. ** Export
  793. Setup html for syntax highlighting on export and add the apppropriate
  794. minted package for PDF export.
  795. #+BEGIN_SRC emacs-lisp :tangle yes
  796. (use-package htmlize)
  797. (require 'ox-latex)
  798. (add-to-list 'org-latex-packages-alist '("" "minted"))
  799. (setq org-export-allow-bind-keywords t
  800. org-latex-listings 'minted)
  801. (setq org-latex-pdf-process
  802. '("pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f"
  803. "pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f"
  804. "pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f"))
  805. #+END_SRC
  806. *** Hugo
  807. #+BEGIN_SRC emacs-lisp :tangle yes
  808. (use-package ox-hugo
  809. :after ox)
  810. #+END_SRC
  811. ** Org Tree Slide
  812. Presentation mode that runs from within an org document. I add a custom hook for [[Org Tree Slides Set Transient Map][a function]] that
  813. repeatedly creates a transient map replacing the controls regardless of my evil mode.
  814. #+BEGIN_SRC emacs-lisp :tangle yes
  815. (use-package org-tree-slide
  816. :config
  817. (add-hook 'org-tree-slide-mode-hook
  818. (lambda ()
  819. (if org-tree-slide-mode
  820. ;; When mode is enabled
  821. (progn (setq wolfe--enable-transient-map t)
  822. (wolfe/org-tree-set-transient-map))
  823. ;; When mode is disabled
  824. (setq wolfe--enable-transient-map nil)))))
  825. #+END_SRC
  826. * Keymaps
  827. ** Hydra
  828. Customizable popup menus.
  829. #+BEGIN_SRC emacs-lisp :tangle yes
  830. (use-package hydra)
  831. (use-package major-mode-hydra
  832. :ensure nil)
  833. #+END_SRC
  834. *** Major Modes
  835. **** C#
  836. #+BEGIN_SRC emacs-lisp :tangle yes
  837. (major-mode-hydra-bind csharp-mode "Find"
  838. ("d" omnisharp-go-to-definition "Goto definition")
  839. ("D" omnisharp-go-to-definition-other-window "Pop-open definition")
  840. ("u" omnisharp-find-usages "Find usages")
  841. ("p" omnisharp-find-implementations "Find implementations"))
  842. (major-mode-hydra-bind csharp-mode "Fix/Refactor"
  843. ("r" omnisharp-rename "Rename symbol")
  844. ("f" omnisharp-run-code-action-refactoring "Code action")
  845. ("i" omnisharp-code-format-region "Indent region")
  846. ("I" omnisharp-code-format-entire-file "Indent entire file"))
  847. (major-mode-hydra-bind csharp-mode "Solution"
  848. ("e" omnisharp-solution-errors "Solution errors")
  849. ("a" omnisharp-add-to-solution-current-file "Add current file to sln")
  850. ("s" omnisharp-reload-solution "Reload solution"))
  851. #+END_SRC
  852. **** Python
  853. #+BEGIN_SRC emacs-lisp :tangle yes
  854. (major-mode-hydra-bind python-mode "Python"
  855. ("i" elpy-importmagic-fixup "Importmagic fixup")
  856. ("d" elpy-goto-definition "Goto definition")
  857. ("r" elpy-multiedit-python-symbol-at-point "Rename symbol")
  858. ("f" elpy-format-code "Format code")
  859. )
  860. #+END_SRC
  861. **** Org Mode
  862. #+BEGIN_SRC emacs-lisp :tangle yes
  863. (major-mode-hydra-bind org-mode "Org Mode"
  864. ("t" (funcall wolfe/hydra-org-expand) "Expand template"))
  865. #+END_SRC
  866. **** Org Templates
  867. #+BEGIN_SRC emacs-lisp :tangle yes
  868. (setq wolfe/hydra-org-expand
  869. (defhydra hydra-org-template (:color blue :hint nil)
  870. "
  871. _c_enter _q_uote _L_aTeX:
  872. _l_atex _e_xample _i_ndex:
  873. _a_scii _v_erse _I_NCLUDE:
  874. _s_rc _t_angle _H_TML:
  875. _h_tml _d_ot src _A_SCII:
  876. "
  877. ("s" (hot-expand "<s"))
  878. ("e" (hot-expand "<e"))
  879. ("q" (hot-expand "<q"))
  880. ("v" (hot-expand "<v"))
  881. ("t" (hot-expand "<s" "emacs-lisp :tangle yes"))
  882. ("d" (hot-expand "<s" "dot :file TMP.png :cmdline -Kdot -Tpng"))
  883. ("c" (hot-expand "<c"))
  884. ("l" (hot-expand "<l"))
  885. ("h" (hot-expand "<h"))
  886. ("a" (hot-expand "<a"))
  887. ("L" (hot-expand "<L"))
  888. ("i" (hot-expand "<i"))
  889. ("I" (hot-expand "<I"))
  890. ("H" (hot-expand "<H"))
  891. ("A" (hot-expand "<A"))))
  892. #+END_SRC
  893. *** Minor Modes
  894. **** Projectile
  895. #+BEGIN_SRC emacs-lisp :tangle yes
  896. (setq wolfe/hydra-projectile
  897. (pretty-hydra-define hydra-projectile (:exit t :hint nil)
  898. ("Files" (("f" counsel-projectile-find-file "Find File")
  899. ("d" counsel-projectile-find-dir "Find Directory")
  900. ("o" projectile-multi-occur "Multi Occur")
  901. ("s" counsel-projectile-switch-project "Switch Project")
  902. ("k" projectile-kill-buffers "Kill Buffers"))
  903. "Cache" (("c" projectile-invalidate-cache "Clear Cache")
  904. ("C" wolfe/projectile-invalidate-list "Clear A Cache")
  905. ("P" projectile-clear-known-projects "Clear Projects")))))
  906. #+END_SRC
  907. **** Jira
  908. #+BEGIN_SRC emacs-lisp :tangle yes
  909. (defun wolfe/hydra-jira ()
  910. (interactive)
  911. (funcall
  912. (pretty-hydra-define hydra-jira (:exit t :hint nil)
  913. ("Get" (("p" org-jira-get-projects "Get Projects")
  914. ("g" org-jira-get-issues "Get Issues")
  915. ("G" org-jira-get-subtasks "Get Subtasks")
  916. ("r" org-jira-refresh-issue "Refresh Issue")
  917. ("R" org-jira-refresh-issues-in-buffer "Refresh Issues in Buffer"))
  918. "Manage" (("b" org-jira-browse-issue "Browse Issue")
  919. ("c" org-jira-create-issue "Create Issue")
  920. ("s" org-jira-create-subtask "Create Subtask")
  921. ("P" org-jira-progress-issue "Update Issue Progress")
  922. ("a" org-jira-assign-issue "Assign Issue"))
  923. "Push" (("u" org-jira-update-issue "Update Issue")
  924. ("y" org-jira-copy-current-issue-key "Copy Current Issue Key")
  925. ("U" org-jira-update-comment "Update Comment")
  926. ("t" org-jira-todo-to-jira "Todo to Jira"))))))
  927. #+END_SRC
  928. ** Evil & General
  929. *** General
  930. #+BEGIN_SRC emacs-lisp :tangle yes
  931. (use-package general)
  932. #+END_SRC
  933. *** Evil
  934. #+BEGIN_SRC emacs-lisp :tangle yes
  935. (use-package evil
  936. :demand
  937. :bind
  938. (:map evil-motion-state-map
  939. ("C-u" . evil-scroll-up))
  940. :init
  941. (setq evil-want-C-u-scroll t
  942. evil-want-C-i-jump t
  943. evil-want-Y-yank-to-eol t)
  944. :config
  945. (evil-mode t)
  946. (setq evil-split-window-below t
  947. evil-vsplit-window-right t
  948. evil-lookup-func #'wolfe/man)
  949. (setq-default evil-symbol-word-search t)
  950. (custom-set-variables '(evil-search-module (quote evil-search)))
  951. (evil-ex-define-cmd "re[load]" 'wolfe/load-init) ; Custom reload command
  952. (evil-ex-define-cmd "Q" 'save-buffers-kill-terminal) ; For typos
  953. (define-key evil-ex-map "e " (lambda () (interactive) (wolfe/call-and-update-ex 'counsel-find-file))) ; Trigger file completion :e
  954. (global-unset-key (kbd "M-SPC")) ; Unbind secondary leader
  955. (add-to-list 'evil-emacs-state-modes 'vterm-mode)
  956. (general-create-definer wolfe/bind-leader
  957. :keymaps 'global
  958. :states '(normal insert visual emacs)
  959. :prefix "SPC"
  960. :non-normal-prefix "M-SPC")
  961. (general-define-key
  962. :states 'motion
  963. "k" 'evil-previous-visual-line
  964. "j" 'evil-next-visual-line)
  965. (general-define-key
  966. :states 'operator
  967. "k" 'evil-previous-line
  968. "j" 'evil-next-line)
  969. (general-define-key
  970. :states 'visual
  971. "<" (lambda ()
  972. (interactive)
  973. (evil-shift-left (region-beginning) (region-end))
  974. (evil-normal-state)
  975. (evil-visual-restore))
  976. ">" (lambda ()
  977. (interactive)
  978. (evil-shift-right (region-beginning) (region-end))
  979. (evil-normal-state)
  980. (evil-visual-restore)))
  981. (general-define-key
  982. :states 'normal
  983. "C-z" 'wolfe/controlz
  984. "C-l" 'evil-ex-nohighlight)
  985. (wolfe/bind-leader
  986. "w" 'save-buffer
  987. "S" 'wolfe/eval-and-replace
  988. "s" 'eval-defun
  989. "b" 'mode-line-other-buffer
  990. "k" 'kill-buffer
  991. "m" 'ivy-switch-buffer
  992. "e" 'iedit-mode
  993. "c" 'wolfe/compile-no-prompt
  994. "n" 'narrow-or-widen-dwim
  995. "a" 'org-agenda
  996. "g" 'magit-status
  997. "''" 'org-edit-src-exit
  998. "t" 'shell-pop
  999. "f" (lambda() (interactive) (wolfe/if-else-projectile 'counsel-projectile-ag 'counsel-ag))
  1000. "p" (lambda() (interactive) (funcall wolfe/hydra-projectile))
  1001. ";" (lambda() (interactive) (save-excursion (end-of-line) (insert-char ?\;)))
  1002. "id" (lambda() (interactive) (indent-region (point-min) (point-max)))
  1003. "o" (lambda() (interactive) (wolfe/org-open "everything"))
  1004. "init" (lambda() (interactive) (evil-buffer-new nil wolfe/init-file))
  1005. "SPC" 'major-mode-hydra))
  1006. #+END_SRC
  1007. *** Evil Surround
  1008. Tpope's surround
  1009. #+BEGIN_SRC emacs-lisp :tangle yes
  1010. (use-package evil-surround
  1011. :config
  1012. (global-evil-surround-mode 1))
  1013. #+END_SRC
  1014. *** Evil Machit
  1015. #+BEGIN_SRC emacs-lisp :tangle yes
  1016. (use-package evil-matchit
  1017. :config
  1018. (global-evil-matchit-mode 1))
  1019. #+END_SRC
  1020. *** Evil Visual Star
  1021. This allows me to easily start a =*= or =#= search from a visual selection.
  1022. #+BEGIN_SRC emacs-lisp :tangle yes
  1023. (use-package evil-visualstar
  1024. :config
  1025. (global-evil-visualstar-mode))
  1026. #+END_SRC
  1027. *** Evil Numbers
  1028. #+BEGIN_SRC emacs-lisp :tangle yes
  1029. (use-package evil-numbers
  1030. :bind
  1031. (:map evil-normal-state-map
  1032. ("C-a" . 'evil-numbers/inc-at-pt)
  1033. ("C--" . 'evil-numbers/dec-at-pt)))
  1034. #+END_SRC
  1035. *** Evil Lion
  1036. #+BEGIN_SRC emacs-lisp :tangle yes
  1037. (use-package evil-lion
  1038. :config
  1039. (evil-lion-mode))
  1040. #+END_SRC
  1041. *** Evil Exchange
  1042. #+BEGIN_SRC emacs-lisp :tangle yes
  1043. (use-package evil-exchange
  1044. :config
  1045. (evil-exchange-install))
  1046. #+END_SRC
  1047. * Project Management
  1048. ** Ag
  1049. Emacs interface for ag
  1050. #+BEGIN_SRC emacs-lisp :tangle yes
  1051. (use-package ag
  1052. :bind (:map ag-mode-map
  1053. ("Q" . wolfe/ag-kill-buffers-and-window)))
  1054. #+END_SRC
  1055. ** Magit
  1056. Magic git interface from within emacs
  1057. #+BEGIN_SRC emacs-lisp :tangle yes
  1058. (use-package magit
  1059. :defer 10
  1060. :config
  1061. (use-package evil-magit)
  1062. (setq magit-bury-buffer-function
  1063. (lambda (con)
  1064. (kill-buffer-and-window))))
  1065. #+END_SRC
  1066. ** Projectile
  1067. Project management
  1068. #+BEGIN_SRC emacs-lisp :tangle yes
  1069. (use-package projectile
  1070. :config
  1071. (use-package counsel-projectile
  1072. :config
  1073. (counsel-projectile-mode))
  1074. (setq projectile-enable-caching t)
  1075. (setq projectile-indexing-method 'alien)
  1076. (setq projectile-globally-ignored-file-suffixes
  1077. '("#" "~" ".swp" ".o" ".so" ".exe" ".dll" ".elc" ".pyc" ".jar" "*.class"))
  1078. (setq projectile-globally-ignored-directories
  1079. '(".git" "node_modules" "__pycache__" ".vs"))
  1080. (setq projectile-globally-ignored-files '("TAGS" "tags" ".DS_Store"))
  1081. (projectile-mode))
  1082. #+END_SRC
  1083. ** Dumb Jump
  1084. Automatically =grep= or =ag= through a project for a definition. This
  1085. is useful when semantic jump to definition or =TAGS= files aren't present
  1086. or don't exist for the language.
  1087. #+BEGIN_SRC emacs-lisp :tangle yes
  1088. (use-package dumb-jump
  1089. :bind
  1090. (:map evil-normal-state-map
  1091. ("g D" . dumb-jump-go))
  1092. :config
  1093. (setq dumb-jump-selector 'ivy))
  1094. #+END_SRC
  1095. ** Persp Mode
  1096. #+BEGIN_SRC emacs-lisp :tangle yes
  1097. (use-package persp-mode
  1098. :hook (after-init . (lambda () (persp-mode 1)))
  1099. :config
  1100. (defvar wolfe/persp-default-workspace "main")
  1101. (defvar wolfe/persp-shared-buffers '("*scratch*" "*Messages*"))
  1102. (defvar wolfe/projectile-project-to-switch nil)
  1103. (setq wg-morph-on nil ;; switch off animation
  1104. persp-autokill-buffer-on-remove 'kill-weak
  1105. persp-auto-save-opt 0
  1106. persp-auto-resume-time -1
  1107. persp-nil-hidden t
  1108. persp-add-buffer-on-find-file t
  1109. persp-add-buffer-on-after-change-major-mode t
  1110. persp-hook-up-emacs-buffer-completion t)
  1111. ;; Make ivy play nice
  1112. (with-eval-after-load "ivy"
  1113. (add-hook 'ivy-ignore-buffers
  1114. #'(lambda (b)
  1115. (when persp-mode
  1116. (let ((persp (get-current-persp)))
  1117. (if persp
  1118. (not (persp-contain-buffer-p b persp))
  1119. nil)))))
  1120. (setq ivy-sort-functions-alist
  1121. (append ivy-sort-functions-alist
  1122. '((persp-kill-buffer . nil)
  1123. (persp-remove-buffer . nil)
  1124. (persp-add-buffer . nil)
  1125. (persp-switch . nil)
  1126. (persp-window-switch . nil)
  1127. (persp-frame-switch . nil)))))
  1128. (defun wolfe/projectile-switch-project-by-name (counsel-projectile-switch-project-by-name &rest args)
  1129. (setq wolfe/projectile-project-to-switch (car args))
  1130. (apply counsel-projectile-switch-project-by-name args)
  1131. (setq wolfe/projectile-project-to-switch nil))
  1132. (advice-add #'counsel-projectile-switch-project-by-name :around #'wolfe/projectile-switch-project-by-name)
  1133. (defun wolfe/persp-create-project-persp ()
  1134. (let ((frame (selected-frame))
  1135. (name (file-name-nondirectory
  1136. (directory-file-name
  1137. (file-name-directory
  1138. wolfe/projectile-project-to-switch)))))
  1139. (with-selected-frame frame
  1140. (persp-add-new name)
  1141. (persp-frame-switch name)
  1142. (persp-add-buffer wolfe/persp-shared-buffers (get-current-persp) nil))))
  1143. (add-hook 'projectile-before-switch-project-hook 'wolfe/persp-create-project-persp)
  1144. (defun wolfe/persp-concat-name (count)
  1145. (if (eq count 0)
  1146. wolfe/persp-default-workspace
  1147. (format "%s-%s" wolfe/persp-default-workspace count)))
  1148. (defun wolfe/persp-next-main-name (&optional count)
  1149. (let ((count (or count 0)))
  1150. (if (persp-with-name-exists-p (wolfe/persp-concat-name count))
  1151. (wolfe/persp-next-main-name (+ count 1))
  1152. (wolfe/persp-concat-name count))))
  1153. (add-hook
  1154. 'after-make-frame-functions
  1155. (lambda (frame)
  1156. (let ((name (wolfe/persp-next-main-name)))
  1157. (with-selected-frame frame
  1158. (set-frame-parameter frame 'wolfe/persp-current-main name)
  1159. (persp-add-new name)
  1160. (persp-frame-switch name frame)
  1161. (persp-add-buffer wolfe/persp-shared-buffers (get-current-persp) nil)))))
  1162. (add-hook
  1163. 'delete-frame-functions
  1164. (lambda (frame)
  1165. (with-selected-frame frame
  1166. (persp-kill (frame-parameter frame 'wolfe/persp-current-main))))))
  1167. #+END_SRC
  1168. * Languages
  1169. ** Generic Web
  1170. #+BEGIN_SRC emacs-lisp :tangle yes
  1171. (use-package web-mode
  1172. :defer t
  1173. :mode ("\\.html\\'" "\\.php\\'" "\\.js\\'")
  1174. :config
  1175. (setq web-mode-enable-auto-closing t)
  1176. (setq web-mode-enable-auto-opening t)
  1177. (setq web-mode-enable-auto-indentation t))
  1178. (use-package json-mode)
  1179. #+END_SRC
  1180. #+BEGIN_SRC emacs-lisp :tangle yes
  1181. (use-package company-restclient
  1182. :after company
  1183. :config
  1184. (add-to-list 'company-backends 'company-restclient))
  1185. #+END_SRC
  1186. ** Javascript
  1187. #+BEGIN_SRC emacs-lisp :tangle yes
  1188. (use-package company-tern
  1189. :after company
  1190. :config
  1191. (add-to-list 'company-backends 'company-tern)
  1192. (add-hook 'web-mode-hook 'tern-mode))
  1193. #+END_SRC
  1194. #+BEGIN_SRC emacs-lisp :tangle yes
  1195. (use-package indium
  1196. :defer t)
  1197. #+END_SRC
  1198. Basic editing mode for React.js files.
  1199. #+BEGIN_SRC emacs-lisp :tangle yes
  1200. (use-package rjsx-mode
  1201. :defer t)
  1202. #+END_SRC
  1203. ** Lisp Family
  1204. #+BEGIN_SRC emacs-lisp :tangle yes
  1205. (use-package parinfer
  1206. :defer t
  1207. :bind
  1208. (("C-," . parinfer-toggle-mode))
  1209. :init
  1210. (setq
  1211. parinfer-extensions '(defaults pretty-parens evil smart-tab smart-yank)
  1212. parinfer-lighters '(" Φi" . " Φp"))
  1213. (add-hook 'racket-mode #'parinfer-mode)
  1214. (add-hook 'clojure-mode-hook #'parinfer-mode)
  1215. (add-hook 'emacs-lisp-mode-hook #'parinfer-mode)
  1216. (add-hook 'common-lisp-mode-hook #'parinfer-mode)
  1217. (add-hook 'scheme-mode-hook #'parinfer-mode)
  1218. (add-hook 'lisp-mode-hook #'parinfer-mode))
  1219. #+END_SRC
  1220. ** Racket
  1221. #+BEGIN_SRC emacs-lisp :tangle yes
  1222. (use-package racket-mode
  1223. :defer t)
  1224. #+END_SRC
  1225. ** Haskell
  1226. #+BEGIN_SRC emacs-lisp :tangle yes
  1227. (use-package haskell-mode
  1228. :defer t)
  1229. #+END_SRC
  1230. ** Latex
  1231. #+BEGIN_SRC emacs-lisp :tangle yes
  1232. (use-package latex-preview-pane
  1233. :defer t
  1234. :ensure f)
  1235. #+END_SRC
  1236. ** C/C++
  1237. #+BEGIN_SRC emacs-lisp :tangle yes
  1238. (setq gdb-many-windows t
  1239. gdb-show-main t
  1240. company-clang-insert-arguments nil)
  1241. (setq-default c-basic-offset 4)
  1242. (use-package company-irony
  1243. :defer t
  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. :defer t
  1255. :after company
  1256. :config
  1257. (when wolfe/windows?
  1258. (setq omnisharp-server-executable-path "C:/emacs/omnisharp/Omnisharp.exe"))
  1259. (add-hook 'csharp-mode-hook
  1260. (lambda ()
  1261. (evil-define-key 'normal omnisharp-mode-map (kbd "g d") 'omnisharp-go-to-definition)
  1262. (unless (file-exists-p "Makefile")
  1263. (set (make-local-variable 'compile-command) (concat "msbuild " (cdr (assoc :project-root omnisharp--server-info)))))))
  1264. (add-hook 'csharp-mode-hook 'omnisharp-mode)
  1265. (add-to-list 'company-backends 'company-omnisharp))
  1266. #+END_SRC
  1267. ** Python
  1268. I explicitly load the python package so that I can defer it
  1269. and =elpy= together since elpy is a bit slow to load at startup.
  1270. #+BEGIN_SRC emacs-lisp :tangle yes
  1271. (use-package python
  1272. :defer 10
  1273. :hook python-mode-hook)
  1274. (use-package elpy
  1275. :after (company python)
  1276. :init (elpy-enable)
  1277. :config
  1278. (setq elpy-rpc-backend "jedi")
  1279. (when (executable-find "ipython")
  1280. (setq python-shell-interpreter "ipython"
  1281. python-shell-interpreter-args "-i --simple-prompt"))
  1282. (delete 'elpy-module-highlight-indentation elpy-modules)
  1283. (delete 'elpy-module-flymake elpy-modules))
  1284. #+END_SRC
  1285. ** Shell Scripts
  1286. #+BEGIN_SRC emacs-lisp :tangle yes
  1287. (use-package company-shell
  1288. :defer t
  1289. :after company
  1290. :config
  1291. (add-to-list 'company-backends '(company-shell company-shell-env)))
  1292. #+END_SRC
  1293. ** Go
  1294. #+BEGIN_SRC emacs-lisp :tangle yes
  1295. (use-package go-mode
  1296. :defer t
  1297. :config
  1298. (add-hook 'go-mode-hook (lambda () (setq tab-width 4))))
  1299. #+END_SRC
  1300. #+BEGIN_SRC emacs-lisp :tangle yes
  1301. (use-package company-go
  1302. :defer t
  1303. :after company
  1304. :config
  1305. (when wolfe/linux?
  1306. (add-to-list 'exec-path "~/Projects/go/bin"))
  1307. (add-to-list 'company-backends 'company-go))
  1308. #+END_SRC
  1309. ** Java
  1310. #+BEGIN_SRC emacs-lisp :tangle yes
  1311. (use-package company-emacs-eclim
  1312. :after company
  1313. :config
  1314. (company-emacs-eclim-setup)
  1315. (setq eclimd-autostart t)
  1316. (defun my-java-mode-hook ()
  1317. (eclim-mode t))
  1318. (add-hook 'java-mode-hook 'my-java-mode-hook))
  1319. #+END_SRC
  1320. * Utility
  1321. ** Ranger
  1322. #+BEGIN_SRC emacs-lisp :tangle yes
  1323. (use-package ranger
  1324. :config
  1325. (setq ranger-cleanup-on-disable t)
  1326. (ranger-override-dired-mode t))
  1327. #+END_SRC
  1328. ** Iedit
  1329. Edit all instances of a string
  1330. #+BEGIN_SRC emacs-lisp :tangle yes
  1331. (use-package iedit
  1332. :config
  1333. (setq iedit-toggle-key-default nil))
  1334. #+END_SRC
  1335. ** Quick Run
  1336. #+BEGIN_SRC emacs-lisp :tangle yes
  1337. (use-package quickrun
  1338. :defer t)
  1339. #+END_SRC
  1340. ** Restclient
  1341. Postman inside of emacs.
  1342. #+BEGIN_SRC emacs-lisp :tangle yes
  1343. (use-package restclient
  1344. :defer t)
  1345. #+END_SRC
  1346. ** Rainbow Mode
  1347. Shows hex colors inline.
  1348. #+BEGIN_SRC emacs-lisp :tangle yes
  1349. (use-package rainbow-mode
  1350. :defer t)
  1351. #+END_SRC
  1352. ** Helpful
  1353. #+BEGIN_SRC emacs-lisp :tangle yes
  1354. (use-package helpful
  1355. :defer t
  1356. :bind
  1357. (("C-h f" . helpful-callable)
  1358. ("C-h v" . helpful-variable)
  1359. ("C-h k" . helpful-key)
  1360. ("C-h F" . helpful-function)
  1361. ("C-h C" . helpful-command))
  1362. :config
  1363. (evil-define-key 'normal helpful-mode-map (kbd "q") 'kill-buffer-and-window)
  1364. (set-face-attribute 'helpful-heading nil :height 1.1))
  1365. #+END_SRC
  1366. ** Shackle
  1367. #+BEGIN_SRC emacs-lisp :tangle yes
  1368. (use-package shackle
  1369. :config
  1370. (setq shackle-default-alignment 'below
  1371. shackle-default-size 0.4
  1372. shackle-rules
  1373. '(("*HTTP Response*" :popup t :align right)))
  1374. (shackle-mode))
  1375. #+END_SRC
  1376. ** Zoom
  1377. #+BEGIN_SRC emacs-lisp :tangle yes
  1378. (use-package zoom
  1379. :config
  1380. (setq zoom-size '(0.618 . 0.618))
  1381. (zoom-mode t))
  1382. #+END_SRC
  1383. ** Exec Path From Shell
  1384. #+BEGIN_SRC emacs-lisp :tangle yes
  1385. (use-package exec-path-from-shell
  1386. :config
  1387. (exec-path-from-shell-copy-env "GPG_TTY")
  1388. (exec-path-from-shell-copy-env "SSH_AUTH_SOCK"))
  1389. #+END_SRC
  1390. ** Shell Pop
  1391. #+BEGIN_SRC emacs-lisp :tangle yes
  1392. (use-package shell-pop
  1393. :config
  1394. (defun shell-pop--set-exit-action ()
  1395. (if (string= shell-pop-internal-mode "eshell")
  1396. (add-hook 'eshell-exit-hook 'shell-pop--kill-and-delete-window nil t)
  1397. (let ((process (get-buffer-process (current-buffer))))
  1398. (when process
  1399. (set-process-sentinel
  1400. process
  1401. (lambda (_proc change)
  1402. (when (string-match-p "\\(?:finished\\|exited\\)" change)
  1403. (if (one-window-p)
  1404. (switch-to-buffer shell-pop-last-buffer)
  1405. (kill-buffer-and-window)))))))))
  1406. (custom-set-variables
  1407. '(shell-pop-shell-type (quote ("vterm" "*vterm*" (lambda nil (vterm)))))
  1408. '(shell-pop-term-shell "/usr/bin/zsh")
  1409. '(shell-pop-window-position "right")))
  1410. #+END_SRC
  1411. * Completion
  1412. ** Ivy & Counsel
  1413. #+BEGIN_SRC emacs-lisp :tangle yes
  1414. (use-package ivy
  1415. :demand
  1416. :bind (("M-x" . counsel-M-x)
  1417. ("C-x C-f" . counsel-find-file)
  1418. :map ivy-minibuffer-map
  1419. ("TAB" . ivy-next-line)
  1420. ("RET" . ivy-alt-done)
  1421. :map ivy-switch-buffer-map
  1422. ("C-d" . ivy-switch-buffer-kill))
  1423. :init
  1424. (use-package smex)
  1425. (use-package counsel)
  1426. :config
  1427. (setq ivy-re-builders-alist
  1428. '((t . ivy--regex-ignore-order)))
  1429. (setq ivy-wrap t)
  1430. (ivy-mode 1)
  1431. (use-package doom-todo-ivy
  1432. :ensure nil
  1433. :config
  1434. (evil-define-command doom/ivy-tasks-ex (&optional bang)
  1435. "An ex wrapper around `doom/ivy-tasks'."
  1436. (interactive "<!>")
  1437. (doom/ivy-tasks bang))
  1438. (evil-ex-define-cmd "todo" 'doom/ivy-tasks-ex))
  1439. (eval-after-load "hydra" (use-package ivy-hydra)))
  1440. #+END_SRC
  1441. ** Swiper
  1442. #+BEGIN_SRC emacs-lisp :tangle yes
  1443. (use-package swiper
  1444. :bind (("C-s" . swiper)))
  1445. #+END_SRC
  1446. ** Company
  1447. Autocomplete engine
  1448. #+BEGIN_SRC emacs-lisp :tangle yes
  1449. (use-package company
  1450. :bind (:map company-active-map
  1451. ("C-n" . company-select-next)
  1452. ("C-p" . company-select-previous))
  1453. :init
  1454. (global-company-mode)
  1455. :config
  1456. (setq company-idle-delay 0) ; Delay to complete
  1457. (setq company-minimum-prefix-length 1)
  1458. (setq company-selection-wrap-around t) ; Loops around suggestions
  1459. (if (display-graphic-p)
  1460. (define-key company-active-map [tab] 'company-select-next)
  1461. (define-key company-active-map (kbd "C-i") 'company-select-next))
  1462. #+END_SRC
  1463. #+BEGIN_SRC emacs-lisp :tangle yes
  1464. (hook-if-daemonp
  1465. (lambda ()
  1466. (require 'color)
  1467. (let ((bg (face-attribute 'default :background))
  1468. (ac (face-attribute 'match :foreground)))
  1469. (custom-set-faces
  1470. `(company-tooltip ((t (:inherit default :background ,(color-lighten-name bg 2)))))
  1471. `(company-scrollbar-bg ((t (:background ,(color-lighten-name bg 10)))))
  1472. `(company-scrollbar-fg ((t (:background ,(color-lighten-name bg 5)))))
  1473. `(company-tooltip-selection ((t (:inherit font-lock-function-name-face))))
  1474. `(company-tooltip-common ((t (:inherit font-lock-constant-face))))
  1475. `(company-preview-common ((t (:foreground ,ac :background ,(color-lighten-name bg 10))))))))))
  1476. #+END_SRC
  1477. ** Flycheck Linting
  1478. On the fly syntax checking
  1479. #+BEGIN_SRC emacs-lisp :tangle yes
  1480. (use-package flycheck
  1481. :config
  1482. (global-flycheck-mode)
  1483. (setq-default flycheck-disabled-checkers '(emacs-lisp-checkdoc)))
  1484. #+END_SRC
  1485. ** Yasnippet
  1486. #+BEGIN_SRC emacs-lisp :tangle yes
  1487. (use-package yasnippet
  1488. :config
  1489. (yas-global-mode 1))
  1490. #+END_SRC
  1491. * Misc
  1492. ** Email
  1493. #+BEGIN_SRC emacs-lisp :tangle yes
  1494. (require 'epa-file)
  1495. (custom-set-variables '(epg-gpg-program "c:/Program Files (x86)/GNU/GnuPG/pub/gpg2"))
  1496. (epa-file-enable)
  1497. (require 'gnus)
  1498. (setq user-mail-address "joshuafwolfe@gmail.com"
  1499. user-full-name "Josh Wolfe")
  1500. (setq gnus-select-method
  1501. '(nnimap "gmail"
  1502. (nnimap-address "imap.gmail.com")
  1503. (nnimap-server-port 993)
  1504. (nnimap-stream ssl)))
  1505. (setq smtpmail-smtp-server "smtp.gmail.com"
  1506. smtpmail-smtp-service 587
  1507. gnus-ignored-newsgroups "^to\\.\\|^[0-9. ]+\\( \\|$\\)\\|^[\"]\"[#'()]")
  1508. (setq gnus-thread-sort-functions
  1509. '(gnus-thread-sort-by-most-recent-date
  1510. (not gnus-thread-sort-by-number)))
  1511. (defun my-gnus-group-list-subscribed-groups ()
  1512. "List all subscribed groups with or without un-read messages"
  1513. (interactive)
  1514. (gnus-group-list-all-groups 5))
  1515. (define-key gnus-group-mode-map
  1516. ;; list all the subscribed groups even they contain zero un-read messages
  1517. (kbd "o") 'my-gnus-group-list-subscribed-groups)
  1518. #+END_SRC
  1519. ** IRC
  1520. My =erc= settings are pretty basic. I have the fill column recalculate
  1521. on window resize and I put the scroll margin back to default so that my
  1522. [[Vim Scrolloff][scrolloff]] settings don't mess with it.
  1523. #+BEGIN_SRC emacs-lisp :tangle yes
  1524. (use-package erc
  1525. :ensure nil
  1526. :defer t
  1527. :config
  1528. (add-hook 'window-configuration-change-hook
  1529. (lambda ()
  1530. (setq erc-fill-column (- (window-width) 2))))
  1531. (add-hook 'erc-mode-hook
  1532. (lambda ()
  1533. (setq-local scroll-margin 1)))
  1534. (setq erc-rename-buffers t
  1535. erc-interpret-mirc-color t
  1536. erc-lurker-hide-list '("JOIN" "PART" "QUIT")
  1537. erc-autojoin-channels-alist '(("freenode.net" "#emacs"))))
  1538. #+END_SRC
  1539. Simple function that pulls my credentials from a GPG encrypted file
  1540. and connects to =freenode= providing a nick and password to verify my user.
  1541. #+BEGIN_SRC emacs-lisp :tangle yes
  1542. (defun wolfe/irc ()
  1543. (interactive)
  1544. (let* ((tupple (wolfe/get-user-pass wolfe/irc-info-path))
  1545. (user (car tupple))
  1546. (pass (cadr tupple)))
  1547. (erc
  1548. :server "irc.freenode.net"
  1549. :port 6667
  1550. :nick user
  1551. :password pass)))
  1552. #+END_SRC
  1553. ** Meme
  1554. Meme creator from within emacs... what more is there to say?
  1555. #+BEGIN_SRC emacs-lisp :tangle yes
  1556. (use-package meme
  1557. :ensure nil
  1558. :commands (meme meme-file))
  1559. #+END_SRC
  1560. * Backups
  1561. Stores all backups and temp files in =~/.bak.emacs/=
  1562. #+BEGIN_SRC emacs-lisp :tangle yes
  1563. (setq backup-by-copying t) ; Stop shinanigans with links
  1564. (setq backup-directory-alist '((".*" . "~/.bak.emacs/backup/")))
  1565. ;; Creates directory if it doesn't already exist
  1566. (make-directory "~/.bak.emacs/" t)
  1567. ;; Creates auto directory if it doesn't already exist
  1568. (make-directory "~/.bak.emacs/auto" t)
  1569. ;; backup in one place. flat, no tree structure
  1570. (setq auto-save-file-name-transforms '((".*" "~/.bak.emacs/auto/" t)))
  1571. #+END_SRC
  1572. * Testing
  1573. ** Org Project
  1574. #+BEGIN_SRC emacs-lisp :tangle yes
  1575. (let ((todo-file-path "~/Projects/todo-projectile/todo-projectile.el"))
  1576. (when wolfe/windows?
  1577. (setq todo-file-path "c:/dev/SideProjects/todo-projectile/todo-projectile.el"))
  1578. (when (file-exists-p todo-file-path)
  1579. (load-file todo-file-path)
  1580. (setq todo-projectile-use-ag t)))
  1581. #+END_SRC
  1582. ** Extract Dates
  1583. #+BEGIN_SRC emacs-lisp :tangle yes
  1584. (defun wolfe/extract-dates (file-path)
  1585. "Parse through a file for a list of all the comments"
  1586. (let (already-open
  1587. buf
  1588. start
  1589. (comments '()))
  1590. (setq already-open (find-buffer-visiting file-path)
  1591. buf (find-file-noselect file-path))
  1592. (with-current-buffer buf
  1593. (goto-char (point-min))
  1594. (while (setq start (text-property-any
  1595. (point) (point-max)
  1596. 'face 'org-date))
  1597. (goto-char start)
  1598. (goto-char (next-single-char-property-change (point) 'face))
  1599. (let ((item (string-trim (buffer-substring-no-properties start (point)))))
  1600. (setq comments (cons item comments)))))
  1601. (unless already-open (kill-buffer buf))
  1602. (reverse comments)))
  1603. #+END_SRC
  1604. ** Vterm
  1605. #+BEGIN_SRC emacs-lisp :tangle yes
  1606. (add-to-list 'load-path "~/emacs-libvterm/")
  1607. (require 'vterm)
  1608. #+END_SRC