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.

1414 lines
40 KiB

6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
  1. #+TITLE: Emacs Configuration
  2. #+AUTHOR: Marc Pohling
  3. * Personal Information
  4. #+begin_src emacs-lisp
  5. (setq user-full-name "Marc Pohling"
  6. user-mail-address "marc.pohling@googlemail.com")
  7. #+end_src
  8. * Stuff to add / to fix
  9. - smartparens
  10. a sane default configuration for navigation, manipulation etc. is still necessary
  11. - Spaceline / Powerline or similar
  12. I want a pretty status bar!
  13. - Markdown mode
  14. There might be more than one package for this.
  15. - Git gutter:
  16. Do some configuration to make it useful (see given source link in the [[*Git][Section]] of gutter)
  17. Maybe only enable it for modes where it is likely I use git?
  18. - Some webmode stuff
  19. * Update config in a running config
  20. Two options:
  21. - reload the open file: M-x load-file, then press twice to accept
  22. the default filename, which is the currently opened
  23. - Point at the end of any sexp and press C-x C-e
  24. * Customize settings
  25. Move the customize settings to its own file, instead of saving
  26. customize settings in [[file:init.el][init.el]].
  27. #+begin_src emacs-lisp
  28. (setq custom-file (expand-file-name "custom.el" user-emacs-directory))
  29. (load custom-file)
  30. #+end_src
  31. Keep the .emacs.d clean by moving user files into separate directories.
  32. - user-local: directory for machine specific files
  33. - user-global: directory for files which work on any machine
  34. #+BEGIN_SRC emacs-lisp
  35. (defvar PATH_USER_LOCAL (expand-file-name "~/.emacs.d/user-local/"))
  36. (defvar PATH_USER_GLOBAL (expand-file-name "~/.emacs.d/user-global/"))
  37. (setq bookmark-default-file (concat PATH_USER_LOCAL "bookmarks")) ;"~/.emacs.d/user-dir/bookmarks")
  38. (setq abbrev-file-name (concat PATH_USER_GLOBAL "abbrev_defs"))
  39. (setq save-abbrevs 'silently) ; don't bother me with asking if new abbrevs should be saved
  40. #+END_SRC
  41. * Theme
  42. ** Font
  43. Don't add the font in the work environment, which I am logged in as POH
  44. #+begin_src emacs-lisp
  45. (unless (string-equal user-login-name "POH")
  46. (set-face-attribute 'default nil :font "Hack-12")
  47. )
  48. #+end_src
  49. ** Material Theme
  50. The [[https://github.com/cpaulik/emacs-material-theme][Material Theme]] comes in a dark and a light variant. Not too dark
  51. to be strenious though.
  52. b
  53. #+begin_src emacs-lisp
  54. (use-package material-theme
  55. :if (window-system)
  56. :defer t
  57. :ensure t
  58. ;; :init
  59. ;; (load-theme 'material t)
  60. )
  61. #+end_src
  62. ** Apropospriate Theme
  63. Variants dark and light
  64. #+begin_src emacs-lisp
  65. (use-package apropospriate-theme
  66. :if (window-system)
  67. :defer t
  68. :ensure t
  69. :config
  70. ; (load-theme 'apropospriate-dark t)
  71. )
  72. #+end_src
  73. ** Ample Theme
  74. Variants:
  75. - ample
  76. - ample-flat
  77. - ample-light
  78. #+begin_src emacs-lisp
  79. (use-package ample-theme
  80. :defer t
  81. :ensure t
  82. :init
  83. (load-theme 'ample-flat)
  84. ; (load-theme 'ample-light)
  85. ; (enable-theme 'ample-flat)
  86. )
  87. #+end_src
  88. * Sane defaults
  89. Sources for this section include [[https://github.com/magnars/.emacs.d/blob/master/settings/sane-defaults.el][Magnars Sveen]] and [[http://pages.sachachua.com/.emacs.d/Sacha.html][Sacha Chua]]
  90. These functions are useful. Activate them.
  91. #+begin_src emacs-lisp
  92. (put 'downcase-region 'disabled nil)
  93. (put 'upcase-region 'disabled nil)
  94. (put 'narrow-to-region 'disabled nil)
  95. (put 'dired-find-alternate-file 'disabled nil)
  96. #+end_src
  97. Answering just 'y' or 'n' should be enough.
  98. #+begin_src emacs-lisp
  99. (defalias 'yes-or-no-p 'y-or-n-p)
  100. #+end_src
  101. Keep all backup and auto-save files in one directory
  102. #+begin_src emacs-lisp
  103. (setq backup-directory-alist `((".*" . ,temporary-file-directory)))
  104. (setq auto-save-file-name-transforms `((".*" ,temporary-file-directory)))
  105. #+end_src
  106. UTF-8 please
  107. #+begin_src emacs-lisp
  108. (setq locale-coding-system 'utf-8)
  109. (set-terminal-coding-system 'utf-8)
  110. (set-keyboard-coding-system 'utf-8)
  111. (set-selection-coding-system 'utf-8)
  112. (prefer-coding-system 'utf-8)
  113. #+end_src
  114. Avoid tabs in place of multiple spaces (they look bad in TeX)
  115. and show empty lines
  116. #+begin_src emacs-lisp
  117. (setq-default indent-tabs-mode nil)
  118. (setq-default indicate-empty-lines t)
  119. #+end_src
  120. Turn off blinking cursor
  121. #+begin_src emacs-lisp
  122. (blink-cursor-mode -1)
  123. #+end_src
  124. Don't count two spaces after a period as the end of a sentence.
  125. Just one space is needed
  126. #+begin_src emacs-lisp
  127. (setq sentence-end-double-space nil)
  128. #+end_src
  129. Delete the region when typing, just like as we expect nowadays.
  130. #+begin_src emacs-lisp
  131. (delete-selection-mode t)
  132. #+end_src
  133. Auto-indent when pressing RET, just new-line when C-j
  134. #+begin_src emacs-lisp
  135. (define-key global-map (kbd "RET") 'newline-and-indent)
  136. (define-key global-map (kbd "C-j") 'newline)
  137. #+end_src
  138. Various stuff
  139. #+begin_src emacs-lisp
  140. (show-paren-mode t)
  141. (column-number-mode t)
  142. (setq uniquify-buffer-name-style 'forward)
  143. #+end_src
  144. Smooth scrolling. Emacs tends to be jumpy, this should change it.
  145. #+BEGIN_SRC emacs-lisp
  146. (setq scroll-margin 5
  147. scroll-conservatively 9999
  148. scroll-step 1)
  149. #+END_SRC
  150. * Prettier Line Wraps
  151. By default there is no line wrapping. M-q actually modifies the buffer, which might not be wanted.
  152. So: enable visual wrapping and keep indentation if there are any.
  153. #+begin_src emacs-lisp
  154. (global-visual-line-mode)
  155. (diminish 'visual-line-mode)
  156. (use-package adaptive-wrap
  157. :ensure t
  158. :init
  159. (when (fboundp 'adaptive-wrap-prefix-mode)
  160. (defun my-activate-adaptive-wrap-prefix-mode ()
  161. "Toggle `visual-line-mode' and `adaptive-wrap-prefix-mode' simultaneously."
  162. (adaptive-wrap-prefix-mode (if visual-line-mode 1 -1)))
  163. (add-hook 'visual-line-mode-hook 'my-activate-adaptive-wrap-prefix-mode))
  164. )
  165. #+end_src
  166. * Mode Line
  167. Change the default mode line to something prettier. [[https://github.com/Malabarba/smart-mode-line][Source]]
  168. #+BEGIN_SRC emacs-lisp
  169. (use-package smart-mode-line
  170. :ensure t
  171. :config
  172. (tool-bar-mode -1)
  173. (setq sml/theme 'respectful)
  174. (setq sml/name-width 40)
  175. (setq sml/mode-width 'full)
  176. (set-face-attribute 'mode-line nil
  177. :box nil)
  178. (sml/setup))
  179. #+END_SRC
  180. * List buffers
  181. Ibuffer is the improved version of list-buffers.
  182. Make ibuffer the default buffer lister. [[http://ergoemacs.org/emacs/emacs_buffer_management.html][Source]]
  183. #+begin_src emacs-lisp
  184. (defalias 'list-buffers 'ibuffer)
  185. #+end_src
  186. Also auto refresh dired, but be quiet about it. [[http://whattheemacsd.com/sane-defaults.el-01.html][Source]]
  187. #+begin_src emacs-lisp
  188. (add-hook 'dired-mode-hook 'auto-revert-mode)
  189. (setq global-auto-revert-non-file-buffers t)
  190. (setq auto-revert-verbose nil)
  191. #+end_src
  192. * Org Mode
  193. ** Installation
  194. Although org mode ships with Emacs, the latest version can be installed externally. The configuration here follows the [[http://orgmode.org/elpa.html][Org mode ELPA Installation instructions.]]
  195. Added a hook to complete org functions, company-capf is necessary for this
  196. #+begin_src emacs-lisp
  197. (use-package org
  198. :ensure org-plus-contrib
  199. :init
  200. (add-hook 'org-mode-hook 'company/org-mode-hook)
  201. )
  202. #+end_src
  203. To avoid problems executing source blocks out of the box. [[https://emacs.stackexchange.com/a/28604][Others have the same problem, too]]. The solution is to remove the .elc files form the package directory:
  204. #+begin_src sh:
  205. var ORG_DIR=(let* ((org-v (cadr (split-string (org-version nil t) "@"))) (len (length org-v))) (substring org-v 1 (- len 2)))
  206. rm ${ORG_DIR}/*.elc
  207. #+end_src
  208. *** Org key bindings
  209. Set up some global key bindings that integrate with Org mode features
  210. #+begin_src emacs-lisp
  211. (bind-key "C-c l" 'org-store-link)
  212. (bind-key "C-c c" 'org-capture)
  213. (bind-key "C-c a" 'org-agenda)
  214. #+end_src
  215. Org overwrites RET and C-j, so I need to disable the rebinds
  216. #+begin_src emacs-lisp
  217. (define-key org-mode-map (kbd "RET") nil) ;;org-return
  218. (define-key org-mode-map (kbd "C-j") nil) ;;org-return-indent
  219. #+end_src
  220. *** Org agenda
  221. For a more detailed example [[https://github.com/sachac/.emacs.d/blob/83d21e473368adb1f63e582a6595450fcd0e787c/Sacha.org#org-agenda][see here]].
  222. #+begin_src emacs-lisp
  223. (setq org-agenda-files
  224. (delq nil
  225. (mapcar (lambda (x) (and (file-exists-p x) x))
  226. '("~/Archiv/Dokumente/Agenda"))
  227. )
  228. )
  229. #+end_src
  230. *** Org capture
  231. #+begin_src emacs-lisp
  232. (bind-key "C-c c" 'org-capture)
  233. (setq org-default-notes-file "~/Archiv/Dokumente/Notizen/notes.org")
  234. #+end_src
  235. ** Org Setup
  236. Speed commands are a nice and quick way to perform certain actions while at the beginning of a heading. It's not activated by default.
  237. See the doc for speed keys by checking out the documentation for speed keys in Org mode.
  238. #+begin_src emacs-lisp
  239. (setq org-use-speed-commands t)
  240. (setq org-image-actual-width 550)
  241. (setq org-highlight-latex-and-related '(latex script entities))
  242. #+end_src
  243. Hide emphasis markup (e.g. / ... / for italics, etc.)
  244. #+begin_src emacs-lisp
  245. (setq org-hide-emphasis-markers t)
  246. #+end_src
  247. Setting some environment paths
  248. #+begin_src emacs-lisp
  249. (if (string-equal user-login-name "POH")
  250. (progn
  251. (defvar PATH_ORG_FILES "p:/Eigene Dateien/Notizen/")
  252. (defvar PATH_ORG_JOURNAL "p:/Eigene Dateien/Notizen/Journal/")
  253. (defvar PATH_START "p:/Eigene Dateien/Notizen/"))
  254. )
  255. #+end_src
  256. Sort org agenda by deadline and priority
  257. #+begin_src emacs-lisp
  258. (setq org-agenda-sorting-strategy
  259. (quote
  260. ((agenda deadline-up priority-down)
  261. (todo priority-down category-keep)
  262. (tags priority-down category-keep)
  263. (search category-keep)))
  264. )
  265. #+end_src
  266. Custom todo-keywords, depending on environment
  267. #+begin_src emacs-lisp
  268. (if (string-equal user-login-name "POH")
  269. (setq org-todo-keywords
  270. '((sequence "OPEN" "TODO" "UNCLEAR" "|" "DONE" "IMPOSSIBLE")))
  271. )
  272. #+end_src
  273. Set locations of some org files
  274. #+begin_src emacs-lisp
  275. (if (string-equal user-login-name "POH")
  276. (progn
  277. (setq org-default-notes-file (concat PATH_ORG_FILES "notes.org"))
  278. (setq org-agenda-files (list(concat PATH_ORG_FILES "notes.org")
  279. (concat PATH_ORG_FILES "projects.org")
  280. (concat PATH_ORG_FILES "todo.org"))))
  281. )
  282. (setq org-id-locations-file (concat PATH_USER_LOCAL ".org-id-locations"))
  283. #+end_src
  284. Work specific org-capture-templates
  285. #+begin_src emacs-lisp
  286. (if (string-equal user-login-name "POH")
  287. (setq org-capture-templates
  288. '(("t" "todo" entry (file (concat PATH_ORG_FILES "todo.org"))
  289. "** TODO %\\n%u\n%a\n")
  290. ("n" "note" entry (file org-default-notes-file))
  291. ("p" "project" entry (file (concat PATH_ORG_FILES "projects.org"))
  292. "** OPEN %?\n%u\n** Beschreibung\n** Zu erledigen\n*** \n** Verlauf\n***" :clock-in t :clock-resume t)
  293. ("u" "Unterbrechung" entry (file org-default-notes-file)
  294. "* Unterbrechnung durch %? :Unterbrechung:\n%t" :clock-in t :clock-resume t)))
  295. )
  296. #+end_src
  297. Customize the org agenda
  298. #+begin_src emacs-lisp
  299. (defun my-org-skip-subtree-if-priority (priority)
  300. "Skip an agenda subtree if it has a priority of PRIORITY.
  301. PRIORITY may be one of the characters ?A, ?B, or ?C."
  302. (let ((subtree-end (save-excursion (org-end-of-subtree t)))
  303. (pri-value (* 1000 (- org-lowest-priority priority)))
  304. (pri-current (org-get-priority (thing-at-point 'line t))))
  305. (if (= pri-value pri-current)
  306. subtree-end
  307. nil)))
  308. (setq org-agenda-custom-commands
  309. '(("c" "Simple agenda view"
  310. ((tags "PRIORITY=\"A\""
  311. ((org-agenda-skip-function '(org-agenda-skip-entry-if 'todo 'done))
  312. (org-agenda-overriding-header "Hohe Priorität:")))
  313. (agenda ""
  314. ((org-agenda-span 7)
  315. (org-agenda-start-on-weekday nil)
  316. (org-agenda-overriding-header "Nächsten 7 Tage:")))
  317. (alltodo ""
  318. ((org-agenda-skip-function '(or (my-org-skip-subtree-if-priority ?A)
  319. (org-agenda-skip-if nil '(scheduled deadline))))
  320. (org-agenda-overriding-header "Sonstige Aufgaben:"))))))
  321. )
  322. #+end_src
  323. ** Org tags
  324. The default value is -77, which is weird for smaller width windows. I'd rather have the tags align horizontally with the header.
  325. 45 is a good column number to do that.
  326. #+begin_src emacs-lisp
  327. (setq org-tags-column 45)
  328. #+end_src
  329. ** Org babel languages
  330. This code block is linux specific. Loading languages which aren't available seems to be a problem
  331. #+begin_src emacs-lisp
  332. (cond ((eq system-type 'gnu/linux)
  333. (org-babel-do-load-languages
  334. 'org-babel-load-languages
  335. '(
  336. (C . t)
  337. (calc . t)
  338. (java . t)
  339. (js . t)
  340. (latex . t)
  341. (ledger . t)
  342. (beancount . t)
  343. (lisp . t)
  344. (python . t)
  345. (R . t)
  346. (ruby . t)
  347. (scheme . t)
  348. (shell . t)
  349. (sqlite . t)
  350. )
  351. ))
  352. )
  353. #+end_src
  354. #+begin_src emacs-lisp
  355. (defun my-org-confirm-babel-evaluate (lang body)
  356. "Do not confirm evaluation for these languages."
  357. (not (or (string= lang "beancount")
  358. (string= lang "C")
  359. (string= lang "emacs-lisp")
  360. (string= lang "java")
  361. (string= lang "ledger")
  362. (string= lang "python")
  363. (string= lang "R")
  364. (string= lang "sqlite"))))
  365. (setq org-confirm-babel-evaluate 'my-org-confirm-babel-evaluate)
  366. #+end_src
  367. I want plots!
  368. #+begin_src emacs-lisp
  369. (use-package ess
  370. :ensure t
  371. )
  372. (add-hook 'org-babel-after-execute-hook 'org-display-inline-images)
  373. (add-hook 'org-mode-hook 'org-display-inline-images)
  374. #+end_src
  375. ** Org babel/source blocks
  376. I like to have source blocks properly syntax highlighted and with the editing popup window staying within the same window so all the windows don't jump around. Also, having the top and bottom trailing lines in the block is a waste of space, so we can remove them
  377. I noticed that fontification doesn't work with markdown mode when the block is indented after editing it in the org src buffer - the leading #s for headers don't get fontified properly because they apppear as Org comments. Setting ~org-src-preserve-identation~ makes things consistent as it doesn't pad source blocks with leading spaces
  378. #+begin_src emacs-lisp
  379. (setq org-src-fontify-natively t
  380. org-src-window-setup 'current-window
  381. org-src-strip-leading-and-trailing-blank-lines t
  382. org-src-preserve-indentation t
  383. org-src-tab-acts-natively t)
  384. #+end_src
  385. * which-key
  386. Greatly increases discovery of functions!
  387. Click [[https://github.com/justbur/emacs-which-key][here]] for source and more info.
  388. Info in Emacs: M-x customize-group which-key
  389. #+begin_src emacs-lisp
  390. (use-package which-key
  391. :ensure t
  392. :diminish which-key-mode
  393. :config
  394. (which-key-mode)
  395. (which-key-setup-side-window-right-bottom)
  396. (which-key-setup-minibuffer)
  397. (setq which-key-idle-delay 0.5)
  398. )
  399. #+end_src
  400. * Hydra
  401. Hydra allows grouping of commands
  402. #+begin_src emacs-lisp
  403. (use-package hydra
  404. :ensure t
  405. :bind
  406. ("C-c f" . hydra-flycheck/body)
  407. :config
  408. (setq-default hydra-default-hint nil)
  409. )
  410. #+end_src
  411. * Undo
  412. #+BEGIN_SRC emacs-lisp
  413. (use-package undo-tree
  414. :ensure t
  415. :diminish undo-tree-mode
  416. :init
  417. (undo-tree-mode))
  418. #+END_SRC
  419. * Ido (currently inactive)
  420. better completion
  421. begin_src emacs-lisp
  422. (use-package ido
  423. :init
  424. (setq ido-enable-flex-matching t)
  425. (setq ido-everywhere t)
  426. (ido-mode t)
  427. (use-package ido-vertical-mode
  428. :ensure t
  429. :defer t
  430. :init
  431. (ido-vertical-mode 1)
  432. (setq ido-vertical-define-keys 'C-n-and-C-p-only)
  433. )
  434. )
  435. end_src
  436. * Recentf
  437. #+begin_src emacs-lisp
  438. (use-package recentf
  439. :init
  440. (setq recentf-save-file (concat PATH_USER_LOCAL "recentf"))
  441. :config
  442. (recentf-mode t)
  443. (setq recentf-max-saved-items 200)
  444. )
  445. #+end_src
  446. * ivy / counsel / swiper
  447. Flx is required for fuzzy-matching
  448. Is it really necessary?
  449. begin_src emacs-lisp
  450. (use-package flx)
  451. end_src
  452. Ivy displays a window with suggestions for hotkeys and M-x
  453. #+begin_src emacs-lisp
  454. (use-package ivy
  455. :ensure t
  456. :diminish
  457. (ivy-mode . "") ;; does not display ivy in the mode line
  458. :init
  459. (ivy-mode 1)
  460. :bind
  461. ("C-c C-r" . ivy-resume)
  462. :config
  463. (setq ivy-use-virtual-buffers t) ;; recent files and bookmarks in ivy-switch-buffer
  464. (setq ivy-height 20) ;; height of ivy window
  465. (setq ivy-count-format "%d/%d") ;; current and total number
  466. (setq ivy-re-builders-alist ;; regex replaces spaces with *
  467. '((t . ivy--regex-plus)))
  468. )
  469. #+end_src
  470. The find-file replacement is nicer to navigate
  471. #+begin_src emacs-lisp
  472. (use-package counsel
  473. :ensure t
  474. :bind* ;; load counsel when pressed
  475. (("M-x" . counsel-M-x)
  476. ("C-x C-f" . counsel-find-file)
  477. ("C-x C-r" . counsel-recentf)
  478. ("C-c C-f" . counsel-git)
  479. ("C-c h f" . counsel-describe-function)
  480. ("C-c h v" . counsel-describe-variable)
  481. ("M-i" . counsel-imenu)
  482. )
  483. )
  484. #+end_src
  485. Swiper ivy-enhances isearch
  486. #+begin_src emacs-lisp
  487. (use-package swiper
  488. :ensure t
  489. :bind
  490. (("C-s" . swiper)
  491. ("C-c C-r" . ivy-resume)
  492. )
  493. )
  494. #+end_src
  495. Ivy-Hydra adds stuff in minibuffer when you press C-o
  496. #+BEGIN_SRC emacs-lisp
  497. (use-package ivy-hydra
  498. :ensure t)
  499. #+END_SRC
  500. * Helm
  501. I placed it after ivy to override any configuration made by the former.
  502. This is just a try to see how it works differently.
  503. #+BEGIN_SRC emacs-lisp
  504. (use-package helm
  505. :ensure t
  506. :init
  507. (helm-mode 1)
  508. :bind
  509. ; (("M-x" . helm-M-x)
  510. ; ("C-x C-f" . helm-find-files)
  511. ; ("C-x C-r" . helm-recentf)
  512. ; ("C-x b" . helm-buffers-list))
  513. :config
  514. (setq helm-buffers-fuzzy-matching t)
  515. )
  516. (use-package helm-descbinds
  517. :ensure t
  518. :bind
  519. ("C-h b" . helm-descbinds))
  520. (use-package helm-projectile
  521. :ensure t
  522. :config
  523. (helm-projectile-on))
  524. #+END_SRC
  525. * Latex
  526. Requirements for Linux:
  527. - Latex
  528. - pdf-tools
  529. #+begin_src emacs-lisp
  530. (unless (string-equal user-login-name "POH")
  531. (use-package pdf-tools
  532. :ensure t
  533. :config
  534. (pdf-tools-install)
  535. (setq TeX-view-program-selection '((output-pdf "pdf-tools")))
  536. (setq TeX-view-program-list '(("pdf-tools" "Tex-pdf-tools-sync-view")))
  537. )
  538. )
  539. #+end_src
  540. For latex-preview-pane a patch might be necessary (as of 2017-10), see the issue [[https://github.com/jsinglet/latex-preview-pane/issues/37][here]]
  541. Update 2018-03: It seems to work without this patch. I will keep it here in case something breaks again.
  542. #+begin_src
  543. latex-preview-pane-update-p()
  544. --- (doc-view-revert-buffer nil t)
  545. +++ (revert-buffer-nil t 'preserve-modes)
  546. #+end_src
  547. After that M-x byte-compile-file
  548. #+begin_src emacs-lisp
  549. (use-package latex-preview-pane
  550. :ensure t
  551. )
  552. (setq auto-mode-alist
  553. (append '(("\\.tex$" . latex-mode)) auto-mode-alist))
  554. ;; one of these works
  555. (add-hook 'LaTeX-mode-hook 'latex-preview-pane-mode)
  556. (add-hook 'latex-mode-hook 'latex-preview-pane-mode)
  557. ;; necessary, because linum-mode isn't compatible and prints errors
  558. (add-hook 'pdf-view-mode-hook (lambda () (linum-mode -1)))
  559. #+end_src
  560. * Emails
  561. Currently following tools are required:
  562. - notmuch (edit, read, tag, delete emails)
  563. - isync /mbsync (fetch or sync emails)
  564. After setting up mbsync, notmuch must be configured. Execute "notmuch" from the command line to launch the setup wizard. After it, "notmuch new" to create a new database, which will index the available local e-mails.
  565. TODO:
  566. - setup of mbsync on linux
  567. - setup of notmuch on linux
  568. - shell script for installation of isync and notmuch
  569. - more config for notmuch?
  570. - hydra for notmuch?
  571. - maybe org-notmuch?
  572. - some way to refresh the notmuch db before I run notmuch?
  573. #+begin_src emacs-lisp
  574. (unless (string-equal user-login-name "POH")
  575. (use-package notmuch
  576. :ensure t
  577. )
  578. )
  579. #+end_src
  580. * Personal Finances
  581. I picked ledger for my personal accounting and will test if it's beneficial over gnucash.
  582. ..and don't activate the modules at work.
  583. #+begin_src emacs-lisp
  584. (unless (string-equal user-login-name "POH")
  585. (use-package ledger-mode
  586. :ensure t
  587. :mode ("\\.ledger$" . ledger-mode)
  588. :init
  589. (setq clear-whole-transactions t)
  590. )
  591. )
  592. #+end_src
  593. Ok, maybe beancount is better.
  594. Since there is no debian package, it is an option to install it via pip.
  595. I picked /opt for the installation path
  596. #+begin_src shell
  597. sudo su
  598. cd /opt
  599. python3 -m venv beancount
  600. source ./beancount/bin/activate
  601. pip3 install wheel
  602. pip3 install beancount
  603. deactivate
  604. #+end_src
  605. When using beancount, it will automatically pick the created virtual environment.
  606. Activate the beancount mode
  607. #+begin_src emacs-lisp
  608. (unless (string-equal user-login-name "POH")
  609. ;; (add-to-list 'package-archives
  610. ;; '("beancount" . "/opt/beancount/elisp") t)
  611. ; (use-package beancount
  612. ; :load-path "/opt/beancount/elisp/"
  613. ;; :ensure t
  614. ; :mode ("\\.beancount$" . beancount-mode)
  615. (load "/home/marc/.emacs.d/elisp/beancount-mode.el") ; somehow load-path in use-package doesn't work
  616. (use-package beancount
  617. :load-path "/home/marc/.emacs.d/elisp"
  618. :mode ("\\.beancount$" . beancount-mode)
  619. :init
  620. (add-hook 'beancount-mode-hook 'company/beancount-mode-hook)
  621. (setenv "PATH"
  622. (concat
  623. "/opt/beancount/bin:"
  624. (getenv "PATH"))
  625. )
  626. :config
  627. (setq beancount-filename-main "/home/marc/Archiv/Finanzen/transactions.beancount")
  628. )
  629. )
  630. #+end_src
  631. For a nice frontend fava seems nice
  632. #+begin_src shell
  633. sudo su
  634. cd /opt
  635. python3 -m venv vava
  636. source ./vava/bin/activate
  637. pip3 install wheel
  638. pip3 install fava
  639. deactivate
  640. #+end_src
  641. Start fava with
  642. #+begin_src shell
  643. fava my_file.beancount
  644. #+end_src
  645. It is accessable on this URL: [[http://127.0.0.1:5000][Fava]]
  646. * Programming
  647. ** Common things
  648. List of plugins and settings which are shared between the language plugins
  649. Highlight whitespaces, tabs, empty lines.
  650. #+begin_src emacs-lisp
  651. (use-package whitespace
  652. :demand t
  653. :ensure nil
  654. :diminish whitespace-mode;;mode shall be active, but not shown in mode line
  655. :init
  656. (dolist (hook '(prog-mode-hook
  657. text-mode-hook
  658. conf-mode-hook))
  659. (add-hook hook #'whitespace-mode))
  660. ;; :hook ;;not working in use-package 2.3
  661. ;; ((prog-mode . whitespace-turn-on)
  662. ;; (text-mode . whitespace-turn-on))
  663. :config
  664. (setq-default whitespace-style '(face empty tab trailing))
  665. )
  666. #+end_src
  667. Disable Eldoc, it interferes with flycheck
  668. #+begin_src emacs-lisp
  669. (use-package eldoc
  670. :ensure nil
  671. :config
  672. (global-eldoc-mode -1)
  673. )
  674. #+end_src
  675. Colorize colors as text with their value
  676. #+begin_src emacs-lisp
  677. (use-package rainbow-mode
  678. :ensure t
  679. :init
  680. (add-hook 'prog-mode-hook 'rainbow-mode t)
  681. :diminish rainbow-mode
  682. ;; :hook prog-mode ;; not working in use-package 2.3
  683. :config
  684. (setq-default rainbow-x-colors-major-mode-list '())
  685. )
  686. #+end_src
  687. Highlight parens etc. for improved readability
  688. #+begin_src emacs-lisp
  689. (use-package rainbow-delimiters
  690. :ensure t
  691. :config
  692. (add-hook 'prog-mode-hook 'rainbow-delimiters-mode)
  693. )
  694. #+end_src
  695. ** Smartparens
  696. Smartparens is a beast on its own, so it's worth having a dedicated section for it
  697. #+begin_src emacs-lisp
  698. (use-package smartparens
  699. :ensure t
  700. :diminish smartparens-mode
  701. :config
  702. (add-hook 'prog-mode-hook 'smartparens-mode)
  703. )
  704. #+end_src
  705. ** Git
  706. [[https://magit.vc/manual/magit/index.html][Link]]
  707. I want to do git stuff here, not in a separate terminal window
  708. Little crashcourse in magit:
  709. - magit-init to init a git project
  710. - magit-status (C-x g) to call the status window
  711. in status buffer:
  712. - s stage files
  713. - u unstage files
  714. - U unstage all files
  715. - a apply changed to staging
  716. - c c commit (type commit message, then C-c C-c to commit)
  717. - b b switch to another branch
  718. - P u git push
  719. - F u git pull
  720. #+begin_src emacs-lisp
  721. (use-package magit
  722. :ensure t
  723. :init
  724. ;; set git-path in work environment
  725. (if (string-equal user-login-name "POH")
  726. (setq magit-git-executable "P:/Eigene Dateien/Tools/Git/bin/git.exe")
  727. )
  728. :defer t
  729. :bind (("C-x g" . magit-status))
  730. )
  731. #+end_src
  732. Display line changes in gutter based on git history. Enable it everywhere
  733. [[https://github.com/syohex/emacs-git-gutter][Source]]
  734. #+begin_src emacs-lisp
  735. (use-package git-gutter
  736. :ensure t
  737. :config
  738. (global-git-gutter-mode t)
  739. :diminish git-gutter-mode
  740. )
  741. #+end_src
  742. Time machine lets me step through the history of a file as recorded in git.
  743. [[https://github.com/pidu/git-timemachine][Source]]
  744. #+begin_src emacs-lisp
  745. (use-package git-timemachine
  746. :ensure t
  747. )
  748. #+end_src
  749. ** Company Mode
  750. Complete Anything!
  751. Activate company and make it react nearly instantly
  752. #+begin_src emacs-lisp
  753. (use-package company
  754. :ensure t
  755. :config
  756. (setq-default company-minimum-prefix-length 1
  757. company-tooltip-align-annotation t
  758. company-tooltop-flip-when-above t
  759. company-show-numbers t
  760. company-idle-delay 0.1)
  761. ;; (define-key company-active-map (kbd "TAB") #'company-complete-selection)
  762. ;; (define-key company-active-map (kbd "RET") nil)
  763. (company-tng-configure-default)
  764. )
  765. #+end_src
  766. For a nicer suggestion box: company-box ([[https://github.com/sebastiencs/company-box][Source]])
  767. It is only available for emacs 26 and higher.
  768. #+begin_src emacs-lisp
  769. (when (> emacs-major-version 25)
  770. (use-package company-box
  771. :ensure t
  772. :init
  773. (add-hook 'company-mode-hook 'company-box-mode)))
  774. #+end_src
  775. *** Company backend hooks
  776. Backend configuration for python-mode
  777. Common backends are:
  778. - company-files: files & directory
  779. - company-keywords: keywords
  780. - company-capf: ??
  781. - company-abbrev: ??
  782. - company-dabbrev: dynamic abbreviations
  783. - company-ispell: ??
  784. #+begin_src emacs-lisp
  785. (defun company/python-mode-hook()
  786. (set (make-local-variable 'company-backends)
  787. '((company-jedi company-dabbrev company-yasnippet) company-capf company-files))
  788. ;; '((company-jedi company-dabbrev) company-capf company-files))
  789. (company-mode t)
  790. )
  791. #+end_src
  792. (defun add-pcomplete-to-capf ()
  793. (add-hook 'completion-at-point-functions 'pcomplete-completions-at-point nil t))
  794. ;; (add-hook 'completion-at-point-functions 'pcomplete-completions-at-point nil t)
  795. (add-hook 'org-mode-hook #'add-pcomplete-to-capf)
  796. Backend for Orgmode
  797. #+begin_src emacs-lisp
  798. (defun company/org-mode-hook()
  799. (set (make-local-variable 'company-backends)
  800. '(company-capf company-files))
  801. (add-hook 'completion-at-point-functions 'pcomplete-completions-at-point nil t)
  802. (company-mode t)
  803. )
  804. #+end_src
  805. Backend configuration for lisp-mode
  806. #+begin_src emacs-lisp
  807. (defun company/elisp-mode-hook()
  808. (set (make-local-variable 'company-backends)
  809. '((company-elisp company-dabbrev) company-capf company-files))
  810. (company-mode t)
  811. )
  812. #+end_src
  813. Backend configuration for beancount
  814. #+begin_src emacs-lisp
  815. (defun company/beancount-mode-hook()
  816. (set (make-local-variable 'company-backends)
  817. '(company-beancount))
  818. ; '((company-beancount company-dabbrev) company-capf company-files))
  819. (company-mode t)
  820. )
  821. #+end_src
  822. *** Misc Company packages
  823. Addon to sort suggestions by usage
  824. #+begin_src emacs-lisp
  825. (use-package company-statistics
  826. :ensure t
  827. :after company
  828. :init
  829. (setq company-statistics-file (concat PATH_USER_LOCAL "company-statistics-cache.el"));~/.emacs.d/user-dir/company-statistics-cache.el")
  830. :config
  831. (company-statistics-mode 1)
  832. )
  833. #+end_src
  834. Get a popup with documentation of the completion candidate.
  835. For the popups the package pos-tip.el is used and automatically installed.
  836. [[https://github.com/expez/company-quickhelp][Company Quickhelp]]
  837. [[https://www.emacswiki.org/emacs/PosTip][See here for Pos-Tip details]]
  838. #+begin_src emacs-lisp
  839. (use-package company-quickhelp
  840. :ensure t
  841. :after company
  842. :config
  843. (company-quickhelp-mode 1)
  844. )
  845. #+end_src
  846. Maybe add [[https://github.com/hlissner/emacs-company-dict][company-dict]]? It's a dictionary based on major modes, plus it has Yasnippet integration.
  847. ** Projectile
  848. Brings search functions on project level
  849. #+begin_src emacs-lisp
  850. (use-package projectile
  851. :ensure t
  852. :defer t
  853. :bind
  854. (("C-c p p" . projectile-switch-project)
  855. ("C-c p s s" . projectile-ag))
  856. :init
  857. (setq-default
  858. projectile-cache-file (concat PATH_USER_LOCAL ".projectile-cache")
  859. projectile-known-projects-file (concat PATH_USER_LOCAL ".projectile-bookmarks"))
  860. :config
  861. (projectile-mode t)
  862. (setq-default
  863. projectile-completion-system 'ivy
  864. projectile-enable-caching t
  865. projectile-mode-line '(:eval (projectile-project-name)))
  866. )
  867. #+end_src
  868. ** Yasnippet
  869. Snippets!
  870. TODO: yas-minor-mode? what's that?
  871. #+begin_src emacs-lisp
  872. (use-package yasnippet
  873. :ensure t
  874. :diminish yas-minor-mode
  875. :init
  876. (setq yas-snippet-dirs (concat PATH_USER_GLOBAL "snippets"))
  877. (yas-global-mode t)
  878. :mode ("\\.yasnippet" . snippet-mode)
  879. ; :config
  880. ; (yas-reload-all) ;; ensure snippets are updated and available, necessary when not using global-mode
  881. )
  882. #+end_src
  883. ** Lisp
  884. #+begin_src emacs-lisp
  885. (add-hook 'emacs-lisp-mode-hook 'company/elisp-mode-hook)
  886. #+end_src
  887. Add some helpers to handle and understand macros
  888. #+begin_src emacs-lisp
  889. (use-package macrostep
  890. :ensure t
  891. :init
  892. (define-key emacs-lisp-mode-map (kbd "C-c e") 'macrostep-expand)
  893. (define-key emacs-lisp-mode-map (kbd "C-c c") 'macrostep-collapse))
  894. #+end_src
  895. ** Python
  896. Systemwide following packages need to be installed:
  897. - venv
  898. The virtual environments need to have following modules installed:
  899. - jedi
  900. - epc
  901. - pylint
  902. #+begin_src emacs-lisp
  903. (use-package flycheck
  904. :ensure t
  905. :diminish flycheck-mode " ✓"
  906. :init
  907. (setq flycheck-emacs-lisp-load-path 'inherit)
  908. (add-hook 'after-init-hook #'global-flycheck-mode)
  909. (add-hook 'python-mode-hook (lambda ()
  910. (semantic-mode 1)
  911. (flycheck-select-checker 'python-pylint)))
  912. )
  913. #+end_src
  914. Automatically start python-mode when opening a .py-file.
  915. Not sure if python.el is better than python-mode.el.
  916. See [[https://github.com/jorgenschaefer/elpy/issues/887][here]] for info about ~python-shell-completion-native-enable~.
  917. The custom function is to run inferiour processes (do I really need that?), see [[https://emacs.stackexchange.com/questions/16361/how-to-automatically-run-inferior-process-when-loading-major-mode][here]].
  918. Also limit the completion backends to those which make sense in Python.
  919. #+begin_src emacs-lisp
  920. (use-package python
  921. :mode ("\\.py\\'" . python-mode)
  922. :interpreter ("python" . python-mode)
  923. :init
  924. (add-hook 'python-mode-hook 'company/python-mode-hook)
  925. :config
  926. (setq python-shell-completion-native-enable nil)
  927. )
  928. #+end_src
  929. Jedi is a backend for python autocompletion and needs to be installed on the server:
  930. - pip install jedi
  931. Code checks need to be installed, too:
  932. - pip install flake8
  933. #+begin_src emacs-lisp
  934. (use-package company-jedi
  935. :defer t
  936. ;; :after company
  937. :ensure t
  938. :config
  939. (setq jedi:environment-virtualenv (list (expand-file-name "~/Archiv/Programmierprojekte/Python/virtualenv/")))
  940. (setq jedi:python-environment-directory (list (expand-file-name "~/Archiv/Programmierprojekte/Python/virtualenv/")))
  941. (add-hook 'python-mode-hook 'jedi:setup)
  942. (setq jedi:complete-on-dot t)
  943. (setq jedi:use-shortcuts t)
  944. ;; (add-hook 'python-mode-hook 'company/python-mode-hook)
  945. )
  946. #+end_src
  947. A wrapper to handle virtual environments.
  948. I strongly recommend to install virtual environments on the terminal, not through this wrapper, but changing venvs is fine.
  949. TODO: automatically start an inferior python process or switch to it if already created
  950. #+begin_src emacs-lisp
  951. (use-package pyvenv
  952. :ensure t
  953. :init
  954. (setenv "WORKON_HOME" (expand-file-name "~/Archiv/Programmierprojekte/Python/virtualenv/"))
  955. :config
  956. (pyvenv-mode t)
  957. (defun my/post-activate-hook()
  958. (setq jedi:environment-root pyvenv-virtual-env)
  959. (setq jedi:environment-virtualenv pyvenv-virtual-env)
  960. (setq jedi:tooltip-method '(nil)) ;; variants: nil or pos-tip and/or popup
  961. (setq python-shell-virtualenv-root pyvenv-virtual-env)
  962. ;; default traceback, other option M-x jedi:toggle-log-traceback
  963. ;; traceback is in jedi:pop-to-epc-buffer
  964. (jedi:setup)
  965. (company/python-mode-hook)
  966. (setq jedi:server-args '("--log-traceback")))
  967. ;; (add-to-list 'company-backends 'company-jedi)
  968. ;; (add-to-list 'company-backends 'company-anaconda)
  969. ;; (lambda ()
  970. ;; (set (make-local-variable 'company-backends)
  971. ;; '((company-jedi company-dabbrev) company-capf company-files)))
  972. ;; (setq flycheck-checker 'python-pylint))
  973. ;; (flycheck-select-checker 'python-pylint))
  974. ;; (setq flycheck-checker 'python-flake8)
  975. (add-hook 'pyvenv-post-activate-hooks 'my/post-activate-hook)
  976. )
  977. #+end_src
  978. I want Emacs to automatically start the proper virtual environment.
  979. Required is a .python-version file with, content in the first line being /path/to/virtualenv/
  980. [[https://github.com/marcwebbie/auto-virtualenv][Github source]]
  981. Depends on pyvenv
  982. #+begin_src emacs-lisp
  983. (use-package auto-virtualenv
  984. :ensure t
  985. ;; :after pyvenv
  986. ;; :defer t
  987. :init
  988. (add-hook 'python-mode-hook 'auto-virtualenv-set-virtualenv)
  989. ;; activate on changing buffers
  990. ;; (add-hook 'window-configuration-change-hook 'auto-virtualenv-set-virtualenv)
  991. ;; activate on focus in
  992. ;; (add-hook 'focus-in-hook 'auto-virtualenv-set-virtualenv)
  993. )
  994. #+end_src
  995. Anaconda test
  996. begin_src emacs-lisp
  997. (use-package anaconda-mode
  998. :ensure t
  999. :defer t
  1000. :init
  1001. (add-hook 'python-mode-hook 'anaconda-mode)
  1002. ;; (add-hook 'python-mode-hook 'anaconda-eldoc-mode)
  1003. :config
  1004. (setq anaconda-eldoc-mode 1)
  1005. )
  1006. end_src
  1007. begin_src emacs-lisp
  1008. (use-package company-anaconda
  1009. :ensure t
  1010. :defer t
  1011. :init
  1012. (defun my/company-anaconda-hook()
  1013. (add-to-list 'company-backends 'company-anaconda))
  1014. (add-hook 'python-mode-hook 'my/company-anaconda-hook)
  1015. )
  1016. end_src
  1017. ** Hydra Flycheck
  1018. Flycheck is necessary, obviously
  1019. #+begin_src emacs-lisp
  1020. (defhydra hydra-flycheck (:color blue)
  1021. "
  1022. ^
  1023. ^Flycheck^ ^Errors^ ^Checker^
  1024. ^────────^──────────^──────^────────────^───────^───────────
  1025. _q_ quit _<_ previous _?_ describe
  1026. _m_ manual _>_ next _d_ disable
  1027. _v_ verify setup _f_ check _s_ select
  1028. ^^ ^^ ^^
  1029. "
  1030. ("q" nil)
  1031. ("<" flycheck-previous-error :color red)
  1032. (">" flycheck-next-error :color red)
  1033. ("?" flycheck-describe-checker)
  1034. ("d" flycheck-disable-checker)
  1035. ("f" flycheck-buffer)
  1036. ("m" flycheck-manual)
  1037. ("s" flycheck-select-checker)
  1038. ("v" flycheck-verify-setup)
  1039. )
  1040. #+end_src
  1041. * Treemacs
  1042. A file manager comparable to neotree.
  1043. [[https://github.com/Alexander-Miller/treemacs][Github]]
  1044. It has some requirements, which gets used here anyway:
  1045. - ace-window
  1046. - hydra
  1047. - projectile
  1048. - python
  1049. I copied the configuration example from the github site.
  1050. No idea what this executable-find is about.
  1051. TODO check it out!
  1052. #+begin_src emacs-lisp
  1053. (use-package treemacs
  1054. :ensure t
  1055. :defer t
  1056. :config
  1057. (setq treemacs-change-root-without-asking nil
  1058. treemacs-collapse-dirs (if (executable-find "python") 3 0)
  1059. treemacs-file-event-delay 5000
  1060. treemacs-follow-after-init t
  1061. treemacs-follow-recenter-distance 0.1
  1062. treemacs-goto-tag-strategy 'refetch-index
  1063. treemacs-indentation 2
  1064. treemacs-indentation-string " "
  1065. treemacs-is-never-other-window nil
  1066. treemacs-never-persist nil
  1067. treemacs-no-png-images nil
  1068. treemacs-recenter-after-file-follow nil
  1069. treemacs-recenter-after-tag-follow nil
  1070. treemacs-show-hidden-files t
  1071. treemacs-silent-filewatch nil
  1072. treemacs-silent-refresh nil
  1073. treemacs-sorting 'alphabetic-desc
  1074. treemacs-tag-follow-cleanup t
  1075. treemacs-tag-follow-delay 1.5
  1076. treemacs-width 35)
  1077. (treemacs-follow-mode t)
  1078. (treemacs-filewatch-mode t)
  1079. (pcase (cons (not (null (executable-find "git")))
  1080. (not (null (executable-find "python3"))))
  1081. (`(t . t)
  1082. (treemacs-git-mode 'extended))
  1083. (`(t . _)
  1084. (treemacs-git-mode 'simple)))
  1085. :bind
  1086. (:map global-map
  1087. ([f8] . treemacs-toggle))
  1088. )
  1089. #+end_src
  1090. Treemacs-projectile is useful for uhh.. TODO explain!
  1091. #+begin_src emacs-lisp
  1092. (use-package treemacs-projectile
  1093. :ensure t
  1094. :defer t
  1095. :config
  1096. (setq treemacs-header-function #'treemacs-projectile-create-header)
  1097. )
  1098. #+end_src
  1099. TODO
  1100. Hydrastuff or keybindings for functions:
  1101. - treemacs-projectile
  1102. - treemacs-projectile-toggle
  1103. - treemacs-toggle
  1104. - treemacs-bookmark
  1105. - treemacs-find-file
  1106. - treemacs-find-tag
  1107. * Evil
  1108. So... Evil Mode might be worth a try
  1109. #+BEGIN_SRC emacs-lisp
  1110. (use-package evil
  1111. :ensure t
  1112. :defer .1 ;; don't block emacs when starting, load evil immediately after startup
  1113. :init
  1114. (setq evil-want-integration nil) ;; required by evil-collection
  1115. :config
  1116. (evil-mode 1)) ;; for now deactivate per default
  1117. #+END_SRC
  1118. Evil-collection is a bundle of configs for different modes.
  1119. 2018-05-01: evil collection causes error
  1120. "Invalid function: with-helm-buffer"
  1121. #+BEGIN_SRC emacs-lisp
  1122. ;(use-package evil-collection
  1123. ; :after evil
  1124. ; :ensure t
  1125. ; :config
  1126. ; (evil-collection-init))
  1127. #+END_SRC
  1128. * Window Handling
  1129. Some tools to easen the navigation, creation and deletion of windows
  1130. ** Ace-Window
  1131. #+begin_src emacs-lisp
  1132. (use-package ace-window
  1133. :ensure t
  1134. :init
  1135. (global-set-key (kbd "C-x o") 'ace-window)
  1136. )
  1137. #+end_src
  1138. ** Windmove
  1139. Windmove easens the navigation between windows.
  1140. Here we are setting the default keybindings (shift+arrow)
  1141. CURRENTLY NOT WORKING, defaults are blocked.
  1142. Also not sure if necessary when using ace-window.
  1143. #+begin_src emacs-lisp
  1144. (use-package windmove
  1145. :ensure t
  1146. :config
  1147. (windmove-default-keybindings)
  1148. )
  1149. #+end_src
  1150. * Custom key mappings
  1151. ** Escape stuff
  1152. Standard is C-g to exit. But with the coming introduction of evil, ESC should be the default key for escaping stuff.
  1153. #+BEGIN_SRC emacs-lisp
  1154. (defun minibuffer-keyboard-quit ()
  1155. "Abort recursive edit.
  1156. In Delete Selection mode, if the mark is active, just deactivate it;
  1157. then it takes a second \\[keyboard-quit] to abort the minibuffer."
  1158. (interactive)
  1159. (if (and delete-selection-mode transient-mark-mode mark-active)
  1160. (setq deactivate-mark t)
  1161. (when (get-buffer "*Completions*") (delete-windows-on "*Completions*"))
  1162. (abort-recursive-edit)))
  1163. (with-eval-after-load 'evil-maps
  1164. (define-key evil-normal-state-map [escape] 'keyboard-quit)
  1165. (define-key evil-visual-state-map [escape] 'keyboard-quit))
  1166. ;(with-eval-after-load 'swiper-map
  1167. ; (define-key ivy-minibuffer-map [escape] 'keyboard-quit)
  1168. ; (define-key swiper-map [escape] 'keyboard-quit)
  1169. ;)
  1170. (define-key minibuffer-local-map [escape] 'minibuffer-keyboard-quit)
  1171. (define-key minibuffer-local-ns-map [escape] 'minibuffer-keyboard-quit)
  1172. (define-key minibuffer-local-completion-map [escape] 'minibuffer-keyboard-quit)
  1173. (define-key minibuffer-local-must-match-map [escape] 'minibuffer-keyboard-quit)
  1174. (define-key minibuffer-local-isearch-map [escape] 'minibuffer-keyboard-quit)
  1175. (global-set-key [escape] 'evil-exit-emacs-state)
  1176. #+END_SRC
  1177. * Quality of Life
  1178. ** Default Window Size
  1179. #+BEGIN_SRC emacs-lisp
  1180. (if (display-graphic-p)
  1181. (progn
  1182. (setq initial-frame-alist
  1183. '(
  1184. (width . 165)
  1185. (height . 70)))
  1186. (setq default-frame-alist
  1187. '(
  1188. (width . 165)
  1189. (height . 70))))
  1190. )
  1191. #+END_SRC