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.

1413 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. 2018-04-29: invalid-function "helm-with-buffer" occurred whenever I tried to start a helm function, so.. back to ivy!
  504. +BEGIN_SRC emacs-lisp
  505. (use-package helm
  506. :ensure t
  507. :init
  508. (helm-mode 1)
  509. ; :bind
  510. ; (("M-x" . helm-M-x)
  511. ; ("C-x C-f" . helm-find-files)
  512. ; ("C-x C-r" . helm-recentf)
  513. ; ("C-x b" . helm-buffers-list))
  514. ; :config
  515. ; (setq helm-buffers-fuzzy-matching t)
  516. )
  517. ;(use-package helm-descbinds
  518. ; :ensure t
  519. ; :bind
  520. ; ("C-h b" . helm-descbinds))
  521. ;(use-package helm-projectile
  522. ; :ensure t
  523. ; :config
  524. ; (helm-projectile-on))
  525. #+END_SRC
  526. * Latex
  527. Requirements for Linux:
  528. - Latex
  529. - pdf-tools
  530. #+begin_src emacs-lisp
  531. (unless (string-equal user-login-name "POH")
  532. (use-package pdf-tools
  533. :ensure t
  534. :config
  535. (pdf-tools-install)
  536. (setq TeX-view-program-selection '((output-pdf "pdf-tools")))
  537. (setq TeX-view-program-list '(("pdf-tools" "Tex-pdf-tools-sync-view")))
  538. )
  539. )
  540. #+end_src
  541. 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]]
  542. Update 2018-03: It seems to work without this patch. I will keep it here in case something breaks again.
  543. #+begin_src
  544. latex-preview-pane-update-p()
  545. --- (doc-view-revert-buffer nil t)
  546. +++ (revert-buffer-nil t 'preserve-modes)
  547. #+end_src
  548. After that M-x byte-compile-file
  549. #+begin_src emacs-lisp
  550. (use-package latex-preview-pane
  551. :ensure t
  552. )
  553. (setq auto-mode-alist
  554. (append '(("\\.tex$" . latex-mode)) auto-mode-alist))
  555. ;; one of these works
  556. (add-hook 'LaTeX-mode-hook 'latex-preview-pane-mode)
  557. (add-hook 'latex-mode-hook 'latex-preview-pane-mode)
  558. ;; necessary, because linum-mode isn't compatible and prints errors
  559. (add-hook 'pdf-view-mode-hook (lambda () (linum-mode -1)))
  560. #+end_src
  561. * Emails
  562. Currently following tools are required:
  563. - notmuch (edit, read, tag, delete emails)
  564. - isync /mbsync (fetch or sync emails)
  565. 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.
  566. TODO:
  567. - setup of mbsync on linux
  568. - setup of notmuch on linux
  569. - shell script for installation of isync and notmuch
  570. - more config for notmuch?
  571. - hydra for notmuch?
  572. - maybe org-notmuch?
  573. - some way to refresh the notmuch db before I run notmuch?
  574. #+begin_src emacs-lisp
  575. (unless (string-equal user-login-name "POH")
  576. (use-package notmuch
  577. :ensure t
  578. )
  579. )
  580. #+end_src
  581. * Personal Finances
  582. I picked ledger for my personal accounting and will test if it's beneficial over gnucash.
  583. ..and don't activate the modules at work.
  584. #+begin_src emacs-lisp
  585. (unless (string-equal user-login-name "POH")
  586. (use-package ledger-mode
  587. :ensure t
  588. :mode ("\\.ledger$" . ledger-mode)
  589. :init
  590. (setq clear-whole-transactions t)
  591. )
  592. )
  593. #+end_src
  594. Ok, maybe beancount is better.
  595. Since there is no debian package, it is an option to install it via pip.
  596. I picked /opt for the installation path
  597. #+begin_src shell
  598. sudo su
  599. cd /opt
  600. python3 -m venv beancount
  601. source ./beancount/bin/activate
  602. pip3 install wheel
  603. pip3 install beancount
  604. deactivate
  605. #+end_src
  606. When using beancount, it will automatically pick the created virtual environment.
  607. Activate the beancount mode
  608. #+begin_src emacs-lisp
  609. (unless (string-equal user-login-name "POH")
  610. ;; (add-to-list 'package-archives
  611. ;; '("beancount" . "/opt/beancount/elisp") t)
  612. ; (use-package beancount
  613. ; :load-path "/opt/beancount/elisp/"
  614. ;; :ensure t
  615. ; :mode ("\\.beancount$" . beancount-mode)
  616. (load "/home/marc/.emacs.d/elisp/beancount-mode.el") ; somehow load-path in use-package doesn't work
  617. (use-package beancount
  618. :load-path "/home/marc/.emacs.d/elisp"
  619. :mode ("\\.beancount$" . beancount-mode)
  620. :init
  621. (add-hook 'beancount-mode-hook 'company/beancount-mode-hook)
  622. (setenv "PATH"
  623. (concat
  624. "/opt/beancount/bin:"
  625. (getenv "PATH"))
  626. )
  627. :config
  628. (setq beancount-filename-main "/home/marc/Archiv/Finanzen/transactions.beancount")
  629. )
  630. )
  631. #+end_src
  632. For a nice frontend fava seems nice
  633. #+begin_src shell
  634. sudo su
  635. cd /opt
  636. python3 -m venv vava
  637. source ./vava/bin/activate
  638. pip3 install wheel
  639. pip3 install fava
  640. deactivate
  641. #+end_src
  642. Start fava with
  643. #+begin_src shell
  644. fava my_file.beancount
  645. #+end_src
  646. It is accessable on this URL: [[http://127.0.0.1:5000][Fava]]
  647. * Programming
  648. ** Common things
  649. List of plugins and settings which are shared between the language plugins
  650. Highlight whitespaces, tabs, empty lines.
  651. #+begin_src emacs-lisp
  652. (use-package whitespace
  653. :demand t
  654. :ensure nil
  655. :diminish whitespace-mode;;mode shall be active, but not shown in mode line
  656. :init
  657. (dolist (hook '(prog-mode-hook
  658. text-mode-hook
  659. conf-mode-hook))
  660. (add-hook hook #'whitespace-mode))
  661. ;; :hook ;;not working in use-package 2.3
  662. ;; ((prog-mode . whitespace-turn-on)
  663. ;; (text-mode . whitespace-turn-on))
  664. :config
  665. (setq-default whitespace-style '(face empty tab trailing))
  666. )
  667. #+end_src
  668. Disable Eldoc, it interferes with flycheck
  669. #+begin_src emacs-lisp
  670. (use-package eldoc
  671. :ensure nil
  672. :config
  673. (global-eldoc-mode -1)
  674. )
  675. #+end_src
  676. Colorize colors as text with their value
  677. #+begin_src emacs-lisp
  678. (use-package rainbow-mode
  679. :ensure t
  680. :init
  681. (add-hook 'prog-mode-hook 'rainbow-mode t)
  682. :diminish rainbow-mode
  683. ;; :hook prog-mode ;; not working in use-package 2.3
  684. :config
  685. (setq-default rainbow-x-colors-major-mode-list '())
  686. )
  687. #+end_src
  688. Highlight parens etc. for improved readability
  689. #+begin_src emacs-lisp
  690. (use-package rainbow-delimiters
  691. :ensure t
  692. :config
  693. (add-hook 'prog-mode-hook 'rainbow-delimiters-mode)
  694. )
  695. #+end_src
  696. ** Smartparens
  697. Smartparens is a beast on its own, so it's worth having a dedicated section for it
  698. #+begin_src emacs-lisp
  699. (use-package smartparens
  700. :ensure t
  701. :diminish smartparens-mode
  702. :config
  703. (add-hook 'prog-mode-hook 'smartparens-mode)
  704. )
  705. #+end_src
  706. ** Git
  707. [[https://magit.vc/manual/magit/index.html][Link]]
  708. I want to do git stuff here, not in a separate terminal window
  709. Little crashcourse in magit:
  710. - magit-init to init a git project
  711. - magit-status (C-x g) to call the status window
  712. in status buffer:
  713. - s stage files
  714. - u unstage files
  715. - U unstage all files
  716. - a apply changed to staging
  717. - c c commit (type commit message, then C-c C-c to commit)
  718. - b b switch to another branch
  719. - P u git push
  720. - F u git pull
  721. #+begin_src emacs-lisp
  722. (use-package magit
  723. :ensure t
  724. :init
  725. ;; set git-path in work environment
  726. (if (string-equal user-login-name "POH")
  727. (setq magit-git-executable "P:/Eigene Dateien/Tools/Git/bin/git.exe")
  728. )
  729. :defer t
  730. :bind (("C-x g" . magit-status))
  731. )
  732. #+end_src
  733. Display line changes in gutter based on git history. Enable it everywhere
  734. [[https://github.com/syohex/emacs-git-gutter][Source]]
  735. #+begin_src emacs-lisp
  736. (use-package git-gutter
  737. :ensure t
  738. :config
  739. (global-git-gutter-mode t)
  740. :diminish git-gutter-mode
  741. )
  742. #+end_src
  743. Time machine lets me step through the history of a file as recorded in git.
  744. [[https://github.com/pidu/git-timemachine][Source]]
  745. #+begin_src emacs-lisp
  746. (use-package git-timemachine
  747. :ensure t
  748. )
  749. #+end_src
  750. ** Company Mode
  751. Complete Anything!
  752. Activate company and make it react nearly instantly
  753. #+begin_src emacs-lisp
  754. (use-package company
  755. :ensure t
  756. :config
  757. (setq-default company-minimum-prefix-length 1
  758. company-tooltip-align-annotation t
  759. company-tooltop-flip-when-above t
  760. company-show-numbers t
  761. company-idle-delay 0.1)
  762. ;; (define-key company-active-map (kbd "TAB") #'company-complete-selection)
  763. ;; (define-key company-active-map (kbd "RET") nil)
  764. (company-tng-configure-default)
  765. )
  766. #+end_src
  767. For a nicer suggestion box: company-box ([[https://github.com/sebastiencs/company-box][Source]])
  768. It is only available for emacs 26 and higher.
  769. #+begin_src emacs-lisp
  770. (when (> emacs-major-version 25)
  771. (use-package company-box
  772. :ensure t
  773. :init
  774. (add-hook 'company-mode-hook 'company-box-mode)))
  775. #+end_src
  776. *** Company backend hooks
  777. Backend configuration for python-mode
  778. Common backends are:
  779. - company-files: files & directory
  780. - company-keywords: keywords
  781. - company-capf: ??
  782. - company-abbrev: ??
  783. - company-dabbrev: dynamic abbreviations
  784. - company-ispell: ??
  785. #+begin_src emacs-lisp
  786. (defun company/python-mode-hook()
  787. (set (make-local-variable 'company-backends)
  788. '((company-jedi company-dabbrev company-yasnippet) company-capf company-files))
  789. ;; '((company-jedi company-dabbrev) company-capf company-files))
  790. (company-mode t)
  791. )
  792. #+end_src
  793. (defun add-pcomplete-to-capf ()
  794. (add-hook 'completion-at-point-functions 'pcomplete-completions-at-point nil t))
  795. ;; (add-hook 'completion-at-point-functions 'pcomplete-completions-at-point nil t)
  796. (add-hook 'org-mode-hook #'add-pcomplete-to-capf)
  797. Backend for Orgmode
  798. #+begin_src emacs-lisp
  799. (defun company/org-mode-hook()
  800. (set (make-local-variable 'company-backends)
  801. '(company-capf company-files))
  802. (add-hook 'completion-at-point-functions 'pcomplete-completions-at-point nil t)
  803. (company-mode t)
  804. )
  805. #+end_src
  806. Backend configuration for lisp-mode
  807. #+begin_src emacs-lisp
  808. (defun company/elisp-mode-hook()
  809. (set (make-local-variable 'company-backends)
  810. '((company-elisp company-dabbrev) company-capf company-files))
  811. (company-mode t)
  812. )
  813. #+end_src
  814. Backend configuration for beancount
  815. #+begin_src emacs-lisp
  816. (defun company/beancount-mode-hook()
  817. (set (make-local-variable 'company-backends)
  818. '(company-beancount))
  819. ; '((company-beancount company-dabbrev) company-capf company-files))
  820. (company-mode t)
  821. )
  822. #+end_src
  823. *** Misc Company packages
  824. Addon to sort suggestions by usage
  825. #+begin_src emacs-lisp
  826. (use-package company-statistics
  827. :ensure t
  828. :after company
  829. :init
  830. (setq company-statistics-file (concat PATH_USER_LOCAL "company-statistics-cache.el"));~/.emacs.d/user-dir/company-statistics-cache.el")
  831. :config
  832. (company-statistics-mode 1)
  833. )
  834. #+end_src
  835. Get a popup with documentation of the completion candidate.
  836. For the popups the package pos-tip.el is used and automatically installed.
  837. [[https://github.com/expez/company-quickhelp][Company Quickhelp]]
  838. [[https://www.emacswiki.org/emacs/PosTip][See here for Pos-Tip details]]
  839. #+begin_src emacs-lisp
  840. (use-package company-quickhelp
  841. :ensure t
  842. :after company
  843. :config
  844. (company-quickhelp-mode 1)
  845. )
  846. #+end_src
  847. Maybe add [[https://github.com/hlissner/emacs-company-dict][company-dict]]? It's a dictionary based on major modes, plus it has Yasnippet integration.
  848. ** Projectile
  849. Brings search functions on project level
  850. #+begin_src emacs-lisp
  851. (use-package projectile
  852. :ensure t
  853. :defer t
  854. :bind
  855. (("C-c p p" . projectile-switch-project)
  856. ("C-c p s s" . projectile-ag))
  857. :init
  858. (setq-default
  859. projectile-cache-file (concat PATH_USER_LOCAL ".projectile-cache")
  860. projectile-known-projects-file (concat PATH_USER_LOCAL ".projectile-bookmarks"))
  861. :config
  862. (projectile-mode t)
  863. (setq-default
  864. projectile-completion-system 'ivy
  865. projectile-enable-caching t
  866. projectile-mode-line '(:eval (projectile-project-name)))
  867. )
  868. #+end_src
  869. ** Yasnippet
  870. Snippets!
  871. TODO: yas-minor-mode? what's that?
  872. #+begin_src emacs-lisp
  873. (use-package yasnippet
  874. :ensure t
  875. :diminish yas-minor-mode
  876. :init
  877. (setq yas-snippet-dirs (concat PATH_USER_GLOBAL "snippets"))
  878. (yas-global-mode t)
  879. :mode ("\\.yasnippet" . snippet-mode)
  880. ; :config
  881. ; (yas-reload-all) ;; ensure snippets are updated and available, necessary when not using global-mode
  882. )
  883. #+end_src
  884. ** Lisp
  885. #+begin_src emacs-lisp
  886. (add-hook 'emacs-lisp-mode-hook 'company/elisp-mode-hook)
  887. #+end_src
  888. Add some helpers to handle and understand macros
  889. #+begin_src emacs-lisp
  890. (use-package macrostep
  891. :ensure t
  892. :init
  893. (define-key emacs-lisp-mode-map (kbd "C-c e") 'macrostep-expand)
  894. (define-key emacs-lisp-mode-map (kbd "C-c c") 'macrostep-collapse))
  895. #+end_src
  896. ** Python
  897. Systemwide following packages need to be installed:
  898. - venv
  899. The virtual environments need to have following modules installed:
  900. - jedi
  901. - epc
  902. - pylint
  903. #+begin_src emacs-lisp
  904. (use-package flycheck
  905. :ensure t
  906. :diminish flycheck-mode " ✓"
  907. :init
  908. (setq flycheck-emacs-lisp-load-path 'inherit)
  909. (add-hook 'after-init-hook #'global-flycheck-mode)
  910. (add-hook 'python-mode-hook (lambda ()
  911. (semantic-mode 1)
  912. (flycheck-select-checker 'python-pylint)))
  913. )
  914. #+end_src
  915. Automatically start python-mode when opening a .py-file.
  916. Not sure if python.el is better than python-mode.el.
  917. See [[https://github.com/jorgenschaefer/elpy/issues/887][here]] for info about ~python-shell-completion-native-enable~.
  918. 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]].
  919. Also limit the completion backends to those which make sense in Python.
  920. #+begin_src emacs-lisp
  921. (use-package python
  922. :mode ("\\.py\\'" . python-mode)
  923. :interpreter ("python" . python-mode)
  924. :init
  925. (add-hook 'python-mode-hook 'company/python-mode-hook)
  926. :config
  927. (setq python-shell-completion-native-enable nil)
  928. )
  929. #+end_src
  930. Jedi is a backend for python autocompletion and needs to be installed on the server:
  931. - pip install jedi
  932. Code checks need to be installed, too:
  933. - pip install flake8
  934. #+begin_src emacs-lisp
  935. (use-package company-jedi
  936. :defer t
  937. ;; :after company
  938. :ensure t
  939. :config
  940. (setq jedi:environment-virtualenv (list (expand-file-name "~/Archiv/Programmierprojekte/Python/virtualenv/")))
  941. (setq jedi:python-environment-directory (list (expand-file-name "~/Archiv/Programmierprojekte/Python/virtualenv/")))
  942. (add-hook 'python-mode-hook 'jedi:setup)
  943. (setq jedi:complete-on-dot t)
  944. (setq jedi:use-shortcuts t)
  945. ;; (add-hook 'python-mode-hook 'company/python-mode-hook)
  946. )
  947. #+end_src
  948. A wrapper to handle virtual environments.
  949. I strongly recommend to install virtual environments on the terminal, not through this wrapper, but changing venvs is fine.
  950. TODO: automatically start an inferior python process or switch to it if already created
  951. #+begin_src emacs-lisp
  952. (use-package pyvenv
  953. :ensure t
  954. :init
  955. (setenv "WORKON_HOME" (expand-file-name "~/Archiv/Programmierprojekte/Python/virtualenv/"))
  956. :config
  957. (pyvenv-mode t)
  958. (defun my/post-activate-hook()
  959. (setq jedi:environment-root pyvenv-virtual-env)
  960. (setq jedi:environment-virtualenv pyvenv-virtual-env)
  961. (setq jedi:tooltip-method '(nil)) ;; variants: nil or pos-tip and/or popup
  962. (setq python-shell-virtualenv-root pyvenv-virtual-env)
  963. ;; default traceback, other option M-x jedi:toggle-log-traceback
  964. ;; traceback is in jedi:pop-to-epc-buffer
  965. (jedi:setup)
  966. (company/python-mode-hook)
  967. (setq jedi:server-args '("--log-traceback")))
  968. ;; (add-to-list 'company-backends 'company-jedi)
  969. ;; (add-to-list 'company-backends 'company-anaconda)
  970. ;; (lambda ()
  971. ;; (set (make-local-variable 'company-backends)
  972. ;; '((company-jedi company-dabbrev) company-capf company-files)))
  973. ;; (setq flycheck-checker 'python-pylint))
  974. ;; (flycheck-select-checker 'python-pylint))
  975. ;; (setq flycheck-checker 'python-flake8)
  976. (add-hook 'pyvenv-post-activate-hooks 'my/post-activate-hook)
  977. )
  978. #+end_src
  979. I want Emacs to automatically start the proper virtual environment.
  980. Required is a .python-version file with, content in the first line being /path/to/virtualenv/
  981. [[https://github.com/marcwebbie/auto-virtualenv][Github source]]
  982. Depends on pyvenv
  983. #+begin_src emacs-lisp
  984. (use-package auto-virtualenv
  985. :ensure t
  986. ;; :after pyvenv
  987. ;; :defer t
  988. :init
  989. (add-hook 'python-mode-hook 'auto-virtualenv-set-virtualenv)
  990. ;; activate on changing buffers
  991. ;; (add-hook 'window-configuration-change-hook 'auto-virtualenv-set-virtualenv)
  992. ;; activate on focus in
  993. ;; (add-hook 'focus-in-hook 'auto-virtualenv-set-virtualenv)
  994. )
  995. #+end_src
  996. Anaconda test
  997. begin_src emacs-lisp
  998. (use-package anaconda-mode
  999. :ensure t
  1000. :defer t
  1001. :init
  1002. (add-hook 'python-mode-hook 'anaconda-mode)
  1003. ;; (add-hook 'python-mode-hook 'anaconda-eldoc-mode)
  1004. :config
  1005. (setq anaconda-eldoc-mode 1)
  1006. )
  1007. end_src
  1008. begin_src emacs-lisp
  1009. (use-package company-anaconda
  1010. :ensure t
  1011. :defer t
  1012. :init
  1013. (defun my/company-anaconda-hook()
  1014. (add-to-list 'company-backends 'company-anaconda))
  1015. (add-hook 'python-mode-hook 'my/company-anaconda-hook)
  1016. )
  1017. end_src
  1018. ** Hydra Flycheck
  1019. Flycheck is necessary, obviously
  1020. #+begin_src emacs-lisp
  1021. (defhydra hydra-flycheck (:color blue)
  1022. "
  1023. ^
  1024. ^Flycheck^ ^Errors^ ^Checker^
  1025. ^────────^──────────^──────^────────────^───────^───────────
  1026. _q_ quit _<_ previous _?_ describe
  1027. _m_ manual _>_ next _d_ disable
  1028. _v_ verify setup _f_ check _s_ select
  1029. ^^ ^^ ^^
  1030. "
  1031. ("q" nil)
  1032. ("<" flycheck-previous-error :color red)
  1033. (">" flycheck-next-error :color red)
  1034. ("?" flycheck-describe-checker)
  1035. ("d" flycheck-disable-checker)
  1036. ("f" flycheck-buffer)
  1037. ("m" flycheck-manual)
  1038. ("s" flycheck-select-checker)
  1039. ("v" flycheck-verify-setup)
  1040. )
  1041. #+end_src
  1042. * Treemacs
  1043. A file manager comparable to neotree.
  1044. [[https://github.com/Alexander-Miller/treemacs][Github]]
  1045. It has some requirements, which gets used here anyway:
  1046. - ace-window
  1047. - hydra
  1048. - projectile
  1049. - python
  1050. I copied the configuration example from the github site.
  1051. No idea what this executable-find is about.
  1052. TODO check it out!
  1053. #+begin_src emacs-lisp
  1054. (use-package treemacs
  1055. :ensure t
  1056. :defer t
  1057. :config
  1058. (setq treemacs-change-root-without-asking nil
  1059. treemacs-collapse-dirs (if (executable-find "python") 3 0)
  1060. treemacs-file-event-delay 5000
  1061. treemacs-follow-after-init t
  1062. treemacs-follow-recenter-distance 0.1
  1063. treemacs-goto-tag-strategy 'refetch-index
  1064. treemacs-indentation 2
  1065. treemacs-indentation-string " "
  1066. treemacs-is-never-other-window nil
  1067. treemacs-never-persist nil
  1068. treemacs-no-png-images nil
  1069. treemacs-recenter-after-file-follow nil
  1070. treemacs-recenter-after-tag-follow nil
  1071. treemacs-show-hidden-files t
  1072. treemacs-silent-filewatch nil
  1073. treemacs-silent-refresh nil
  1074. treemacs-sorting 'alphabetic-desc
  1075. treemacs-tag-follow-cleanup t
  1076. treemacs-tag-follow-delay 1.5
  1077. treemacs-width 35)
  1078. (treemacs-follow-mode t)
  1079. (treemacs-filewatch-mode t)
  1080. (pcase (cons (not (null (executable-find "git")))
  1081. (not (null (executable-find "python3"))))
  1082. (`(t . t)
  1083. (treemacs-git-mode 'extended))
  1084. (`(t . _)
  1085. (treemacs-git-mode 'simple)))
  1086. :bind
  1087. (:map global-map
  1088. ([f8] . treemacs-toggle))
  1089. )
  1090. #+end_src
  1091. Treemacs-projectile is useful for uhh.. TODO explain!
  1092. #+begin_src emacs-lisp
  1093. (use-package treemacs-projectile
  1094. :ensure t
  1095. :defer t
  1096. :config
  1097. (setq treemacs-header-function #'treemacs-projectile-create-header)
  1098. )
  1099. #+end_src
  1100. TODO
  1101. Hydrastuff or keybindings for functions:
  1102. - treemacs-projectile
  1103. - treemacs-projectile-toggle
  1104. - treemacs-toggle
  1105. - treemacs-bookmark
  1106. - treemacs-find-file
  1107. - treemacs-find-tag
  1108. * Evil
  1109. So... Evil Mode might be worth a try
  1110. #+BEGIN_SRC emacs-lisp
  1111. (use-package evil
  1112. :ensure t
  1113. :defer .1 ;; don't block emacs when starting, load evil immediately after startup
  1114. :init
  1115. (setq evil-want-integration nil) ;; required by evil-collection
  1116. :config
  1117. (evil-mode 1)) ;; for now deactivate per default
  1118. #+END_SRC
  1119. Evil-collection is a bundle of configs for different modes
  1120. #+BEGIN_SRC emacs-lisp
  1121. (use-package evil-collection
  1122. :after evil
  1123. :ensure t
  1124. :config
  1125. (evil-collection-init))
  1126. #+END_SRC
  1127. * Window Handling
  1128. Some tools to easen the navigation, creation and deletion of windows
  1129. ** Ace-Window
  1130. #+begin_src emacs-lisp
  1131. (use-package ace-window
  1132. :ensure t
  1133. :init
  1134. (global-set-key (kbd "C-x o") 'ace-window)
  1135. )
  1136. #+end_src
  1137. ** Windmove
  1138. Windmove easens the navigation between windows.
  1139. Here we are setting the default keybindings (shift+arrow)
  1140. CURRENTLY NOT WORKING, defaults are blocked.
  1141. Also not sure if necessary when using ace-window.
  1142. #+begin_src emacs-lisp
  1143. (use-package windmove
  1144. :ensure t
  1145. :config
  1146. (windmove-default-keybindings)
  1147. )
  1148. #+end_src
  1149. * Custom key mappings
  1150. ** Escape stuff
  1151. Standard is C-g to exit. But with the coming introduction of evil, ESC should be the default key for escaping stuff.
  1152. #+BEGIN_SRC emacs-lisp
  1153. (defun minibuffer-keyboard-quit ()
  1154. "Abort recursive edit.
  1155. In Delete Selection mode, if the mark is active, just deactivate it;
  1156. then it takes a second \\[keyboard-quit] to abort the minibuffer."
  1157. (interactive)
  1158. (if (and delete-selection-mode transient-mark-mode mark-active)
  1159. (setq deactivate-mark t)
  1160. (when (get-buffer "*Completions*") (delete-windows-on "*Completions*"))
  1161. (abort-recursive-edit)))
  1162. (with-eval-after-load 'evil-maps
  1163. (define-key evil-normal-state-map [escape] 'keyboard-quit)
  1164. (define-key evil-visual-state-map [escape] 'keyboard-quit))
  1165. ;(with-eval-after-load 'swiper-map
  1166. ; (define-key ivy-minibuffer-map [escape] 'keyboard-quit)
  1167. ; (define-key swiper-map [escape] 'keyboard-quit)
  1168. ;)
  1169. (define-key minibuffer-local-map [escape] 'minibuffer-keyboard-quit)
  1170. (define-key minibuffer-local-ns-map [escape] 'minibuffer-keyboard-quit)
  1171. (define-key minibuffer-local-completion-map [escape] 'minibuffer-keyboard-quit)
  1172. (define-key minibuffer-local-must-match-map [escape] 'minibuffer-keyboard-quit)
  1173. (define-key minibuffer-local-isearch-map [escape] 'minibuffer-keyboard-quit)
  1174. (global-set-key [escape] 'evil-exit-emacs-state)
  1175. #+END_SRC
  1176. * Quality of Life
  1177. ** Default Window Size
  1178. #+BEGIN_SRC emacs-lisp
  1179. (if (display-graphic-p)
  1180. (progn
  1181. (setq initial-frame-alist
  1182. '(
  1183. (width . 165)
  1184. (height . 70)))
  1185. (setq default-frame-alist
  1186. '(
  1187. (width . 165)
  1188. (height . 70))))
  1189. )
  1190. #+END_SRC