Human Readable Emacs Configuration using Org mode
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.

1652 lines
68 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. #+TITLE: Emacs Configuration
  2. #+AUTHOR: Levi Olson
  3. #+EMAIL: olson.levi@gmail.com
  4. #+DATE: <2019-01-30 Wed>
  5. #+LANGUAGE: en
  6. #+BABEL: :cache yes
  7. #+HTML_HEAD: <link rel="stylesheet" type="text/css" href="public/style.css" />
  8. #+EXPORT_FILE_NAME: index.html
  9. #+PROPERTY: header-args :tangle yes
  10. #+OPTIONS: num:10 whn:nil toc:10 H:10
  11. #+STARTUP: content
  12. * Summary
  13. I've really been wanting to have a nicely formatted emacs config file and this is my attempt at it.
  14. * Required Magic
  15. ** Lexical Binding
  16. #+BEGIN_SRC emacs-lisp :results silent
  17. ;;; -*- lexical-binding: t -*-
  18. ;;; DO NOT EDIT THIS FILE DIRECTLY
  19. ;;; EDIT ~init.org~ instead
  20. #+END_SRC
  21. ** The Magical Glue
  22. The following auto compiles the emacs-lisp within the =init.org= file.
  23. Simply run `org-babel-tangle` to make it RAIN!
  24. #+BEGIN_SRC emacs-lisp :results silent
  25. ;; (setq byte-compile-warnings nil)
  26. (defun tangle-init ()
  27. "If the current buffer is 'init.org' the code-blocks are tangled, and the tangled file is compiled."
  28. (when (equal (buffer-file-name)
  29. (expand-file-name (concat user-emacs-directory "init.org")))
  30. ;; Avoid running hooks when tangling.
  31. (let ((prog-mode-hook nil))
  32. (org-babel-tangle)
  33. (byte-compile-file (concat user-emacs-directory "init.el")))))
  34. (add-hook 'after-save-hook 'tangle-init)
  35. #+END_SRC
  36. * Config
  37. ** Packages
  38. #+BEGIN_SRC emacs-lisp :results silent
  39. (require 'package)
  40. (package-initialize)
  41. (defvar my-packages
  42. '(all-the-icons
  43. anzu
  44. base16-theme
  45. bbdb
  46. better-defaults
  47. company
  48. company-go
  49. counsel
  50. counsel-projectile
  51. dash-at-point
  52. dashboard
  53. diminish
  54. dockerfile-mode
  55. doom-modeline
  56. doom-themes
  57. ein
  58. eldoc-eval
  59. elfeed
  60. elfeed-org
  61. elpy
  62. emmet-mode
  63. expand-region
  64. fic-mode
  65. flycheck
  66. gitignore-mode
  67. go-mode
  68. go-playground
  69. gorepl-mode
  70. iedit
  71. ivy
  72. ivy-hydra
  73. jabber
  74. json-mode
  75. magit
  76. material-theme
  77. multiple-cursors
  78. projectile
  79. rainbow-delimiters
  80. rust-mode
  81. shrink-path
  82. tide
  83. typescript-mode
  84. ;; use-package
  85. web-mode
  86. which-key))
  87. (add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/"))
  88. (add-to-list 'package-archives '("melpa-stable" . "http://stable.melpa.org/packages/"))
  89. (when (not package-archive-contents)
  90. (package-refresh-contents))
  91. (package-initialize)
  92. (dolist (p my-packages)
  93. (when (not (package-installed-p p))
  94. (package-install p)))
  95. #+END_SRC
  96. ** Server
  97. #+BEGIN_SRC emacs-lisp :results silent :tangle no
  98. (require 'edit-server)
  99. (edit-server-start)
  100. #+END_SRC
  101. ** Better Defaults
  102. #+BEGIN_SRC emacs-lisp :results silent
  103. (require 'better-defaults)
  104. ;; Instead of the annoying giant warning icon, just flash the modeline.
  105. ;; (this happens when you do something like C-g)
  106. (setq ring-bell-function
  107. (lambda ()
  108. (let ((orig-fg (face-foreground 'mode-line)))
  109. (set-face-foreground 'mode-line "#F2804F")
  110. (run-with-idle-timer 0.1 nil
  111. (lambda (fg) (set-face-foreground 'mode-line fg))
  112. orig-fg))))
  113. (defun set-frame-size-according-to-resolution ()
  114. "Set the Emacs window size on startup."
  115. (interactive)
  116. (if window-system
  117. (progn
  118. ;; WIDTH
  119. (if (> (x-display-pixel-width) 1280)
  120. ;; Large Screen (only show 120 cols)
  121. (add-to-list 'default-frame-alist (cons 'width 240))
  122. ;; Small Screen (fill window)
  123. (add-to-list 'default-frame-alist (cons 'width (/ (x-display-pixel-width) (frame-char-width)))))
  124. ;; HEIGHT
  125. (if (> (x-display-pixel-height) 1080)
  126. ;; Large Screen (only fill half screen)
  127. (add-to-list 'default-frame-alist (cons 'height (/ (/ (x-display-pixel-height) 2)
  128. (frame-char-height))))
  129. ;; Small Screen (fill window)
  130. (add-to-list 'default-frame-alist (cons 'height (/ (x-display-pixel-height) (frame-char-height)))))
  131. )))
  132. (set-frame-size-according-to-resolution)
  133. (defun window-px-width ()
  134. "Get the width of the Emacs window in pixels."
  135. (interactive)
  136. (* (* (window-total-width) 2.874) (frame-char-width)))
  137. (defun window-px-left-pos ()
  138. "Calculate the left position of the Emacs window."
  139. (interactive)
  140. (/ (- (x-display-pixel-width) (window-px-width)) 2))
  141. (add-to-list 'default-frame-alist (cons 'top 0))
  142. (add-to-list 'default-frame-alist (cons 'left 1000))
  143. #+END_SRC
  144. ** Enable Disabled Commands
  145. #+BEGIN_SRC emacs-lisp :results silent
  146. (put 'narrow-to-region 'disabled nil)
  147. (put 'upcase-region 'disabled nil)
  148. (put 'downcase-region 'disabled nil)
  149. #+END_SRC
  150. ** Splash Screen
  151. #+BEGIN_SRC emacs-lisp :results silent
  152. (require 'dashboard)
  153. (dashboard-setup-startup-hook)
  154. ;; Set the title
  155. (setq dashboard-banner-logo-title "Let's begin...")
  156. ;; Set the banner
  157. (setq dashboard-startup-banner "~/.emacs.d/public/emacs-logo-512.png")
  158. ;; Value can be
  159. ;; 'official which displays the official emacs logo
  160. ;; 'logo which displays an alternative emacs logo
  161. ;; 1, 2 or 3 which displays one of the text banners
  162. ;; "path/to/your/image.png" which displays whatever image you would prefer
  163. ;; Content is not centered by default. To center, set
  164. (setq dashboard-center-content t)
  165. ;; To disable shortcut "jump" indicators for each section, set
  166. (setq dashboard-show-shortcuts t)
  167. (setq show-week-agenda-p t)
  168. (setq dashboard-items '((recents . 5)
  169. (bookmarks . 5)
  170. (projects . 5)
  171. (agenda . 5)
  172. (registers . 5)))
  173. #+END_SRC
  174. ** Basic Customization
  175. #+BEGIN_SRC emacs-lisp :results silent
  176. (defvar backup-dir (expand-file-name "~/.emacs.d/backup/"))
  177. (defvar autosave-dir (expand-file-name "~/.emacs.d/autosave/"))
  178. (setq initial-scratch-message nil
  179. backup-directory-alist (list (cons ".*" backup-dir))
  180. auto-save-list-file-prefix autosave-dir
  181. auto-save-file-name-transforms `((".*" ,autosave-dir t)))
  182. (menu-bar-mode 0)
  183. (scroll-bar-mode 0)
  184. (tool-bar-mode 0)
  185. (setq auth-sources '("~/.authinfo.gpg"))
  186. (set-default 'truncate-lines t)
  187. ;; (load-theme 'doom-city-lights t)
  188. ;; (load-theme 'doom-dracula t)
  189. ;; (load-theme 'doom-nord t)
  190. (load-theme 'doom-one t)
  191. ;; (load-theme 'doom-spacegrey t)
  192. ;; (load-theme 'base16-ocean t)
  193. (load-theme 'base16-onedark t)
  194. (global-linum-mode t)
  195. (global-auto-revert-mode t)
  196. (defalias 'yes-or-no-p 'y-or-n-p)
  197. #+END_SRC
  198. *** Diary
  199. #+BEGIN_SRC emacs-lisp :results silent
  200. (defvar diary-file (expand-file-name "~/.emacs.d/diary/main"))
  201. (add-hook 'diary-list-entries-hook 'diary-sort-entries t)
  202. (add-hook 'diary-list-entries-hook 'diary-include-other-diary-files)
  203. (add-hook 'diary-mark-entries-hook 'diary-mark-included-diary-files)
  204. (add-hook 'calendar-today-visible-hook 'calendar-mark-today)
  205. (setq calendar-latitude 44
  206. calendar-longitude -97
  207. calendar-location-name "Hayti, SD")
  208. #+END_SRC
  209. ** Custom Modes
  210. #+BEGIN_SRC emacs-lisp :results silent
  211. (require 'font-lock)
  212. (defvar openhab-mode-hook nil)
  213. (defvar openhab-mode-map
  214. (let ((map (make-keymap)))
  215. (define-key map "\C-j" 'newline-and-indent)
  216. map)
  217. "Keymap for OPENHAB major mode.")
  218. (add-to-list 'auto-mode-alist '("\\.sitemap\\'" . openhab-mode))
  219. (add-to-list 'auto-mode-alist '("\\.items\\'" . openhab-mode))
  220. (add-to-list 'auto-mode-alist '("\\.rules\\'" . openhab-mode))
  221. (add-to-list 'auto-mode-alist '("\\.things\\'" . openhab-mode))
  222. (defconst openhab-font-lock-keywords
  223. `(
  224. ("\<.*\>" . font-lock-constant-face)
  225. (,(regexp-opt
  226. '(
  227. ;; KEYWORDS
  228. "Selection" "Slider" "List" "Setpoint" "Video" "Chart" "Webview" "Colorpicker"
  229. "Timer" "Number" "String"
  230. "Switch" "Rollershutter" "Number" "String" "Dimmer" "Contact" "DateTime" "Color"
  231. "Text" "Group" "Image" "Frame"
  232. "Thing" "Bridge"
  233. "Time" "System"
  234. "sitemap"
  235. "rule" "when" "then" "end"
  236. "if" "val"
  237. "import" "var" "say" "postUpdate" "switch" "println" "case" "or" "sendCommand"
  238. )
  239. 'words)
  240. (1 font-lock-keyword-face))
  241. (,(regexp-opt
  242. '(
  243. "ON" "OFF" "on" "off"
  244. "AND" "OR" "NAND" "NOR" "AVG" "SUM" "MAX" "MIN"
  245. "true" "false"
  246. )
  247. 'words)
  248. (1 font-lock-constant-face))
  249. (,(regexp-opt
  250. '(
  251. "name" "label" "item" "period" "refresh" "icon" "mappings" "minValue" "maxValue" "step" "switchsupport" "url" "height" "refresh" "visibility" "valuecolor"
  252. )
  253. 'words)
  254. (1 font-lock-type-face))
  255. ("\(.*\)" . font-lock-variable-name-face)
  256. ("[^a-zA-Z0-9_:]\\([0-9]*\\)[^a-zA-Z0-9_:]" . (1 font-lock-variable-name-face))
  257. ("\s@\s" . font-lock-variable-name-face)
  258. ("\s\\([a-zA-Z0-9_:]*\\)\\(\s\\|$\\)" . (1 font-lock-type-face))
  259. ("=\\([a-zA-Z_]*\\)" . (1 font-lock-string-face))
  260. ("\\([a-zA-Z]*\\)=" . (1 font-lock-type-face))
  261. )
  262. "The regexps to highlight in openHAB mode.")
  263. (defvar openhab-mode-syntax-table
  264. (let ((st (make-syntax-table)))
  265. (modify-syntax-entry ?/ ". 12b" st) ;; C-style comments // ...
  266. (modify-syntax-entry ?\n "> b" st) ;; \n ends comment
  267. ;; Block comments /*...*/
  268. (modify-syntax-entry ?\/ ". 14" st)
  269. (modify-syntax-entry ?* ". 23" st)
  270. st)
  271. "Syntax table for openhab-mode.")
  272. (defun openhab-mode ()
  273. "Major mode for editing OPENHAB config files."
  274. (interactive)
  275. (kill-all-local-variables)
  276. (set-syntax-table openhab-mode-syntax-table)
  277. (use-local-map openhab-mode-map)
  278. (set (make-local-variable 'font-lock-defaults) '(openhab-font-lock-keywords nil t))
  279. (electric-pair-mode -1)
  280. (flycheck-mode -1)
  281. (setq major-mode 'openhab-mode)
  282. (setq mode-name "OpenHAB")
  283. (run-hooks 'openhab-mode-hook))
  284. (provide 'openhab-mode)
  285. #+END_SRC
  286. ** Custom Packages
  287. *** Hyperspace
  288. #+BEGIN_SRC emacs-lisp :results silent
  289. ;;; hyperspace.el --- Get there from here -*- lexical-binding: t; -*-
  290. ;; Copyright (C) 2017-2019 Ian Eure
  291. ;; Author: Ian Eure <ian@retrospec.tv>
  292. ;; URL: https://github.com/ieure/hyperspace-el
  293. ;; Version: 0.8.4
  294. ;; Package-Requires: ((emacs "25") (s "1.12.0"))
  295. ;; Keywords: tools, convenience
  296. ;; This program is free software; you can redistribute it and/or modify
  297. ;; it under the terms of the GNU General Public License as published by
  298. ;; the Free Software Foundation, either version 3 of the License, or
  299. ;; (at your option) any later version.
  300. ;; This program is distributed in the hope that it will be useful,
  301. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  302. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  303. ;; GNU General Public License for more details.
  304. ;; You should have received a copy of the GNU General Public License
  305. ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
  306. ;;; Commentary:
  307. ;; Hyperspace is a way to get nearly anywhere from wherever you are,
  308. ;; whether that's within Emacs or on the web. It's somewhere in
  309. ;; between Quicksilver and keyword URLs, giving you a single,
  310. ;; consistent interface to get directly where you want to go. It’s
  311. ;; for things that you use often, but not often enough to justify a
  312. ;; dedicated binding.
  313. ;;
  314. ;; When you enter Hyperspace, it prompts you where to go:
  315. ;;
  316. ;; HS:
  317. ;;
  318. ;; This prompt expects a keyword and a query. The keyword picks where
  319. ;; you want to go, and the remainder of the input is an optional
  320. ;; argument which can be used to further search or direct you within
  321. ;; that space.
  322. ;;
  323. ;; Some concrete examples:
  324. ;;
  325. ;; | *If you enter* | *then Hyperspace* |
  326. ;; |------------------+----------------------------------------------------------|
  327. ;; | "el" | opens info node "(elisp)Top" |
  328. ;; | "el eval-region" | searches for "eval-region" in the elisp Info index |
  329. ;; | "bb" | shows all BBDB entries |
  330. ;; | "bb kenneth" | shows all BBDB entries with a name matching "kenneth" |
  331. ;; | "ddg foo" | searches DuckDuckGo for "foo" using browse-url |
  332. ;; | "wp foo" | searches Wikipedia for "foo" using browse-url |
  333. ;;
  334. ;;; Code:
  335. (require 'subr-x)
  336. (require 's)
  337. ;; Action helpers
  338. (defun hyperspace-action->browse-url-pattern (pattern query)
  339. "Browse a URL former from PATTERN and QUERY."
  340. (browse-url (format pattern query)))
  341. (defun hyperspace-action->info (node &optional query)
  342. "Open an Info buffer for NODE.
  343. If QUERY is present, look it up in the index."
  344. (info node)
  345. (when query
  346. (Info-index query)))
  347. ;; Package definitions
  348. (defvar hyperspace-history nil
  349. "History of Hyperspace actions.")
  350. (defgroup hyperspace nil
  351. "Getting there from here"
  352. :prefix "hyperspace-"
  353. :group 'applications)
  354. (defcustom hyperspace-actions
  355. '(("ddg" . "https://duckduckgo.com/?q=%s")
  356. ("dis" . "https://duckduckgo.com/?q=%s&iax=images&ia=images")
  357. ("wp" . "https://en.wikipedia.org/wiki/%s")
  358. ("g" . "https://www.google.com/search?q=%s")
  359. ("gi" . "https://www.google.com/search?tbm=isch&q=%s")
  360. ("gm" . "https://www.google.com/maps/search/%s")
  361. ("yt" . "https://www.youtube.com/results?search_query=%s")
  362. ("clp" . "https://portland.craigslist.org/search/sss?query=%s")
  363. ("eb" . "https://www.ebay.com/sch/i.html?_nkw=%s")
  364. ("nf" . "https://www.netflix.com/search?q=%s")
  365. ("sh" . (lambda (query) (interactive) (shell-command query)))
  366. ("imdb" . "https://www.imdb.com/find?q=peter+jackson&s=all")
  367. ("bb" . bbdb-search-name)
  368. ("el" . (apply-partially #'hyperspace-action->info "(elisp)Top"))
  369. ("av" . apropos-variable)
  370. ("ac" . apropos-command)
  371. ("af" . (lambda (query) (apropos-command query t))))
  372. "Where Hyperspace should send you.
  373. Hyperspace actions are a cons of (KEYWORD . DISPATCHER). When
  374. Hyperspace is invoked, the keyword is extracted from the user
  375. input and looked up in this alist. The remainder of the
  376. string is passed to the dispatcher as its QUERY argument.
  377. DISPATCHER can be a function which performs the action.
  378. DISPATCHER can also be an expression which returns a function
  379. to perform the action.
  380. Finally, DISPATCHER can be a string with a URL pattern containing
  381. '%s'. The '%s' will be replaced with the query, and the URL browsed."
  382. :group 'hyperspace
  383. :type '(alist :key-type (string :tag "Keyword")
  384. :value-type (choice
  385. (function :tag "Function")
  386. (string :tag "URL Pattern")
  387. (sexp :tag "Expression"))))
  388. (defcustom hyperspace-default-action
  389. (caar hyperspace-actions)
  390. "A place to go if you don't specify one."
  391. :group 'hyperspace
  392. :type `(radio
  393. ,@(mapcar (lambda (action) (list 'const (car action))) hyperspace-actions)))
  394. (defcustom hyperspace-max-region-size 256
  395. "Maximum size of a region to consider for a Hyperspace query.
  396. If the region is active when Hyperspace is invoked, it's used
  397. as the default query, unless it's more than this number of
  398. characters."
  399. :group 'hyperspace
  400. :type 'integer)
  401. (defun hyperspace--cleanup (text)
  402. "Clean TEXT so it can be used for a Hyperspace query."
  403. (save-match-data
  404. (string-trim
  405. (replace-regexp-in-string (rx (1+ (or blank "\n"))) " " text))))
  406. (defun hyperspace--initial-text ()
  407. "Return the initial text.
  408. This is whatever's in the active region, but cleaned up."
  409. (when (use-region-p)
  410. (let* ((start (region-beginning))
  411. (end (region-end))
  412. (size (- end start)))
  413. (when (<= size hyperspace-max-region-size)
  414. (hyperspace--cleanup
  415. (buffer-substring-no-properties start end))))))
  416. (defun hyperspace--initial (initial-text)
  417. "Turn INITIAL-TEXT into INITIAL-CONTENTS for reading."
  418. (when initial-text (cons (concat " " initial-text) 1)))
  419. (defun hyperspace--process-input (text)
  420. "Process TEXT into an actionable keyword and query."
  421. (let ((kw-text (s-split-up-to "\\s-+" text 1)))
  422. (if (assoc (car kw-text) hyperspace-actions)
  423. kw-text
  424. (list hyperspace-default-action text))))
  425. (defun hyperspace--query ()
  426. "Ask the user for the Hyperspace action and query.
  427. Returns (KEYWORD . QUERY).
  428. If the region isn't active, the user is prompted for the
  429. action and query.
  430. If the region is active, its text is used as the initial value
  431. for the query, and the user enters the action.
  432. If a prefix argument is specified and the region is active,
  433. `HYPERSPACE-DEFAULT-ACTION' is chosen without prompting."
  434. (let ((initial (hyperspace--initial-text)))
  435. (if (and initial current-prefix-arg)
  436. (list hyperspace-default-action initial)
  437. (hyperspace--process-input
  438. (read-from-minibuffer "HS: " (hyperspace--initial initial) nil nil
  439. 'hyperspace-history)))))
  440. (defun hyperspace--evalable-p (form)
  441. "Can FORM be evaluated?"
  442. (and (listp form)
  443. (or (functionp (car form))
  444. (subrp (car form)))))
  445. (defun hyperspace--dispatch (action &optional query)
  446. "Execute ACTION, with optional QUERY argument."
  447. (pcase action
  448. ((pred functionp) (funcall action query))
  449. ((pred hyperspace--evalable-p) (funcall (eval action) query))
  450. ((pred stringp) (hyperspace-action->browse-url-pattern action query))
  451. (_ (error "Unknown action"))))
  452. ;;;###autoload
  453. (defun hyperspace (keyword &optional query)
  454. "Execute action for keyword KEYWORD, with optional QUERY."
  455. (interactive (hyperspace--query))
  456. (let ((action (cdr (assoc keyword hyperspace-actions))))
  457. (hyperspace--dispatch (or action hyperspace-default-action) query)))
  458. ;;;###autoload
  459. (defun hyperspace-enter (&optional query)
  460. "Enter Hyperspace, sending QUERY to the default action.
  461. If the region is active, use that as the query for
  462. ‘hyperspace-default-action’. Otherwise, prompt the user."
  463. (interactive (list (hyperspace--initial-text)))
  464. (hyperspace
  465. hyperspace-default-action
  466. (or query
  467. (read-from-minibuffer
  468. (format "HS: %s " hyperspace-default-action) nil nil
  469. 'hyperspace-history))))
  470. ;; Minor mode
  471. (defvar hyperspace-minor-mode-map
  472. (let ((kmap (make-sparse-keymap)))
  473. (define-key kmap (kbd "H-SPC") #'hyperspace)
  474. (define-key kmap (kbd "<H-return>") #'hyperspace-enter)
  475. kmap))
  476. ;;;###autoload
  477. (define-minor-mode hyperspace-minor-mode
  478. "Global (universal) minor mode to jump from here to there."
  479. nil nil hyperspace-minor-mode-map
  480. :group 'hyperspace
  481. :global t)
  482. (provide 'hyperspace)
  483. ;;; hyperspace.el ends here
  484. #+END_SRC
  485. ** Tools
  486. *** General
  487. #+BEGIN_SRC emacs-lisp :results silent
  488. (require 'which-key)
  489. (which-key-setup-minibuffer)
  490. (which-key-mode)
  491. (require 'fic-mode)
  492. (add-hook 'js-mode-hook 'fic-mode)
  493. #+END_SRC
  494. *** Company
  495. #+BEGIN_SRC emacs-lisp :results silent
  496. (require 'company)
  497. (add-hook 'after-init-hook 'global-company-mode)
  498. (setq company-dabbrev-downcase nil)
  499. (setq company-idle-delay 0.1)
  500. #+END_SRC
  501. *** Diminish
  502. #+BEGIN_SRC emacs-lisp :results silent
  503. (require 'diminish)
  504. (diminish 'auto-revert-mode)
  505. (eval-after-load "company" '(diminish 'company-mode))
  506. (eval-after-load "counsel" '(diminish 'counsel-mode))
  507. (eval-after-load "elpy" '(diminish 'elpy-mode))
  508. (eval-after-load "go-mode" '(diminish 'go-mode))
  509. (eval-after-load "go-playground" '(diminish 'go-playground-mode))
  510. (eval-after-load "gorepl-mode" '(diminish 'gorepl-mode))
  511. (eval-after-load "flycheck" '(diminish 'flycheck-mode))
  512. (eval-after-load "ivy" '(diminish 'ivy-mode))
  513. (eval-after-load "projectile" '(diminish 'projectile-mode))
  514. (eval-after-load "which-key" '(diminish 'which-key-mode))
  515. #+END_SRC
  516. *** Dired
  517. #+BEGIN_SRC emacs-lisp :results silent
  518. (defun dired-mode-setup ()
  519. "Will run as hook for `dired-mode'."
  520. (dired-hide-details-mode nil))
  521. (add-hook 'dired-mode-hook 'dired-mode-setup)
  522. #+END_SRC
  523. *** Ivy
  524. #+BEGIN_SRC emacs-lisp :results silent
  525. (require 'ivy-hydra)
  526. (require 'ivy)
  527. (require 'swiper)
  528. (ivy-mode 1)
  529. (counsel-mode)
  530. (setq ivy-use-virtual-buffers t
  531. enable-recursive-minibuffers t
  532. ivy-height 25
  533. ivy-initial-inputs-alist nil
  534. ivy-extra-directories nil)
  535. (global-set-key (kbd "C-s") 'swiper)
  536. (global-set-key (kbd "C-c C-r") 'ivy-resume)
  537. (global-set-key (kbd "M-x") 'counsel-M-x)
  538. (global-set-key (kbd "C-x C-f") 'counsel-find-file)
  539. (global-set-key (kbd "C-c g") 'counsel-git)
  540. (global-set-key (kbd "C-c j") 'counsel-git-grep)
  541. (global-set-key (kbd "C-c k") 'counsel-ag)
  542. (define-key minibuffer-local-map (kbd "C-r") 'counsel-minibuffer-history)
  543. (defun ivy-open-current-typed-path ()
  544. (interactive)
  545. (when ivy--directory
  546. (let* ((dir ivy--directory)
  547. (text-typed ivy-text)
  548. (path (concat dir text-typed)))
  549. (delete-minibuffer-contents)
  550. (ivy--done path))))
  551. (define-key ivy-minibuffer-map (kbd "<return>") 'ivy-alt-done)
  552. (define-key ivy-minibuffer-map (kbd "C-f") 'ivy-open-current-typed-path)
  553. #+END_SRC
  554. *** Magit
  555. #+BEGIN_SRC emacs-lisp :results silent
  556. (require 'magit)
  557. (global-set-key (kbd "C-x g") 'magit-status)
  558. (global-set-key (kbd "C-c g") 'magit-status)
  559. (setq magit-completing-read-function 'ivy-completing-read)
  560. #+END_SRC
  561. *** Mu4e
  562. #+BEGIN_SRC emacs-lisp :results silent
  563. (add-to-list 'load-path "/usr/local/share/emacs/site-lisp/mu/mu4e")
  564. (require 'mu4e)
  565. ;; default
  566. (setq mu4e-maildir "~/Mail"
  567. mu4e-mu-binary "/usr/local/bin/mu"
  568. mu4e-change-filenames-when-moving t ;; Rename files when moving (required by mbsync)
  569. mu4e-compose-in-new-frame t ;; New compose gets new frame
  570. mu4e-context-policy 'pick-first
  571. mu4e-get-mail-command "mbsync -a" ;; MBSYNC is the mail cmd
  572. mu4e-html2text-command "/usr/local/bin/w3m -T text/html" ;; HTML to text command
  573. mu4e-headers-include-related nil ;; Stop threading in INBOX
  574. mu4e-sent-messages-behavior 'delete ;; Delete sent messages
  575. mu4e-update-interval 300 ;; 5 mins
  576. mu4e-use-fancy-chars t ;; use 'fancy' chars
  577. mu4e-user-mail-address-list '("lolson@eaglecrk.com"
  578. "lolson@vlocity.com"
  579. "olson.levi@gmail.com")
  580. mu4e-view-show-images t ;; attempt to show images
  581. mu4e-view-image-max-width 400 ;; max image size
  582. message-citation-line-format "On %a %d %b %Y at %R, %f wrote:\n" ;; customize the reply-quote-string
  583. message-citation-line-function 'message-insert-formatted-citation-line ;; choose to use the formatted string
  584. message-kill-buffer-on-exit t ;; don't keep messages around
  585. send-mail-function 'smtpmail-send-it ;; Default email send function
  586. smtpmail-default-smtp-server "smtp.gmail.com"
  587. smtpmail-smtp-service 587
  588. )
  589. (defun leo/convert-message-set-point ()
  590. "Set the point to the start of the message body."
  591. (interactive)
  592. (beginning-of-buffer)
  593. (search-forward "--text follows this line--")
  594. (forward-char)
  595. )
  596. (defun leo/convert-message-from-markdown ()
  597. "Convert a markdown flavored mail buffer to html w/mime support."
  598. (interactive)
  599. (if (y-or-n-p "Convert to HTML? ")
  600. ((leo/convert-message-set-point)
  601. (save-excursion
  602. (message-goto-body)
  603. (shell-command-on-region (point) (point-max) "~/.emacs.d/scripts/expand-mime.sh" nil t)))
  604. (message "Aborting."))
  605. )
  606. (setq mu4e-contexts
  607. `(
  608. ;; ,(make-mu4e-context
  609. ;; :name "Vlocity"
  610. ;; :enter-func (lambda () (mu4e-message "Entering Vlocity"))
  611. ;; :leave-func (lambda () (mu4e-message "Leaving Vlocity"))
  612. ;; ;; we match based on the contact-fields of the message
  613. ;; :match-func (lambda (msg)
  614. ;; (when msg
  615. ;; (string= (mu4e-message-field msg :maildir) "/Vlocity")))
  616. ;; :vars '( ( user-mail-address . "lolson@vlocity.com" )
  617. ;; ( smtpmail-mail-address . "lolson@vlocity.com" )
  618. ;; ( smtpmail-smtp-user . "lolson@vlocity.com" )
  619. ;; ( smtpmail-smtp-server . "smtp.gmail.com" )
  620. ;; ( user-full-name . "Levi Olson" )
  621. ;; ( mu4e-compose-signature .
  622. ;; (concat
  623. ;; "Levi Olson\n"
  624. ;; "Senior UI Developer"))
  625. ;; ( mu4e-sent-folder . "/Vlocity/[Gmail].Sent Mail" )
  626. ;; ( mu4e-drafts-folder . "/Vlocity/[Gmail].Drafts" )
  627. ;; ( mu4e-trash-folder . "/Vlocity/[Gmail].Trash" )
  628. ;; ( mu4e-maildir-shortcuts . (("/Vlocity/INBOX" . ?i)
  629. ;; ("/Vlocity/[Gmail].Sent Mail" . ?s)
  630. ;; ("/Vlocity/[Gmail].Trash" . ?t)
  631. ;; ("/Vlocity/[Gmail].All Mail" . ?a)))))
  632. ,(make-mu4e-context
  633. :name "EagleCreek"
  634. :enter-func (lambda () (mu4e-message "Entering EagleCreek"))
  635. :leave-func (lambda () (mu4e-message "Leaving EagleCreek"))
  636. ;; we match based on the contact-fields of the message
  637. :match-func (lambda (msg)
  638. (when msg
  639. (string= (mu4e-message-field msg :maildir) "/eaglecrk")))
  640. :vars '( ( user-mail-address . "lolson@eaglecrk.com" )
  641. ( smtpmail-mail-address . "lolson@eaglecrk.com" )
  642. ( smtpmail-smtp-user . "lolson@eaglecrk.com" )
  643. ( smtpmail-smtp-server . "smtp.office365.com" )
  644. ( user-full-name . "Levi Olson" )
  645. ;; ( mu4e-compose-signature .
  646. ;; (concat
  647. ;; "Levi Olson\n"
  648. ;; "Eagle Creek Software Services\n"
  649. ;; "Senior Application Developer Consultant\n"))
  650. ( mu4e-sent-folder . "/eaglecrk/Sent Items" )
  651. ( mu4e-drafts-folder . "/eaglecrk/Drafts" )
  652. ( mu4e-trash-folder . "/eaglecrk/Deleted Items" )
  653. ( mu4e-maildir-shortcuts . (("/eaglecrk/Inbox" . ?i)
  654. ("/eaglecrk/Sent Items" . ?s)
  655. ("/eaglecrk/Deleted Items" . ?t)
  656. ("/eaglecrk/Archive" . ?a)))))
  657. ;; ,(make-mu4e-context
  658. ;; :name "Gmail"
  659. ;; :enter-func (lambda () (mu4e-message "Entering Gmail"))
  660. ;; :leave-func (lambda () (mu4e-message "Leaving Gmail"))
  661. ;; ;; this matches maildir /Arkham and its sub-directories
  662. ;; :match-func (lambda (msg)
  663. ;; (when msg
  664. ;; (string= (mu4e-message-field msg :maildir) "/Gmail")))
  665. ;; :vars '( ( user-mail-address . "olson.levi@gmail.com" )
  666. ;; ( smtpmail-mail-address . "olson.levi@gmail.com" )
  667. ;; ( smtpmail-smtp-user . "olson.levi@gmail.com" )
  668. ;; ( smtpmail-smtp-server . "smtp.gmail.com" )
  669. ;; ( user-full-name . "Levi Olson" )
  670. ;; ( mu4e-compose-signature .
  671. ;; (concat
  672. ;; "Levi\n"))
  673. ;; ( mu4e-sent-folder . "/Gmail/[Gmail].Sent Mail" )
  674. ;; ( mu4e-drafts-folder . "/Gmail/[Gmail].Drafts" )
  675. ;; ( mu4e-trash-folder . "/Gmail/[Gmail].Trash" )
  676. ;; ( mu4e-maildir-shortcuts . (("/Gmail/INBOX" . ?i)
  677. ;; ("/Gmail/[Gmail].Sent Mail" . ?s)
  678. ;; ("/Gmail/[Gmail].Trash" . ?t)
  679. ;; ("/Gmail/[Gmail].All Mail" . ?a))
  680. ;; )))
  681. ))
  682. ;; Add option to view HTML in browser
  683. (add-to-list 'mu4e-headers-actions
  684. '("in browser" . mu4e-action-view-in-browser) t)
  685. (add-to-list 'mu4e-view-actions
  686. '("in browser" . mu4e-action-view-in-browser) t)
  687. (defun my-message-current-line-cited-p ()
  688. "Indicate whether the line at point is a cited line."
  689. (save-match-data
  690. (string-match (concat "^" message-cite-prefix-regexp)
  691. (buffer-substring (line-beginning-position) (line-end-position)))))
  692. (defun my-message-says-attachment-p ()
  693. "Return t if the message suggests there can be an attachment."
  694. (save-excursion
  695. (goto-char (point-min))
  696. (save-match-data
  697. (let (search-result)
  698. (while
  699. (and (setq search-result (re-search-forward "\\(attach\\|pdf\\|file\\)" nil t))
  700. (my-message-current-line-cited-p)))
  701. search-result))))
  702. (defun my-message-has-attachment-p ()
  703. "Return t if the message has an attachment."
  704. (save-excursion
  705. (goto-char (point-min))
  706. (save-match-data
  707. (re-search-forward "<#part" nil t))))
  708. (defun my-message-pre-send-check-attachment ()
  709. (when (and (my-message-says-attachment-p)
  710. (not (my-message-has-attachment-p)))
  711. (unless
  712. (y-or-n-p "No attachment. Send anyway?")
  713. (error "It seems that an attachment is needed, but none was found. Aborting sending."))))
  714. (add-hook 'message-send-hook 'my-message-pre-send-check-attachment)
  715. #+END_SRC
  716. *** Projectile
  717. #+BEGIN_SRC emacs-lisp :results silent
  718. (require 'projectile)
  719. (require 'counsel-projectile)
  720. (projectile-mode)
  721. (setq projectile-mode-line '(:eval (format " %s" (projectile-project-name)))
  722. projectile-remember-window-configs t
  723. projectile-completion-system 'ivy)
  724. (counsel-projectile-mode)
  725. #+END_SRC
  726. *** Notify
  727. #+BEGIN_SRC emacs-lisp :results silent
  728. ;;; notify.el --- notification front-end
  729. ;; Copyright (C) 2008 Mark A. Hershberger
  730. ;; Original Author: Mark A. Hershberger <mhersberger@intrahealth.org>
  731. ;; Modified by Andrey Kotlarski <m00naticus@gmail.com>
  732. ;; Modified by Andrew Gwozdziewycz <git@apgwoz.com>
  733. ;; Modified by Aidan Gauland <aidalgol@no8wireless.co.nz> October 2011
  734. ;; Modified by Olivier Sirven <the.slaa@gmail.com> November 2013
  735. ;; Keywords: extensions, convenience, lisp
  736. ;; This file is free software; you can redistribute it and/or modify
  737. ;; it under the terms of the GNU General Public License as published by
  738. ;; the Free Software Foundation; either version 2, or (at your option)
  739. ;; any later version.
  740. ;; This file is distributed in the hope that it will be useful,
  741. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  742. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  743. ;; GNU General Public License for more details.
  744. ;; You should have received a copy of the GNU General Public License
  745. ;; along with GNU Emacs; see the file COPYING. If not, write to
  746. ;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  747. ;; Boston, MA 02111-1307, USA.
  748. ;;; Commentary:
  749. ;; This provides a single function, `notify', that will produce a notify
  750. ;; pop-up via D-Bus, libnotify, simple message or growl.
  751. ;; To use, just put (autoload 'notify "notify" "Notify TITLE, BODY.")
  752. ;; in your init file. You may override default chosen notification
  753. ;; method by assigning `notify-method' to one of 'notify-via-dbus
  754. ;; 'notify-via-libnotify or 'notify-via-message
  755. ;;; Code:
  756. (defvar notify-defaults (list :app "Emacs" :icon "emacs" :timeout 5000
  757. :urgency "low"
  758. :category "emacs.message")
  759. "Notification settings' defaults.
  760. May be overridden with key-value additional arguments to `notify'.")
  761. (defvar notify-delay '(0 5 0)
  762. "Minimum time allowed between notifications in time format.")
  763. (defvar notify-last-notification '(0 0 0) "Time of last notification.")
  764. (defvar notify-method 'notify-via-growl "Notification method among
  765. 'notify-via-dbus, 'notify-via-libnotify, 'notify-via-message or
  766. 'notify-via-growl")
  767. ;; determine notification method unless already set
  768. ;; prefer growl > D-Bus > libnotify > message
  769. (cond
  770. ((null notify-method)
  771. (setq notify-method
  772. (cond
  773. ((executable-find "growlnotify") 'notify-via-growl)
  774. ((and (require 'dbus nil t)
  775. (dbus-ping :session "org.freedesktop.Notifications"))
  776. (defvar notify-id 0 "Current D-Bus notification id.")
  777. 'notify-via-dbus)
  778. ((executable-find "notify-send") 'notify-via-libnotify)
  779. (t 'notify-via-message))))
  780. ((eq notify-method 'notify-via-dbus) ;housekeeping for pre-chosen DBus
  781. (if (and (require 'dbus nil t)
  782. (dbus-ping :session "org.freedesktop.Notifications"))
  783. (defvar notify-id 0 "Current D-Bus notification id.")
  784. (setq notify-method (if (executable-find "notify-send")
  785. 'notify-via-libnotify
  786. 'notify-via-message))))
  787. ((and (eq notify-method 'notify-via-libnotify)
  788. (not (executable-find "notify-send"))) ;housekeeping for pre-chosen libnotify
  789. (setq notify-method
  790. (if (and (require 'dbus nil t)
  791. (dbus-ping :session "org.freedesktop.Notifications"))
  792. (progn
  793. (defvar notify-id 0 "Current D-Bus notification id.")
  794. 'notify-via-dbus)
  795. 'notify-via-message)))
  796. ((and (eq notify-method 'notify-via-growl)
  797. (not (executable-find "growlnotify")))
  798. (setq notify-method 'notify-via-message)))
  799. (defun notify-via-dbus (title body)
  800. "Send notification with TITLE, BODY `D-Bus'."
  801. (dbus-call-method :session "org.freedesktop.Notifications"
  802. "/org/freedesktop/Notifications"
  803. "org.freedesktop.Notifications" "Notify"
  804. (get 'notify-defaults :app)
  805. (setq notify-id (+ notify-id 1))
  806. (get 'notify-defaults :icon) title body '(:array)
  807. '(:array :signature "{sv}") ':int32
  808. (get 'notify-defaults :timeout)))
  809. (defun notify-via-libnotify (title body)
  810. "Notify with TITLE, BODY via `libnotify'."
  811. (call-process "notify-send" nil 0 nil
  812. title body "-t"
  813. (number-to-string (get 'notify-defaults :timeout))
  814. "-i" (get 'notify-defaults :icon)
  815. "-u" (get 'notify-defaults :urgency)
  816. "-c" (get 'notify-defaults :category)))
  817. (defun notify-via-message (title body)
  818. "Notify TITLE, BODY with a simple message."
  819. (message "%s: %s" title body))
  820. (defun notify-via-growl (title body)
  821. "Notify TITLE, BODY with a growl"
  822. (call-process "growlnotify" nil 0 nil
  823. "-a" (get 'notify-defaults :app)
  824. "-n" (get 'notify-defaults :category)
  825. "-t" (notify-via-growl-stringify title)
  826. "-m" (notify-via-growl-stringify body)))
  827. (defun notify-via-growl-stringify (thing)
  828. (cond ((null thing) "")
  829. ((stringp thing) thing)
  830. (t (format "%s" thing))))
  831. (defun keywords-to-properties (symbol args &optional defaults)
  832. "Add to SYMBOL's property list key-values from ARGS and DEFAULTS."
  833. (when (consp defaults)
  834. (keywords-to-properties symbol defaults))
  835. (while args
  836. (put symbol (car args) (cadr args))
  837. (setq args (cddr args))))
  838. ;;;###autoload
  839. (defun notify (title body &rest args)
  840. "Notify TITLE, BODY via `notify-method'.
  841. ARGS may be amongst :timeout, :icon, :urgency, :app and :category."
  842. (when (time-less-p notify-delay
  843. (time-since notify-last-notification))
  844. (or (eq notify-method 'notify-via-message)
  845. (keywords-to-properties 'notify-defaults args
  846. notify-defaults))
  847. (setq notify-last-notification (current-time))
  848. (funcall notify-method title body)))
  849. (provide 'notify)
  850. ;;; notify.el ends here
  851. #+END_SRC
  852. *** Jabber
  853. #+BEGIN_SRC emacs-lisp :results silent
  854. (require 'jabber)
  855. (setq jabber-history-enabled t
  856. jabber-use-global-history nil
  857. jabber-backlog-number 40
  858. jabber-backlog-days 30
  859. jabber-alert-presence-message-function (lambda (_who _oldstatus _newstatus _statustext) nil)
  860. )
  861. (setq jabber-account-list '(
  862. ;; ("olson.levi@gmail.com"
  863. ;; (:network-server . "talk.google.com")
  864. ;; (:connection-type . ssl))
  865. ("lolson@vlocity.com"
  866. (:network-server . "talk.google.com")
  867. (:connection-type . ssl))
  868. ))
  869. (defvar my-chat-prompt "[%t] %n>\n" "Customized chat prompt")
  870. (when (featurep 'jabber)
  871. (setq
  872. jabber-chat-foreign-prompt-format my-chat-prompt
  873. jabber-chat-local-prompt-format my-chat-prompt
  874. jabber-groupchat-prompt-format my-chat-prompt
  875. jabber-muc-private-foreign-prompt-format "[%t] %g/%n>\n"
  876. )
  877. )
  878. (defun notify-jabber-notify (from buf text _proposed-alert)
  879. "(jabber.el hook) Notify of new Jabber chat messages via notify.el"
  880. (when (or jabber-message-alert-same-buffer
  881. (not (memq (selected-window) (get-buffer-window-list buf))))
  882. (if (jabber-muc-sender-p from)
  883. (notify (format "(PM) %s"
  884. (jabber-jid-displayname (jabber-jid-user from)))
  885. (format "%s: %s" (jabber-jid-resource from) text)))
  886. (notify (format "%s" (jabber-jid-displayname from))
  887. text)))
  888. ;; (add-hook 'jabber-alert-message-hooks 'notify-jabber-notify)
  889. ;; (require 'autosmiley)
  890. ;; (add-hook 'jabber-chat-mode-hook 'autosmiley-mode)
  891. (defun jabber ()
  892. (interactive)
  893. (jabber-connect-all)
  894. (switch-to-buffer "*-jabber-roster-*"))
  895. #+END_SRC
  896. *** Terminal-Notifier
  897. #+BEGIN_SRC emacs-lisp :results silent :tangle no
  898. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  899. ;; Terminal notifier
  900. ;; requires 'brew install terminal-notifier'
  901. ;; stolen from erc-notifier
  902. (defvar terminal-notifier-command (executable-find "terminal-notifier") "The path to terminal-notifier.")
  903. ; (terminal-notifier-notify "Emacs notification" "Something amusing happened")
  904. (defun terminal-notifier-notify (title message)
  905. "Show a message with
  906. terminal-notifier-command
  907. ."
  908. (start-process "terminal-notifier"
  909. "terminal-notifier"
  910. terminal-notifier-command
  911. "-title" title
  912. "-message" message
  913. "-activate" "org.gnu.Emacs"))
  914. (defun timed-notification (time msg)
  915. (interactive "sNotification when (e.g: 2 minutes, 60 seconds, 3 days): \nsMessage: ")
  916. (run-at-time time nil (lambda (msg) (terminal-notifier-notify "Emacs" msg)) msg))
  917. #+END_SRC
  918. *** Hyperspace
  919. #+BEGIN_SRC emacs-lisp :results silent
  920. (defun hyperspace-action->mu4e (&optional query)
  921. "Search mu4e with QUERY.
  922. If QUERY is unspecified, use the first bookmark in variable
  923. ‘mu4e-bookmarks’ and update mail and index."
  924. (mu4e-headers-search (or query (caar mu4e-bookmarks)))
  925. (unless query
  926. (mu4e-update-mail-and-index nil)))
  927. (add-to-list 'hyperspace-actions '("m4" . hyperspace-action->mu4e))
  928. (defun hyperspace-action->elfeed (&optional query)
  929. "Load elfeed, optionally searching for QUERY."
  930. (elfeed)
  931. (if query
  932. (elfeed-search-set-filter query)
  933. (elfeed-search-fetch nil)))
  934. (add-to-list 'hyperspace-actions '("lf" . hyperspace-action->elfeed))
  935. #+END_SRC
  936. ** Development Specific
  937. *** General
  938. #+BEGIN_SRC emacs-lisp :results silent
  939. (require 'rainbow-delimiters)
  940. (global-flycheck-mode)
  941. (add-hook 'before-save-hook 'delete-trailing-whitespace)
  942. (add-hook 'prog-mode-hook 'rainbow-delimiters-mode)
  943. (setq-default indent-tabs-mode nil
  944. tab-width 4)
  945. (defvaralias 'c-basic-offset 'tab-width)
  946. (defvaralias 'cperl-indent-level 'tab-width)
  947. (electric-pair-mode 1)
  948. (show-paren-mode 1)
  949. (require 'dockerfile-mode)
  950. (add-to-list 'auto-mode-alist '("Dockerfile*\\'" . dockerfile-mode))
  951. (require 'gitignore-mode)
  952. (add-to-list 'auto-mode-alist '("gitignore\\'" . gitignore-mode))
  953. (require 'json-mode)
  954. (add-to-list 'auto-mode-alist '("\\.json\\'" . json-mode))
  955. (require 'web-mode)
  956. (add-to-list 'auto-mode-alist '("\\.html\\'" . web-mode))
  957. #+END_SRC
  958. *** Python
  959. #+BEGIN_SRC emacs-lisp :results silent
  960. (elpy-enable)
  961. (setq python-shell-interpreter "jupyter"
  962. python-shell-interpreter-args "console --simple-prompt")
  963. (when (require 'flycheck nil t)
  964. (setq elpy-modules (delq 'elpy-module-flymake elpy-modules))
  965. (add-hook 'elpy-mode-hook 'flycheck-mode))
  966. (require 'py-autopep8)
  967. (setq py-autopep8-options '("--ignore=E501"))
  968. (add-hook 'elpy-mode-hook 'py-autopep8-enable-on-save)
  969. #+END_SRC
  970. *** Go
  971. #+BEGIN_SRC emacs-lisp :results silent
  972. (require 'go-mode)
  973. (require 'go-playground)
  974. (require 'gorepl-mode)
  975. (require 'company-go)
  976. (add-to-list 'auto-mode-alist '("\\.go\\'" . go-mode))
  977. (add-hook 'go-mode-hook (lambda ()
  978. (add-hook 'before-save-hook 'gofmt-before-save)
  979. (local-set-key (kbd "M-.") 'godef-jump)
  980. (local-set-key (kbd "M-,") 'pop-tag-mark)
  981. (local-set-key (kbd "C-c C-c") (lambda ()
  982. (interactive)
  983. (ansi-term)
  984. (comint-send-string "*ansi-term*" "make\n")))
  985. (set (make-local-variable 'company-backends) '(company-go))
  986. (setq company-tooltip-limit 20
  987. company-echo-delay 0
  988. company-begin-commands '(self-insert-command))
  989. (gorepl-mode)))
  990. (defun set-exec-path-from-shell-PATH ()
  991. (let ((path-from-shell (replace-regexp-in-string
  992. "[ \t\n]*$"
  993. ""
  994. (shell-command-to-string "$SHELL --login -i -c 'echo $PATH'"))))
  995. (setenv "PATH" path-from-shell)
  996. (setq eshell-path-env path-from-shell)
  997. (setq exec-path (split-string path-from-shell path-separator))))
  998. (when window-system (set-exec-path-from-shell-PATH))
  999. (setenv "GOPATH" "/Users/leviolson/go")
  1000. (add-to-list 'exec-path "/Users/leviolson/go/bin")
  1001. #+END_SRC
  1002. *** TypeScript
  1003. #+BEGIN_SRC emacs-lisp :results silent
  1004. (defun setup-tide-mode ()
  1005. "Tide setup function."
  1006. (interactive)
  1007. (tide-setup)
  1008. (flycheck-mode +1)
  1009. (setq flycheck-check-syntax-automatically '(save mode-enabled))
  1010. (eldoc-mode +1)
  1011. (tide-hl-identifier-mode +1)
  1012. (company-mode +1))
  1013. ;; aligns annotation to the right hand side
  1014. (setq company-tooltip-align-annotations t)
  1015. ;; formats the buffer before saving
  1016. (add-hook 'before-save-hook 'tide-format-before-save)
  1017. (add-hook 'typescript-mode-hook #'setup-tide-mode)
  1018. (require 'typescript-mode)
  1019. (require 'tide)
  1020. (add-to-list 'auto-mode-alist '("\\.ts\\'" . typescript-mode))
  1021. (add-hook 'typescript-mode-hook
  1022. '(lambda ()
  1023. (set (make-local-variable 'company-backends) '(company-tide))
  1024. (setq company-tooltip-limit 20
  1025. company-echo-delay 0
  1026. company-begin-commands '(self-insert-command)
  1027. tide-format-options '(:insertSpaceAfterFunctionKeywordForAnonymousFunctions t :placeOpenBraceOnNewLineForFunctions nil))
  1028. (tide-setup)))
  1029. #+END_SRC
  1030. **** TSX
  1031. #+BEGIN_SRC emacs-lisp :results silent
  1032. (require 'web-mode)
  1033. (add-to-list 'auto-mode-alist '("\\.tsx\\'" . web-mode))
  1034. (add-hook 'web-mode-hook
  1035. (lambda ()
  1036. (when (string-equal "tsx" (file-name-extension buffer-file-name))
  1037. (setup-tide-mode))))
  1038. ;; enable typescript-tslint checker
  1039. (flycheck-add-mode 'typescript-tslint 'web-mode)
  1040. #+END_SRC
  1041. **** JSX
  1042. #+BEGIN_SRC emacs-lisp :results silent
  1043. (require 'web-mode)
  1044. (add-to-list 'auto-mode-alist '("\\.jsx\\'" . web-mode))
  1045. (add-hook 'web-mode-hook
  1046. (lambda ()
  1047. (when (string-equal "jsx" (file-name-extension buffer-file-name))
  1048. (setup-tide-mode))))
  1049. ;; configure jsx-tide checker to run after your default jsx checker
  1050. (flycheck-add-mode 'javascript-eslint 'web-mode)
  1051. (flycheck-add-next-checker 'javascript-eslint 'jsx-tide 'append)
  1052. #+END_SRC
  1053. *** Org
  1054. #+BEGIN_SRC emacs-lisp :results silent
  1055. (org-babel-do-load-languages
  1056. 'org-babel-load-languages
  1057. '((js . t)
  1058. (shell . t)
  1059. (emacs-lisp . t)))
  1060. (setq org-todo-keywords
  1061. '((sequence "TODO(t)" "|" "DONE(d)")
  1062. (sequence "BUG(b)" "|" "INPROGRESS(i)" "FIXED(f)")
  1063. (sequence "|" "CANCELED(c)")
  1064. (sequence "|" "NEEDCLARIFICATION(n)")
  1065. (sequence "|" "PROVIDEUPDATE(p)")
  1066. (sequence "|" "WAITING(w)")
  1067. ))
  1068. (setq org-agenda-files
  1069. '("~/Dropbox/Org/todo.org" "~/Dropbox/Org/archive.org"))
  1070. (setq org-refile-targets
  1071. '((nil :maxlevel . 1)
  1072. (org-agenda-files :maxlevel . 1)))
  1073. (add-hook 'focus-in-hook
  1074. (lambda () (progn
  1075. (setq org-tags-column (- 5 (frame-width)))) (org-align-all-tags)))
  1076. (add-hook 'focus-out-hook
  1077. (lambda () (progn
  1078. (setq org-tags-column (- 5 (frame-width)))) (org-align-all-tags)))
  1079. (defvar org-src-tab-acts-natively)
  1080. (setq org-src-tab-acts-natively t)
  1081. ;; (setenv "NODE_PATH"
  1082. ;; (getenv "NODE_PATH"))
  1083. (defvar org-confirm-babel-evaluate)
  1084. (defun my-org-confirm-babel-evaluate (lang _body)
  1085. "Execute certain languages without confirming.
  1086. Takes LANG to allow and BODY to execute."
  1087. (not (or (string= lang "js")
  1088. (string= lang "restclient")
  1089. (string= lang "emacs-lisp")
  1090. (string= lang "shell"))))
  1091. (setq org-confirm-babel-evaluate #'my-org-confirm-babel-evaluate)
  1092. (add-to-list 'org-structure-template-alist
  1093. (list "e" (concat "#+BEGIN_SRC emacs-lisp :results silent\n"
  1094. "\n"
  1095. "#+END_SRC")))
  1096. (add-to-list 'org-structure-template-alist
  1097. (list "j" (concat "#+BEGIN_SRC js :cmd \"babel-node\"\n"
  1098. "\n"
  1099. "#+END_SRC")))
  1100. (add-to-list 'org-structure-template-alist
  1101. (list "r" (concat "#+BEGIN_SRC restclient :results raw\n"
  1102. "\n"
  1103. "#+END_SRC")))
  1104. #+END_SRC
  1105. **** Mu4e
  1106. #+BEGIN_SRC emacs-lisp :results silent
  1107. ;;store org-mode links to messages
  1108. (require 'org-mu4e)
  1109. ;;store link to message if in header view, not to header query
  1110. (setq org-mu4e-link-query-in-headers-mode nil)
  1111. (setq org-capture-templates
  1112. '(("t" "todo" entry (file+headline "~/todo.org" "Tasks")
  1113. "* TODO [#A] %?\nSCHEDULED: %(org-insert-time-stamp (org-read-date nil t \"+0d\"))\n%a\n")))
  1114. #+END_SRC
  1115. **** ElFeed
  1116. #+BEGIN_SRC emacs-lisp :results silent
  1117. (elfeed-org)
  1118. (setq rmh-elfeed-org-files (list "~/Dropbox/Org/elfeed.org"))
  1119. (defun leo/elfeed-search (arg)
  1120. "Search for ARG in feed."
  1121. (interactive)
  1122. (elfeed-search-set-filter arg))
  1123. (define-key elfeed-search-mode-map "a" (lambda () (interactive) (leo/elfeed-search "")))
  1124. (define-key elfeed-search-mode-map "e" (lambda () (interactive) (leo/elfeed-search "+emacs")))
  1125. (define-key elfeed-search-mode-map "d" (lambda () (interactive) (leo/elfeed-search "+daily")))
  1126. (define-key elfeed-search-mode-map "x" (lambda () (interactive) (leo/elfeed-search "xkcd")))
  1127. #+End_SRC
  1128. ** Functions
  1129. #+BEGIN_SRC emacs-lisp :results silent
  1130. (defun find-user-init-file ()
  1131. "Edit the `~/.emacs.d/init.org' file."
  1132. (interactive)
  1133. (find-file "~/.emacs.d/init.org"))
  1134. (defun find-todo-file ()
  1135. "Edit the `~/todo.org' file."
  1136. (interactive)
  1137. (find-file "~/Dropbox/Org/todo.org"))
  1138. (defun load-user-init-file ()
  1139. "LO: Reload the `~/.emacs.d/init.elc' file."
  1140. (interactive)
  1141. (load-file "~/.emacs.d/init.elc"))
  1142. (defun jump-to-symbol-internal (&optional backwardp)
  1143. "Jumps to the next symbol near the point if such a symbol exists. If BACKWARDP is non-nil it jumps backward."
  1144. (let* ((point (point))
  1145. (bounds (find-tag-default-bounds))
  1146. (beg (car bounds)) (end (cdr bounds))
  1147. (str (isearch-symbol-regexp (find-tag-default)))
  1148. (search (if backwardp 'search-backward-regexp
  1149. 'search-forward-regexp)))
  1150. (goto-char (if backwardp beg end))
  1151. (funcall search str nil t)
  1152. (cond ((<= beg (point) end) (goto-char point))
  1153. (backwardp (forward-char (- point beg)))
  1154. (t (backward-char (- end point))))))
  1155. (defun jump-to-previous-like-this ()
  1156. "Jumps to the previous occurrence of the symbol at point."
  1157. (interactive)
  1158. (jump-to-symbol-internal t))
  1159. (defun jump-to-next-like-this ()
  1160. "Jumps to the next occurrence of the symbol at point."
  1161. (interactive)
  1162. (jump-to-symbol-internal))
  1163. (defun match-paren (arg)
  1164. "Go to the matching paren if on a paren; otherwise insert ARG (a literal % sign)."
  1165. (interactive "p")
  1166. (cond ((looking-at "\\s(") (forward-list 1))
  1167. ((looking-back "\\s(" 2) (backward-char 1) (forward-list 1))
  1168. ((looking-at "\\s)") (forward-char 1) (backward-list 1))
  1169. ((looking-back "\\s)" 2) (backward-list 1))
  1170. (t (self-insert-command (or arg 1)))))
  1171. (defun kill-this-buffer-unless-scratch ()
  1172. "Works like `kill-this-buffer' unless the current buffer is the *scratch* buffer. In which case the buffer content is deleted and the buffer is buried."
  1173. (interactive)
  1174. (if (not (string= (buffer-name) "*scratch*"))
  1175. (kill-this-buffer)
  1176. (delete-region (point-min) (point-max))
  1177. (switch-to-buffer (other-buffer))
  1178. (bury-buffer "*scratch*")))
  1179. (defun delete-backward-sentence ()
  1180. "LO: Delete to the beginning of the sentence/line."
  1181. (interactive)
  1182. (delete-region (point) (progn (backward-sentence) (point))))
  1183. (defun delete-backward-to-boundary (arg)
  1184. "LO: Delete backward to the previous word boundary. With ARG, do this many times."
  1185. (interactive "p")
  1186. (let ((a (point))
  1187. (b (progn
  1188. (backward-word arg)
  1189. (forward-word)
  1190. (point))))
  1191. (if (< a b)
  1192. (delete-region a (progn (backward-word arg) (point)))
  1193. (if (= a b)
  1194. (delete-region a (progn (backward-word arg) (point)))
  1195. (delete-region a b)))))
  1196. (defun comment-or-uncomment-region-or-line ()
  1197. "Comments or uncomments the region or the current line if there's no active region."
  1198. (interactive)
  1199. (let (beg end)
  1200. (if (region-active-p)
  1201. (setq beg (region-beginning) end (region-end))
  1202. (setq beg (line-beginning-position) end (line-end-position)))
  1203. (comment-or-uncomment-region beg end)))
  1204. (defun fold-toggle (column)
  1205. "Code folding by COLUMN."
  1206. (interactive "P")
  1207. (set-selective-display
  1208. (or column
  1209. (unless selective-display
  1210. (1+ (current-column))))))
  1211. (defun new-line-below ()
  1212. "LO: Create a new line below current line."
  1213. (interactive)
  1214. (move-end-of-line 1)
  1215. (newline-and-indent))
  1216. (defun new-line-above ()
  1217. "LO: Create a new line above current line."
  1218. (interactive)
  1219. (move-beginning-of-line 1)
  1220. (newline)
  1221. (forward-line -1))
  1222. (defun duplicate-thing (comment)
  1223. "LO: Duplicates the current line, or the region if active. If an argument (COMMENT) is given, the duplicated region will be commented out."
  1224. (interactive "P")
  1225. (save-excursion
  1226. (let ((start (if (region-active-p) (region-beginning) (point-at-bol)))
  1227. (end (if (region-active-p) (region-end) (point-at-eol))))
  1228. (goto-char end)
  1229. (unless (region-active-p)
  1230. (newline))
  1231. (insert (buffer-substring start end))
  1232. (when comment (comment-region start end)))))
  1233. (defun tidy ()
  1234. "LO: Ident, untabify and unwhitespacify current buffer, or region if active."
  1235. (interactive)
  1236. (let ((beg (if (region-active-p) (region-beginning) (point-min)))
  1237. (end (if (region-active-p) (region-end) (point-max))))
  1238. (let ((inhibit-message t))
  1239. (indent-region beg end))
  1240. (whitespace-cleanup)
  1241. (untabify beg (if (< end (point-max)) end (point-max)))
  1242. (if (region-active-p) (message "Indenting Region...Done") (message "Indenting File...Done"))))
  1243. (defun phil-columns ()
  1244. "LO: Good 'ol Phil-Columns."
  1245. (interactive)
  1246. (message "Good 'ol fill-columns")
  1247. (with-output-to-temp-buffer "*PHIL-COLUMN*"
  1248. (shell-command "mpv --no-video 'https://www.youtube.com/watch?v=YkADj0TPrJA&t=3m16s' > /dev/null 2>&1 & sleep 8; pkill mpv"))
  1249. (other-window 1)
  1250. (delete-window))
  1251. (declare-function first "Goto FIRST shell.")
  1252. (declare-function goto-non-shell-buffer "Goto something other than a shell buffer.")
  1253. (declare-function switch-shell "Switch shell.")
  1254. (let ((last-shell ""))
  1255. (defun toggle-shell ()
  1256. (interactive)
  1257. (cond ((string-match-p "^\\*shell<[1-9][0-9]*>\\*$" (buffer-name))
  1258. (goto-non-shell-buffer))
  1259. ((get-buffer last-shell) (switch-to-buffer last-shell))
  1260. (t (shell (setq last-shell "*shell<1>*")))))
  1261. (defun switch-shell (n)
  1262. (let ((buffer-name (format "*shell<%d>*" n)))
  1263. (setq last-shell buffer-name)
  1264. (cond ((get-buffer buffer-name)
  1265. (switch-to-buffer buffer-name))
  1266. (t (shell buffer-name)
  1267. (rename-buffer buffer-name)))))
  1268. (defun goto-non-shell-buffer ()
  1269. (let* ((r "^\\*shell<[1-9][0-9]*>\\*$")
  1270. (shell-buffer-p (lambda (b) (string-match-p r (buffer-name b))))
  1271. (non-shells (cl-remove-if shell-buffer-p (buffer-list))))
  1272. (when non-shells
  1273. (switch-to-buffer (first non-shells))))))
  1274. (defadvice shell (after kill-with-no-query nil activate)
  1275. "."
  1276. (set-process-query-on-exit-flag (get-buffer-process ad-return-value) nil))
  1277. (declare-function comint-truncate-buffer ".")
  1278. (defun clear-comint ()
  1279. "Run `comint-truncate-buffer' with the `comint-buffer-maximum-size' set to zero."
  1280. (interactive)
  1281. (let ((comint-buffer-maximum-size 0))
  1282. (comint-truncate-buffer)))
  1283. (defun c-setup ()
  1284. "Compile."
  1285. (local-set-key (kbd "C-c C-c") 'compile))
  1286. #+END_SRC
  1287. ** Bindings
  1288. #+begin_src emacs-lisp :results silent
  1289. (require 'company)
  1290. (add-hook 'comint-mode-hook (lambda () (local-set-key (kbd "c-l") 'clear-comint)))
  1291. (add-hook 'emacs-lisp-mode-hook 'turn-on-eldoc-mode)
  1292. (add-hook 'lisp-interaction-mode-hook 'turn-on-eldoc-mode)
  1293. (add-hook 'c-mode-common-hook 'c-setup)
  1294. (add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode))
  1295. (defvar company-active-map (make-keymap)
  1296. "company mode keymap.")
  1297. (defvar custom-bindings (make-keymap)
  1298. "a keymap of custom bindings.")
  1299. (define-key custom-bindings (kbd "M-p") 'jump-to-previous-like-this)
  1300. (define-key custom-bindings (kbd "M-n") 'jump-to-next-like-this)
  1301. (define-key custom-bindings (kbd "M-<tab>") 'switch-to-next-buffer)
  1302. (define-key custom-bindings (kbd "M-<backspace>")'delete-backward-to-boundary)
  1303. (define-key custom-bindings (kbd "C-<backspace>")'delete-backward-to-boundary)
  1304. (define-key custom-bindings (kbd "C-}") 'mc/mark-next-like-this)
  1305. (define-key custom-bindings (kbd "C-)") 'mc/unmark-next-like-this)
  1306. (define-key custom-bindings (kbd "C-{") 'mc/mark-previous-like-this)
  1307. (define-key custom-bindings (kbd "C-(") 'mc/unmark-previous-like-this)
  1308. (define-key custom-bindings (kbd "C-'") 'mc-hide-unmatched-lines-mode)
  1309. (define-key custom-bindings (kbd "C-c 1") 'mc/insert-numbers)
  1310. (define-key custom-bindings (kbd "C-c s") 'mc/sort-regions)
  1311. (define-key custom-bindings "%" 'match-paren)
  1312. (define-key custom-bindings (kbd "C-x .") 'dash-at-point)
  1313. (define-key custom-bindings (kbd "C-x ,") 'dash-at-point-with-docset)
  1314. (define-key custom-bindings (kbd "C-s") (lambda () (interactive) (swiper (format "%s" (thing-at-point 'symbol)))))
  1315. (define-key custom-bindings (kbd "C-x C-l m") 'mu4e)
  1316. (define-key custom-bindings (kbd "C-x C-o t") 'find-todo-file)
  1317. (define-key custom-bindings (kbd "C-x C-l j") 'jabber)
  1318. (define-key custom-bindings (kbd "C-x C-l f") 'elfeed)
  1319. (define-key custom-bindings (kbd "C-x C-l a") 'org-agenda)
  1320. (define-key custom-bindings (kbd "C-x C-l c") 'calendar)
  1321. (define-key custom-bindings (kbd "M-SPC") #'hyperspace)
  1322. ;; (dolist (n (number-sequence 1 9))
  1323. ;; (global-set-key (kbd (concat "M-" (int-to-string n)))
  1324. ;; (lambda () (interactive) (switch-shell n))))
  1325. (define-key company-active-map (kbd "C-d") 'company-show-doc-buffer)
  1326. (define-key company-active-map (kbd "C-n") 'company-select-next)
  1327. (define-key company-active-map (kbd "C-p") 'company-select-previous)
  1328. (define-key company-active-map (kbd "<tab>") 'company-complete)
  1329. (define-key custom-bindings (kbd "C-c p") 'counsel-projectile-switch-project)
  1330. (define-key custom-bindings (kbd "C-c f") 'counsel-projectile-find-file)
  1331. (define-key custom-bindings (kbd "C-c m") 'magit-status)
  1332. (define-key custom-bindings (kbd "C-c D") 'define-word-at-point)
  1333. (define-key custom-bindings (kbd "C-@") 'er/expand-region)
  1334. (define-key custom-bindings (kbd "C-#") 'er/contract-region)
  1335. (define-key custom-bindings (kbd "C-S-c C-S-c") 'mc/edit-lines)
  1336. (define-key custom-bindings (kbd "C-c b") 'ivy-switch-buffer)
  1337. (define-key custom-bindings (kbd "C-c l") 'org-store-link)
  1338. (define-key custom-bindings (kbd "C-c t") 'org-set-tags)
  1339. (define-key custom-bindings (kbd "M-u") 'upcase-dwim)
  1340. (define-key custom-bindings (kbd "M-c") 'capitalize-dwim)
  1341. (define-key custom-bindings (kbd "M-l") 'downcase-dwim)
  1342. (define-key custom-bindings (kbd "M-o") 'other-window)
  1343. (define-key custom-bindings (kbd "C-c s") 'ispell-word)
  1344. (define-key custom-bindings (kbd "C-c C-d") 'org-capture)
  1345. (define-key custom-bindings (kbd "C-c <up>") 'windmove-up)
  1346. (define-key custom-bindings (kbd "C-c <down>") 'windmove-down)
  1347. (define-key custom-bindings (kbd "C-c <left>") 'windmove-left)
  1348. (define-key custom-bindings (kbd "C-c <right>") 'windmove-right)
  1349. (define-key custom-bindings (kbd "C-c a") (lambda () (interactive) (org-agenda nil "n")))
  1350. (define-key custom-bindings (kbd "C-c e") 'find-user-init-file)
  1351. (define-key custom-bindings (kbd "C-x f") 'phil-columns)
  1352. (define-key custom-bindings (kbd "C-x k") 'kill-this-buffer-unless-scratch)
  1353. (define-key custom-bindings (kbd "C-c d") 'duplicate-thing)
  1354. (define-key custom-bindings (kbd "C-c c") 'comment-or-uncomment-region-or-line)
  1355. (define-key custom-bindings (kbd "C-;") 'comment-or-uncomment-region-or-line)
  1356. (define-key custom-bindings (kbd "C-o") 'new-line-below)
  1357. (define-key custom-bindings (kbd "C-S-o") 'new-line-above)
  1358. (define-key custom-bindings (kbd "<C-tab>") 'tidy)
  1359. (define-key custom-bindings (kbd "M-q") 'kill-this-buffer)
  1360. (define-key custom-bindings (kbd "M-RET") '(lambda () (interactive) (term (getenv "SHELL"))))
  1361. (define-minor-mode custom-bindings-mode
  1362. "A mode that activates custom-bindings."
  1363. t nil custom-bindings)
  1364. #+END_SRC
  1365. ** UI
  1366. #+BEGIN_SRC emacs-lisp :results silent
  1367. (cond ((member "PragmataPro Mono Liga" (font-family-list))
  1368. (set-face-attribute 'default nil :font "PragmataPro Mono Liga-13")))
  1369. #+END_SRC
  1370. *** Doom Modeline
  1371. #+BEGIN_SRC emacs-lisp :results silent
  1372. (require 'doom-modeline)
  1373. (doom-modeline-mode 1)
  1374. ;; How tall the mode-line should be (only respected in GUI Emacs).
  1375. (setq doom-modeline-height 30)
  1376. ;; How wide the mode-line bar should be (only respected in GUI Emacs).
  1377. (setq doom-modeline-bar-width 4)
  1378. ;; Determines the style used by `doom-modeline-buffer-file-name'.
  1379. ;;
  1380. ;; Given ~/Projects/FOSS/emacs/lisp/comint.el
  1381. ;; truncate-upto-project => ~/P/F/emacs/lisp/comint.el
  1382. ;; truncate-from-project => ~/Projects/FOSS/emacs/l/comint.el
  1383. ;; truncate-with-project => emacs/l/comint.el
  1384. ;; truncate-except-project => ~/P/F/emacs/l/comint.el
  1385. ;; truncate-upto-root => ~/P/F/e/lisp/comint.el
  1386. ;; truncate-all => ~/P/F/e/l/comint.el
  1387. ;; relative-from-project => emacs/lisp/comint.el
  1388. ;; relative-to-project => lisp/comint.el
  1389. ;; file-name => comint.el
  1390. ;; buffer-name => comint.el<2> (uniquify buffer name)
  1391. ;;
  1392. ;; If you are expereicing the laggy issue, especially while editing remote files
  1393. ;; with tramp, please try `file-name' style.
  1394. ;; Please refer to https://github.com/bbatsov/projectile/issues/657.
  1395. (setq doom-modeline-buffer-file-name-style 'truncate-upto-project)
  1396. ;; What executable of Python will be used (if nil nothing will be showed).
  1397. (setq doom-modeline-python-executable "python")
  1398. ;; Whether show `all-the-icons' or not (if nil nothing will be showed).
  1399. (setq doom-modeline-icon t)
  1400. ;; Whether show the icon for major mode. It respects `doom-modeline-icon'.
  1401. (setq doom-modeline-major-mode-icon t)
  1402. ;; Display color icons for `major-mode'. It respects `all-the-icons-color-icons'.
  1403. (setq doom-modeline-major-mode-color-icon nil)
  1404. ;; Whether display minor modes or not. Non-nil to display in mode-line.
  1405. (setq doom-modeline-minor-modes nil)
  1406. ;; If non-nil, a word count will be added to the selection-info modeline segment.
  1407. (setq doom-modeline-enable-word-count nil)
  1408. ;; If non-nil, only display one number for checker information if applicable.
  1409. (setq doom-modeline-checker-simple-format t)
  1410. ;; Whether display perspective name or not. Non-nil to display in mode-line.
  1411. (setq doom-modeline-persp-name t)
  1412. ;; Whether display `lsp' state or not. Non-nil to display in mode-line.
  1413. (setq doom-modeline-lsp t)
  1414. ;; Whether display github notifications or not. Requires `ghub` package.
  1415. (setq doom-modeline-github nil)
  1416. ;; The interval of checking github.
  1417. (setq doom-modeline-github-interval (* 30 60))
  1418. ;; Whether display environment version or not.
  1419. (setq doom-modeline-env-version t)
  1420. ;; Whether display mu4e notifications or not. Requires `mu4e-alert' package.
  1421. (setq doom-modeline-mu4e t)
  1422. #+END_SRC